mask your secrets from your logs
Project description
Masker Logger
Keep Your logs safe!
This formatter ensures the security of your logs and prevents sensitive data leaks.
For example -
Using this Formatter will print this line:
logger.info(f'Dont Give Your {secrets} away')
like this:
Dont Give Your ****** away
Getting started
This formatter utilizes the standard logging.Formatter
module.
Before printing each record to any destination (file, stdout, etc.), it ensures sensitive data is masked with asterisks to prevent leaks.
Install the library
pip install maskerlogger
Basic Usage
Like any formatter - just init your logger handler with the MaskerLogger formatter.
from maskerlogger import MaskerFormatter
logger = logging.getLogger('logger')
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler()
handler.setFormatter(
MaskerFormatter("%(asctime)s %(name)s %(levelname)s %(message)s"))
logger.addHandler(handler)
skip masking
If, for some reason, you want to disable masking on a specific log line, use the SKIP_MASK
mechanism.
from masker_formatter import MaskerFormatter, SKIP_MASK
...
...
logger.info('Line you want to skip', extra=SKIP_MASK)
fix len masking
If you want the masking to be in a fixed size (and not in the secret len),
please set the fix_masking_len
:
handler.setFormatter(
MaskerFormatter("%(asctime)s %(name)s %(levelname)s %(message)s",
fix_masking_len=30))
The Config File
Here's where the magic happens!
Our tool is built upon the powerful Gitleaks tool,
leveraging its default configuration to scan for sensitive data leaks in repositories.
You can find the default configuration here
Use custom config file
To create and use your own config file, set the path when initializing the formatter:
handler.setFormatter(
MaskerFormatter("%(asctime)s %(name)s %(levelname)s %(message)s",
regex_config_path="your/config/gitleaks.toml"))
Good luck!
Brought to you by OX Security
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
Built Distribution
File details
Details for the file maskerlogger-0.2.3.tar.gz
.
File metadata
- Download URL: maskerlogger-0.2.3.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a07cb4d2845bcc8b3ecc58b9e9fad4efebe07c3543de2e41cd88cc0217b4baa |
|
MD5 | 506ab8e19332debf2d7dfb0831053fa7 |
|
BLAKE2b-256 | 5dd6da66c675ba52d101c2b95c0a9cce56c8d84631ff15adb8e1bb027145798a |
File details
Details for the file maskerlogger-0.2.3-py3-none-any.whl
.
File metadata
- Download URL: maskerlogger-0.2.3-py3-none-any.whl
- Upload date:
- Size: 21.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32086f74dc9a2160836e41aa990ba813f7edb5f35f5708fd8318f5ef4592e416 |
|
MD5 | 93bfa2ada284e7fcf296b86f45b6b473 |
|
BLAKE2b-256 | 18897c365039f585160c7de86a8d5cadc310cb539111cdac26da19c60c5173e2 |