sentry event processor for protecting sensitive infos
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file sentry-processor-0.0.1.tar.gz
.
File metadata
- Download URL: sentry-processor-0.0.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd7a30fb57aaf05c01cd04cf7d949c628376b2b55d7a0aaa222efe58a8f122bc |
|
MD5 | cfeba3ec07239bf35947256304653bc4 |
|
BLAKE2b-256 | 36e3c93206b20e503925094e72fa0d0e4d7bbb7cc617edbb5548166a6d4396a0 |