Repository navigation
feat(native): read embedded cargo-auditable Rust dependency lists - #2456
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@greptileai review |
|
|
Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open. Source fix: The output limit was applied after normalization, edge allocation, reverse-graph construction, and serialization. The reader now admits raw package/dependency counts against a conservative lower bound on the required normalized JSON representation before Zod clones the document or any graph arrays are built. Admission reports the existing 8 MiB transport budget; the final exact serialized-size guard still covers string sizes and all other report fields. Added an unrun regression with 400,000 valid repeated indices in a below-1-MiB, ratio-admissible section. Source inspection confirms admission precedes normalization and SCC/reverse-edge construction. No superseded graph representation remains. Tests, typechecks, builds, lint, workloads, and CI reruns were not run, as explicitly requested; performance was not measured. Source fix: The reader failure carried every limit in a single Updated the overflow assertion and added an unrun public MCP error-contract regression using the same shared overflow fixture. Source inspection followed the failure from image reader through provider projection to the MCP contract; no old count-as-bytes consumer remains. Tests, typechecks, builds, lint, provider workloads, and CI reruns were not run, as explicitly requested. |
…er paths Fail the first malformed cargo-auditable package before Zod collects an issue per field. Require cyclic dependency indices to match the cycles in package dependencies. Keep read-only ELF ranges when a section name does not fit the bounded name window, so a rustc path in that range is still reported.
Summary
Agents can now read the dependency list that
cargo auditableembeds in a Rust binary.inspect_rust_binary/inspect-rust-binaryreads the.dep-v0section (__DATA,.dep-v0on Mach-O) from one ELF, PE or thin Mach-O file without running it, and returns the packages, their versions and sources, the root package and the dependency edges. It answers for Rust the questioninspect_go_binaryanswers for Go.No issue is linked. This is a new static, read-only primitive within the existing format-inspection scope, proposed here with the implementation.
Demo
Full-quality MP4
Simulated demo rendered from real output. Every value on screen is copied from
rea inspect-rust-binaryon this branch, run against an auditable and a plain build of the same one-line crate.Problem and expected behavior
Rust binaries built with
cargo auditablecarry their full crate dependency tree as zlib-compressed JSON in a.dep-v0section. REA had no Rust metadata lane, so an agent asked "which crates and versions are in this binary" had nothing to call short of a full disassembly.With this change, one call returns the section name, file offset, compressed and uncompressed sizes, format version, packages in original order (
name,version,source,kind,dependencies,root), the root package index, dependency edges, and any packages that sit on a dependency cycle. When the section is absent,auditable_metadataisnullwith the limitation "Absence of .dep-v0 does not mean the binary has no dependencies." Read-only/rustc/<commit>/paths are reported separately as an inferred compiler commit.Change and scope
Section lookup reuses the ELF, PE and Mach-O readers that
inspect_go_binaryalready validates; they now also expose a list of named sections with their file ranges. PE content length ismin(VirtualSize, SizeOfRawData), so file-alignment padding never reaches the decoder, and ELFSHT_NOBITSsections are never treated as stored bytes. The inflate is capped by a fixed ratio and an absolute maximum. The JSON is parsed with a strict schema, dependency indices are range-checked, and cycle members are found with an iterative strongly-connected-component pass, so long chains cannot exhaust the stack. Overlapping read-only sections are scanned once, and more than 64 distinct compiler paths is a typed resource failure rather than unbounded output.Universal Mach-O files are refused with a typed unsupported error rather than picking a slice. Not included: recovering dependencies from binaries built without
cargo auditable(panic strings, symbol names); that would be inference rather than an embedded record.One naming note for review: the shared container readers keep their existing
Go*names (GoImageSectionand friends) to keep this diff small. If you would rather they move to neutral names now that two lanes use them, I can do that here or in a follow-up.Contract and boundary impact
src/rust/RustAuditableReader.ts(section payload),src/rust/RustBinaryImage.ts(section selection and compiler paths), schema insrc/domain/rust/rustBinary.ts; section ranges added tosrc/go/Go{Elf,Pe,Macho}Image.ts.inspect_rust_binary/inspect-rust-binarywith onepathinput; registered next to the Go tool, effects entry read-only, catalog builders and capability inventory updated.cargo auditableformat version 1.inferred..agents/skills/reverse-engineer-anything/,docs/rust-binaries.md, a README row; build outputs not committed.Expected effects:
Evidence and regression coverage
src/rust/RustAuditableReader.test.ts(schema, inflate bound, out-of-range indices, cycle membership including members reached through finished vertices, a 20,000-package chain),src/application/rust/RustBinaryService.test.ts,tests/boundary/rust/rustBinaryImage.test.ts(ELF, PE with aligned raw size, Mach-O, missing section, universal refused,SHT_NOBITS, compiler-path cap),tests/acceptance/rustBinaryCli.test.ts,tests/boundary/mcp/rustBinaryMcp.test.ts; Go boundary tests rerun unchanged.itoa, one withcargo auditable build --releaseand one with plaincargo build --release.__DATA,.dep-v0at file offset 298088, 120 compressed and 165 uncompressed bytes, format 1, packagesitoa1.0.18 (crates.io) andsample0.1.0 (local, root, depends on 0). That matches an independent read of the same section withotooland zlib. The plain build reportsauditable_metadata: nullwith the absence limitation. Both report the inferred compiler commitb940084d7eb6a299eb4bfeb8e34901bc051e7ac4, which matchesrustc -vVfor the toolchain that built them. A full result is about 960 tokens.For evidence-bearing changes:
Validation performed
All on macOS 27 with Node 26 and the pinned npm 11.16.0, on this branch rebased on
a2d8b94:Compatibility, safety, and release
inspect_go_binaryoutput is unchanged.Before merge
type(scope): outcome.