Skip to content

refactor(rust): report cargo-auditable section failures through ParseFailure - #10652

Merged
morluto merged 3 commits into
mainfrom
refactor/rust-auditable-parse-failure
Nov 14, 2026
Merged

morluto merged 3 commits into
mainfrom
refactor/rust-auditable-parse-failure

Conversation

@morluto

@morluto morluto commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

This migrates the Rust cargo auditable dependency-section reader onto the shared ParseFailure algebra (src/domain/parseFailure.ts, #10593). It is the first per-format slice of W7 step 2. It also adds a counted architecture guard so that no new per-format failure class can appear, while the remaining ones shrink.

Problem and expected behavior

  • RustAuditableFormatFailure restated malformed | unsupported under its own class. RustBinaryProvider then translated it by hand into AnalysisInputError / AnalysisUnsupportedTargetError. That duplicated parseFailureAnalysisError.
  • RustBinaryImage.readContainer caught the container's BinaryFormatFailure (already a ParseFailureError) and re-wrapped it as a Rust failure, collapsing truncated into malformed and dropping undecodedContent.

Expected and now true:

  • The reader throws ParseFailureError with format rust-auditable.
  • Container failures propagate with their own kind and facts.
  • The provider maps every parse failure through parseFailureAnalysisError, so the public category is unchanged: malformed → invalid_request/invalid_format on path; unsupported → unsupported_target.

Change and scope

  • src/rust/RustAuditableReader.ts: RustAuditableFormatFailure is deleted. Throws use malformedInput/unsupportedInput. A local malformedSection(detail, cause) keeps the decoder/schema cause, because the helpers on main do not yet accept cause (fix(parsers): stop reading every RangeError as a format failure #10602 adds that). RUST_AUDITABLE_FORMAT is exported for the image reader.
  • src/rust/RustBinaryImage.ts: BinaryFormatFailure is no longer re-wrapped. Section-level refusals use the shared helpers.
  • src/rust/RustBinaryProvider.ts: the hand-written mapping is replaced by parseFailureAnalysisError(...) ?? artifactFailure(...).
  • New counted guard parser-format-failure-class in scripts/verify/architecture-guards.mjs: class *FormatFailure|*FormatError|*ParseFailure extends Error outside src/domain/parseFailure.ts. The baseline lists the 11 remaining files (IL2CPP ×2, pyc, model, Capture, SourceMap, AppleIps, WebArtifactReads, xmlDocument, and two Mach-O classes). Removing one lowers the count with --shrink-baselines.
  • Not included:
    • RustAuditableResourceFailure. It carries a typed memory/transport constraint that maps to AnalysisResourceConstraintError with caller-adjustable producer_limits, which ParseFailure's limit kind does not model.
    • The reader's own duplicate-member detection (jsonc visit). It belongs to the duplicate-key policy work.

Contract and boundary impact

  • Semantic owner and earliest changed stage: ParseFailure (domain) owns the failure kind; parseFailureAnalysisError owns its public category. The Rust-specific class and translation are removed.
  • Contribution scope fit and linked maintainer decision: not applicable (refactor within the existing boundary).
  • CLI and MCP/tool-catalog contract: unchanged categories, issue paths and messages for Rust dependency-section failures. A container failure of kind truncated keeps its own kind internally and still maps to invalid_format.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • 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 updated:
    • src/rust/RustAuditableReader.test.ts now asserts ParseFailureError with failure.kind: "malformed" and format: "rust-auditable".
    • tests/boundary/rust/rustBinaryImage.test.ts asserts ParseFailureError for the universal Mach-O refusal and the SHT_NOBITS section.
  • Public mapping coverage: the CLI acceptance tests rustBinaryCli, rustDependencyViews and rustUnnamedSections pass unchanged.
  • The guard flags the deleted class's spelling (git show origin/main:src/rust/RustAuditableReader.ts matches the pattern once).
  • Remaining proof gaps: none specific. This is a behavior-preserving refactor apart from container failure kinds.

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.

Validation performed

  • npm run test:focused -- tests/boundary/rust/rustBinaryImage.test.ts tests/boundary/rust/rustBinaryBudget.test.ts tests/acceptance/rustBinaryCli.test.ts tests/acceptance/rustDependencyViews.test.ts tests/acceptance/rustUnnamedSections.test.ts src/rust/RustAuditableReader.test.ts: 6 files, 83 tests passed.
  • node scripts/verify/architecture-guards.mjs: passed.
  • npm run check:fast: typecheck and lint passed.
  • npx oxfmt --check src/rust tests/boundary/rust scripts/verify: passed.
  • After review: added keeps the container's truncated failure and its facts unchanged; npm run test:focused -- tests/boundary/rust/rustBinaryImage.test.ts: 39 tests passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. RustAuditableFormatFailure was internal.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no change.

Author readiness

Human owner:

  • 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.

…Failure

RustAuditableFormatFailure restated the malformed/unsupported algebra and
the provider translated it by hand; container BinaryFormatFailures were
re-wrapped and lost their kind. The reader now throws ParseFailureError
(format rust-auditable), container failures propagate unchanged, and the
provider maps both through parseFailureAnalysisError. A counted guard
keeps new per-format failure classes from returning.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T20:28:43.477440Z 445531a New commits
ℹ️ 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.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

Moves Rust dependency-section errors onto ParseFailureError and uses the shared public-error mapping.

  • Rust binary parsing keeps shared failure kinds through analysis.
  • Architecture checks now count per-format failure classes.

No new actionable issues or security problems were found. Review conclusions are based on source inspection; tests were not run during this review. Live supersession status could not be checked because GitHub access required authentication.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Native container reader] -->|Original parse failure| C[ParseFailureError]
  B[Rust dependency reader] -->|Malformed or unsupported section| C
  C --> D[parseFailureAnalysisError]
  D --> E[Invalid format or unsupported target]
  F[Resource refusal] --> G[RustAuditableResourceFailure]
  G --> H[AnalysisResourceConstraintError]
Loading

Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

# Conflicts:
#	scripts/verify/architecture-guard-baselines.json
@morluto
morluto merged commit 29fb608 into main Nov 14, 2026
7 checks passed
@morluto
morluto deleted the refactor/rust-auditable-parse-failure branch November 14, 2026 20:28
@morluto morluto added provider: rust Analysis provider / engine: rust area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior provider: rust Analysis provider / engine: rust

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant