Skip to content

Secrets check reads files whose names hold a space or an accent (GST-3528) - #4701

Merged
capy-ai[bot] merged 4 commits into
mainfrom
secrets-check-reads-quoted-paths
Nov 22, 2026
Merged

capy-ai[bot] merged 4 commits into
mainfrom
secrets-check-reads-quoted-paths

Conversation

@garrytan

@garrytan garrytan commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

The secrets check now reads a file whose name holds a space, an accent, a quote or a backslash, such as src/clé.rs or src/my file.rs.
Why: git writes those names quoted or with a trailing tab, so the file reached the scanner with no type and a key in it passed; the push check also listed it as an unknown file.
Nothing to do.

What changed
  • New diffHeaderPath in lib/pregate/checks/secrets.ts reads a +++ header the way git writes it: a C-quoted name ("b/src/cl\303\251.rs", octal UTF-8 bytes and \t-style escapes) is unquoted, and the tab git adds after an unquoted name holding a space is dropped.
  • The secrets check's three diff parsers (added lines, added line numbers, postimages) and the push check's parser all use it, so they can't drift.
  • The old reading stays: a name git quoted or tab-ended is also scanned the way main read it (as a file with no type), so every rule main applied to it still runs. Its findings are now listed under the decoded name, so an allowlist entry scoped to that path can match them where main's nameless findings matched none.
  • A decoded name too long to write as a scratch file falls back to added plus its extension instead of stopping the check.
  • A file name holding control, C1 or bidi-override characters is printed quoted on allowlist and scanner-error lines, so it can't rewrite the terminal.
  • The secrets check's docs and a changelog fragment say what changed.
Tests and replay
  • Failing first (773c5bb): on main, a Rust key in src/clé.rs or src/my file.rs passed the secrets check, and the push check named the first (unknown file) and dropped the second. The parser unit test read both names wrong.
  • Negative control: a quoted .ts name still reports at least what main reported.
  • Replay of the secrets check's parsers over a diff of every tracked file (main vs this branch, at 47982a8): 5,321 files each, 0 lost, 0 changed; this repo has no quoted names.
Agent notes

Thread GSTA-800 for GST-3528, found by the second-model review on #4697. lib/pregate/index.ts is not touched. Other +++ parsers with the same raw read, left out of scope: lib/banned-terms.ts, lib/no-stop.ts, lib/sealed-guard.ts, bin/gstack-brain-secret-scan.py (lib/gate-diff/git.ts already drops the tab).

Approvals

Approved: yes (record r-b892276d528e). The full approval record stays private.
Plan: exempt: bug fix with failing-first tests (R4)
Plan check: exempt bug fix

Ruled note: lib/pregate/checks/secrets.ts:222:outside-voice at 51b4ade ruled by GSTA-36 (relayed from GSTA-800:01M81RHGYNFEZ2M7QFY416WBRR) at 2026-11-22T13:54:08.335Z: contrived backslash file name; the allowlist matcher's backslash handling predates this PR (approval a-ba36c6b64041)

{
  "schema_version": 1,
  "pr": 4701,
  "head": "47982a880c930b83b5c2c463f919f337448b27b7",
  "version": "1.102.2.0",
  "base": "main",
  "gate": {
    "test": {
      "pass": 1759,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 45032673223,
      "attempt": 1,
      "tree": "fd65eb6622afee0fb0b11e98c35bd762fdd820d4"
    }
  ],
  "session_kind": "unattended",
  "run": "ship-4701",
  "head_tree": "fd65eb6622afee0fb0b11e98c35bd762fdd820d4",
  "product_patch_id": "924ceaadfa54fcf631014ac8ffa2915e2ef63fba",
  "gstack_version": "1.102.2.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 102,
    "rules": "618ea1985b54beb1",
    "base": "596ff8a7cc913d405e7682ac99106cdfa7aab7e9",
    "registry": "596ff8a7cc913d405e7682ac99106cdfa7aab7e9",
    "gate_scan": {
      "tagged": 0,
      "head": "47982a880c930b83b5c2c463f919f337448b27b7"
    },
    "reasons": [
      "gate-class",
      "risk:secret",
      "risk:security",
      "runtime=102"
    ],
    "risk": [
      "secret",
      "security"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @fd65eb6622af (8 checks, current for 47982a880c93)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/45032083892/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/45032083881/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=fd65eb6622af tests=39080 skipped=72 runs=45032673223/1 profiles=ci-reuse/free-tests heads=47982a880c93 verified=2026-11-22T14:36:50.102Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/, README.md, CONTRIBUTING.md against 9055979..47982a8"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 3,
    "deferred": 0,
    "noted": 8,
    "fixed": 3,
    "scope": "frozen",
    "fix_checks": 1,
    "rounds": 2,
    "ledgers_read": 5,
    "dispatches": {
      "specialist": 2,
      "red-team": 2
    }
  },
  "review_round_grants": [
    {
      "kind": "fix-check",
      "head": "51b4ade2cf90e04bbf6917d2c9c6aa603a578eac",
      "pr": 4701,
      "by": "GSTA-36",
      "reason": "p2v outside-voice #2 (long decoded name stops the check) and #3 (lost pathless push warning), plus quoting names on the remaining report lines; first exception",
      "at": "2026-11-22T13:54:08.146Z",
      "approval": "a-ef41f7879038",
      "stop_run": "ship-4701",
      "findings": [
        "p2v/outside-voice#2",
        "p2v/outside-voice#3"
      ]
    }
  ],
  "ruled_notes": [
    {
      "finding": "lib/pregate/checks/secrets.ts:222:outside-voice",
      "head": "51b4ade2cf90e04bbf6917d2c9c6aa603a578eac",
      "by": "GSTA-36",
      "reason": "contrived backslash file name; the allowlist matcher's backslash handling predates this PR",
      "at": "2026-11-22T13:54:08.335Z",
      "approval": "a-ba36c6b64041",
      "relayed": "GSTA-800:01M81RHGYNFEZ2M7QFY416WBRR"
    }
  ],
  "gate_dispositions": [],
  "review_targeted": {
    "classes": [
      "secret"
    ],
    "rules": "7c9346274d9d1e1c",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "924ceaadfa54fcf631014ac8ffa2915e2ef63fba",
    "status": "done",
    "findings": 0,
    "raised_by": "targeted"
  }
}

REVIEW_LOOP: passes=2 blocking_found=3 deferred=0 noted=8 fixed=3 scope=frozen open=1 ledgers_read=5 fix_checks=1 dispatches=4

{"head":"51b4ade2cf90e04bbf6917d2c9c6aa603a578eac","run":"ship-4701","mark":"stop","tree":"20dc67b9e04f5429d91ffa8abafb004fcc2a791b","at":"2026-11-22T13:53:00.034Z"}
{"head":"51b4ade2cf90e04bbf6917d2c9c6aa603a578eac","run":"ship-4701","mark":"grant","grant":"a-ef41f7879038","at":"2026-11-22T14:18:35.770Z"}
{
  "schema_version": 1,
  "pr": 4701,
  "head": "47982a880c930b83b5c2c463f919f337448b27b7",
  "version": "1.102.2.0",
  "base": "main",
  "gate": {
    "test": {
      "pass": 1759,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "test",
      "run": 45032673223,
      "attempt": 1,
      "tree": "fd65eb6622afee0fb0b11e98c35bd762fdd820d4"
    }
  ],
  "session_kind": "unattended",
  "run": "ship-4701",
  "head_tree": "fd65eb6622afee0fb0b11e98c35bd762fdd820d4",
  "product_patch_id": "924ceaadfa54fcf631014ac8ffa2915e2ef63fba",
  "gstack_version": "1.102.2.0",
  "review_depth": {
    "depth": "full",
    "class": "gate",
    "runtime_lines": 102,
    "rules": "618ea1985b54beb1",
    "base": "596ff8a7cc913d405e7682ac99106cdfa7aab7e9",
    "registry": "596ff8a7cc913d405e7682ac99106cdfa7aab7e9",
    "gate_scan": {
      "tagged": 0,
      "head": "47982a880c930b83b5c2c463f919f337448b27b7"
    },
    "reasons": [
      "gate-class",
      "risk:secret",
      "risk:security",
      "runtime=102"
    ],
    "risk": [
      "secret",
      "security"
    ],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @fd65eb6622af (8 checks, current for 47982a880c93)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/45032083892/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/45032083881/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=fd65eb6622af tests=39080 skipped=72 runs=45032673223/1 profiles=ci-reuse/free-tests heads=47982a880c93 verified=2026-11-22T14:36:50.102Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "docs/, README.md, CONTRIBUTING.md against 9055979..47982a8"
  },
  "review_loop": {
    "passes": 2,
    "blocking_found": 3,
    "deferred": 0,
    "noted": 8,
    "fixed": 3,
    "scope": "frozen",
    "fix_checks": 1,
    "rounds": 2,
    "ledgers_read": 5,
    "dispatches": {
      "specialist": 2,
      "red-team": 2
    }
  },
  "review_round_grants": [
    {
      "kind": "fix-check",
      "head": "51b4ade2cf90e04bbf6917d2c9c6aa603a578eac",
      "pr": 4701,
      "by": "GSTA-36",
      "reason": "p2v outside-voice #2 (long decoded name stops the check) and #3 (lost pathless push warning), plus quoting names on the remaining report lines; first exception",
      "at": "2026-11-22T13:54:08.146Z",
      "approval": "a-ef41f7879038",
      "stop_run": "ship-4701",
      "findings": [
        "p2v/outside-voice#2",
        "p2v/outside-voice#3"
      ]
    }
  ],
  "ruled_notes": [
    {
      "finding": "lib/pregate/checks/secrets.ts:222:outside-voice",
      "head": "51b4ade2cf90e04bbf6917d2c9c6aa603a578eac",
      "by": "GSTA-36",
      "reason": "contrived backslash file name; the allowlist matcher's backslash handling predates this PR",
      "at": "2026-11-22T13:54:08.335Z",
      "approval": "a-ba36c6b64041",
      "relayed": "GSTA-800:01M81RHGYNFEZ2M7QFY416WBRR"
    }
  ],
  "gate_dispositions": [],
  "review_targeted": {
    "classes": [
      "secret"
    ],
    "rules": "7c9346274d9d1e1c",
    "brief_sha": "7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5",
    "product_patch_id": "924ceaadfa54fcf631014ac8ffa2915e2ef63fba",
    "status": "done",
    "findings": 0,
    "raised_by": "targeted"
  }
}

Open in Capy

garrytan and others added 2 commits November 22, 2026 11:55
…aders (failing first)

A Rust key in src/clé.rs or src/my file.rs passes pregate on main, and the
pre-push hook names the first an unknown file and drops the second.

Refs GST-3528

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
pregate and the pre-push hook took a file's name from a raw +++ b/ header,
so a name git C-quotes (non-ASCII, quote, backslash, control character)
became no file and a name holding a space kept git's trailing tab. Either
way the scanner got no file type and every path-scoped rule skipped it.
diffHeaderPath decodes the header the way git writes it, and all four
parsers use it.

Refs GST-3528

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 2 commits November 22, 2026 13:41
Now that the secrets check decodes git-quoted names, a name holding ESC or a
newline would reach the terminal raw and could rewrite the line that names
the file. Both report lines print such a name JSON-quoted.

Review-Finding: p1b/red-team#1 reader=red-team
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… long ones

A name git quotes or tab-ends is now scanned both ways: under its decoded
name and the way main read it (added.txt in the secrets check, no path in
the push check), so it never reports less than before. A decoded basename
too long to write is scanned as added plus its extension instead of
stopping the check. Allowlist and scanner-error lines print names through
displayPath, which now also escapes C1 and bidi-override characters.

Review-Finding: p2v/outside-voice#2 reader=outside-voice
Review-Finding: p2v/outside-voice#3 reader=outside-voice
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit a88cc7c into main Nov 22, 2026
79 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