secretscreen 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. secretscreen-0.2.0/.github/FUNDING.yml +1 -0
  2. secretscreen-0.2.0/.github/ISSUE_TEMPLATE/bug_report.yml +56 -0
  3. secretscreen-0.2.0/.github/dependabot.yml +33 -0
  4. secretscreen-0.2.0/.github/pull_request_template.md +10 -0
  5. secretscreen-0.2.0/.github/workflows/ci.yml +63 -0
  6. secretscreen-0.2.0/.github/workflows/codeql.yml +29 -0
  7. secretscreen-0.2.0/.github/workflows/dependabot-automerge.yml +29 -0
  8. {secretscreen-0.1.0 → secretscreen-0.2.0}/.github/workflows/publish.yml +3 -3
  9. secretscreen-0.2.0/.github/workflows/scorecard.yml +35 -0
  10. secretscreen-0.2.0/CODE_OF_CONDUCT.md +39 -0
  11. secretscreen-0.2.0/CONTRIBUTING.md +41 -0
  12. {secretscreen-0.1.0 → secretscreen-0.2.0}/LICENSE +0 -5
  13. secretscreen-0.2.0/NOTICE +4 -0
  14. secretscreen-0.2.0/PKG-INFO +125 -0
  15. secretscreen-0.2.0/README.md +95 -0
  16. secretscreen-0.2.0/SECURITY.md +12 -0
  17. secretscreen-0.2.0/docs/audits/security-audit-2026-04-05.md +223 -0
  18. {secretscreen-0.1.0 → secretscreen-0.2.0}/pyproject.toml +8 -2
  19. {secretscreen-0.1.0 → secretscreen-0.2.0}/src/secretscreen/__init__.py +1 -1
  20. secretscreen-0.2.0/src/secretscreen/_cli.py +265 -0
  21. {secretscreen-0.1.0 → secretscreen-0.2.0}/src/secretscreen/_core.py +109 -45
  22. {secretscreen-0.1.0 → secretscreen-0.2.0}/src/secretscreen/_entropy.py +5 -4
  23. {secretscreen-0.1.0 → secretscreen-0.2.0}/src/secretscreen/_formats.py +22 -7
  24. {secretscreen-0.1.0 → secretscreen-0.2.0}/src/secretscreen/_keys.py +6 -6
  25. {secretscreen-0.1.0 → secretscreen-0.2.0}/src/secretscreen/_parsers.py +14 -4
  26. {secretscreen-0.1.0 → secretscreen-0.2.0}/src/secretscreen/_urls.py +30 -9
  27. secretscreen-0.2.0/tests/test_architecture.py +346 -0
  28. secretscreen-0.2.0/tests/test_cli.py +234 -0
  29. {secretscreen-0.1.0 → secretscreen-0.2.0}/tests/test_core.py +176 -31
  30. {secretscreen-0.1.0 → secretscreen-0.2.0}/tests/test_parsers.py +0 -1
  31. secretscreen-0.1.0/.github/workflows/ci.yml +0 -33
  32. secretscreen-0.1.0/PKG-INFO +0 -78
  33. secretscreen-0.1.0/README.md +0 -51
  34. {secretscreen-0.1.0 → secretscreen-0.2.0}/.gitignore +0 -0
  35. {secretscreen-0.1.0 → secretscreen-0.2.0}/src/secretscreen/gitleaks.toml +0 -0
  36. {secretscreen-0.1.0 → secretscreen-0.2.0}/src/secretscreen/py.typed +0 -0
  37. {secretscreen-0.1.0 → secretscreen-0.2.0}/tests/__init__.py +0 -0
  38. {secretscreen-0.1.0 → secretscreen-0.2.0}/tests/test_entropy.py +0 -0
  39. {secretscreen-0.1.0 → secretscreen-0.2.0}/tests/test_formats.py +0 -0
  40. {secretscreen-0.1.0 → secretscreen-0.2.0}/tests/test_keys.py +0 -0
  41. {secretscreen-0.1.0 → secretscreen-0.2.0}/tests/test_urls.py +0 -0
@@ -0,0 +1 @@
1
+ buy_me_a_coffee: featurecreep
@@ -0,0 +1,56 @@
1
+ name: Bug Report
2
+ description: Report a bug in secretscreen
3
+ labels: [bug]
4
+ body:
5
+ - type: input
6
+ id: version
7
+ attributes:
8
+ label: Secretscreen version
9
+ description: Output of `pip show secretscreen`
10
+ placeholder: "0.1.0"
11
+ validations:
12
+ required: true
13
+
14
+ - type: dropdown
15
+ id: environment
16
+ attributes:
17
+ label: Python version
18
+ options:
19
+ - "3.11"
20
+ - "3.12"
21
+ - "3.13"
22
+ validations:
23
+ required: true
24
+
25
+ - type: textarea
26
+ id: description
27
+ attributes:
28
+ label: What happened?
29
+ description: A clear description of the bug.
30
+ validations:
31
+ required: true
32
+
33
+ - type: textarea
34
+ id: expected
35
+ attributes:
36
+ label: What did you expect?
37
+ validations:
38
+ required: true
39
+
40
+ - type: textarea
41
+ id: reproduce
42
+ attributes:
43
+ label: Steps to reproduce
44
+ description: Minimal steps to reproduce the behavior.
45
+ placeholder: |
46
+ 1. Call `redact_dict(...)` with ...
47
+ 2. See unexpected result
48
+ validations:
49
+ required: true
50
+
51
+ - type: textarea
52
+ id: logs
53
+ attributes:
54
+ label: Relevant logs
55
+ description: Paste any relevant log output. This will be formatted as code.
56
+ render: shell
@@ -0,0 +1,33 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: pip
4
+ directory: /
5
+ schedule:
6
+ interval: daily
7
+ cooldown:
8
+ semver-major-days: 30
9
+ semver-minor-days: 7
10
+ semver-patch-days: 3
11
+ groups:
12
+ pip-patches:
13
+ update-types: ["patch"]
14
+ pip-minors:
15
+ update-types: ["minor"]
16
+ commit-message:
17
+ prefix: chore
18
+ include: scope
19
+ labels:
20
+ - dependencies
21
+
22
+ - package-ecosystem: github-actions
23
+ directory: /
24
+ schedule:
25
+ interval: weekly
26
+ groups:
27
+ actions:
28
+ patterns: ["*"]
29
+ commit-message:
30
+ prefix: chore
31
+ include: scope
32
+ labels:
33
+ - dependencies
@@ -0,0 +1,10 @@
1
+ ## What does this PR do?
2
+
3
+ <!-- Brief description of the change -->
4
+
5
+ ## Checklist
6
+
7
+ - [ ] Tests pass (`pytest`)
8
+ - [ ] Linting passes (`ruff check src/ tests/ && ruff format --check .`)
9
+ - [ ] Type checking passes (`mypy src/secretscreen/`)
10
+ - [ ] Breaking changes documented (if any)
@@ -0,0 +1,63 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ concurrency:
10
+ group: ${{ github.workflow }}-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
13
+ permissions:
14
+ contents: read
15
+
16
+ jobs:
17
+ lint:
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
21
+
22
+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
23
+ with:
24
+ python-version: "3.13"
25
+ cache: pip
26
+
27
+ - name: Install dependencies
28
+ run: pip install -e ".[dev]"
29
+
30
+ - name: Lint
31
+ run: ruff check src/ tests/
32
+
33
+ - name: Format check
34
+ run: ruff format --check .
35
+
36
+ - name: Type check
37
+ run: mypy src/secretscreen/
38
+
39
+ test:
40
+ runs-on: ubuntu-latest
41
+ strategy:
42
+ matrix:
43
+ python-version: ["3.11", "3.12", "3.13"]
44
+ steps:
45
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
46
+
47
+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
48
+ with:
49
+ python-version: ${{ matrix.python-version }}
50
+ cache: pip
51
+
52
+ - name: Install dependencies
53
+ run: pip install -e ".[dev]"
54
+
55
+ - name: Test with coverage
56
+ run: pytest --cov --cov-report=xml --tb=short -q
57
+
58
+ - name: Upload coverage
59
+ if: matrix.python-version == '3.13'
60
+ uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v6
61
+ with:
62
+ files: coverage.xml
63
+ token: ${{ secrets.CODECOV_TOKEN }}
@@ -0,0 +1,29 @@
1
+ name: CodeQL
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+ schedule:
9
+ - cron: "0 6 * * 3"
10
+
11
+ permissions:
12
+ security-events: write
13
+
14
+ jobs:
15
+ analyze:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
19
+
20
+ - name: Initialize CodeQL
21
+ uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
22
+ with:
23
+ languages: python
24
+
25
+ - name: Autobuild
26
+ uses: github/codeql-action/autobuild@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
27
+
28
+ - name: Perform CodeQL Analysis
29
+ uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
@@ -0,0 +1,29 @@
1
+ name: Dependabot Auto-merge
2
+
3
+ on:
4
+ pull_request_target:
5
+
6
+ permissions:
7
+ contents: write
8
+ pull-requests: write
9
+
10
+ jobs:
11
+ automerge:
12
+ if: github.actor == 'dependabot[bot]'
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - name: Generate token
16
+ id: generate_token
17
+ uses: actions/create-github-app-token@v3
18
+ with:
19
+ app-id: ${{ secrets.BOT_APP_ID }}
20
+ private-key: ${{ secrets.BOT_PRIVATE_KEY }}
21
+ - name: Auto-approve PR
22
+ uses: hmarr/auto-approve-action@b40d6c9ed2fa10c9a2749eca7eb004418a705501
23
+ with:
24
+ github-token: ${{ steps.generate_token.outputs.token }}
25
+ - name: Enable auto-merge
26
+ run: gh pr merge --auto --rebase "$PR_URL"
27
+ env:
28
+ PR_URL: ${{ github.event.pull_request.html_url }}
29
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -13,9 +13,9 @@ jobs:
13
13
  environment: pypi
14
14
 
15
15
  steps:
16
- - uses: actions/checkout@v4
16
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
17
17
 
18
- - uses: actions/setup-python@v5
18
+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
19
19
  with:
20
20
  python-version: "3.13"
21
21
 
@@ -25,4 +25,4 @@ jobs:
25
25
  python -m build
26
26
 
27
27
  - name: Publish to PyPI
28
- uses: pypa/gh-action-pypi-publish@release/v1
28
+ uses: pypa/gh-action-pypi-publish@ba38be9e461d3875417946c167d0b5f3d385a247 # v1.14.1
@@ -0,0 +1,35 @@
1
+ name: OpenSSF Scorecard
2
+
3
+ on:
4
+ branch_protection_rule:
5
+ schedule:
6
+ - cron: "0 6 * * 1"
7
+ push:
8
+ branches: [main]
9
+
10
+ permissions: read-all
11
+
12
+ jobs:
13
+ analysis:
14
+ name: Scorecard analysis
15
+ runs-on: ubuntu-latest
16
+ permissions:
17
+ security-events: write
18
+ id-token: write
19
+
20
+ steps:
21
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
22
+ with:
23
+ persist-credentials: false
24
+
25
+ - name: Run analysis
26
+ uses: ossf/scorecard-action@2d1146689b8cda280b9bc96326124645441f03bc # v2.4.4
27
+ with:
28
+ results_file: results.sarif
29
+ results_format: sarif
30
+ publish_results: true
31
+
32
+ - name: Upload to code-scanning
33
+ uses: github/codeql-action/upload-sarif@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
34
+ with:
35
+ sarif_file: results.sarif
@@ -0,0 +1,39 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to a positive environment:
15
+
16
+ * Using welcoming and inclusive language
17
+ * Being respectful of differing viewpoints and experiences
18
+ * Gracefully accepting constructive criticism
19
+ * Focusing on what is best for the community
20
+ * Showing empathy towards other community members
21
+
22
+ Examples of unacceptable behavior:
23
+
24
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
25
+ * Trolling, insulting or derogatory comments, and personal or political attacks
26
+ * Public or private harassment
27
+ * Publishing others' private information without explicit permission
28
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
29
+
30
+ ## Enforcement
31
+
32
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
33
+ reported to the project maintainers at cron@featurecreep.dev. All complaints
34
+ will be reviewed and investigated.
35
+
36
+ ## Attribution
37
+
38
+ This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
39
+ version 2.0.
@@ -0,0 +1,41 @@
1
+ # Contributing to secretscreen
2
+
3
+ ## Dev setup
4
+
5
+ Requires Python 3.11+.
6
+
7
+ ```bash
8
+ pip install -e ".[dev]"
9
+ ```
10
+
11
+ ## Running tests
12
+
13
+ ```bash
14
+ pytest
15
+ ```
16
+
17
+ ## Code style
18
+
19
+ This project uses [Ruff](https://github.com/astral-sh/ruff) for linting and formatting.
20
+
21
+ ```bash
22
+ ruff check src/ tests/ # lint
23
+ ruff format --check . # format check
24
+ ruff format . # auto-format
25
+ ```
26
+
27
+ Both checks run in CI. PRs that fail either check will not merge.
28
+
29
+ ## Type checking
30
+
31
+ ```bash
32
+ mypy src/secretscreen/
33
+ ```
34
+
35
+ ## PR process
36
+
37
+ 1. Fork the repo and create a branch from `main`.
38
+ 2. Make your changes. Add tests for new behavior.
39
+ 3. Ensure `pytest`, `ruff check src/ tests/`, `ruff format --check .`, and `mypy src/secretscreen/` all pass.
40
+ 4. Open a PR against `main`. Fill in the template.
41
+ 5. CI must pass before merge.
@@ -19,8 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
-
23
- ---
24
-
25
- This package vendors pattern data from the gitleaks project
26
- (https://github.com/gitleaks/gitleaks), which is also MIT-licensed.
@@ -0,0 +1,4 @@
1
+ This package vendors pattern data from the gitleaks project
2
+ (https://github.com/gitleaks/gitleaks), which is MIT-licensed.
3
+
4
+ See src/secretscreen/gitleaks.toml for the vendored rules.
@@ -0,0 +1,125 @@
1
+ Metadata-Version: 2.4
2
+ Name: secretscreen
3
+ Version: 0.2.0
4
+ Summary: Detect and redact secrets in key-value pairs, dicts, and environment variables.
5
+ Project-URL: Homepage, https://github.com/featurecreep-cron/secretscreen
6
+ Project-URL: Repository, https://github.com/featurecreep-cron/secretscreen
7
+ Project-URL: Issues, https://github.com/featurecreep-cron/secretscreen/issues
8
+ Author-email: Cron <cron@featurecreep.dev>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Keywords: docker,environment,redaction,secrets,security
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Security
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.11
24
+ Provides-Extra: dev
25
+ Requires-Dist: mypy<3,>=1.10; extra == 'dev'
26
+ Requires-Dist: pytest-cov>=5.0; extra == 'dev'
27
+ Requires-Dist: pytest>=7.0; extra == 'dev'
28
+ Requires-Dist: ruff<0.17,>=0.4; extra == 'dev'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # secretscreen
32
+
33
+ [![CI](https://github.com/featurecreep-cron/secretscreen/actions/workflows/ci.yml/badge.svg)](https://github.com/featurecreep-cron/secretscreen/actions/workflows/ci.yml)
34
+ [![Codecov](https://codecov.io/gh/featurecreep-cron/secretscreen/graph/badge.svg)](https://codecov.io/gh/featurecreep-cron/secretscreen)
35
+ [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/featurecreep-cron/secretscreen/badge)](https://scorecard.dev/viewer/?uri=github.com/featurecreep-cron/secretscreen)
36
+ [![License: MIT](https://img.shields.io/github/license/featurecreep-cron/secretscreen)](https://github.com/featurecreep-cron/secretscreen/blob/main/LICENSE)
37
+ [![Python](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Ffeaturecreep-cron%2Fsecretscreen%2Fmain%2Fpyproject.toml)](https://www.python.org/downloads/)
38
+ [![PyPI](https://img.shields.io/pypi/v/secretscreen)](https://pypi.org/project/secretscreen/)
39
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
40
+
41
+ Detect and redact secrets in key-value pairs, dicts, and environment variables.
42
+
43
+ Best-effort defense-in-depth. Not a security boundary.
44
+
45
+ ## Install
46
+
47
+ ```
48
+ pip install secretscreen
49
+ ```
50
+
51
+ ## Quick start
52
+
53
+ ```python
54
+ from secretscreen import redact_pair, redact_dict, audit_dict, Mode
55
+
56
+ # Single pair
57
+ redact_pair("DB_PASSWORD", "hunter2") # → "[REDACTED]"
58
+ redact_pair("APP_NAME", "myapp") # → "myapp"
59
+
60
+ # Dict with recursion
61
+ redact_dict({"db": {"password": "x", "host": "localhost"}})
62
+ # → {"db": {"password": "[REDACTED]", "host": "localhost"}}
63
+
64
+ # Aggressive mode (adds entropy detection)
65
+ redact_dict(env, mode=Mode.AGGRESSIVE)
66
+
67
+ # Audit mode (structured findings, no mutation)
68
+ findings = audit_dict(env)
69
+ # → [Finding(key="DB_PASSWORD", reason="key_pattern:password", ...)]
70
+
71
+ # Custom safe suffixes (keys ending with these are never redacted)
72
+ redact_dict(env, safe_suffixes=("_config", "_enabled"))
73
+ ```
74
+
75
+ ## Command line
76
+
77
+ The library only helps Python callers. The CLI covers the shell side — `docker exec`, Makefiles, CI logs, anything you are about to paste somewhere.
78
+
79
+ ```
80
+ secretscreen tandoor.env # redact and print, cat-like
81
+ docker exec app env | secretscreen # scrub a stream before it hits your terminal
82
+ secretscreen --audit config.json # findings only, no values, exit 1 if any
83
+ ```
84
+
85
+ ```
86
+ secretscreen [FILE...] reads stdin when FILE is omitted or '-'
87
+ --audit report findings without values; exit 1 if any
88
+ --format env|json|ini|dsn|auto default: auto-detect from extension, then content
89
+ --aggressive add entropy detection; more false positives
90
+ --replacement TEXT default: [REDACTED]
91
+ ```
92
+
93
+ 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.
94
+
95
+ **What the exit code means:**
96
+
97
+ | Code | Meaning |
98
+ |------|---------|
99
+ | 0 | Everything was parsed and screened |
100
+ | 1 | `--audit` found secrets |
101
+ | 2 | Something could not be parsed or read — see stderr |
102
+
103
+ 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 1 MB detection cap — they are reported as unscanned rather than passed off as clean.
104
+
105
+ If you are scanning a git repository rather than config-shaped data, use [gitleaks](https://github.com/gitleaks/gitleaks) instead. That is a different job.
106
+
107
+ ## Detection layers
108
+
109
+ 1. **Key-name denylist** — substring match against ~30 known secret key patterns
110
+ 2. **Structured value parsing** — JSON, Python literals, DSN, INI, URL query params
111
+ 3. **Value-format detection** — 222 known formats via vendored [gitleaks](https://github.com/gitleaks/gitleaks) patterns (MIT)
112
+ 4. **URL credential detection** — partial redaction of `user:pass@host` URLs
113
+ 5. **Entropy detection** — Shannon entropy for machine-generated strings (aggressive mode only)
114
+
115
+ ## Contributing
116
+
117
+ Bug reports and pull requests welcome. See [CONTRIBUTING.md](CONTRIBUTING.md).
118
+
119
+ ## Support
120
+
121
+ If you find secretscreen useful, consider [buying us a coffee](https://buymeacoffee.com/featurecreep).
122
+
123
+ ## License
124
+
125
+ MIT. Gitleaks patterns are also MIT-licensed.
@@ -0,0 +1,95 @@
1
+ # secretscreen
2
+
3
+ [![CI](https://github.com/featurecreep-cron/secretscreen/actions/workflows/ci.yml/badge.svg)](https://github.com/featurecreep-cron/secretscreen/actions/workflows/ci.yml)
4
+ [![Codecov](https://codecov.io/gh/featurecreep-cron/secretscreen/graph/badge.svg)](https://codecov.io/gh/featurecreep-cron/secretscreen)
5
+ [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/featurecreep-cron/secretscreen/badge)](https://scorecard.dev/viewer/?uri=github.com/featurecreep-cron/secretscreen)
6
+ [![License: MIT](https://img.shields.io/github/license/featurecreep-cron/secretscreen)](https://github.com/featurecreep-cron/secretscreen/blob/main/LICENSE)
7
+ [![Python](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Ffeaturecreep-cron%2Fsecretscreen%2Fmain%2Fpyproject.toml)](https://www.python.org/downloads/)
8
+ [![PyPI](https://img.shields.io/pypi/v/secretscreen)](https://pypi.org/project/secretscreen/)
9
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
10
+
11
+ Detect and redact secrets in key-value pairs, dicts, and environment variables.
12
+
13
+ Best-effort defense-in-depth. Not a security boundary.
14
+
15
+ ## Install
16
+
17
+ ```
18
+ pip install secretscreen
19
+ ```
20
+
21
+ ## Quick start
22
+
23
+ ```python
24
+ from secretscreen import redact_pair, redact_dict, audit_dict, Mode
25
+
26
+ # Single pair
27
+ redact_pair("DB_PASSWORD", "hunter2") # → "[REDACTED]"
28
+ redact_pair("APP_NAME", "myapp") # → "myapp"
29
+
30
+ # Dict with recursion
31
+ redact_dict({"db": {"password": "x", "host": "localhost"}})
32
+ # → {"db": {"password": "[REDACTED]", "host": "localhost"}}
33
+
34
+ # Aggressive mode (adds entropy detection)
35
+ redact_dict(env, mode=Mode.AGGRESSIVE)
36
+
37
+ # Audit mode (structured findings, no mutation)
38
+ findings = audit_dict(env)
39
+ # → [Finding(key="DB_PASSWORD", reason="key_pattern:password", ...)]
40
+
41
+ # Custom safe suffixes (keys ending with these are never redacted)
42
+ redact_dict(env, safe_suffixes=("_config", "_enabled"))
43
+ ```
44
+
45
+ ## Command line
46
+
47
+ The library only helps Python callers. The CLI covers the shell side — `docker exec`, Makefiles, CI logs, anything you are about to paste somewhere.
48
+
49
+ ```
50
+ secretscreen tandoor.env # redact and print, cat-like
51
+ docker exec app env | secretscreen # scrub a stream before it hits your terminal
52
+ secretscreen --audit config.json # findings only, no values, exit 1 if any
53
+ ```
54
+
55
+ ```
56
+ secretscreen [FILE...] reads stdin when FILE is omitted or '-'
57
+ --audit report findings without values; exit 1 if any
58
+ --format env|json|ini|dsn|auto default: auto-detect from extension, then content
59
+ --aggressive add entropy detection; more false positives
60
+ --replacement TEXT default: [REDACTED]
61
+ ```
62
+
63
+ 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.
64
+
65
+ **What the exit code means:**
66
+
67
+ | Code | Meaning |
68
+ |------|---------|
69
+ | 0 | Everything was parsed and screened |
70
+ | 1 | `--audit` found secrets |
71
+ | 2 | Something could not be parsed or read — see stderr |
72
+
73
+ 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 1 MB detection cap — they are reported as unscanned rather than passed off as clean.
74
+
75
+ If you are scanning a git repository rather than config-shaped data, use [gitleaks](https://github.com/gitleaks/gitleaks) instead. That is a different job.
76
+
77
+ ## Detection layers
78
+
79
+ 1. **Key-name denylist** — substring match against ~30 known secret key patterns
80
+ 2. **Structured value parsing** — JSON, Python literals, DSN, INI, URL query params
81
+ 3. **Value-format detection** — 222 known formats via vendored [gitleaks](https://github.com/gitleaks/gitleaks) patterns (MIT)
82
+ 4. **URL credential detection** — partial redaction of `user:pass@host` URLs
83
+ 5. **Entropy detection** — Shannon entropy for machine-generated strings (aggressive mode only)
84
+
85
+ ## Contributing
86
+
87
+ Bug reports and pull requests welcome. See [CONTRIBUTING.md](CONTRIBUTING.md).
88
+
89
+ ## Support
90
+
91
+ If you find secretscreen useful, consider [buying us a coffee](https://buymeacoffee.com/featurecreep).
92
+
93
+ ## License
94
+
95
+ MIT. Gitleaks patterns are also MIT-licensed.
@@ -0,0 +1,12 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a Vulnerability
4
+
5
+ If you discover a security vulnerability, please report it through
6
+ [GitHub Security Advisories](https://github.com/featurecreep-cron/secretscreen/security/advisories/new).
7
+
8
+ Do not open a public issue for security vulnerabilities.
9
+
10
+ ## Supported Versions
11
+
12
+ Only the latest release is supported with security updates.