secretscreen 0.4.0__tar.gz → 0.5.1__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 (45) hide show
  1. secretscreen-0.5.1/.github/scripts/pr_test_gate.py +200 -0
  2. {secretscreen-0.4.0 → secretscreen-0.5.1}/.github/workflows/codeql.yml +3 -3
  3. {secretscreen-0.4.0 → secretscreen-0.5.1}/.github/workflows/publish.yml +1 -1
  4. {secretscreen-0.4.0 → secretscreen-0.5.1}/.github/workflows/scorecard.yml +1 -1
  5. secretscreen-0.5.1/.github/workflows/test-gate.yml +61 -0
  6. {secretscreen-0.4.0 → secretscreen-0.5.1}/PKG-INFO +50 -2
  7. {secretscreen-0.4.0 → secretscreen-0.5.1}/README.md +48 -0
  8. {secretscreen-0.4.0 → secretscreen-0.5.1}/pyproject.toml +14 -1
  9. {secretscreen-0.4.0 → secretscreen-0.5.1}/src/secretscreen/__init__.py +1 -1
  10. secretscreen-0.5.1/src/secretscreen/_cli.py +832 -0
  11. secretscreen-0.5.1/src/secretscreen/_config.py +381 -0
  12. {secretscreen-0.4.0 → secretscreen-0.5.1}/src/secretscreen/_core.py +78 -19
  13. {secretscreen-0.4.0 → secretscreen-0.5.1}/tests/test_cli.py +76 -0
  14. secretscreen-0.5.1/tests/test_config.py +642 -0
  15. {secretscreen-0.4.0 → secretscreen-0.5.1}/tests/test_core.py +104 -2
  16. {secretscreen-0.4.0 → secretscreen-0.5.1}/tests/test_yaml_and_prefixes.py +4 -1
  17. secretscreen-0.4.0/src/secretscreen/_cli.py +0 -438
  18. {secretscreen-0.4.0 → secretscreen-0.5.1}/.github/FUNDING.yml +0 -0
  19. {secretscreen-0.4.0 → secretscreen-0.5.1}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  20. {secretscreen-0.4.0 → secretscreen-0.5.1}/.github/dependabot.yml +0 -0
  21. {secretscreen-0.4.0 → secretscreen-0.5.1}/.github/pull_request_template.md +0 -0
  22. {secretscreen-0.4.0 → secretscreen-0.5.1}/.github/workflows/ci.yml +0 -0
  23. {secretscreen-0.4.0 → secretscreen-0.5.1}/.github/workflows/dependabot-automerge.yml +0 -0
  24. {secretscreen-0.4.0 → secretscreen-0.5.1}/.gitignore +0 -0
  25. {secretscreen-0.4.0 → secretscreen-0.5.1}/CODE_OF_CONDUCT.md +0 -0
  26. {secretscreen-0.4.0 → secretscreen-0.5.1}/CONTRIBUTING.md +0 -0
  27. {secretscreen-0.4.0 → secretscreen-0.5.1}/LICENSE +0 -0
  28. {secretscreen-0.4.0 → secretscreen-0.5.1}/NOTICE +0 -0
  29. {secretscreen-0.4.0 → secretscreen-0.5.1}/SECURITY.md +0 -0
  30. {secretscreen-0.4.0 → secretscreen-0.5.1}/docs/audits/security-audit-2026-04-05.md +0 -0
  31. {secretscreen-0.4.0 → secretscreen-0.5.1}/src/secretscreen/_entropy.py +0 -0
  32. {secretscreen-0.4.0 → secretscreen-0.5.1}/src/secretscreen/_formats.py +0 -0
  33. {secretscreen-0.4.0 → secretscreen-0.5.1}/src/secretscreen/_keys.py +0 -0
  34. {secretscreen-0.4.0 → secretscreen-0.5.1}/src/secretscreen/_parsers.py +0 -0
  35. {secretscreen-0.4.0 → secretscreen-0.5.1}/src/secretscreen/_urls.py +0 -0
  36. {secretscreen-0.4.0 → secretscreen-0.5.1}/src/secretscreen/gitleaks.toml +0 -0
  37. {secretscreen-0.4.0 → secretscreen-0.5.1}/src/secretscreen/py.typed +0 -0
  38. {secretscreen-0.4.0 → secretscreen-0.5.1}/tests/__init__.py +0 -0
  39. {secretscreen-0.4.0 → secretscreen-0.5.1}/tests/test_architecture.py +0 -0
  40. {secretscreen-0.4.0 → secretscreen-0.5.1}/tests/test_entropy.py +0 -0
  41. {secretscreen-0.4.0 → secretscreen-0.5.1}/tests/test_explain.py +0 -0
  42. {secretscreen-0.4.0 → secretscreen-0.5.1}/tests/test_formats.py +0 -0
  43. {secretscreen-0.4.0 → secretscreen-0.5.1}/tests/test_keys.py +0 -0
  44. {secretscreen-0.4.0 → secretscreen-0.5.1}/tests/test_parsers.py +0 -0
  45. {secretscreen-0.4.0 → secretscreen-0.5.1}/tests/test_urls.py +0 -0
@@ -0,0 +1,200 @@
1
+ #!/usr/bin/env python3
2
+ """Require every behaviour change to arrive with a test that proves it.
3
+
4
+ The gate runs the pull request's own tests against the pull request's *base*
5
+ source. At least one newly added test must fail there, and every changed test
6
+ must pass once the patch is applied. A test that passes without the patch does
7
+ not demonstrate anything; it is the failure on base that turns a test into
8
+ evidence.
9
+
10
+ Exit codes: 0 pass, 1 gate failure, 2 harness error.
11
+
12
+ Run it locally the same way CI does:
13
+
14
+ python .github/scripts/pr_test_gate.py --base origin/main --head HEAD
15
+
16
+ Escape hatch: a pull request that genuinely changes no behaviour (a pure
17
+ refactor, a rename, a performance change covered by existing tests) is exempt
18
+ via the `no-test-gate` label. The label is checked by the workflow, not here,
19
+ so that the reason is recorded on the pull request rather than buried in a log.
20
+ """
21
+
22
+ from __future__ import annotations
23
+
24
+ import argparse
25
+ import re
26
+ import subprocess
27
+ import sys
28
+ from pathlib import Path
29
+
30
+ SRC_DIR = "src"
31
+ TEST_DIR = "tests"
32
+
33
+ # `def test_x`, `async def test_x`, added by the diff.
34
+ ADDED_TEST_RE = re.compile(r"^\+\s*(?:async\s+)?def\s+(test_[A-Za-z0-9_]+)")
35
+ # pytest's short summary lines: "FAILED tests/test_x.py::Cls::test_y - detail"
36
+ OUTCOME_RE = re.compile(r"^(?:FAILED|ERROR)\s+(\S+)")
37
+
38
+
39
+ class GateError(RuntimeError):
40
+ """The gate could not run. Distinct from the gate deciding to fail."""
41
+
42
+
43
+ def git(*args: str) -> str:
44
+ result = subprocess.run(["git", *args], capture_output=True, text=True, check=False)
45
+ if result.returncode != 0:
46
+ raise GateError(f"git {' '.join(args)} failed: {result.stderr.strip()}")
47
+ return result.stdout
48
+
49
+
50
+ def changed_files(base: str, head: str, path: str) -> list[str]:
51
+ out = git("diff", "--name-only", "--diff-filter=ACMR", base, head, "--", path)
52
+ return [line for line in out.splitlines() if line.strip()]
53
+
54
+
55
+ def added_test_names(base: str, head: str) -> set[str]:
56
+ diff = git("diff", base, head, "--", TEST_DIR)
57
+ return {match.group(1) for line in diff.splitlines() if (match := ADDED_TEST_RE.match(line))}
58
+
59
+
60
+ def run_pytest(paths: list[str]) -> tuple[int, str, set[str]]:
61
+ """Run pytest over `paths`; return (exit code, output, failing test names)."""
62
+ result = subprocess.run(
63
+ [
64
+ sys.executable,
65
+ "-m",
66
+ "pytest",
67
+ *paths,
68
+ "-q",
69
+ "--no-header",
70
+ "-p",
71
+ "no:cacheprovider",
72
+ "--tb=no",
73
+ "-rfE",
74
+ ],
75
+ capture_output=True,
76
+ text=True,
77
+ check=False,
78
+ )
79
+ output = result.stdout + result.stderr
80
+ failing = set()
81
+ for line in output.splitlines():
82
+ if match := OUTCOME_RE.match(line):
83
+ # tests/test_core.py::TestFoo::test_bar -> test_bar
84
+ failing.add(match.group(1).split("::")[-1].split("[")[0])
85
+ return result.returncode, output, failing
86
+
87
+
88
+ def fail(reason: str, *, detail: str = "") -> int:
89
+ print(f"\n::error::PR test gate: {reason}")
90
+ print(f"\n FAILED — {reason}\n")
91
+ if detail:
92
+ print(detail)
93
+ print(
94
+ "\n A change to src/ has to arrive with a test that fails without it.\n"
95
+ " If this pull request genuinely changes no behaviour — a pure refactor,\n"
96
+ " a rename, a dependency bump — add the `no-test-gate` label and say why\n"
97
+ " in the pull request body. The exemption is recorded, not silent.\n"
98
+ )
99
+ return 1
100
+
101
+
102
+ def main() -> int:
103
+ parser = argparse.ArgumentParser(description=__doc__)
104
+ parser.add_argument("--base", required=True, help="base ref or SHA")
105
+ parser.add_argument("--head", default="HEAD", help="head ref or SHA")
106
+ args = parser.parse_args()
107
+
108
+ if not Path(SRC_DIR).is_dir() or not Path(TEST_DIR).is_dir():
109
+ raise GateError(f"expected {SRC_DIR}/ and {TEST_DIR}/ in {Path.cwd()}")
110
+
111
+ base, head = args.base, args.head
112
+ src_changed = changed_files(base, head, SRC_DIR)
113
+ test_changed = changed_files(base, head, TEST_DIR)
114
+
115
+ print(f" base {git('rev-parse', '--short', base).strip()} head {git('rev-parse', '--short', head).strip()}")
116
+
117
+ if not src_changed:
118
+ print("\n SKIPPED — no changes under src/. Nothing to demonstrate.\n")
119
+ return 0
120
+
121
+ print(f"\n source files changed ({len(src_changed)}):")
122
+ for path in src_changed:
123
+ print(f" {path}")
124
+
125
+ if not test_changed:
126
+ return fail(
127
+ "src/ changed but no test changed",
128
+ detail=" Changed without a test:\n" + "".join(f" {p}\n" for p in src_changed),
129
+ )
130
+
131
+ added = added_test_names(base, head)
132
+ if not added:
133
+ return fail(
134
+ "test files changed but no new test was added",
135
+ detail=f" Changed test files: {', '.join(test_changed)}\n"
136
+ " The gate looks for added `def test_*`. Editing an existing\n"
137
+ " test in place cannot show that the defect was ever present.\n",
138
+ )
139
+
140
+ print(f"\n tests added ({len(added)}):")
141
+ for name in sorted(added):
142
+ print(f" {name}")
143
+
144
+ # --- Half one: the new tests must fail against the base source. ----------
145
+ # Only src/ is reverted. Packaging and test fixtures stay at head so the
146
+ # single variable under test is the source change itself.
147
+ print("\n [1/2] running the PR's tests against base source ...")
148
+ git("checkout", base, "--", SRC_DIR)
149
+ try:
150
+ code, output, failing = run_pytest(test_changed)
151
+ finally:
152
+ git("checkout", head, "--", SRC_DIR)
153
+
154
+ if code == 0:
155
+ return fail(
156
+ "every test passes without the patch",
157
+ detail=" The tests in this pull request pass against the base source,\n"
158
+ " so they do not demonstrate that anything was broken.\n"
159
+ " Write a test that fails first, then make it pass.\n",
160
+ )
161
+
162
+ proving = sorted(added & failing)
163
+ if not proving:
164
+ if not failing:
165
+ # Base could not even collect the tests — they reference API that
166
+ # only exists on head. That is the strongest possible signal.
167
+ print(" base run could not collect the tests (new API referenced).")
168
+ print(" accepted as evidence the tests require the patch.")
169
+ else:
170
+ return fail(
171
+ "no *added* test fails without the patch",
172
+ detail=f" Failing on base: {', '.join(sorted(failing))}\n"
173
+ f" Added by this PR: {', '.join(sorted(added))}\n"
174
+ " Something failed on base, but nothing this pull request\n"
175
+ " added. That is a pre-existing failure, not evidence.\n",
176
+ )
177
+ else:
178
+ print(f" {len(proving)} added test(s) fail without the patch:")
179
+ for name in proving:
180
+ print(f" {name}")
181
+
182
+ # --- Half two: everything must pass with the patch applied. -------------
183
+ print("\n [2/2] running the same tests against the PR ...")
184
+ code, output, failing = run_pytest(test_changed)
185
+ if code != 0:
186
+ return fail(
187
+ "the tests do not pass with the patch applied",
188
+ detail=f" Still failing: {', '.join(sorted(failing))}\n\n{output[-2000:]}",
189
+ )
190
+
191
+ print("\n PASSED — the defect is demonstrated and the patch closes it.\n")
192
+ return 0
193
+
194
+
195
+ if __name__ == "__main__":
196
+ try:
197
+ sys.exit(main())
198
+ except GateError as exc:
199
+ print(f"::error::PR test gate could not run: {exc}", file=sys.stderr)
200
+ sys.exit(2)
@@ -21,12 +21,12 @@ jobs:
21
21
  - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
22
22
 
23
23
  - name: Initialize CodeQL
24
- uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
24
+ uses: github/codeql-action/init@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
25
25
  with:
26
26
  languages: python
27
27
 
28
28
  - name: Autobuild
29
- uses: github/codeql-action/autobuild@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
29
+ uses: github/codeql-action/autobuild@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
30
30
 
31
31
  - name: Perform CodeQL Analysis
32
- uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
32
+ uses: github/codeql-action/analyze@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
@@ -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@ba38be9e461d3875417946c167d0b5f3d385a247 # v1.14.1
28
+ uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
@@ -30,6 +30,6 @@ jobs:
30
30
  publish_results: true
31
31
 
32
32
  - name: Upload to code-scanning
33
- uses: github/codeql-action/upload-sarif@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
33
+ uses: github/codeql-action/upload-sarif@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
34
34
  with:
35
35
  sarif_file: results.sarif
@@ -0,0 +1,61 @@
1
+ name: Test Gate
2
+
3
+ # Every change to src/ must arrive with a test that fails without it. The gate
4
+ # runs the pull request's own tests against the base source: at least one newly
5
+ # added test has to fail there, and all of them have to pass once the patch is
6
+ # applied. A test that passes either way proves nothing.
7
+ #
8
+ # Exemptions are deliberate and visible: Dependabot is skipped by author, and a
9
+ # genuine no-behaviour-change pull request is skipped by the `no-test-gate`
10
+ # label, which leaves the reason on the pull request instead of in a log.
11
+
12
+ on:
13
+ pull_request:
14
+
15
+ concurrency:
16
+ group: ${{ github.workflow }}-${{ github.ref }}
17
+ cancel-in-progress: true
18
+
19
+ permissions:
20
+ contents: read
21
+
22
+ jobs:
23
+ gate:
24
+ runs-on: ubuntu-latest
25
+ if: >-
26
+ github.actor != 'dependabot[bot]' &&
27
+ !contains(github.event.pull_request.labels.*.name, 'no-test-gate')
28
+ steps:
29
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
30
+ with:
31
+ # Full history: the gate diffs against the merge base and checks the
32
+ # base revision of src/ out in place.
33
+ fetch-depth: 0
34
+
35
+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
36
+ with:
37
+ python-version: "3.13"
38
+ cache: pip
39
+
40
+ - name: Install dependencies
41
+ run: pip install -e ".[dev]"
42
+
43
+ - name: Resolve merge base
44
+ run: |
45
+ BASE=$(git merge-base "origin/${{ github.base_ref }}" HEAD)
46
+ echo "BASE_SHA=$BASE" >> "$GITHUB_ENV"
47
+ echo "Comparing against $BASE (merge base with ${{ github.base_ref }})"
48
+
49
+ - name: Does the test prove the fix?
50
+ run: python .github/scripts/pr_test_gate.py --base "$BASE_SHA" --head HEAD
51
+
52
+ # Reports the exemption rather than leaving a silent gap in the checks list.
53
+ exempt:
54
+ runs-on: ubuntu-latest
55
+ if: contains(github.event.pull_request.labels.*.name, 'no-test-gate')
56
+ steps:
57
+ - name: Record the exemption
58
+ run: |
59
+ echo "::notice::Test gate skipped via the no-test-gate label."
60
+ echo "This pull request claims it changes no behaviour."
61
+ echo "That claim is the reviewer's to check."
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: secretscreen
3
- Version: 0.4.0
3
+ Version: 0.5.1
4
4
  Summary: Detect and redact secrets in key-value pairs, dicts, and environment variables. Library and CLI.
5
5
  Project-URL: Homepage, https://github.com/featurecreep-cron/secretscreen
6
6
  Project-URL: Repository, https://github.com/featurecreep-cron/secretscreen
@@ -139,6 +139,54 @@ That stripping is what makes colon-separated detection safe to attempt at all. W
139
139
 
140
140
  One case stays deliberately blunt: a single stream mixing formats, such as `grep -rn` across both `.env` and `.yaml` files, picks the majority format and redacts the rest wholesale. Loud and safe rather than half-parsed.
141
141
 
142
+ ### Config
143
+
144
+ Once you have found a false positive, `--explain` tells you which key it was. A config file stops you diagnosing it again next run.
145
+
146
+ ```toml
147
+ # ~/.config/secretscreen.toml or .secretscreen.toml beside a stack
148
+
149
+ # Never redact these. Exact key names — no wildcards.
150
+ show = ["DEPLOY_PUBLIC_KEY"]
151
+
152
+ # Always redact these. Globs are fine.
153
+ hide = ["*_NOTIFICATION_URL", "*_WEBHOOK_URL"]
154
+
155
+ [detection]
156
+ mode = "normal" # normal | aggressive
157
+ entropy_threshold = 4.5
158
+
159
+ # Applies only while this filename is being processed.
160
+ [files."demo.env"]
161
+ show = ["API_TOKEN"]
162
+ ```
163
+
164
+ Order: user config, then `.secretscreen.toml` files discovered upward from **each input file**, nearest last, then flags. Lists union rather than replace, so a closer file extends the broader one instead of silently discarding it. Discovery runs per input, so `secretscreen a/compose.yaml b/compose.yaml` can pick up a different config beside each. Add `root = true` to stop the upward walk.
165
+
166
+ **`hide` takes globs. `show` does not.** `show = ["*_KEY"]` would print `AWS_SECRET_ACCESS_KEY`, and it would go on matching keys nobody has written yet. Every show entry is a credential you are choosing to print, so every entry gets named in full. `hide` always wins over `show`, at every scope.
167
+
168
+ The same asymmetry decides what a rule can cover in JSON. `hide` names a key and takes whatever that key holds — a string, a port number, a whole object — and replaces all of it, because the shape and key names of a hidden subtree are usually the half worth hiding. `show` is honoured for a string and refused for anything else, with a note on stderr: vouching for one named key is a decision about one value, and vouching for an object is a decision about values nobody has added yet. In a `--format dsn` stream the whole line is the value, and rules match the key `dsn`.
169
+
170
+ **A discovered project config may tighten redaction but not relax it.** A `.secretscreen.toml` can arrive with a repository you cloned five minutes ago, or be dropped in a shared directory by anyone who can write there, so every setting one carries is read as a request to tighten:
171
+
172
+ | setting | from a discovered config |
173
+ |---|---|
174
+ | `hide` | applied |
175
+ | `show` | ignored |
176
+ | `[detection] mode` | only `normal` → `aggressive` |
177
+ | `[detection] entropy_threshold` | only downward |
178
+ | `root` | ignored |
179
+
180
+ `--trust-config` honours all five. Each ignored setting is named on stderr, so a rule that did not fire says so rather than looking like one that did.
181
+
182
+ The three settings below `show` matter as much as `show` does. `show` prints a credential and is the obvious one; `entropy_threshold = 99` and `mode = "normal"` stop a credential being *found*, and `root = true` needs no rules of its own — it ends the upward walk before your own config one directory up is ever read. All four end with a secret on stdout and `--audit` exiting 0.
183
+
184
+ Only your own `~/.config` file, or a file you name yourself with `--config`, can loosen anything.
185
+
186
+ Every loaded config is named on stderr, and a malformed one — bad TOML, an unknown setting, a wildcard where none is allowed — is fatal rather than skipped. A typo that silently disabled a `hide` rule would leave you believing you had configured something you had not.
187
+
188
+ Equivalent flags exist for one-off use: `--show KEY`, `--hide GLOB`, `--entropy-threshold N`, `--no-config`, and `--config FILE` — which uses that file *only*, skipping both discovery and your own `~/.config`, and trusts it because you named it.
189
+
142
190
  ### Knowing what was left alone
143
191
 
144
192
  A missed secret is invisible: the output looks screened and nothing says otherwise. `--explain` writes an account of every value to **stderr**, so stdout stays a usable redacted stream and `secretscreen app.env --explain > clean.env` still works.
@@ -107,6 +107,54 @@ That stripping is what makes colon-separated detection safe to attempt at all. W
107
107
 
108
108
  One case stays deliberately blunt: a single stream mixing formats, such as `grep -rn` across both `.env` and `.yaml` files, picks the majority format and redacts the rest wholesale. Loud and safe rather than half-parsed.
109
109
 
110
+ ### Config
111
+
112
+ Once you have found a false positive, `--explain` tells you which key it was. A config file stops you diagnosing it again next run.
113
+
114
+ ```toml
115
+ # ~/.config/secretscreen.toml or .secretscreen.toml beside a stack
116
+
117
+ # Never redact these. Exact key names — no wildcards.
118
+ show = ["DEPLOY_PUBLIC_KEY"]
119
+
120
+ # Always redact these. Globs are fine.
121
+ hide = ["*_NOTIFICATION_URL", "*_WEBHOOK_URL"]
122
+
123
+ [detection]
124
+ mode = "normal" # normal | aggressive
125
+ entropy_threshold = 4.5
126
+
127
+ # Applies only while this filename is being processed.
128
+ [files."demo.env"]
129
+ show = ["API_TOKEN"]
130
+ ```
131
+
132
+ Order: user config, then `.secretscreen.toml` files discovered upward from **each input file**, nearest last, then flags. Lists union rather than replace, so a closer file extends the broader one instead of silently discarding it. Discovery runs per input, so `secretscreen a/compose.yaml b/compose.yaml` can pick up a different config beside each. Add `root = true` to stop the upward walk.
133
+
134
+ **`hide` takes globs. `show` does not.** `show = ["*_KEY"]` would print `AWS_SECRET_ACCESS_KEY`, and it would go on matching keys nobody has written yet. Every show entry is a credential you are choosing to print, so every entry gets named in full. `hide` always wins over `show`, at every scope.
135
+
136
+ The same asymmetry decides what a rule can cover in JSON. `hide` names a key and takes whatever that key holds — a string, a port number, a whole object — and replaces all of it, because the shape and key names of a hidden subtree are usually the half worth hiding. `show` is honoured for a string and refused for anything else, with a note on stderr: vouching for one named key is a decision about one value, and vouching for an object is a decision about values nobody has added yet. In a `--format dsn` stream the whole line is the value, and rules match the key `dsn`.
137
+
138
+ **A discovered project config may tighten redaction but not relax it.** A `.secretscreen.toml` can arrive with a repository you cloned five minutes ago, or be dropped in a shared directory by anyone who can write there, so every setting one carries is read as a request to tighten:
139
+
140
+ | setting | from a discovered config |
141
+ |---|---|
142
+ | `hide` | applied |
143
+ | `show` | ignored |
144
+ | `[detection] mode` | only `normal` → `aggressive` |
145
+ | `[detection] entropy_threshold` | only downward |
146
+ | `root` | ignored |
147
+
148
+ `--trust-config` honours all five. Each ignored setting is named on stderr, so a rule that did not fire says so rather than looking like one that did.
149
+
150
+ The three settings below `show` matter as much as `show` does. `show` prints a credential and is the obvious one; `entropy_threshold = 99` and `mode = "normal"` stop a credential being *found*, and `root = true` needs no rules of its own — it ends the upward walk before your own config one directory up is ever read. All four end with a secret on stdout and `--audit` exiting 0.
151
+
152
+ Only your own `~/.config` file, or a file you name yourself with `--config`, can loosen anything.
153
+
154
+ Every loaded config is named on stderr, and a malformed one — bad TOML, an unknown setting, a wildcard where none is allowed — is fatal rather than skipped. A typo that silently disabled a `hide` rule would leave you believing you had configured something you had not.
155
+
156
+ Equivalent flags exist for one-off use: `--show KEY`, `--hide GLOB`, `--entropy-threshold N`, `--no-config`, and `--config FILE` — which uses that file *only*, skipping both discovery and your own `~/.config`, and trusts it because you named it.
157
+
110
158
  ### Knowing what was left alone
111
159
 
112
160
  A missed secret is invisible: the output looks screened and nothing says otherwise. `--explain` writes an account of every value to **stderr**, so stdout stays a usable redacted stream and `secretscreen app.env --explain > clean.env` still works.
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "secretscreen"
7
- version = "0.4.0"
7
+ version = "0.5.1"
8
8
  description = "Detect and redact secrets in key-value pairs, dicts, and environment variables. Library and CLI."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -45,6 +45,19 @@ packages = ["src/secretscreen"]
45
45
  [tool.pytest.ini_options]
46
46
  testpaths = ["tests"]
47
47
 
48
+ # Measure the package, not the suite. Bare `pytest --cov` measures everything
49
+ # imported, which counts tests/ as covered code and puts patch coverage on the
50
+ # test file itself. That penalises exactly the tests worth writing: a branch
51
+ # that exists to fail the suite if a bug returns never runs while the code is
52
+ # correct, so a passing suite reads as an uncovered line.
53
+ #
54
+ # Omit rather than `source`: setting a source root rewrites every path in
55
+ # coverage.xml relative to it, and codecov matches those paths against the
56
+ # repository. Dropping the suite leaves `src/secretscreen/...` exactly as it
57
+ # has always been reported.
58
+ [tool.coverage.run]
59
+ omit = ["tests/*"]
60
+
48
61
  [tool.mypy]
49
62
  strict = true
50
63
  warn_return_any = true
@@ -37,4 +37,4 @@ __all__ = [
37
37
  "redact_pair",
38
38
  ]
39
39
 
40
- __version__ = "0.4.0"
40
+ __version__ = "0.5.1"