Skip to content

v1.92.8.0 fix(redact): env.kv reads Python, Dart and JSX source syntax as code (#3630) - #3742

Merged
capy-ai[bot] merged 9 commits into
mainfrom
gsta213-3630
Nov 1, 2026
Merged

capy-ai[bot] merged 9 commits into
mainfrom
gsta213-3630

Conversation

@garrytan

@garrytan garrytan commented Oct 31, 2026 •

Copy link
Copy Markdown
Owner
{
  "schema_version": 1,
  "pr": 3742,
  "head": "bd60f3a5f8885debf0b438dc627f52796f02903f",
  "version": "1.91.377.0",
  "base": "main",
  "gate": {
    "redact": {
      "pass": 366,
      "fail": 0,
      "skip": 0
    },
    "remote-pregate": {
      "pass": 8480,
      "fail": 0,
      "skip": 0
    }
  },
  "session_kind": "unattended",
  "head_tree": "e36466aaed48ff615c37ec7837e5dd69db407039",
  "product_patch_id": "b5025f616d803f1bce6527f4a8adba5ae773bb26",
  "gstack_version": "1.91.376.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 249,
    "rules": "150435b0a543019a",
    "base": "2d1b55d7621df1a71e02037c79b63b7ee2fdc64f",
    "registry": "2d1b55d7621df1a71e02037c79b63b7ee2fdc64f",
    "gate_scan": {
      "tagged": 0,
      "head": "bd60f3a5f8885debf0b438dc627f52796f02903f"
    },
    "reasons": [
      "gate-class",
      "runtime=249>50"
    ]
  },
  "pregate": "requires-remote cleared @e36466aaed48 (7 checks, current for bd60f3a5f888)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/41237414248",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/41237414248",
    "free-tests.yml/cso-windows-launcher: https://github.com/garrytan/gstack/actions/runs/41237414248",
    "windows-free-tests.yml/windows-free-shard: https://github.com/garrytan/gstack/actions/runs/41237414239",
    "pregate.json/remote_gate: remote-gate tree=e36466aaed48 tests=8480 receipt=/home/user/.capy/work/gsta213/ship3630/remote-receipt.txt sha256=f148c1f7b2e8"
  ],
  "issues": {
    "fixes": [],
    "refs": [
      3048,
      3630
    ],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "docs/pregate.md, docs/CONTRIBUTOR_REFERENCE.md, CLAUDE.md, changelog fragment"
  },
  "review_loop": {
    "passes": 3,
    "blocking_found": 3,
    "deferred": 0,
    "noted": 3,
    "fixed": 10,
    "scope": "frozen",
    "fix_checks": 3,
    "dispatches": {
      "specialist": 2,
      "red-team": 2
    }
  },
  "review_targeted": {
    "classes": [
      "secret"
    ],
    "rules": "baeb8f7ef7da92d0",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "b5025f616d803f1bce6527f4a8adba5ae773bb26",
    "status": "done",
    "findings": 0,
    "raised_by": "targeted"
  }
}

What changed

The secrets scanner stopped reading Python, Dart and JSX source syntax as credentials, without letting a real literal through.

  • env.kv source exemption (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, .pyi and .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 +.
  • Strings stay strings. In Python and Dart, one linear pass records every string's span: '''/""" blocks, and one-line strings that a backslash can continue. It skips #, // and nested /* */ comments and handles Dart raw strings. A password: pair inside any string still reports.
  • Literals still report. The rest of the name's expression is checked for a literal: = "<secret>", or "<secret>", ?? '<secret>'. So is an expression that continues on the next line. A trailing comment is cut off first.
  • pregate 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.
  • Allowlist (lib/pregate/allowlist.ts). A pattern entry written from the name instead of the value now prints a row saying it missed. Before, the issue's session: HttpSession entry failed silently. A row prints only when the pattern matches the line but not at the value.
  • Pre-push hook (bin/gstack-redact-prepush). It sees only added lines, so it scans Python and Dart lines without their path and still warns on a password: line added inside an existing """ block.

Before (main c830c9b): session: HttpSession, in a Python signature fails gstack-pregate --only secrets as 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.ts and test/redact-prepush-hook.test.ts fail on main c830c9b and pass here. Every widening has a negative control that still reports.

Refs #3630
Refs #3048

Blast radius

  • A whole-repo env.kv scan of 2473 tracked .ts/.tsx/.js/.py/.dart files finds 127 findings, the same file for file as main c830c9b.
  • TypeScript keeps fix(redact): ignore TypeScript parameter types and dynamic JSX values #3048's behavior, with two additions: a literal fallback after the name and an expression continued on the next line both report now. TS skips the string-span pass because a regex literal can hold a quote.
  • Remote pregate (tree e36466aa): 8480 tests, 0 failed.

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_SOURCE extension 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:

  • Python subscript annotations (api_key: Optional[str] = None, session: list[HttpSession]) still report.
  • A trailing /* … */ comment that holds an odd quote or an open bracket ends the TypeScript exemption. This shape is rare, and no tracked file has it.
  • A literal in a trailing comment after a Python or Dart name no longer reports. A comment line on its own never did.
  • TypeScript template literals that span lines stay exempt, as they are on main.
  • Python's = forms (password=request.password) still report.
  • A docker-compose list item, - 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

Date Asked Exact words Outcome Covers Still pending
2026-10-31 Approve the plan "Plan: env.kv false positives in Python, Dart and JSX source (#3630; rewrites #3605, #3418, #3419)" (autoplan run autoplan-20261031175220, 4 decisions) “do it” (Garry (via GStack Minder), relayed by agent:jam_01M69H8PAFAZG4MNCSCTH9RN34) approved the reviewed plan (sha256 e9c03712987d), every recommendation taken none
2026-10-31 Approve the plan "Plan: env.kv false positives in Python, Dart and JSX source (#3630; rewrites #3605, #3418, #3419)" (autoplan run autoplan-20261031175220, 3 decisions) “Approved: do it on #3630 (accept the gate_rev 2 delta uc2/uc3, which is exactly what was approved; /ship review covers it).” (Garry (via GStack Minder), relayed by agent:jam_01M69H8PAFAZG4MNCSCTH9RN34) approved the reviewed plan (sha256 e9c03712987d), every recommendation taken none

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:

  • docs/pregate.md: Updated. The allowlist section's Python/Dart bullet now limits the named-argument exemption to Dart, notes that Python's password=request.password still reports, and says the pre-push hook scans Python and Dart added lines without the exemption, so it may still warn (MEDIUM, non-blocking).
  • docs/CONTRIBUTOR_REFERENCE.md: Current.
  • CLAUDE.md: Current.
  • changelog.d/gsta213-3630-env-kv-source.md: Current (read only).

Documentation Debt

Test plan

  • Redact lane (8 files): 366 pass, 0 fail.
  • Remote pregate (Ubicloud, tree e36466aa): 8480 tests, 0 failed, $0.05.
  • The macOS and Windows lanes are cleared from this PR's CI runs.

Open in Capy

garrytan and others added 9 commits October 31, 2026 19:02
…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>
@trunk-io

trunk-io Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@github-actions github-actions Bot changed the title fix(redact): env.kv reads Python, Dart and JSX source syntax as code (#3630) v1.92.8.0 fix(redact): env.kv reads Python, Dart and JSX source syntax as code (#3630) Nov 1, 2026
@capy-ai
capy-ai Bot merged commit 64fb6ec into main Nov 1, 2026
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant