Skip to content

fix(native): preserve thin architectures across echoed filename lines - #762

Closed
rudycelekli wants to merge 1 commit into
morluto:mainfrom
rudycelekli:fix/rea-thin-macho-filename-lines-20261006
Closed

rudycelekli wants to merge 1 commit into
morluto:mainfrom
rudycelekli:fix/rea-thin-macho-filename-lines-20261006

Conversation

@rudycelekli

Copy link
Copy Markdown

Summary

Read the complete thin lipo -detailed_info record before splitting output into lines. Native lipo echoes a pathname verbatim; a line break in an ordinary local filename must not become an architecture name. Universal-slice parsing is unchanged.

Native evidence and checks

Signed DCO head 726ecbe8749c6d339f9170f9b1788687c7a61efa, freshly rebased onto main 82382324855a3a4ed51d2cdc3b2b455c9e8419e2 after the Windows extraction and IDA additions. Neither changed file overlaps those additions or the fresh open inventory.

  • Actual host Clang produces the benign Mach-O fixtures. Native lipo -archs independently reports arm64 for ordinary and newline filenames.
  • Before: compiled public inspect-macho reports the pathname fragment as an exhaustive architecture for the newline filename; ordinary filename control succeeds.
  • After: compiled public CLI plus a separate real stdio MCP subprocess agree for inspect_macho and list_architectures, using actual native utilities and the pinned SDK client. No provider runner is substituted.
  • Focused before: three filename regressions fail, three controls pass. Exact-head after: 26 tests pass in four existing native provider/slice files, including universal-slice controls.
  • npm run build:cached, npm run check, and npm run check:fast: pass. Check reports 125 warnings, zero errors; no warnings concern either changed file. Existing exact dependency runtime reused; no install/model download.
  • SSH signature verification and git diff --check: pass.

No contract or package change. This proves macOS native format inspection; it does not claim Hopper, Ghidra, IDA, GUI, Windows, target execution, or full hosted CI coverage. Hosted results will be recorded separately.

AI-assisted implementation and independent source review; signed DCO retained.

Fixes #760.

@morluto

morluto commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Reviewed: matching trailing 'is architecture:' before line-splitting correctly handles newlines inside lipo's verbatim-echoed thin-file pathname (greedy match anchors to last occurrence). Fat/universal-slice path untouched, non-matching output falls through to legacy parser. Three adversarial filename cases + universal-slice controls + real lipo cross-check + CLI/MCP agreement cover it. APPROVE.

@morluto

morluto commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Review — APPROVE

Fixes #760.

Summary

parseLipoArchitectures now matches the trailing is architecture: <arch> record before line-splitting, so a newline inside lipo's verbatim-echoed thin-file pathname can't be mistaken for an architecture name. Fat / universal-slice parsing untouched.

Verification

  • Regex /(?:^|\r?\n)Non-fat file:[\s\S]* is architecture: ([^\s]+)\s*$/u is well-constructed: greedy [\s\S]* anchors to the last is architecture: occurrence, which is exactly why the adversarial "name is architecture: x86_64\ncontinued" filename case resolves to arm64.
  • Handles CRLF captures; ([^\s]+) always satisfies architectureSchema.min(1); non-matching output falls through to the legacy parser (including its throw on empty output).
  • Thin lipo -detailed_info output is a single record line, so returning nulls for cpu_type / offset / size / alignment loses nothing real.
  • Tests: three adversarial filename cases plus existing universal-slice controls; native lipo -archs cross-check and CLI+MCP agreement on real macOS artifacts.
  • CI: all 20 checks SUCCESS. No contract/package change — correct.

Notes (informational, no action needed)

  • A hypothetical fat output whose filename contains a Non-fat file: … is architecture: substring would take the thin early-return — vanishingly contrived.

@morluto

morluto commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Superseded by #815, which integrated this change and has now merged (3af3811). Thanks @rudycelekli for the fix and the thorough verification — much appreciated!

@morluto morluto closed this Oct 7, 2026
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Thin Mach-O architecture inventory misreads filenames containing line breaks

2 participants