Repository navigation
feat(rust): read cargo-auditable dependencies from WebAssembly modules - #5069
Conversation
cargo-auditable embeds the same zlib-compressed `.dep-v0` JSON in a WebAssembly custom section for wasm32 targets, but inspect_rust_binary rejected every module as an unsupported target because only ELF, PE and thin Mach-O containers were recognized. Walk the section framing of version 1 core modules to locate the `.dep-v0` custom-section payload and the data section, where rustc keeps its constant /rustc/<hash>/ paths. Rust lookups now read one format-neutral layout, so native and WebAssembly images share a single dependency-section owner. WebAssembly declares no container word size, so `bits` is null for that format only; the Evidence subject format is `file`, as for inspect_wasm_artifact. Truncated sections, invalid LEB128 sizes, custom-section names that run past their section or are not UTF-8, duplicate `.dep-v0` sections and a second data section are malformed. Components, such as wasm32-wasip2 output, embed core modules and are refused as unsupported, like universal Mach-O containers, rather than inspected through one selected module.
Codex Review Summary: ✅ CompletedThis 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. |
[Medium impact] The PR appears safe to merge; no blocking issues remain. SummaryAdds cargo-auditable dependency inspection for WebAssembly core modules through the existing Rust CLI and MCP tool.
No new actionable issues found. The earlier concerns about section limits, feature records, and unfinished section names are addressed. The current base does not already provide this capability. Tests were not rerun. Reviews (13) · Last reviewed commit: "fix(rust): state container word size as ..." · Reviewed by Greptile |
The WebAssembly reader visited every section synchronously, and the format sets no section count. A 256 MiB input of three-byte custom sections with empty names walked about 89 million sections and held the event loop for about 7.4 seconds, delaying cancellation and other MCP requests; empty type sections took about 1.9 seconds. Refuse a module with more than 65,536 sections with a typed cpu resource constraint that reports maximum_wasm_sections, as the Go header search reports its work budget. Producer output holds a few dozen sections, and the same inputs are now refused within tens of milliseconds.
|
CI note on the failed I merged current main into the branch in cda31a6. There, that test, the Rust, MCP schema and documentation tests (22 files), |
Keep this branch's span-based Rust dependency reader under main's ImageSection rename (formerly GoImageSection), import both sides' Rust fixtures in the CLI acceptance test, and reapply the WebAssembly wording to main's README and Korean README tables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged latest What changed and why
Validation (local macOS, merged head)
|
Retained Rust views compared the parent subject with a Mach-O-only format mapping, so WebAssembly Evidence, whose subject format is file, was refused as a different artifact. The report domain now owns the subject format next to the architecture mapping, and the service and the view both use it. The real CLI/MCP view workflow now also covers a WebAssembly module.
Fixed-allowance recovery mapped every Rust resource other than capacity and transport to the parser allowance, so the section-walk refusal said host memory does not raise it. Each Rust resource now maps to its own allowance, and the cpu bound is a fixed work allowance. The MCP error contract test checks that the refusal is not retryable and names that allowance.
|
Thanks @kaoru0822-kitauji for merging main in 162590b. The Main moved again (#5815 retained Rust dependency views, #5813 skill text), so 345f0f4 merges 6d356b8, and two commits fix where WebAssembly meets those changes:
On bdb41d2, |
Main reworked the Rust reader: universal Mach-O slices, PE stream alignment, ELF read-only load ranges, section-name limitations and a shared metadata subject format. The WebAssembly layout now feeds the same dependency and compiler-path spans as the native layout, and metadataReportSubjectFormat maps a WebAssembly report to the file subject that the service and the retained view both check.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6ce932ee82
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Main reworked the Rust reader after bdb41d2 (universal Mach-O slices in #6219, PE stream extents, ELF read-only load ranges, section-name limitations and a shared subject-format owner), so 6ce932e merges bb17e90. Resolution notes:
On 6ce932e, with the pinned Node 24.22.1: |
The report schema tied a null word size to WebAssembly, but it accepted a wasm report that named a native architecture or big-endian byte order, and a native report that named the wasm architecture. Retained views parse imported Evidence with this schema, so such a contradictory report was accepted. The architecture is now wasm exactly when the container is WebAssembly, and a WebAssembly report must be little-endian.
Main moved format failures to the ParseFailure algebra, removed the Rust format failure class, turned rustc path retention into partial coverage and added producer limits, CycloneDX views and target-identity subjects. The WebAssembly reader now reports malformed, truncated and unsupported framing through ParseFailure, and its section bound is a named decode limit that the provider projects as a fixed work allowance. The Rust layout feeds main's dependency and compiler-path readers, and the shared metadata-report subject check accepts a WebAssembly report.
|
Main had moved about 2,700 commits and reworked the Rust reader again, so a86deb1 merges bb5278c and ports the WebAssembly reader onto the new structure:
On a86deb1, with the pinned Node 24.22.1: @morluto the CI run for this PR is still waiting for workflow approval. Could you approve it when you have a moment? I'm happy to adjust scope or split anything out if that helps review. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a86deb136f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Feature work now carries a spec, plan and task list under docs/specs. This adds that record for reading cargo-auditable metadata from WebAssembly core modules and indexes it. The record states that it was written during review and lists the verification that remains open.
The report schema accepted a dependency section name that does not belong to the report's container, such as a WebAssembly report naming the Mach-O section. rustDependencySectionName now owns that name for the reader and the schema, which refuses a mismatch for every container. The WebAssembly reader decoded section sizes with its own loop. It now uses the shared readLeb128, and an integer cut off by the end of the file is truncated rather than malformed.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e88658c2ce
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
The reader called an unfinished LEB128 integer truncated whenever its limit equalled the file length. A name length cut off inside the final section was therefore truncated, and the same bytes followed by another section were malformed. Each caller now states whether the file or the enclosing section bounds the integer.
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bb745a3a8b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
The section walk kept two .dep-v0 matches but walked on, so a module with two dependency sections and more than 65,536 sections after them was refused for the section bound instead of the duplicate it had already established. The walk now ends at the second match.
|
@kaoru0822-kitauji thanks again for merging main into this branch in October. Could I ask for your help once more? The CI, CodeQL and PR title runs for this PR have been waiting for workflow approval since it was opened. The runs from Oct 18 have now expired unapproved after 30 days, so they show as failed even though no job ran. If you are able to approve the runs on the current head (3753f11), or to point @morluto at this PR, I would appreciate it. Current state, to save you a look:
If the scope is the concern, I am happy to split anything out or adjust it. |
Co-authored-by: morluto <morluto@users.noreply.github.com>
…prose The CLI acceptance test matched an English limitation sentence. It now checks format, architecture, bits and byte order on the parsed report.
Output contract: inspect_rust_binary bits, including the summary view, is 32 | 64 | null. Null is valid only for WebAssembly and is not a number. ELF, PE and Mach-O reports stay 32 or 64. The schema description, guide, feature record and skill state that, and CLI renderers keep null instead of substituting a word size.
Summary
inspect_rust_binary/inspect-rust-binarynow reads the cargo-auditabledependency list from WebAssembly core modules.
cargo auditable buildfor awasm32target stores the same zlib-compressed.dep-v0JSON in a WebAssemblycustom section, but REA refused every
.wasminput as an unsupported targetbecause only ELF, PE and thin Mach-O containers were recognized. The reference
reader,
auditable-extract0.3.5, reads WebAssembly through its defaultwasmfeature.
No issue is linked: searching issues and PRs for
cargo-auditable,inspect_rust_binaryandrust wasmfound nothing on WebAssembly (#3398 and#3454 concern an unrelated ELF section).
Problem and expected behavior
Smallest trigger:
cargo auditable build --release --target wasm32-wasip1,then
rea inspect-rust-binary target/wasm32-wasip1/release/<crate>.wasm --json.cee95b2a): exit 1,unsupported_target, reasonOnly ELF, PE, and thin Mach-O native images are supported.file_offsetandsection_byteslocate the custom-section payload.Change and scope
src/rust/RustWasmImage.ts(new) owns WebAssembly section framing: theheader, u32 section sizes read with the shared
readLeb128, custom-section names(bounded and UTF-8), the
.dep-v0payload and the data section. It walksframing only; section contents are not validated, and nothing is
instantiated or executed. Retention is bounded to two
.dep-v0ranges (enoughto establish a duplicate) and one data section, and the synchronous walk to
65,536 sections (the format sets no section count; producer output holds a
few dozen). Framing failures use main's
ParseFailurealgebra with formatwasm: malformed, truncated or unsupported input, and amax_wasm_sectionsdecode limit for the section bound.
src/rust/RustBinaryImage.tsnow reads one format-neutral layout built by thenative container reader or the WebAssembly reader, so a single function owns
the one-dependency-section rule for both, and the rustc scan receives spans
(native read-only sections and ELF read-only load ranges, or the module's
data section) instead of re-deriving them.
formataddswasmandbitsbecomes nullable. Refinementsrequire
bits: nullandarchitecture: wasmexactly whenformatiswasm, andbyte_order: littleforwasm: WebAssembly declares nocontainer word size (memory address types are not inspected) and is
little-endian. The schema also binds the dependency section name to the
container (
__DATA,.dep-v0exactly for Mach-O), through onerustDependencySectionNameowner that the reader uses too. The Evidencesubject format is
file, as forinspect_wasm_artifact.output keeps its
/rustc/<hash>/paths (the native analogue is read-onlydata). Limitations name the scanned source for each format.
detail: "summary",viewandinspect_analysis_viewkindrust) accept WebAssembly Evidence: the sharedmetadataReportSubjectFormatowner, which the service and the view identitycheck both use, maps a
wasmreport tofile.cpuresource constraintwith a fixed work allowance of 65,536 sections; it is not retryable and
producer_limitsdoes not raise it.wasm32-wasip2output) arerefused as
unsupported. They embed several core modules (the measured buildcarries three: the Rust module and two small generated modules), so reporting
one
.dep-v0needs a module-selection or multi-module contract decision,comparable to
architecturefor universal Mach-O. That could be a follow-up.docs/rust-binaries.md, the README support row (English and the fourtranslations that list container names), skill instructions, the tool
description and the CLI argument help. The feature record is
docs/specs/native/rust-wasm-auditable/(spec, plan and tasks), writtenduring review; it says so and lists the verification that remains open.
Follow the contribution scope.
This is static format inspection inside the existing
inspect_rust_binaryboundary: it reads only the selected file, with no execution, injection,
mutation or network access. A maintainer scope decision is not applicable.
Contract and boundary impact
src/rust/RustWasmImage.ts(WebAssembly framing), then
src/rust/RustBinaryImage.ts(Rust layout), thensrc/domain/rust/rustBinary.ts(report contract).existing tool; not applicable.
formatgainswasmandbitsadmitsnullonly forwasm; ELF, PE and Mach-O reports areunchanged apart from limitation wording.
WebAssembly core modules; components and pre-release module versions return
unsupported_target, and more than 65,536 sections returnsresource_constraintwith resourcecpu.architectureon a module isrejected, as on any image that is not a universal Mach-O.
the original file; the subject is
filewithout an architecture.stable artifact reader; no new resources.
docs/public/product-catalog.json), package, orinstallation impact: the catalog changes only through the tool description and
output schema;
npm run docs:checkpasses. No package or installation change.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:
tests/boundary/rust/rustBinaryImage.test.ts: a module with.dep-v0and adata-section rustc path; a module without
.dep-v0; twelve refusals(component, pre-release version, truncated header, section past the end of
the file, size cut off by the end of the file, name length cut off by its
section, with and without a following section, size over 32 bits, custom name past its section, non-UTF-8 name,
duplicate
.dep-v0, second data section), each asserted by failure kind,format, offset and field; 65,536 sections are admitted and 65,537 stop at
the
max_wasm_sectionslimit; a duplicate.dep-v0followed by morethan 65,536 sections is still reported as the duplicate.
tests/acceptance/rustBinaryCli.test.ts: public CLI success for a module(
format: wasm,bits: null, subjectfile) andunsupported_targetfor acomponent.
tests/boundary/mcp/rustBinaryMcp.test.ts: the existing session also callsthe tool on a module after
listTools(), so the client validatesbits: nullagainst the advertised output schema; a separate case checksthe section-bound refusal through the public error contract (
cpu, themax_wasm_sectionsboundary,retryable: falseand the fixed workceiling).
src/domain/analysisView/rustBinaryView.test.ts: imported reports whoseword size, architecture, byte order or section name contradict their
container are refused.
tests/acceptance/rustDependencyViews.test.ts: the real CLI/MCP retainedview workflow (selected view, summary, CLI bundle, retained and portable
pages, the CycloneDX view, malformed-Evidence refusal) also runs on a
WebAssembly module.
tests/fixtures/rust/image.ts: a synthetic core module shaped likecargo-auditable output. During development Node 24.18.0
WebAssembly.validateaccepted it; the test does not assert this becausethe ES2023 lib does not type the
WebAssemblyglobal.Base reproduction: with only the test changes on
cee95b2a, all 14 new casesfail and every existing case passes; with the source change all pass. The two
section-budget checks fail on
85c9f888, where the over-budget module wasaccepted, and pass on
9bac2e32.Real producer (executed on Linux x64 with rustc 1.97.0 (2d8144b78 2026-07-07)
and cargo-auditable 0.7.7): an independent Python LEB128 walker with zlib and
JSON located each
.dep-v0section and matched REA'sfile_offset,section_bytes,format_version, every package field, the root index and theSHA-256.
wasm32-wasip1binary, 10 packages (2.2 MB)unsupported_target2d8144b78…wasm32-unknown-unknownbinary, same crate (1.6 MB)unsupported_target2d8144b78…wasm32-unknown-unknowncdylib,strip = true(17 KB)unsupported_target2d8144b78…wasm32-wasip2componentunsupported_targetunsupported_target(component refusal)User-visible CLI/MCP output (
wasm32-wasip1, abridged):{ "format": "wasm", "architecture": "wasm", "bits": null, "byte_order": "little", "auditable_metadata": { "section_name": ".dep-v0", "file_offset": 2130985, "section_bytes": 246, "uncompressed_bytes": 733, "format_version": 1, "root_package_index": 1, "packages": [ { "name": "cc", "version": "1.8.0", "source": "crates.io", "kind": "build", "dependencies": [2, 7], "root": false }, "…9 more" ] }, "rustc_commit": { "evidence_kind": "inferred", "hashes": [ { "hash": "2d8144b7880597b6e6d3dfd63a9a9efae3f533d3", "file_offset": 64960 } ] } }Remaining proof gaps: not run against wasm-bindgen or wasm-opt
post-processed modules,
wasm32-wasip1-threads,wasm64-unknown-unknown,macOS or Windows hosts, or third-party
.wasmartifacts. Components remainunsupported.
For evidence-bearing changes:
Validation performed
On
a86deb13(mainbb5278c7merged) with the pinned Node 24.22.1 on Linuxx64:
npm run check(including the architecture guards) andnpm run docs:check— passed.
npm run jscpd— 3.40% duplicated lines (threshold 4%).npm run test:focused --46 Rust, Go, universal Mach-O, analysis-view,CycloneDX, parse-failure, contract, MCP schema and module-boundary files —
792 tests passed, 1 skipped.
npm run test:fast— 1,691 files passed and 4 were skipped (31,803 testspassed).
On
8865878f(the feature record):npm run docs:checkandnpm run verify:docs:routes— passed.On
e88658c2(section-name binding and the shared LEB128 reader):npm run checkandnpm run docs:check— passed; the same 46 focused files —794 tests passed, 1 skipped;
npm run test:fast— 1,691 files passed and 4were skipped.
On
bb745a3a(cut-off integers classified by their boundary):npm run check— passed; the same 46 focused files — 795 tests passed, 1 skipped.
On
3753f11e(the walk ends at a duplicate.dep-v0):npm run checkandnpm run docs:check— passed; the same 46 focused files — 796 tests passed, 1skipped.
Earlier, on
9bac2e32:npm run test:focused --the three changed test files plustoolSchemaValidity,outputSchemaProfile,clientCapabilities,RustBinaryService,RustAuditableReader,stableArtifactConsumers,callerPathSymlinkParentCli,toolEffectsand the four Go test files(shared container readers) — 15 files, 237 tests passed.
npm run check— passed (typecheck, lint with module boundaries,format:check, knip, metadata:check, architecture guards).
npm run docs:check— passed, including the README consistency suite.npm run jscpd— 3.36% duplicated lines (threshold 3.5%).ELF 4.4 MB: 1.43 s / 2.06 s / 342 MiB / 4,873 B;
wasm32-wasip12.2 MB:1.23 s / 1.94 s / 337 MiB / 5,311 B;
wasm32-unknown-unknown1.6 MB:1.33 s / 2.11 s / 337 MiB / 5,347 B. CLI startup dominates; token counts were
not measured. Native inputs gain one four-byte prefix comparison.
sections took 7.4 s synchronously on
85c9f888and are refused in 35 ms;134 million empty type sections took 1.9 s and are refused in 8 ms.
Compatibility, safety, and release
formatgainswasm, andbitsadmitsnullonly forwasmreports, which werepreviously refused.
real-producer coverage is Linux x64 only.
version is unchanged, as for the original Rust skill text.
file through the existing stable artifact reader; no subprocess, temporary
file or network access. The framing walk visits at most 65,536 sections and
retains at most three ranges, and the existing 256 MiB, 1 MiB and 8 MiB guards
still apply.
Author readiness
Human owner: @yu0809
Before merge
type(scope): outcome.