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.1.tar.gz
.
File metadata
- Download URL: maskerlogger-0.2.1.tar.gz
- Upload date:
- Size: 21.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50131bd42ca01eb13584edb62272681992c3366274427cf3bd64f490c9cb0545 |
|
MD5 | 4b31bfc66c95acdbf21c8dc1080e4327 |
|
BLAKE2b-256 | 330272e0270d1abda83dca43771460c56d47623858d768ad95fefdeba03cdcce |
File details
Details for the file maskerlogger-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: maskerlogger-0.2.1-py3-none-any.whl
- Upload date:
- Size: 21.3 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 | 6d347b218731eac59d1c18ce6e2f2c78aea992ce12345c642b2140973c46830b |
|
MD5 | 7e23edadec0c30259958ce4b7b9c975c |
|
BLAKE2b-256 | 37b1b32a1f277c830e1cf7ed47855adbc49d73304b57127bf09fdc867980ff97 |