Skip to main content

mask your secrets from your logs

Project description

Flake Status PyPI version GitHub release License GitHub stars PRs Welcome

MaskerLoggerTitle

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:
looger.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 tp skip', extra=SKIP_MASK)

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maskerlogger-0.1.0.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

maskerlogger-0.1.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file maskerlogger-0.1.0.tar.gz.

File metadata

  • Download URL: maskerlogger-0.1.0.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for maskerlogger-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9f9b316450beb6477422b62aa7528575b8e5a9916d4c3cb56142e1a6e3d0bfb9
MD5 3fdba06d0c88f3a2d67509b389d61b82
BLAKE2b-256 7511c05f796c1519307700790d712fc6670cd6940c3787dcd7f83669ae81a98b

See more details on using hashes here.

File details

Details for the file maskerlogger-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: maskerlogger-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for maskerlogger-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2d01075863f6144857791cebbd183c7380d44cf5d9b3cc6308e6c58264eb39f4
MD5 1b3a824c3a6e7fbe08207e2ee455a56d
BLAKE2b-256 4083eed0ac69830c3e3ffc496cdc8a4ddd52a3b4797204d1d130807209db4629

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page