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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: maskerlogger-0.2.2.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.2.tar.gz
Algorithm Hash digest
SHA256 66f46e0495fc748cb1935bbd8ebaa740fc919d3b4bcabe24a88b861053d91e35
MD5 623745e502b7228a27664a8dda86fa1e
BLAKE2b-256 de434f2b2eb17248c087c130477ac0097ed0be261863ec5e506267e597dbf1b5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: maskerlogger-0.2.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a79434e725801fae29c57b9745444b2cc3dd7372fc83c7a29d5d270711883d83
MD5 64ddf42dade3714f48ddfe8889df6be7
BLAKE2b-256 4bc8d473bfe5d01ed40b5d10a72e3425c2e6880dc185f781dcf34f9745eabef7

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