Skip to content

fix(rust): isolate ELF section reads from Go build-info admission - #3454

Closed
chqcjq wants to merge 5 commits into
morluto:mainfrom
chqcjq:fix/rust-elf-go-section-isolation
Closed

chqcjq wants to merge 5 commits into
morluto:mainfrom
chqcjq:fix/rust-elf-go-section-isolation

Conversation

@chqcjq

@chqcjq chqcjq commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #3398. Rust dependency inspection now accepts an ELF with an unrelated nonallocated .go.buildinfo section while preserving the original artifact identity.

Problem and expected behavior

The existing shared ELF reader applies Go build-info mapping admission before Rust can decode .dep-v0. On the affected base, a valid synthetic ELF succeeds when the extra section is named .extra, but the same bytes with .go.buildinfo fail with invalid_request / invalid_format: “Virtual address or string range is not file mapped”. Rust should not interpret that unrelated section as Go metadata.

Change and scope

Distinguish the two existing ELF read purposes at the producing boundary. Rust requests section/container facts; the Go path retains its default build-info admission and mapping checks. This keeps one structural parser and avoids catching or suppressing generic container errors. The internal purpose is not a CLI/MCP option.

  • Semantic owner: GoElfImage; forwarded by GoBinaryImage and selected by RustBinaryImage.
  • Scope decision: not applicable; ordinary static metadata fix within existing boundaries.
  • CLI/MCP schema and generated metadata: unchanged.
  • Evidence: exact path, bytes, and SHA-256 remain those of the selected artifact.
  • Effects: reads selected local files; no target execution, attachment, instrumentation, or mutation.

Evidence and regression coverage

Executed on Windows with pinned Node 24.18.0 and locked dependencies:

  • Before the fix, the compiled CLI and stdio MCP regressions both fail on the Go-named file after the name-only control succeeds.
  • After the fix, both adapters return identical dependency metadata for the original and control while preserving each file's independently calculated SHA-256.
  • Malformed ELF section tables and corrupted dependency payloads still return invalid_request; Go inspection still rejects the invalid Go build-info mapping.
  • Eight focused files: 156 tests pass, 2 existing Windows-conditional tests skip. Covers Rust image/CLI/MCP, Go image/mappings/provider/CLI, and the new public regression.

Validation performed

  • npm run test:focused -- tests/acceptance/rustGoSectionCli.test.ts tests/acceptance/rustBinaryCli.test.ts tests/acceptance/goBinaryCli.test.ts tests/boundary/rust/rustBinaryImage.test.ts tests/boundary/go/goBinaryImage.test.ts tests/boundary/go/goBinaryMappings.test.ts tests/boundary/go/goBinaryProvider.test.ts tests/boundary/mcp/rustBinaryMcp.test.ts — 156 passed, 2 skipped.
  • npm run check and npm run check:ci — pass; typecheck, lint, format, knip, metadata, duplication and architecture guards succeed.
  • npm run docs:check — pass.
  • npm run verify:test-discovery — all 1,274 test files discovered exactly once.

Local source/diff review traced structural parsing, Go-specific admission, Rust dependency decoding, typed failures, and artifact identity. Fixtures are authored synthetic binaries; no compiler-produced Rust/Go binary or Linux/macOS runtime was exercised, and the full repository test suite was not run.

Review follow-up

Commit d97e4b0f9 addresses Greptile's Wrong rejection still passes finding. Both CLI and stdio MCP now parse the complete typed Go error and assert invalid_format with the mapping-specific diagnostic Virtual address or string range is not file mapped. The name-only .extra control also succeeds as Go with build_info: null, preventing unrelated rejections from satisfying the regression.

Executed for this follow-up: the two public adapter tests pass; npm run check:ci and normal pre-push check:fast pass. Only the regression test changed; production behavior remains the original fix. The earlier 156-test run above is historical validation of the original revision.

Latest CI integration validation

Synced this branch with main eab789aed. Both lint task cache inputs now include checker-consumed code under .github, correcting the CI inventory failure caused by the publishing-action files.

Commit 41955b140 addresses the valid review finding that the previous test-side path conversion could hide incorrect saved report paths. The test again asserts the raw report names. The report writer now normalizes both absolute paths to the same Windows namespace before computing relative paths; clone locations and threshold handling are preserved. Restoring the strict assertion reproduced absolute //?/C:/... names before the writer fix, and the unchanged assertion passes after it.

Executed for this correction: 2 files / 10 tests (CLI/MCP Go-error controls and static-check reports) pass; npm run check:ci and normal pre-push checks pass. New-head remote CI is pending. Earlier validation above applies to its stated revisions; native runtime checks were not repeated for this CI/reporting correction.

Author readiness

Human owner: @chqcjq

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

The human owner's readiness declarations are recorded above.

@chqcjq
chqcjq marked this pull request as ready for review October 14, 2026 13:25
@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 Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge, with no outstanding findings.

Summary

Rust reads ELF sections without applying Go-specific build-info checks. Go inspection keeps those checks by default.

  • Rust ELF inspection reads dependency sections without treating them as Go build info.
  • Static checks track GitHub code and normalize Windows report paths.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Rust["RustBinaryImage"] -->|"sections"| Container["readGoBinaryContainer"]
  Go["Go inspection"] -->|"default: build-info"| Container
  Container --> ELF["readGoElfImage"]
  ELF --> Structural["Read ELF sections and mappings"]
  Structural --> Purpose{"Read purpose"}
  Purpose -->|"sections"| RustResult["Return container facts"]
  Purpose -->|"build-info"| Admission["Check Go build-info mappings"]
  Admission --> GoResult["Return admitted container facts"]
Loading

Reviews (4) · Last reviewed commit: "fix(ci): normalize Windows paths in dupl..." · Reviewed by Greptile

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: I ran the new test file for this fix on current main. Both cases fail without the source change. Both pass with it. The one red check on GitHub is the PR-template check.

Results

I applied the PR's test changes and then its source changes onto current main (62bf098). Head is 41955b1. The PR's own base is older than main. Both halves applied cleanly.

Case Main plus new tests With source change
Rust ELF with a .go.buildinfo section, CLI fail pass
Same file, stdio MCP fail pass

Without the source change, both fail. The error says "Virtual address or string range is not file mapped". The ELF is a synthetic file built by the new fixture createRustElfWithGoSection. With the source change, Rust inspection works and both cases pass. The test file also checks that the Go inspector still refuses that file. That check passes.

CI state

On GitHub, the one failed check is "Validate author declaration". That is only the PR-template check, not a build or test failure. Real CI did run on this head. Its source tests, five test shards and static checks report success. Nine other runs show as cancelled.

Not run

  • The PR's own head tree. I tested on current main with the diff applied.
  • The Windows path fix for CI in the PR. I applied it but ran no Windows job.
  • A real Rust binary or a real Go binary. The test uses a synthetic ELF.
  • The full test suite. I ran one named file.
  • Any test that runs the doctor command. I checked the file and its fixture first and neither does.

Thanks, chqcjq, for the fix and for the two-case test with a name-only control.

Commands
# in a copy of main at 62bf09809, Node 24, after npm ci and npm run build
git apply 3454.tests.diff
npm run test:focused -- tests/acceptance/rustGoSectionCli.test.ts   # exit 1, 2 failed
git apply 3454.src.diff
npm run test:focused -- tests/acceptance/rustGoSectionCli.test.ts   # exit 0, 2 passed
Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 24.18.0
  • Head: 41955b1. Base: 62bf098.
  • Other: the box was shared with other test agents.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@chqcjq

chqcjq commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the independent reproduction and validation. The current head now passes CI required and PR readiness, and GitHub reports no merge conflicts. Could a maintainer review this PR and let me know if any changes are needed before merging? The validation scope and remaining limitations are documented in the PR body.

@chqcjq chqcjq closed this Oct 20, 2026
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working provider: rust Analysis provider / engine: rust labels Nov 23, 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 bug Something isn't working provider: rust Analysis provider / engine: rust

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] An unrelated .go.buildinfo section blocks Rust dependency inspection

3 participants