Repository navigation
fix(cli): reject non-decimal firmware range and limit options - #9169
Plastic-time wants to merge 1 commit 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 was found. SummaryThe firmware commands now use
Reviews (2) · Last reviewed commit: "fix(cli): reject non-decimal firmware ra..." · Reviewed by Greptile |
Summary
extract-firmwareandinspect-firmware-regionsregistered their range, limits and deadlines as the shared firmware number fields. Incur reads those throughNumber(). So--offset=(empty) became offset 0,--length 0x10became 16 bytes, and--max-output-bytes 1e3meant 1000 bytes. #8919 fixed the same coercion for the byte-entropy window withcliDecimalField. This change uses that helper for the eight firmware options.No issue is linked. I found this while checking which numeric CLI options still go through
Number().Problem and expected behavior
On main
bacc1e384, on Windows:rea extract-firmware fw.bin out --offset= --length=5 --jsonpasses argument parsing and stops atcapability_unavailable(unblob needs Linux). On a Linux host withREA_UNBLOB_COMMAND, the same call would select a range that starts at 0. That host run was not done here.--length=0x10,--max-depth=0x2,--max-output-bytes=1e3,--max-output-files=0x10,--publication-timeout-ms=1e3,--analysis-timeout-ms=0x10, andinspect-firmware-regions --analysis-timeout-ms=1e3.Expected: these options take decimal text only. A non-decimal or empty spelling is refused during argument parsing and names the field. Decimal values keep the shared bounds and defaults. The offset/length pairing check is unchanged.
Change and scope
src/cli/firmwareCommands.ts:--offset,--length,--max-depth,--max-output-bytes,--max-output-files,--publication-timeout-msand--analysis-timeout-msusecliDecimalField(...)on the shared fields. Both commands share one--analysis-timeout-msparser. The CLI descriptions for--offsetand--lengthstay.Scope decision: not applicable. This is an ordinary fix within the existing CLI boundary.
Contract and boundary impact
firmwareInputSchemasstill owns the bounds and defaults. CLI argument parsing now admits only decimal text before it.<number>to<value>, as for the other decimal options. The advertised JSON Schema keeps the same bounds and defaults; the existing check incliInputSchemaRequired.test.tspasses. 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: one table test in
tests/boundary/cli/firmwareIncompleteRange.test.ts, after the existing range test.0x…or1e…spelling thatNumber()admits within that field's bounds, and expectsVALIDATION_ERRORnaming the field.--offset 5and--length 5and gets the companion-option error, so decimal values keep reaching validation.Base reproduction: with main's
firmwareCommands.ts(rebuilt bytest:focused),firmwareIncompleteRange.test.tsandcliInputSchemaRequired.test.tsgive 8 failed, 24 passed. All 8 new rows getcapability_unavailable. With this change: 32 passed.User-visible CLI output,
extract-firmware fw.bin out --offset= --length=5 --jsonon Windows:Before: exit 1,
"code":"capability_unavailable", "This integration requires Linux and an absolute REA_UNBLOB_COMMAND path to the caller-supplied tool".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":"offset","expected":"","received":"","message":"Expected a decimal integer"}]}--helpshows--offset <value> Selected byte offset; requires lengthand--max-depth <value> Extraction depth; reaching it yields partial analysis (default: 3).Remaining proof gaps: Linux CI has not run yet. No real unblob or binwalk extraction ran, because both integrations need Linux.
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/firmwareIncompleteRange.test.ts tests/boundary/cli/cliInputSchemaRequired.test.ts: 32 passed. With main'sfirmwareCommands.ts: 8 failed, 24 passed.npm run typecheckandnpm run check:fast: passed.npx oxfmton the two changed files.firmwareCommands.tsor the test file.Compatibility, safety, and release
0x1000or1e3, and an empty value, are now refused. A script that passed a hexadecimal firmware offset must convert it to decimal. The options are documented as byte offsets, counts 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.