secretscreen 0.2.0__tar.gz → 0.2.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.
- {secretscreen-0.2.0 → secretscreen-0.2.1}/PKG-INFO +2 -2
- {secretscreen-0.2.0 → secretscreen-0.2.1}/README.md +1 -1
- {secretscreen-0.2.0 → secretscreen-0.2.1}/docs/audits/security-audit-2026-04-05.md +23 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/pyproject.toml +1 -1
- {secretscreen-0.2.0 → secretscreen-0.2.1}/src/secretscreen/__init__.py +1 -1
- {secretscreen-0.2.0 → secretscreen-0.2.1}/src/secretscreen/_core.py +22 -8
- {secretscreen-0.2.0 → secretscreen-0.2.1}/tests/test_core.py +30 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/.github/FUNDING.yml +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/.github/dependabot.yml +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/.github/pull_request_template.md +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/.github/workflows/ci.yml +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/.github/workflows/codeql.yml +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/.github/workflows/dependabot-automerge.yml +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/.github/workflows/publish.yml +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/.github/workflows/scorecard.yml +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/.gitignore +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/CODE_OF_CONDUCT.md +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/CONTRIBUTING.md +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/LICENSE +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/NOTICE +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/SECURITY.md +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/src/secretscreen/_cli.py +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/src/secretscreen/_entropy.py +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/src/secretscreen/_formats.py +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/src/secretscreen/_keys.py +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/src/secretscreen/_parsers.py +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/src/secretscreen/_urls.py +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/src/secretscreen/gitleaks.toml +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/src/secretscreen/py.typed +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/tests/__init__.py +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/tests/test_architecture.py +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/tests/test_cli.py +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/tests/test_entropy.py +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/tests/test_formats.py +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/tests/test_keys.py +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/tests/test_parsers.py +0 -0
- {secretscreen-0.2.0 → secretscreen-0.2.1}/tests/test_urls.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: secretscreen
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Detect and redact secrets in key-value pairs, dicts, and environment variables.
|
|
5
5
|
Project-URL: Homepage, https://github.com/featurecreep-cron/secretscreen
|
|
6
6
|
Project-URL: Repository, https://github.com/featurecreep-cron/secretscreen
|
|
@@ -100,7 +100,7 @@ Redaction is structural, not line-based: it parses the format, so it catches `DB
|
|
|
100
100
|
| 1 | `--audit` found secrets |
|
|
101
101
|
| 2 | Something could not be parsed or read — see stderr |
|
|
102
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
|
|
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 64 KB detection cap — they are reported as unscanned rather than passed off as clean.
|
|
104
104
|
|
|
105
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
106
|
|
|
@@ -70,7 +70,7 @@ Redaction is structural, not line-based: it parses the format, so it catches `DB
|
|
|
70
70
|
| 1 | `--audit` found secrets |
|
|
71
71
|
| 2 | Something could not be parsed or read — see stderr |
|
|
72
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
|
|
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 64 KB detection cap — they are reported as unscanned rather than passed off as clean.
|
|
74
74
|
|
|
75
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
76
|
|
|
@@ -131,6 +131,29 @@ never touches the value — so `AWS_SECRET_ACCESS_KEY=<2MB blob>` passed through
|
|
|
131
131
|
unredacted and `audit_pair` reported no finding. Trading a 7.7s CPU stall for a silent secret
|
|
132
132
|
leak is the wrong direction for a redaction library.
|
|
133
133
|
|
|
134
|
+
**Second correction (2026-07-27)**: the 1MB threshold was also wrong, and for the same
|
|
135
|
+
reason the finding understated the problem — both were measured on benign input. The
|
|
136
|
+
"~7.7s at 50MB" figure above reproduces (I measured 11.7s for 50MB of `"x"`), but a run of
|
|
137
|
+
one character is not the worst case. On random high-entropy text — what a secret-shaped
|
|
138
|
+
blob actually looks like — at least one vendored pattern backtracks and cost goes roughly
|
|
139
|
+
quadratic above ~128KB:
|
|
140
|
+
|
|
141
|
+
| size | `"x" * n` | random |
|
|
142
|
+
|------|-----------|--------|
|
|
143
|
+
| 64KB | — | 0.57s |
|
|
144
|
+
| 128KB | — | 1.00s |
|
|
145
|
+
| 256KB | — | 14s |
|
|
146
|
+
| 1MB | 0.195s | **107s** |
|
|
147
|
+
| 10MB | 1.8s | 20.7 min |
|
|
148
|
+
|
|
149
|
+
A 1MB cap therefore admitted exactly the input that hurts most: a value one byte under it
|
|
150
|
+
pinned a core for nearly two minutes. Lowered to 64KB (0.57s worst case), matching
|
|
151
|
+
`MAX_PARSE_LENGTH`, which already bounded Layer 2 — so only Layers 3–5 narrow, and only
|
|
152
|
+
for values large enough to be data dumps rather than config. Pinned by
|
|
153
|
+
`test_worst_case_input_at_the_cap_stays_sub_second`.
|
|
154
|
+
|
|
155
|
+
Not yet identified: *which* rule backtracks. Tracked with the gitleaks sync work in #1.
|
|
156
|
+
|
|
134
157
|
The cap now gates Layers 2–5 only; Layer 1 always runs. Residual gap, accepted and tested
|
|
135
158
|
(`test_oversized_value_under_non_denylisted_key_is_a_known_gap`): an oversized value under a key
|
|
136
159
|
that Layer 1 does not match — including safe-suffix keys like `DATABASE_URL`, which depend on
|
|
@@ -173,14 +173,28 @@ def audit_dict(
|
|
|
173
173
|
# Prevents stack overflow from crafted nested JSON/Python literals.
|
|
174
174
|
_MAX_DETECT_DEPTH = 3
|
|
175
175
|
|
|
176
|
-
# Maximum value length for the value-scanning layers (2-5).
|
|
177
|
-
#
|
|
178
|
-
#
|
|
179
|
-
#
|
|
180
|
-
#
|
|
181
|
-
#
|
|
182
|
-
#
|
|
183
|
-
|
|
176
|
+
# Maximum value length for the value-scanning layers (2-5). Prevents DoS via large
|
|
177
|
+
# inputs hitting 221+ regex patterns, at least one of which backtracks badly.
|
|
178
|
+
#
|
|
179
|
+
# The threshold is set from measured worst-case input — random high-entropy text,
|
|
180
|
+
# which is what a secret-shaped blob looks like — not from a run of one character.
|
|
181
|
+
# Cost is roughly quadratic above ~128KB:
|
|
182
|
+
#
|
|
183
|
+
# 64KB 0.57s 256KB 14s
|
|
184
|
+
# 128KB 1.00s 1MB 107s
|
|
185
|
+
#
|
|
186
|
+
# This was originally 1MB, chosen against a benign benchmark (a run of 'x', which
|
|
187
|
+
# is ~500x faster at the same size). That admitted exactly the input that hurts:
|
|
188
|
+
# a value one byte under the cap pinned a core for nearly two minutes. 64KB matches
|
|
189
|
+
# MAX_PARSE_LENGTH in _parsers.py, which already bounded layer 2 — so this only
|
|
190
|
+
# narrows layers 3-5, and only for values big enough to be data dumps, not config.
|
|
191
|
+
#
|
|
192
|
+
# Layer 1 (key-name match) is deliberately exempt: it reads only the key, so an
|
|
193
|
+
# oversized value under a secret-named key is still redacted. Residual gap: an
|
|
194
|
+
# oversized value under an innocuous key name is not scanned and passes through
|
|
195
|
+
# unredacted. Callers that print values (e.g. a CLI) should surface that skip
|
|
196
|
+
# rather than let it look screened.
|
|
197
|
+
_MAX_DETECT_LENGTH = 65_536 # 64 KB
|
|
184
198
|
|
|
185
199
|
|
|
186
200
|
def _detect(key: str, value: str, config: ScreenConfig, _depth: int = 0) -> Finding | None:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Tests for core orchestration — redact_pair, redact_dict, audit_pair, audit_dict."""
|
|
2
2
|
|
|
3
3
|
from secretscreen import Finding, Mode, audit_dict, audit_pair, redact_dict, redact_pair
|
|
4
|
+
from secretscreen._core import _MAX_DETECT_LENGTH
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
class TestRedactPair:
|
|
@@ -303,6 +304,35 @@ class TestSecurityFixes:
|
|
|
303
304
|
assert finding is not None
|
|
304
305
|
assert finding.layer == "key_pattern"
|
|
305
306
|
|
|
307
|
+
def test_worst_case_input_at_the_cap_stays_sub_second(self) -> None:
|
|
308
|
+
"""The cap must be set against adversarial input, not a run of one character.
|
|
309
|
+
|
|
310
|
+
At least one vendored gitleaks pattern backtracks: cost is roughly quadratic
|
|
311
|
+
above ~128KB on random high-entropy text (what a secret-shaped blob looks
|
|
312
|
+
like). The original 1MB cap allowed a ~107s scan. A run of 'x' is ~500x
|
|
313
|
+
faster at the same size, which is why it was not a safe benchmark.
|
|
314
|
+
"""
|
|
315
|
+
import random
|
|
316
|
+
import time
|
|
317
|
+
|
|
318
|
+
random.seed(0)
|
|
319
|
+
alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/+="
|
|
320
|
+
at_cap = "".join(random.choices(alphabet, k=_MAX_DETECT_LENGTH))
|
|
321
|
+
|
|
322
|
+
start = time.perf_counter()
|
|
323
|
+
redact_pair("BLOB", at_cap)
|
|
324
|
+
elapsed = time.perf_counter() - start
|
|
325
|
+
|
|
326
|
+
# Measured ~0.57s at 64KB. 5s leaves headroom for slow CI without letting a
|
|
327
|
+
# future cap increase quietly reintroduce a multi-minute scan.
|
|
328
|
+
assert elapsed < 5.0, f"scan at the cap took {elapsed:.1f}s — is _MAX_DETECT_LENGTH too high?"
|
|
329
|
+
|
|
330
|
+
def test_cap_matches_the_parser_bound(self) -> None:
|
|
331
|
+
"""Layer 2 was already bounded at 64KB; keeping both at one value is simpler."""
|
|
332
|
+
from secretscreen._parsers import MAX_PARSE_LENGTH
|
|
333
|
+
|
|
334
|
+
assert _MAX_DETECT_LENGTH == MAX_PARSE_LENGTH
|
|
335
|
+
|
|
306
336
|
def test_large_value_layer_one_is_cheap(self) -> None:
|
|
307
337
|
"""Layer 1 on an oversized value must not fall through to the regex layers."""
|
|
308
338
|
import time
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|