gstack-redact says that input over 16 MiB is always refused (#4351) (#4373)

gstack-redact refuses any input over 16 MiB before --max-bytes is read, so
a bigger --max-bytes never helped and nothing said so. --help and both
"too large" errors now name the 16 MiB limit, say --max-bytes can't raise
it, and suggest splitting the input. The help's exit line also says that
exit 3 covers input that is too large. What gets scanned, what gets
redacted, the exit codes and where output goes are unchanged.

Rebuilt on main from #4352.

Co-authored-by: ElNeMeR70 <83190847+ElNeMeR70@users.noreply.github.com>
Co-authored-by: exGeni <135786749+exGeni@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-11-15 01:32:03 +00:00
1 parent 81fb900835
commit 3805969159
3 files changed
+47 -4

No files matched your search

+33
View File
@@ -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", () => {