gstack/lib
Jayesh Betala bfeb6462ee fix(redact): invalid --max-bytes must not disable the fail-closed guard
A malformed `--max-bytes` value silently turned the redaction engine's
oversize guard from fail-CLOSED into fail-OPEN.

`bin/gstack-redact` parsed the flag with `parseInt(...)` and passed the
result straight through, so `--max-bytes notanumber` became `maxBytes: NaN`.
In `lib/redact-engine.ts`, `opts.maxBytes ?? DEFAULT_MAX_BYTES` only catches
null/undefined — `NaN` slipped past, and `byteLen > NaN` is always false, so
the "input too large to scan safely" block never fired. A negative value made
the opposite happen: every input blocked with a nonsensical `> -5 bytes`.

- engine: treat a non-finite or non-positive `maxBytes` as invalid and fall
  back to the known-good 1 MiB default, so the guard stays intact for every
  caller regardless of how the cap was computed.
- CLI: reject a malformed `--max-bytes` with a clear stderr error and exit 1
  (usage error, distinct from the 0/2/3 finding-tier codes) instead of
  silently passing NaN.
- tests: engine regression (invalid cap still fails closed at the default)
  and CLI contract (malformed flag exits 1).

Fixes #1824

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 13:17:24 +05:30
..
conductor-env-shim.ts v1.39.2.0 feat: GSTACK_* env-shim for Conductor + gbrain/gstack setup docs (#1534) 2026-05-16 12:32:33 -07:00
gbrain-exec.ts v1.55.0.0 fix wave: gbrain data-loss guards + browser crash-loop + 6 more (#1808) 2026-05-30 14:57:07 -07:00
gbrain-guards.ts v1.55.0.0 fix wave: gbrain data-loss guards + browser crash-loop + 6 more (#1808) 2026-05-30 14:57:07 -07:00
gbrain-local-status.ts v1.55.0.0 fix wave: gbrain data-loss guards + browser crash-loop + 6 more (#1808) 2026-05-30 14:57:07 -07:00
gbrain-sources.ts v1.55.0.0 fix wave: gbrain data-loss guards + browser crash-loop + 6 more (#1808) 2026-05-30 14:57:07 -07:00
gstack-memory-helpers.ts v1.43.2.0 fix wave: post-Daegu paper-cut — 18 fixes, 28 bisect commits (#1642) 2026-05-21 21:21:07 -07:00
redact-audit-log.ts v1.53.0.0 feat: smarter redaction — PII/secrets/legal guard across /spec, /ship, /cso, /document-* (#1797) 2026-05-30 08:54:46 -07:00
redact-engine.ts fix(redact): invalid --max-bytes must not disable the fail-closed guard 2026-06-01 13:17:24 +05:30
redact-patterns.ts v1.53.0.0 feat: smarter redaction — PII/secrets/legal guard across /spec, /ship, /cso, /document-* (#1797) 2026-05-30 08:54:46 -07:00
worktree.ts feat: content security — 4-layer prompt injection defense for pair-agent (#815) 2026-04-06 14:41:06 -07:00