Repository navigation
feat(rizin): select the decoder and map address for one-shot commands - #8991
Conversation
execute_rizin_command and rea execute-rizin-command accept optional asm_arch, asm_bits, asm_cpu and base_address (CLI --asm-arch, --asm-bits, --asm-cpu and --base-address). REA passes them to Rizin before the artifact path as -a, -b, -e asm.cpu= and -m. Rizin 0.9.1 refuses -e asm.arch= and -e asm.bits= at startup, while -a and -b work in 0.7.4 and 0.9.1. Rizin applies -e settings after -a and -b. base_address is the address of file offset 0, as in REA's raw-binary inputs. REA checks only the spelling, because Rizin owns the arch and CPU vocabulary and its builds differ. The Homebrew build of Rizin 0.9.1 has no xtensa or riscv plugin; the official static Linux build of 0.7.4 has both. Evidence records each input and the complete argument list. When any input is set, Evidence also states that REA does not confirm the decoder or map that Rizin used: Rizin uses another value for one it cannot apply and exits 0. Rizin 0.9.1 keeps its default and reports the value on stderr, and Rizin 0.7.4 turned -b 8 for arm into 16 without a message. Calls without these inputs keep their argument list and Evidence. The real-provider gate tests/boundary/providers/RizinDecoderInputs.test.ts checks the effect of each flag through MCP with Rizin's own e asm.*, omlj and byte reads. It skips when no Rizin is on PATH. It passes with Rizin 0.9.1 (Homebrew, macOS arm64) and 0.7.4 (official static build, Linux x86_64).
An ESP32-family app or bootloader image holds several segments, each loaded at its own address, so one base_address cannot map it. The recipe removes the default map with om-* and adds one om map per segment, using the segment offsets from the image format or from esptool image-info. It does not depend on an ESP image reader in REA. The offsets were checked against esptool 4.12.0 image_info on a synthetic two-segment ESP32 image. Rizin 0.9.1 and 0.7.4 mapped its segments at their load addresses. Rizin 0.7.4, whose static Linux build has the xtensa plugin, decoded the IRAM segment as nop.n, nop.n, ret.n and nop.n.
On Rizin 0.9.1, base_address could read 0xff at the mapped address with exit 0. -m maps the file, but Rizin still runs its format loaders, and a loose one can claim a raw image. Rizin 0.9.1's AVR loader matches when bytes 1 and 3 look like rjmp and turns io.va off, so reads use file offsets. The BIOS loader, in 0.7.4 and 0.9.1, matches a 64 KiB file with a jmp 16 bytes from its end and maps it at another address. An acceptance run on a raw ESP32-S3 segment hit the first case. With base_address, REA now passes -n together with -m. Rizin then skips the loaders and maps the whole file at the address: rizin.c calls rz_io_map_new at the -m address and leaves io.va at its default. The input therefore means a raw image, and Rizin loads no sections, symbols or entry point, even from an ELF file. Evidence states this in its own limitation, and the decoder limitation no longer covers the map. The real-provider gate adds an AVR-like and a BIOS-like image and reads below the base, at it, at the end of the image and past it. Without -n it fails on Rizin 0.9.1. It passes with Rizin 0.9.1 (Homebrew, macOS arm64) and 0.7.4 (official static build, Linux x86_64). The ESP om recipe now starts with e io.va=true, because reads use the maps only while io.va is on.
The asm_arch and asm_cpu pattern ended its character class with an unescaped '-', which JavaScript's v (unicodeSets) mode rejects, so clients compiling advertised patterns in that mode could not use execute_rizin_command's schema. Escaping it keeps the same names valid in every mode, as main's own patterns write it.
The base_address limitation reported a map REA never observes and left out that -n keeps Rizin's default arch, bits and byte order. The asm_* limitation implied Rizin replaces a bad CPU, but e asm.cpu echoes any value. Compact schemas drop property descriptions, so the tool description now carries the raw-loading warning. The real-provider gate checks that asm_cpu changes a decode, and a base_address-only call.
Codex Review SummaryThis 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 new blocking issue remains in the reviewed changes. SummaryAdds optional decoder and raw-map inputs to one-shot Rizin commands through CLI and MCP. Evidence keeps the selected inputs, arguments, and limits of what REA confirms.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
Input["CLI or MCP inputs"] --> Schema["rizinInputSchema"]
Schema --> Args["RizinCommand"]
Args --> Decoder["-a, -b, asm.cpu"]
Args --> Map["base_address → -n -m"]
Decoder --> Rizin["Rizin command"]
Map --> Rizin
Rizin --> Evidence["Output, arguments, and limitations"]
Reviews (2) · Last reviewed commit: "test(rizin): follow the test guide in th..." · Reviewed by Greptile |
Focused tests resolve execute_rizin_command from its contract family, the harness owns the temporary directory before setup can fail, and guidance is compared with its owner, not with sentences from it.
Summary
Part of #7955.
execute_rizin_commandcould not open a raw firmware image at its load address:-nis a startup option, so no command can set it, and a Rizin format loader can claim a raw image and give wrong reads with no error. This PR adds four optional inputs that select the decoder and the map, and states what REA does not confirm about them.Problem and expected behavior
An analyst with a Cortex-M or ESP32 flash dump needs the bytes decoded with the right arch at the right address. Rizin 0.9.1's AVR loader can claim such an image and turn
io.vaoff, so every read at the mapped address returns0xff. The BIOS loader maps the file at another address. With these inputs the same call reads the file at the caller's address, and Evidence records the choice.Change and scope
asm_arch,asm_bits,asm_cpuandbase_addressbecome-a,-b,-e asm.cpu=and-n -m, on MCP and the CLI (--asm-arch,--asm-bits,--asm-cpu,--base-address). Rizin 0.9.1 refuses-e asm.arch=at startup, so REA uses-aand-b.asm_*values, and the map.-nalso keeps Rizin's default arch, bits and byte order unless the call selects them.src/composition/reverseEngineering.ts, which the PR that lands second takes. Until feat(rizin)!: record which tool and version answered execute_rizin_command #7487 lands, Evidence for these calls has no Rizin version.e cfg.bigendian=truein the command does this), a rebase of a format-loaded file, and a Rizin session mode.Contract and boundary impact
rizinInputSchemainsrc/domain/reverseEngineering.tsowns the inputs.src/rizin/RizinCommand.tsowns the arguments and limitations, and the application port carries limitations generically.-a,-b,-nand-m. Arch and CPU availability depends on the build.parametersrecords each input and the completecommand_arguments. Limitations are added only when an input is set.docs/public/product-catalog.json), package, or installation impact: none beyond the regenerated tool catalog.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
RizinDecoderInputs.test.ts, a real-provider gate through MCP, covers the arguments' effect on raw images, reads around the map, images that the AVR and BIOS loaders claim, an arch and bits value Rizin lacks,asm_cpuchanging a decode (msr primask, r0withcortexm,invalidwithout), and abase_address-only call whose command removes the map. CLI, MCP and composition tests cover the arguments,parameters, limitations and refusal of a value such ascortexm; q.docs/testing-lanes.md.omrecipe, or Linux host defaults. Homebrew's Rizin has noxtensaorriscvplugin..github/workflowsdoes not mention Rizin, so the gate presumably skips in CI (inferred, not observed).For evidence-bearing changes:
Validation performed
On the head
30120e099, which changes only test files aftered30d26df:npm run check:fast,format:check,docs:check,knip— passed.npm run test:focused -- tests/boundary/providers/RizinDecoderInputs.test.ts— 6 passed on Rizin 0.7.4 (official static build, Linux x86_64).On
1fb5a7435, which containsmain71f680d7c(ed30d26dfafter it changesdocs/testing-lanes.mdonly, andformat:checkanddocs:checkpassed there):npm run test:focused -- tests/boundary/providers/RizinDecoderInputs.test.ts— 6 passed on Rizin 0.9.1 (Homebrew, macOS arm64) and 6 passed on Rizin 0.7.4 (official static build, Linux x86_64).npm run check:fast,format:check,docs:check,knip— passed.src/contractsandtoolSchemaValidity— 28 files, 286 passed, 3 skipped.Compatibility, safety, and release
_,.,+and-, start with a letter or digit, and reach Rizin as separate arguments, so a value cannot become a flag or a command. The tool's existing warning about Rizin commands and plugins still applies.Author readiness
Human owner: @Entrpi
Before merge
type(scope): outcome.