sentry-processor
sentry event processor for protecting sensitive infos.
Demo:
import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_processor import DesensitizationProcessor, POSITION
'''
# origin:
{
...
"vars": {
"pwd": "12345!@#$%",
"phone": "13012341234"
}
...
}
# result:
{
...
"vars": {
"pwd": "********",
"phone": "130****1234"
}
...
}
'''
def before_send(event, hint):
# https://docs.sentry.io/error-reporting/configuration/filtering/?platform=python
# modify event here
# ...
# process sensitive infos
processor = DesensitizationProcessor(
sensitive_keys=["pwd"],
with_default_keys=True,
partial_keys=["phone"],
mask_position=POSITION.RIGHT,
off_set=4
)
event = processor(event, hint)
# or
# event = processor.process(event, hint)
return event
sentry_sdk.init(
dsn="dsn",
integrations=[LoggingIntegration()],
before_send=before_send
)
API Reference
class DesensitizationProcessor(sensitive_keys=None, mask=None, with_default_keys=True,
partial_keys=None, partial_mask=None, mask_position=POSITION.RIGHT, off_set=0)
Parameters:
- sensitive_keys:
A list of sensitive information keys that need to be filtered
required: false
- mask:
The string to replace sensitive informations
required: false
- with_default_keys:
Whether to use the default sensitive information keys
required: false
default: True
- partial_keys:
A list of sensitive information keys that need to partially hidden(e.g: "12345678" -> "1234****")
required: false
- partial_mask:
The string to partially hidden sensitive informations
required: false
- off_set:
offset of partial_mask string relative to the starting point
required: false
default: 0
- mask_position:
starting point, the left or right side of original string
required: false
default: POSITION.RIGHT
process(self, event, hint)
- event
- hint
__call__(self, event, hint)
- event
- hint
Metadata
Release files for sentry-processor 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sentry-processor-0.0.1.tar.gz | 4.3 kB | Without provenance | Details for sentry-processor-0.0.1.tar.gz |
Release files / sentry-processor-0.0.1.tar.gz
| Download URL | sentry-processor-0.0.1.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fd7a30fb57aaf05c01cd04cf7d949c628376b2b55d7a0aaa222efe58a8f122bc
|
|
BLAKE2b-256 checksum How to use checksums |
36e3c93206b20e503925094e72fa0d0e4d7bbb7cc617edbb5548166a6d4396a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.6
|
Security for sentry-processor 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.