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:
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


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.2.4.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

maskerlogger-0.2.4-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: maskerlogger-0.2.4.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for maskerlogger-0.2.4.tar.gz
Algorithm Hash digest
SHA256 1a8fd55fda8aaf93c851630251aac4c9d82b6d38eea4c9697425a833b292b585
MD5 006235ec27ef8d7ef518dd364054e14d
BLAKE2b-256 9155ba39ea75532dfcb2185c10430c642da5ef04d612bdcc3b19e83a126d2b53

See more details on using hashes here.

File details

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

File metadata

  • Download URL: maskerlogger-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for maskerlogger-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c850dbfc6a977f60165fa3593bd1d9266ffd7c121ae48940d3a36ecfd2003610
MD5 1b97d0967c10de97d3d12b5405990fbb
BLAKE2b-256 acd88dba09232aa3d30dd87394a0a1618eb85cfc16de681d327721be0108e4ea

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