diff --git a/bin/gstack-redact-prepush b/bin/gstack-redact-prepush index bdc3f7169..c988d2807 100755 --- a/bin/gstack-redact-prepush +++ b/bin/gstack-redact-prepush @@ -47,7 +47,7 @@ import * as fs from "fs"; import * as path from "path"; import { normalizeWithMap, scan, type Finding, type ScanOptions } from "../lib/redact-engine"; import { mkdirpSync } from "../lib/fs-utils"; -import { scannableReadings } from "../lib/pregate/checks/secrets"; +import { diffHeaderPath, displayPath, gitMangledPath, scannableReadings } from "../lib/pregate/checks/secrets"; import { resolveStateRoot } from "../lib/state-root"; import { evaluateSealed, publishedCommits, renderSealed, sealedErrorReport, type SealedReport } from "../lib/sealed-guard"; @@ -354,7 +354,7 @@ function collectAddedLines(diff: string, commit?: string): AddedFile[] { nextLine = Number(/ \+(\d+)(?:,\d+)? @+/.exec(line)?.[1] ?? 0); continue; } - if (!inHunk && line.startsWith("+++ ")) { file = line.startsWith("+++ b/") ? line.slice(6) : ""; continue; } + if (!inHunk && line.startsWith("+++ ")) { file = diffHeaderPath(line); continue; } if (!inHunk && (line.startsWith("+++") || line.startsWith("---"))) continue; const inResult = inHunk && !line.startsWith("\\") && !line.slice(0, parents).includes("-"); const lineNumber = inResult ? nextLine++ : 0; @@ -601,7 +601,7 @@ function committedAllowlist(sha: string): string[] { /** File line (and commit) of a finding. Never the matched value. */ function findingWhere(f: Finding, part: AddedFile): string { const line = part.lines[f.line - 1]; - return `${part.file || "(unknown file)"}${line ? `:${line}` : ""}` + + return `${part.file ? displayPath(part.file) : "(unknown file)"}${line ? `:${line}` : ""}` + (part.commit ? ` in commit ${part.commit.slice(0, 12)}` : ""); } @@ -710,8 +710,10 @@ function main() { const findingKey = (f: Finding) => `${f.id}:${f.line}:${f.col}`; // The readings of one binary file share its line list: a token every reading keeps is reported once. const reported = new Map>(); - for (const { part, allowlist } of parts) { - const opts = { repoVisibility: "private" as const, ...emails.options, ...(part.file && !/\.(?:dart|pyi?)$/i.test(part.file) ? { sourcePath: part.file } : {}) }; + // A name git quotes or tab-ends was read as no file before GST-3528, so it is + // also scanned without its path: the decoded name never reports less than that. + for (const { part, allowlist } of parts) for (const pathless of part.file && gitMangledPath(part.file) && !/\.(?:dart|pyi?)$/i.test(part.file) ? [false, true] : [false]) { + const opts = { repoVisibility: "private" as const, ...emails.options, ...(part.file && !pathless && !/\.(?:dart|pyi?)$/i.test(part.file) ? { sourcePath: part.file } : {}) }; const findings = scanAddedLines(part.text, opts); const kept = allowlist.length ? new Set(scanAddedLines(part.text, { ...opts, allowlist }).map(findingKey)) diff --git a/changelog.d/secrets-check-reads-quoted-paths.md b/changelog.d/secrets-check-reads-quoted-paths.md new file mode 100644 index 000000000..ab3282757 --- /dev/null +++ b/changelog.d/secrets-check-reads-quoted-paths.md @@ -0,0 +1 @@ +**The secrets check now reads files whose names hold a space, an accent or another character git quotes.** A key in `src/clé.rs` or `src/my file.rs` passed the check, because the file reached the scanner with no type and the rules for Rust and other languages skipped it; the push check also listed such a file as unknown. Both now read the name the way git writes it. (GST-3528) diff --git a/docs/pregate.md b/docs/pregate.md index f05df7781..93b4e0545 100644 --- a/docs/pregate.md +++ b/docs/pregate.md @@ -2009,6 +2009,17 @@ those, each with its scope and its reason: without a path reports it too, and the pre-push hook scans Dart and Python files without one, so a Dart `const token = "";` gets an `env.kv.rust` warning there. +- File names git quotes (GST-3528): pregate and the pre-push hook read each + file's name from the diff's `+++ ` header the way git writes it, so the + rules that depend on a file's type also read a file whose name holds a + non-ASCII letter, a quote or a backslash (git writes `+++ "b/src/cl\303\251.rs"`) + or a space (git ends the name with a tab). Before, such a file reached the + scanner with no type, so a Rust key in `src/clé.rs` or `src/my file.rs` + passed, and the hook listed the first as an unknown file. Such a file is + also still scanned the way it was before (as `added.txt` in pregate, with + no path in the hook), so it never reports less than before. A name too long + to write once decoded is scanned as `added` plus its extension, and a name + holding a control character is printed quoted. - Known limits, still reported, allowlist them by value: a JS/TS template key built from `${…}` slots (#4287), an array of names in source code (`"get_token": [load_auth, "authOperations"]`), and a generic type with diff --git a/lib/pregate/allowlist.ts b/lib/pregate/allowlist.ts index fe5a85574..7eab007c4 100644 --- a/lib/pregate/allowlist.ts +++ b/lib/pregate/allowlist.ts @@ -70,21 +70,31 @@ export function applyAllowlist(findings: readonly F[ return { kept, allowlisted, untested, missed }; } +/** + * GST-3528: a file name as reports print it. A name holding a control, C1 or + * bidi-override character is JSON-quoted with those characters escaped, so it + * can't rewrite the terminal line that names it. + */ +export function displayPath(file: string): string { + const unsafe = /[\x00-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/g; + return unsafe.test(file) ? JSON.stringify(file).replace(unsafe, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, '0')}`) : file; +} + /** sha256 of the entries, for the check's `inputs.allowlist`. */ export const allowlistDigest = (entries: readonly AllowlistEntry[]) => sha256(JSON.stringify(entries)); /** One table line per finding a pattern entry named but could not test: the finding is kept. */ export function describeUntested(a: Allowlisted): string { - return `allowlist[${a.index}] ${a.entry.finding} not tested on ${a.finding.id} (${a.finding.file}): the scanner gave no position for its pattern; the finding is kept`; + return `allowlist[${a.index}] ${a.entry.finding} not tested on ${a.finding.id} (${displayPath(a.finding.file)}): the scanner gave no position for its pattern; the finding is kept`; } /** One table line per finding a pattern entry named but did not match: the pattern is tested from where the flagged value starts, never the name before it. */ export function describeMissed(a: Allowlisted): string { - return `allowlist[${a.index}] ${a.entry.finding} pattern did not match ${a.finding.id} (${a.finding.file}${a.finding.line ? `, ${a.finding.fileLine ? 'line' : 'added line'} ${a.finding.line}` : ''}, col ${a.finding.col}): a pattern is matched from where the flagged value starts, not from the name; the finding is kept`; + return `allowlist[${a.index}] ${a.entry.finding} pattern did not match ${a.finding.id} (${displayPath(a.finding.file)}${a.finding.line ? `, ${a.finding.fileLine ? 'line' : 'added line'} ${a.finding.line}` : ''}, col ${a.finding.col}): a pattern is matched from where the flagged value starts, not from the name; the finding is kept`; } /** One table line per allowlisted finding: what, where, and which entry (with its reason) covered it. */ export function describeAllowlisted(a: Allowlisted): string { - const where = a.finding.line ? ` (${a.finding.file}, ${a.finding.fileLine ? 'line' : 'added line'} ${a.finding.line})` : ` (${a.finding.file})`; + const where = a.finding.line ? ` (${displayPath(a.finding.file)}, ${a.finding.fileLine ? 'line' : 'added line'} ${a.finding.line})` : ` (${displayPath(a.finding.file)})`; return `allowlisted ${a.finding.id}${where} by allowlist[${a.index}] ${a.entry.finding}: ${a.entry.reason}`; } diff --git a/lib/pregate/checks/secrets.ts b/lib/pregate/checks/secrets.ts index 2ab833c88..75f417d84 100644 --- a/lib/pregate/checks/secrets.ts +++ b/lib/pregate/checks/secrets.ts @@ -12,7 +12,7 @@ import { spawnSync } from '../../spawn-sync'; import * as fs from 'node:fs'; import * as path from 'node:path'; import { runScriptSync } from '../../script-invocation'; -import { allowlistDigest, applyAllowlist, describeAllowlisted, describeMissed, describeUntested, type AllowlistFinding } from '../allowlist'; +import { allowlistDigest, applyAllowlist, describeAllowlisted, describeMissed, describeUntested, displayPath, type AllowlistFinding } from '../allowlist'; import { baseInputs, sha256 } from '../context'; import { environmentResult, launchCause } from '../environment'; import { checkScratch } from '../run-scratch'; @@ -20,6 +20,35 @@ import type { CheckDef, CheckResult, PregateContext } from '../types'; const BIN_DIR = path.resolve(path.dirname(Bun.fileURLToPath(import.meta.url)), '..', '..', '..', 'bin'); +/** + * GST-3528: the file a `+++ ` header names, or '' when it is not under `b/`. + * Git C-quotes a path holding a non-ASCII byte, a quote, a backslash or a + * control character (`+++ "b/cl\\303\\251.rs"`: octal bytes of UTF-8 and + * `\\t`-style escapes), and ends an unquoted path holding a space with a tab + * (`+++ b/my file.rs`). Reading either raw gave the scanner no file + * type, so every path-scoped rule skipped it. + */ +export function diffHeaderPath(line: string): string { + const raw = line.slice(4); + if (!raw.startsWith('"')) return raw.startsWith('b/') ? raw.replace(/\t$/, '').slice(2) : ''; + const bytes: number[] = []; + const chars = Array.from(raw); + for (let i = 1; i < chars.length; i++) { + const c = chars[i]!; + if (c === '"') { const name = new TextDecoder().decode(Uint8Array.from(bytes)); return name.startsWith('b/') ? name.slice(2) : ''; } + if (c !== '\\') { bytes.push(...new TextEncoder().encode(c)); continue; } + const next = chars[++i] ?? ''; + if (/^[0-7]{3}$/.test(chars.slice(i, i + 3).join(''))) { bytes.push(parseInt(chars.slice(i, i + 3).join(''), 8)); i += 2; continue; } + bytes.push(({ a: 7, b: 8, t: 9, n: 10, v: 11, f: 12, r: 13 } as Record)[next] ?? next.charCodeAt(0)); + } + return ''; +} + +export { displayPath }; + +/** A name git writes quoted or tab-ended in a `+++ ` header (a space, a non-ASCII byte, a quote, a backslash or a control character): main read it as no file. */ +export const gitMangledPath = (file: string): boolean => /[^\x21-\x7e]|["\\]/.test(file); + /** The diff's added-line text per file, hunk-aware: a `+++` inside a hunk is content, not a header. */ export function parseAddedLines(diff: string): Map { const files = new Map(); @@ -28,7 +57,7 @@ export function parseAddedLines(diff: string): Map { for (const line of diff.split('\n')) { if (line.startsWith('diff --')) { file = ''; inHunk = false; continue; } if (line.startsWith('@@')) { inHunk = true; continue; } - if (!inHunk) { if (line.startsWith('+++ ')) file = line.startsWith('+++ b/') ? line.slice(6) : ''; continue; } + if (!inHunk) { if (line.startsWith('+++ ')) file = diffHeaderPath(line); continue; } if (!line.startsWith('+')) continue; const lines = files.get(file); if (lines) lines.push(line.slice(1)); else files.set(file, [line.slice(1)]); @@ -45,7 +74,7 @@ export function parseAddedLineNumbers(diff: string): Map { if (line.startsWith('diff --')) { file = ''; next = 0; continue; } const hunk = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(line); if (hunk) { next = Number(hunk[1]); continue; } - if (!next) { if (line.startsWith('+++ ')) file = line.startsWith('+++ b/') ? line.slice(6) : ''; continue; } + if (!next) { if (line.startsWith('+++ ')) file = diffHeaderPath(line); continue; } if (line.startsWith('+')) { if (!files.has(file)) files.set(file, []); files.get(file)!.push(next++); } else if (line.startsWith(' ')) next++; } @@ -66,7 +95,7 @@ export function parsePostimages(diff: string): Map { if (lines) files.set(file, lines); else file = ''; continue; } - if (lines === null) { if (line.startsWith('+++ ')) file = line.startsWith('+++ b/') ? line.slice(6) : ''; continue; } + if (lines === null) { if (line.startsWith('+++ ')) file = diffHeaderPath(line); continue; } if (line.startsWith('+') || line.startsWith(' ')) lines.push(line.slice(1)); } return files; @@ -106,6 +135,22 @@ export function scannableReadings(text: string): string[] { /** Files whose source-syntax exemption needs the whole file: a line added inside an existing `'''`/`"""` block is a literal (#3630). */ const LEXICAL_CONTEXT_SOURCE = /\.(?:dart|pyi?)$/i; + +/** + * The scratch names a part is scanned under. The scanner reads the file type + * from the name. A basename too long for the filesystem once decoded (invalid + * UTF-8 bytes become three-byte U+FFFD) is scanned as `added` plus its + * extension, so a long name never stops the check. A name git quotes or + * tab-ends is also scanned as `added.txt`, the way main read it, so the + * decoded name never reports less than main did (GST-3528). + */ +function scratchNames(part: { file: string; keep?: number[] }): string[] { + const base = path.basename(part.file); + const ext = path.extname(base); + const fit = Buffer.byteLength(base) <= 200 ? base : `added${Buffer.byteLength(ext) <= 32 ? ext : ''}`; + const name = (!part.keep && LEXICAL_CONTEXT_SOURCE.test(part.file) ? '' : fit) || 'added.txt'; + return gitMangledPath(part.file) && name !== 'added.txt' ? [name, 'added.txt'] : [name]; +} const WHOLE_FILE_MAX_BYTES = 4 * 1024 * 1024; /** @@ -177,13 +222,13 @@ function run(ctx: PregateContext): CheckResult { let high = false; let medium = false; let parsedAll = true; - for (const [i, part] of parts.entries()) for (const [j, text] of part.texts.entries()) { - const file = path.join(tmp, `${i}.${j}`, (!part.keep && LEXICAL_CONTEXT_SOURCE.test(part.file) ? '' : path.basename(part.file)) || 'added.txt'); + for (const [i, part] of parts.entries()) for (const [j, text] of part.texts.entries()) for (const [k, name] of scratchNames(part).entries()) { + const file = path.join(tmp, `${i}.${j}.${k}`, name); fs.mkdirSync(path.dirname(file), { mode: 0o700 }); fs.writeFileSync(file, text, { mode: 0o600 }); const r = runScriptSync(path.join(BIN_DIR, 'gstack-redact'), ['--from-file', file, '--json', '--max-bytes', String(64 * 1024 * 1024)], { cwd: ctx.repoRoot, encoding: 'utf8', timeout: Math.min(ctx.timeoutMs, 300_000), maxBuffer: 64 * 1024 * 1024, env: ctx.env }); - if (r.error || r.status === null) return environmentResult(base, launchCause('tool', `gstack-redact did not finish on ${part.file || 'added lines'} (${r.error?.message ?? 'killed'})`), `gstack-redact did not finish on ${part.file || 'added lines'}; an incomplete scan never passes`); - if (r.status !== 0 && r.status !== 2 && r.status !== 3) return environmentResult(base, launchCause('tool', `gstack-redact exited ${r.status} on ${part.file || 'added lines'}: ${(r.stderr ?? '').trim().split('\n').pop() ?? ''}`), `gstack-redact exited ${r.status}; an incomplete scan never passes`); + if (r.error || r.status === null) return environmentResult(base, launchCause('tool', `gstack-redact did not finish on ${part.file ? displayPath(part.file) : 'added lines'} (${r.error?.message ?? 'killed'})`), `gstack-redact did not finish on ${part.file ? displayPath(part.file) : 'added lines'}; an incomplete scan never passes`); + if (r.status !== 0 && r.status !== 2 && r.status !== 3) return environmentResult(base, launchCause('tool', `gstack-redact exited ${r.status} on ${part.file ? displayPath(part.file) : 'added lines'}: ${(r.stderr ?? '').trim().split('\n').pop() ?? ''}`), `gstack-redact exited ${r.status}; an incomplete scan never passes`); high ||= r.status === 3; medium ||= r.status === 2; const lines = text.split('\n'); @@ -200,7 +245,7 @@ function run(ctx: PregateContext): CheckResult { return true; }); if (parsedAll) { high = kept.some(f => f.severity === 'HIGH'); medium = kept.some(f => f.severity === 'MEDIUM'); } - const render = (f: Scanned) => `${f.severity} ${f.id} [${f.category}]: ${f.description ?? ''}${f.line ? ` (${f.file ? `${f.file}, ` : ''}${f.fileLine ? 'line' : 'added line'} ${f.line})` : ''}`; + const render = (f: Scanned) => `${f.severity} ${f.id} [${f.category}]: ${f.description ?? ''}${f.line ? ` (${f.file ? `${displayPath(f.file)}, ` : ''}${f.fileLine ? 'line' : 'added line'} ${f.line})` : ''}`; const allowLines = [...applied.allowlisted.map(describeAllowlisted), ...applied.untested.map(describeUntested), ...applied.missed.map(describeMissed)]; const allowNote = applied.allowlisted.length ? `; ${applied.allowlisted.length} allowlisted (${[...new Set(applied.allowlisted.map(a => a.finding.id))].join(', ')})` : ''; // HIGH and any MEDIUM credential fail; a MEDIUM hygiene/internal/pii/legal diff --git a/test/pregate-secrets-source-context.test.ts b/test/pregate-secrets-source-context.test.ts index ecbd49bf3..fae85b009 100644 --- a/test/pregate-secrets-source-context.test.ts +++ b/test/pregate-secrets-source-context.test.ts @@ -8,7 +8,7 @@ import { spawnSync } from 'child_process'; import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { parseAddedLineNumbers, parseAddedLines, secretsCheck } from '../lib/pregate/checks/secrets'; +import { diffHeaderPath, displayPath, parseAddedLineNumbers, parseAddedLines, parsePostimages, secretsCheck } from '../lib/pregate/checks/secrets'; import type { PregateContext } from '../lib/pregate/types'; import { cleanup, commit, makeFixtureRepo, runBin, BASE_PREGATE, type FixtureRepo } from './helpers/pregate-fixture'; @@ -67,6 +67,48 @@ describe('pregate secrets: source context and diff integrity', () => { expect([...parseAddedLines(diff)]).toEqual([['a.ts', ['one', '++two']], ['b.env', ['three']]]); }); + // Value: protects=path-scoped rules read files git quotes or tab-ends in the diff header; fails_when=a quoted or spaced path reaches the scanner as added.txt; why_new=GST-3528 had no test; seam=pure parser; no_claim=git's quoting rules beyond C-style escapes + test('a quoted or space-holding +++ path is read as the file git names (GST-3528)', () => { + const diff = ['diff --git "a/src/cl\\303\\251.rs" "b/src/cl\\303\\251.rs"', '+++ "b/src/cl\\303\\251.rs"', '@@ -0,0 +1 @@', '+one', 'diff --git a/src/my file.rs b/src/my file.rs', '+++ b/src/my file.rs\t', '@@ -0,0 +1 @@', '+two', 'diff --git "a/q\\"t\\\\x.ts" "b/q\\"t\\\\x.ts"', '+++ "b/q\\"t\\\\x\\ty.ts"', '@@ -0,0 +1 @@', '+three'].join('\n'); + const files = ['src/clé.rs', 'src/my file.rs', 'q"t\\x\ty.ts']; + expect([...parseAddedLines(diff).keys()]).toEqual(files); + expect([...parseAddedLineNumbers(diff).keys()]).toEqual(files); + expect([...parsePostimages(diff).keys()]).toEqual(files); + }); + + test('a decoded name holding a control character is printed quoted, never raw (GST-3528 review)', () => { + const name = diffHeaderPath('+++ "b/a\\033[2Kb.rs"'); + expect(name).toBe('a\x1b[2Kb.rs'); + expect(displayPath(name)).toBe('"a\\u001b[2Kb.rs"'); + expect(displayPath('src/my file.rs')).toBe('src/my file.rs'); + expect(displayPath('a\u009bb\u202ec.rs')).toBe('"a\\u009bb\\u202ec.rs"'); + }); + + test('a quoted .ts file reports at least what main reported when it read the file as added.txt (GST-3528 grant)', () => { + const body = 'const cfg = {\n token: credentials.token,\n apiKey: settings.apiKey,\n};\n'; + const r = repo({ 'src/clé.ts': body }).secrets(); + expect({ status: r.status, rows: r.lines.filter((l) => l.includes('src/clé.ts')).length > 0 }).toEqual({ status: 'fail', rows: true }); + expect(repo({ 'src/cle.ts': body }).secrets()).toMatchObject({ status: 'pass' }); + }, 60_000); + + test.skipIf(process.platform !== 'linux')('a long name of invalid UTF-8 bytes is still scanned, never stopping the check (GST-3528 grant)', () => { + const secret = ['sk-live-FAKE-', 'Qx9vL2mZ', 'p8Rt4Kw7', 'Yn3Bh2Jd'].join(''); + const f = repo({ 'README.md': 'base\n' }); + const name = Buffer.concat([Buffer.from('src/'), Buffer.alloc(120, 0xff), Buffer.from('.rs')]); + fs.mkdirSync(path.join(f.dir, 'src'), { recursive: true }); + fs.writeFileSync(Buffer.concat([Buffer.from(f.dir + '/'), name]), 'fn c() {\n let token = "' + secret + '";\n}\n'); + f.git('add', '-A'); + f.git('commit', '-qm', 'long name'); + const r = f.secrets(); + expect({ status: r.status, rust: r.lines.some((l) => l.includes('env.kv.rust')) }).toEqual({ status: 'fail', rust: true }); + }, 60_000); + + test('a Rust key in a file whose name git quotes or ends with a tab still fails, naming the file (GST-3528)', () => { + const secret = ['sk-live-FAKE-', 'Qx9vL2mZ', 'p8Rt4Kw7', 'Yn3Bh2Jd'].join(''); + const r = repo({ 'src/clé.rs': 'fn c() {\n let token = "' + secret + '";\n}\n', 'src/my file.rs': 'fn d() {\n let token = "' + secret + '";\n}\n' }).secrets(); + expect({ status: r.status, rows: r.lines.filter((l) => l.includes('env.kv.rust')).sort() }).toEqual({ status: 'fail', rows: [expect.stringContaining('(src/clé.rs, added line 2)'), expect.stringContaining('(src/my file.rs, added line 2)')] }); + }, 60_000); + test('a Python call that reads key.json is code; the same key name holding a literal key still fails (GST-1064)', () => { expect(repo({ 'attach.py': 'import json\nkey = json.loads(files.get("key.json", ""))\n' }).secrets().status).toBe('pass'); const fake = 'Zx9Q' + 'w8Er7Ty6Ui5Op4As3Df2'; diff --git a/test/redact-prepush-hook.test.ts b/test/redact-prepush-hook.test.ts index 6c9d9ee43..3409010bd 100644 --- a/test/redact-prepush-hook.test.ts +++ b/test/redact-prepush-hook.test.ts @@ -125,6 +125,27 @@ describe("pre-push hook gating", () => { }); }); +// Value: protects=pushed files git quotes or tab-ends in the diff header keep their names; fails_when=the hook reports them as an unknown file or a tab-ended name; why_new=GST-3528 had no test; seam=hook on a real repo; no_claim=path-scoped exemptions beyond the file name +describe("a file git quotes or tab-ends in the diff header keeps its name (GST-3528)", () => { + test("a Rust key in src/clé.rs and src/my file.rs is reported under each file's name", () => { + const secret = ["sk-live-FAKE-", "Qx9vL2mZ", "p8Rt4Kw7", "Yn3Bh2Jd"].join(""); + const base = git(["rev-parse", "HEAD"]); + const head = commitFiles({ "src/clé.rs": 'fn c() {\n let token = "' + secret + '";\n}\n', "src/my file.rs": 'fn d() {\n let token = "' + secret + '";\n}\n' }, "add keys"); + const { stderr } = runHook(`refs/heads/main ${head} refs/heads/main ${base}\n`); + expect(stderr).toContain("env.kv.rust src/clé.rs:2"); + expect(stderr).toContain("env.kv.rust src/my file.rs:2"); + expect(stderr).not.toContain("(unknown file)"); + }); + + test("a quoted .ts file still gets the no-path warning main gave it", () => { + const secret = ["sk-live-FAKE-", "Qx9vL2mZ", "p8Rt4Kw7", "Yn3Bh2Jd"].join(""); + const base = git(["rev-parse", "HEAD"]); + const head = commitFiles({ "src/clé.ts": 'const token = "' + secret + '";\n' }, "add key"); + const { stderr } = runHook(`refs/heads/main ${head} refs/heads/main ${base}\n`); + expect(stderr).toContain("env.kv.rust src/clé.ts:1"); + }); +}); + // #2856: a 4-part release version is shaped like a public IPv4 address. // Assembled at runtime so this file's own pushed diff carries no IP-shaped // literal for the repo's pre-push scan to warn about.