Skip to content

fix(cli): reject non-decimal firmware range and limit options - #9169

Closed
Plastic-time wants to merge 1 commit into
morluto:mainfrom
Plastic-time:rrfz/decimal-firmware-options
Closed

Plastic-time wants to merge 1 commit into
morluto:mainfrom
Plastic-time:rrfz/decimal-firmware-options

Conversation

@Plastic-time

@Plastic-time Plastic-time commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

extract-firmware and inspect-firmware-regions registered their range, limits and deadlines as the shared firmware number fields. Incur reads those through Number(). So --offset= (empty) became offset 0, --length 0x10 became 16 bytes, and --max-output-bytes 1e3 meant 1000 bytes. #8919 fixed the same coercion for the byte-entropy window with cliDecimalField. 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 --json passes argument parsing and stops at capability_unavailable (unblob needs Linux). On a Linux host with REA_UNBLOB_COMMAND, the same call would select a range that starts at 0. That host run was not done here.
  • The same holds for --length=0x10, --max-depth=0x2, --max-output-bytes=1e3, --max-output-files=0x10, --publication-timeout-ms=1e3, --analysis-timeout-ms=0x10, and inspect-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-ms and --analysis-timeout-ms use cliDecimalField(...) on the shared fields. Both commands share one --analysis-timeout-ms parser. The CLI descriptions for --offset and --length stay.
  • An omitted range option and an omitted analysis deadline stay absent.
  • MCP is unchanged.

Scope decision: not applicable. This is an ordinary fix within the existing CLI boundary.

Contract and boundary impact

  • Semantic owner and earliest changed stage: firmwareInputSchemas still owns the bounds and defaults. CLI argument parsing now admits only decimal text before it.
  • Contribution scope fit and linked maintainer decision: ordinary fix; not applicable.
  • CLI and MCP/tool-catalog contract: the eight CLI options now refuse non-decimal text. Help keeps the descriptions and defaults; the type hint changes from <number> to <value>, as for the other decimal options. The advertised JSON Schema keeps the same bounds and defaults; the existing check in cliInputSchemaRequired.test.ts passes. MCP is unchanged.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none. A decimal value reaches the same service input as before.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): a refused option reads no firmware and creates no output directory.
  • Generated metadata (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.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: one table test in tests/boundary/cli/firmwareIncompleteRange.test.ts, after the existing range test.

    • One row per option. Each passes a single empty, 0x… or 1e… spelling that Number() admits within that field's bounds, and expects VALIDATION_ERROR naming the field.
    • The existing range test in the same file still passes decimal --offset 5 and --length 5 and gets the companion-option error, so decimal values keep reaching validation.
  • Base reproduction: with main's firmwareCommands.ts (rebuilt by test:focused), firmwareIncompleteRange.test.ts and cliInputSchemaRequired.test.ts give 8 failed, 24 passed. All 8 new rows get capability_unavailable. With this change: 32 passed.

  • User-visible CLI output, extract-firmware fw.bin out --offset= --length=5 --json on 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"}]}

    --help shows --offset <value> Selected byte offset; requires length and --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:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

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's firmwareCommands.ts: 8 failed, 24 passed.
  • npm run typecheck and npm run check:fast: passed.
  • npx oxfmt on the two changed files.
  • No open PR touches firmwareCommands.ts or the test file.

Compatibility, safety, and release

  • Breaking changes or migration steps: a non-decimal spelling such as 0x1000 or 1e3, 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.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new process, file, or network effect.

Author readiness

Human owner: @Plastic-time

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-06T16:29:03.237689Z
We couldn’t complete this review. Comment @codex review to try again.
e2e5349 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no blocking issue was found.

Summary

The firmware commands now use cliDecimalField to reject empty and non-decimal option values before running firmware work.

  • Firmware commands now accept only decimal numbers in their numeric options.

Reviews (2) · Last reviewed commit: "fix(cli): reject non-decimal firmware ra..." · Reviewed by Greptile

@morluto morluto closed this Nov 7, 2026
@morluto morluto added area: cli CLI adapter and one-shot commands bug Something isn't working labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants