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

Uploaded Source

Built Distribution

maskerlogger-0.2.0-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: maskerlogger-0.2.0.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

Hashes for maskerlogger-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d7100b0ba75dd110febe2445d9f37041bb8e1583d7268c0c0a465e040f858dd1
MD5 428f1be162e79ea69c1402170c631736
BLAKE2b-256 7d0dc61fc97b9dc4fc37e133fac33434c4dc3bda3e3621c0563919504ae78fdb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: maskerlogger-0.2.0-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

Hashes for maskerlogger-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ba186a12aa89fa90b7d3b9bc257ad6da27b4791c4deb3ac230372fd063eae55
MD5 32109817e9f01c12ccd73c3bb4a6f86d
BLAKE2b-256 dd269f758ec9ebe42d43f2997bdf314092383a36113516eea3c4374d1091982d

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