Skip to content

fix: batch rg to avoid arg-length crash (audit H4) - #49

Merged
emmanuelgjr merged 1 commit into
mainfrom
fix/audit-engine-args
Jul 18, 2026
Merged

fix: batch rg to avoid arg-length crash (audit H4)#49
emmanuelgjr merged 1 commit into
mainfrom
fix/audit-engine-args

Conversation

@emmanuelgjr

Copy link
Copy Markdown
Contributor

run_rule/detect_stack passed every candidate file on one rg command line. On Windows (32 KB CreateProcess cap) this crashed at ~180 files with an uncaught OSError that exited 1 — so a scanner crash looked like 'findings present' and no report was written. detect_stack was worst (all files, ignoring per-rule globs).

Fix: _batches() keeps each rg command under a 24 KB budget; _run_rg() maps OSErrorRuntimeError → exit 2 (documented execution error). Verified: a 400-file repo that crashed before now scans (exit 0); fixture unchanged (32); _batches unit test added. 24 pass.

run_rule and detect_stack passed every candidate file on one rg command line. On
Windows (32767-char CreateProcess cap) this crashed at ~180 files with an
uncaught OSError (WinError 206) that exited 1 — so a scanner crash masqueraded as
'findings present' and no checkpoint/report was written. detect_stack was worst:
it passed ALL files regardless of per-rule globs.

Fix: _batches() splits files so each rg command stays under a conservative
24000-char budget; _run_rg() runs the batches and maps OSError -> RuntimeError
(caught by cmd_scan -> exit 2, the documented 'execution error'). Verified: a
400-file repo that crashed before now scans (exit 0); fixture unchanged (32).
Added a _batches unit test.
@emmanuelgjr
emmanuelgjr merged commit 901c0bf into main Jul 18, 2026
8 checks passed
@emmanuelgjr
emmanuelgjr deleted the fix/audit-engine-args branch July 18, 2026 18:05
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