Repository navigation
fix(cli): reject non-decimal binary diagnostic limits - #9166
Plastic-time wants to merge 2 commits into
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The PR appears safe to merge; no blocking issue remains. SummaryUses
Reviews (3) · Last reviewed commit: "test(cli): assert binary limit facts and..." · Reviewed by Greptile |
The decimal keep case matched "max_functions above 1" in the remediation text. It now checks details.reported_limits for the functions limit with maximum 1, so a wording change cannot break it. The rejection rows put the value third. The test name now prints the tested spelling, such as --max-functions=1e1, instead of the field.
Summary
Most limits in
src/cli/binaryDiagnosticsCommands.tswere registered as the shared numeric fields. Incur reads those throughNumber(). Soinspect-pe-imports --max-dlls 0x2enforced a two-descriptor budget, and--max-file-bytes 1e3meant 1000 bytes. #8919 fixed the same coercion for the byte-entropy window in this file withcliDecimalField. This change uses that helper for the other 26 limits in the file.No issue is linked. I found this while checking which numeric CLI options still go through
Number().Problem and expected behavior
On main
bacc1e384, withC:\Windows\System32\notepad.exe(3 import descriptors):rea inspect-pe-imports notepad.exe --max-dlls 0x2 --jsonexits 1 withresource_constraint: "Import inventory declares 3 descriptors, above the 2-entry DLL allowance".--max-dlls 2gives the same result.0x…or1e…spelling within the field's bounds is admitted as its numeric value.Expected: these limits take decimal text only. A non-decimal spelling is refused during argument parsing and names the field. Decimal values keep the shared bounds and defaults.
Change and scope
src/cli/binaryDiagnosticsCommands.tswraps each shared field incliDecimalField(...):inspect-elf-notes:--max-file-bytes,--max-entriesinspect-apple-ips:--max-file-bytes,--max-threads,--max-frames,--max-images,--max-registers,--max-integer-text-bytesinspect-kernel-module:--max-file-bytes,--max-entriesinspect-pe-load-config:--max-file-bytes,--max-callbacksinspect-binary-hardening:--max-file-bytesinspect-pe-certificates:--max-file-bytes,--max-entriesinspect-pe-imports:--max-file-bytes,--max-dlls,--max-functionsinspect-pe-resources:--max-file-bytes,--max-entriesinspect-devicetree:--max-file-bytes,--max-nodes,--max-properties,--max-depth(the CLI descriptions stay)inspect-native-exports:--max-file-bytesinspect-binary-layoutandinspect-recorded-crash:--pwntools-timeout-ms(optional, still absent when omitted)The byte-entropy options were already decimal-only. MCP is unchanged.
Scope decision: not applicable. This is an ordinary fix within the existing CLI boundary.
Contract and boundary impact
inspect*InputSchemastill owns its bounds and defaults. CLI argument parsing now admits only decimal text before it.<number>to<value>, as for the byte-entropy options. MCP is unchanged.docs/public/product-catalog.json), package, or installation impact: none committed.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
Tests added or updated: a "binary diagnostic limit options" block in
tests/boundary/cli/cliIntegerArguments.test.ts, after the pyc and BEAM block.0x…or1e…spelling thatNumber()admits within that field's bounds, and expectsVALIDATION_ERRORnaming the field.inspect-pe-imports --max-functions=01on the existingpeImportImage()fixture (two functions). It expectsresource_constraintwithdetails.reported_limits{ limit: "functions", maximum: 1 }, so the decimal value reaches the service.Base reproduction: with main's
binaryDiagnosticsCommands.ts(rebuilt bytest:focused), the file gives 27 failed, 112 passed. All 27 rejection rows fail; the positive case passes. With this change: 139 passed.User-visible CLI output,
inspect-pe-imports C:\Windows\System32\notepad.exe --max-dlls 0x2 --json:Before: exit 1,
"code":"resource_constraint", "above the 2-entry DLL allowance".After:
{"code":"VALIDATION_ERROR","message":"REA could not read the command arguments. Check the named argument and its expected type, then try again.","fieldErrors":[{"code":"invalid_format","missing":false,"path":"maxDlls","expected":"","received":"","message":"Expected a decimal integer"}]}--max-dlls 2still gives the 2-entryresource_constraint.inspect-pe-imports --helpshows the same descriptions and defaults as main.Remaining proof gaps: Linux CI has not run yet. The pwntools options are only checked at argument parsing here, since pwntools runs on Linux x64 only.
Boundary regressions: input admission at the CLI argument boundary, through the compiled CLI. Lifecycle regressions: not applicable.
For evidence-bearing changes:
Not an evidence-bearing change.
Validation performed
Windows 11, Node.js 24.22.1, base
bacc1e384.npm run test:focused -- tests/boundary/cli/cliIntegerArguments.test.ts: 139 passed. With main'sbinaryDiagnosticsCommands.ts: 27 failed, 112 passed.npm run typecheckandnpm run check:fast: passed.npx oxfmton the two changed files.git merge-treewith feat(pe): inspect Rich header linker records #8923, fix(cli): reject non-decimal objdump and Rizin command timeouts #9059 and the other open PRs that touch this file: no new conflicts. The ones that conflict already conflict with main.Compatibility, safety, and release
0x2or1e3is now refused. The limits are documented as counts, byte sizes and milliseconds, so this follows fix(cli): reject non-decimal byte-entropy window options #8919 without a breaking marker.Author readiness
Human owner: @Plastic-time
Before merge
type(scope): outcome.