Repository navigation
v1.92.8.0 fix(redact): env.kv reads Python, Dart and JSX source syntax as code (#3630) - #3742
Merged
Merged
Conversation
…ds as code (#3630) Extends the #3048 source-syntax exemption to .dart/.py/.pyi and JSX braces joined by ?? || &&, with a Dart/Python-only triple-quote guard. pregate scans changed Python/Dart files whole and keeps added-line findings, and the allowlist names a pattern entry that missed its finding. Co-authored-by: Adam Balazs <[email protected]> Co-authored-by: Hamish Barney <[email protected]> Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…repush and large-file fallback scan Python/Dart without the exemption (#3630) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…allowlist rows name file lines for whole-file scans (#3630) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… when the working copy differs from the diff; count added lines, not file lines (#3630) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…w strings, continuations); a literal fallback after a name still reports (#3630) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… reports; allowlist miss rows only for patterns written from the name; clear the span cache after each scan (#3630) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…3630) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…cans Python/Dart without the exemption (#3630) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
|
😎 This pull request was merged. |
This was referenced Nov 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
The secrets scanner stopped reading Python, Dart and JSX source syntax as credentials, without letting a real literal through.
lib/redact-patterns.ts). The fix(redact): ignore TypeScript parameter types and dynamic JSX values #3048 rule, which covered TypeScript only, now also covers.py,.pyiand.dart. A bare name after:(a parameter annotation, a dict entry, a Dart named argument) is code. A JSX brace may join names with??,||and&&as well as+.'''/"""blocks, and one-line strings that a backslash can continue. It skips#,//and nested/* */comments and handles Dart raw strings. Apassword:pair inside any string still reports.= "<secret>",or "<secret>",?? '<secret>'. So is an expression that continues on the next line. A trailing comment is cut off first.secrets(lib/pregate/checks/secrets.ts). A changed Python or Dart file is scanned whole, so the scanner can see an existing"""block. It is read whole only when it is a regular file of at most 4 MiB whose working copy holds the diff's added lines at their numbers. Only findings on added lines count, and rows give the file's line number. Untracked files are read whole too. Anything else is scanned by its added lines under a neutral name, without the exemption.lib/pregate/allowlist.ts). Apatternentry written from the name instead of the value now prints a row saying it missed. Before, the issue'ssession: HttpSessionentry failed silently. A row prints only when the pattern matches the line but not at the value.bin/gstack-redact-prepush). It sees only added lines, so it scans Python and Dart lines without their path and still warns on apassword:line added inside an existing"""block.Before (main c830c9b):
session: HttpSession,in a Python signature failsgstack-pregate --only secretsas MEDIUM env.kv. Secrets can't be downgraded, so /ship writes no receipt.After (this branch): it passes.
session: "<random value>",on the same name still fails.Why
In #3630, @dgrant reported that Python type annotations failed pregate as credentials, and the only workaround was a file-wide allowlist entry. Dart handlers (#3418, #3419 by @hbarney) and React keys (#3605 by @adam-balazs) failed the same way.
Proof: the new cases in
test/redact-engine.test.ts,test/pregate-secrets-source-context.test.ts,test/pregate-allowlist.test.tsandtest/redact-prepush-hook.test.tsfail on main c830c9b and pass here. Every widening has a negative control that still reports.Refs #3630
Refs #3048
Blast radius
.ts/.tsx/.js/.py/.dartfiles finds 127 findings, the same file for file as main c830c9b.Outside code and security read
I read #3605, #3418 and #3419 as text only and never checked out, ran or built them. This branch was written on current main. Two pieces were carried over after a line-by-line read: the
CODE_SOURCEextension to dart/py/pyi (#3418, #3419) and the JSX??/||/&&split (#3605). The first commit credits Adam Balazs and Hamish Barney with Co-authored-by. #3418's triple-quote guard was rewritten from scratch. This change adds no network calls, environment reads, permission changes, workflow, setup or install edits, or dependencies. Because it narrows a secret scanner, the review hunted for fail-open paths. Five readers took part, one of them a cross-family voice. Every finding at the blocking floor was fixed with a test that fails first.Pre-Landing Review
REVIEW_LOOP: passes=3 blocking_found=3 deferred=0 noted=3 fixed=10 scope=frozen fix_checks=3 dispatches=4
Gate edits:
lib/pregate/checks/secrets.ts(whole-file Python/Dart scan; added-line fallback without the exemption),lib/pregate/allowlist.ts(the miss row; verdicts unchanged),bin/gstack-redact-prepush(Python/Dart scanned without their path).Pass 1 of 3 was voided because the reader ran in the wrong checkout; it is counted above. GStack Minder asked for the third fix-check instead of a review-loop exception.
Noted below the blocking floor, not fixed:
api_key: Optional[str] = None,session: list[HttpSession]) still report./* … */comment that holds an odd quote or an open bracket ends the TypeScript exemption. This shape is rare, and no tracked file has it.=forms (password=request.password) still report.- API_TOKEN=<value>, doesn't match env.kv. This predates this PR (v1.92.3.0 fix(redact): env.kv catches a credential on a diff line (GST-543) #3726's bullet rule).Approvals
Source: gstack-approvals record for gsta213-3630 (display only; not an approval citation).
Documentation
Status: updated. One factual correction in docs/pregate.md; no blockers.
Scope: c830c9b..e16eafa (11 committed files, nothing staged, unstaged or untracked). Docs that describe gstack-redact, env.kv, the pre-push hook or the secrets allowlist: docs/pregate.md, docs/CONTRIBUTOR_REFERENCE.md (redaction guard section), CLAUDE.md (redaction guard section) and the changelog.d fragment (read only).
Documentation health:
password=request.passwordstill reports, and says the pre-push hook scans Python and Dart added lines without the exemption, so it may still warn (MEDIUM, non-blocking).Documentation Debt
pattern did not matchrow and the pre-push hook behavior have reference coverage only (docs/pregate.md, the changelog fragment). There is no how-to in docs/troubleshooting.md for an env.kv false positive in source code.Test plan