Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA
TypeScript
gstack-redact says that input over 16 MiB is always refused (#4351) (#4373)
Garry Tan3805969159bc
diff --git a/bin/gstack-redact b/bin/gstack-redactindex cf4dc74cf..e8ed46382 100755--- a/bin/gstack-redact+++ b/bin/gstack-redact@@ -22,6 +22,8 @@* --auto-redact IDS Comma-separated finding ids to auto-redact;* prints the redacted body to stdout + diff to stderr.* --max-bytes N Override the fail-closed size cap (default 1 MiB).+ * Input over 16 MiB is always refused; --max-bytes+ * can't raise that ceiling, so split larger input.** Security note: this is a GUARDRAIL, not airtight enforcement. A determined* user can always bypass it (direct gh/git). It catches accidents.@@ -39,7 +41,11 @@ import {} from "../lib/redact-engine";import { mkdirpSync } from "../lib/fs-utils";-const MAX_STDIN_BYTES = 16 * 1024 * 1024; // hard ceiling before the engine cap+const MAX_STDIN_MIB = 16;+const MAX_STDIN_BYTES = MAX_STDIN_MIB * 1024 * 1024; // hard ceiling before the engine cap+const CEILING_NOTE =+ `The limit is ${MAX_STDIN_MIB} MiB and --max-bytes can't raise it. ` ++ "Split the input and scan the parts.";// ── pre-push hook install/uninstall (chains any existing hook) ────────────────@@ -156,7 +162,7 @@ function readInput(): string {const st = fs.statSync(file);if (st.size > MAX_STDIN_BYTES) {// Don't even read it — fail closed at the CLI boundary.- process.stderr.write(`gstack-redact: input file too large (${st.size} bytes)\n`);+ process.stderr.write(`gstack-redact: input file too large (${st.size} bytes). ${CEILING_NOTE}\n`);process.exit(3);}return fs.readFileSync(file, "utf8");@@ -178,7 +184,7 @@ function readInput(): string {if (n === 0) break;total += n;if (total > MAX_STDIN_BYTES) {- process.stderr.write("gstack-redact: stdin too large\n");+ process.stderr.write(`gstack-redact: stdin too large. ${CEILING_NOTE}\n`);process.exit(3);}chunks.push(Buffer.from(buf.subarray(0, n)));@@ -259,7 +265,10 @@ function printUsage(code: number): never {" --self-email EMAIL --repo-public-emails PATH --auto-redact IDS\n" +" --max-bytes N\n" +"\n" +- "Exit: 0 clean · 1 usage error · 2 MEDIUM present · 3 HIGH present\n",+ `--max-bytes N raises the 1 MiB scan cap. Input over ${MAX_STDIN_MIB} MiB is always refused,\n` ++ "whatever --max-bytes says; split it and scan the parts.\n" ++ "\n" ++ "Exit: 0 clean · 1 usage error · 2 MEDIUM present · 3 HIGH present or input too large\n",);process.exit(code);}diff --git a/changelog.d/gstack-redact-names-its-16-mib-input-limit.md b/changelog.d/gstack-redact-names-its-16-mib-input-limit.mdnew file mode 100644index 000000000..c449fb296--- /dev/null+++ b/changelog.d/gstack-redact-names-its-16-mib-input-limit.md@@ -0,0 +1 @@+- `gstack-redact` now says that input over 16 MiB is always refused: `--help` and both `too large` errors name the limit, say `--max-bytes` can't raise it, and suggest splitting the input. Reported by @exGeni (#4351), first fixed by @ElNeMeR70 (#4352).diff --git a/test/gstack-redact-cli.test.ts b/test/gstack-redact-cli.test.tsindex 703b2a45a..b583e0bd9 100644--- a/test/gstack-redact-cli.test.ts+++ b/test/gstack-redact-cli.test.ts@@ -102,6 +102,39 @@ describe("gstack-redact oversize fails closed", () => {expect(code).toBe(3);expect(stdout).toContain("too large");});++ // #4351: input over the 16 MiB ceiling is refused before --max-bytes is+ // consulted, so --help and both errors have to say so.+ test("--help names the 16 MiB ceiling that --max-bytes can't raise", () => {+ const { code, stdout } = run(["--help"], "");+ expect(code).toBe(0);+ expect(stdout).toContain("Input over 16 MiB is always refused");+ expect(stdout).toContain("3 HIGH present or input too large");+ });++ test("a --from-file input over 16 MiB names the ceiling even with a bigger --max-bytes", () => {+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), "redact-ceiling-"));+ try {+ const f = path.join(dir, "big.txt");+ fs.writeFileSync(f, "");+ fs.truncateSync(f, 16 * 1024 * 1024 + 1);+ const proc = Bun.spawnSync(["bun", BIN, "--from-file", f, "--max-bytes", "33554432"], {+ timeout: 30_000,+ });+ expect(proc.exitCode).toBe(3);+ expect(proc.stderr.toString()).toContain(+ "input file too large (16777217 bytes). The limit is 16 MiB and --max-bytes can't raise it.",+ );+ } finally {+ fs.rmSync(dir, { recursive: true, force: true });+ }+ });++ test("stdin over 16 MiB names the ceiling even with a bigger --max-bytes", () => {+ const { code, stderr } = run(["--max-bytes", "33554432"], "a".repeat(16 * 1024 * 1024 + 1));+ expect(code).toBe(3);+ expect(stderr).toContain("stdin too large. The limit is 16 MiB and --max-bytes can't raise it.");+ });});describe("gstack-redact argv dispatch", () => {