secretscreen
Detect and redact secrets in key-value pairs, dicts, and environment variables.
Best-effort defense-in-depth. Not a security boundary.
Install
As a library:
pip install secretscreen
As a command-line tool — pipx or uv keep it in its own environment and put secretscreen on your PATH everywhere, rather than only in whichever venv is active:
pipx install secretscreen
uv tool install secretscreen
Zero dependencies, Python 3.11+.
Quick start
from secretscreen import redact_pair, redact_dict, audit_dict, Mode
# Single pair
redact_pair("DB_PASSWORD", "hunter2") # → "[REDACTED]"
redact_pair("APP_NAME", "myapp") # → "myapp"
# Dict with recursion
redact_dict({"db": {"password": "x", "host": "localhost"}})
# → {"db": {"password": "[REDACTED]", "host": "localhost"}}
# Aggressive mode (adds entropy detection)
redact_dict(env, mode=Mode.AGGRESSIVE)
# Audit mode (structured findings, no mutation)
findings = audit_dict(env)
# → [Finding(key="DB_PASSWORD", reason="key_pattern:password", ...)]
# Custom safe suffixes (keys ending with these are never redacted)
redact_dict(env, safe_suffixes=("_config", "_enabled"))
Command line
The library only helps Python callers. The CLI covers the shell side — docker exec, Makefiles, CI logs, anything you are about to paste somewhere.
secretscreen tandoor.env # redact and print, cat-like
docker exec app env | secretscreen # scrub a stream before it hits your terminal
secretscreen --audit config.json # findings only, no values, exit 1 if any
secretscreen [FILE...] reads stdin when FILE is omitted or '-'
--audit report findings without values; exit 1 if any
--format env|json|ini|dsn|auto default: auto-detect from extension, then content
--aggressive add entropy detection; more false positives
--replacement TEXT default: [REDACTED]
Redaction is structural, not line-based: it parses the format, so it catches DB_PASSWORD=hunter2 on the key name and rewrites postgres://admin:s3cr3t@host/db to postgres://admin:[REDACTED]@host/db without destroying the rest of the line. Comments, blank lines, quoting, export prefixes, INI sections and : separators all survive the round trip.
What the exit code means:
| Code | Meaning |
|---|---|
| 0 | Everything was parsed and screened |
| 1 | --audit found secrets |
| 2 | Something could not be parsed or read — see stderr |
That third case is the one that matters. This is best-effort defense-in-depth, and a cat-replacement is exactly the tool people stop thinking about, so the CLI never prints unparsed content verbatim: a line it cannot structure is replaced with the redaction token, named on stderr, and turns the exit code non-zero. The same applies to values above the 64 KB detection cap — they are reported as unscanned rather than passed off as clean.
If you are scanning a git repository rather than config-shaped data, use gitleaks instead. That is a different job.
Detection layers
- Key-name denylist — substring match against ~30 known secret key patterns
- Structured value parsing — JSON, Python literals, DSN, INI, URL query params
- Value-format detection — 222 known formats via vendored gitleaks patterns (MIT)
- URL credential detection — partial redaction of
user:pass@hostURLs - Entropy detection — Shannon entropy for machine-generated strings (aggressive mode only)
Contributing
Bug reports and pull requests welcome. See CONTRIBUTING.md.
Support
If you find secretscreen useful, consider buying us a coffee.
License
MIT. Gitleaks patterns are also MIT-licensed.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file secretscreen-0.3.0.tar.gz.
File metadata
- Download URL: secretscreen-0.3.0.tar.gz
- Upload date:
- Size: 64.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33a8c35aca3e907afda5de9e9c74339af4fba4e7857e70fcc42ff7820d940fa7
|
|
| MD5 |
c77189d39a963b0d1b13308978181c69
|
|
| BLAKE2b-256 |
4745753b4d49675a0a2580dcc30a8863f8012029146d12fe4bcc8416c36381e9
|
Provenance
The following attestation bundles were made for secretscreen-0.3.0.tar.gz:
Publisher:
publish.yml on featurecreep-cron/secretscreen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
secretscreen-0.3.0.tar.gz -
Subject digest:
33a8c35aca3e907afda5de9e9c74339af4fba4e7857e70fcc42ff7820d940fa7 - Sigstore transparency entry: 2292365326
- Sigstore integration time:
-
Permalink:
featurecreep-cron/secretscreen@a1cc8ccc0ac18ca398c98d6da4699786cd7c8035 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/featurecreep-cron
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a1cc8ccc0ac18ca398c98d6da4699786cd7c8035 -
Trigger Event:
release
-
Statement type:
File details
Details for the file secretscreen-0.3.0-py3-none-any.whl.
File metadata
- Download URL: secretscreen-0.3.0-py3-none-any.whl
- Upload date:
- Size: 44.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0aec730f0b425f082b6eba250809eb73ca3ccc50da2978f843084d6d834d6053
|
|
| MD5 |
2e8f95309d973aa6b2c498e3f8627665
|
|
| BLAKE2b-256 |
7cbf400d276cfad57ca6c4879c20d79b8e78c1b5cd0dc9954de18c323c09c6ca
|
Provenance
The following attestation bundles were made for secretscreen-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on featurecreep-cron/secretscreen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
secretscreen-0.3.0-py3-none-any.whl -
Subject digest:
0aec730f0b425f082b6eba250809eb73ca3ccc50da2978f843084d6d834d6053 - Sigstore transparency entry: 2292365374
- Sigstore integration time:
-
Permalink:
featurecreep-cron/secretscreen@a1cc8ccc0ac18ca398c98d6da4699786cd7c8035 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/featurecreep-cron
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a1cc8ccc0ac18ca398c98d6da4699786cd7c8035 -
Trigger Event:
release
-
Statement type: