Skip to content

fix(apple): preserve line terminators in dyld path expansion - #5363

Merged
morluto merged 1 commit into
morluto:mainfrom
Doribelove:fix/dyld-path-line-terminators
Oct 22, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
Doribelove:fix/dyld-path-line-terminators

Conversation

@Doribelove

@Doribelove Doribelove commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #5362. Expand @loader_path and @executable_path when the dependency name or rpath suffix contains a line terminator, preserving the exact path rather than reporting an existing dependency as undetermined.

Problem and expected behavior

A synthetic app with LC_LOAD_DYLIB set to @loader_path/lib\u2028core.dylib and the matching file on disk returns an undetermined resolution. An LC_RPATH containing U+2029 has the same problem. The load-command reader retains both names correctly; the path expander's .* rejects line terminators.

Change and scope

Enable dot-all at the existing path-token parser. Keep the exact token/slash grammar, downstream containment checks, rpath ownership, and unknown executable context unchanged. Add domain regressions for LF, CR, CRLF, U+2028 and U+2029 plus lookalike-token controls, and a real-file CLI regression for direct dependencies and rpaths.

This is a routine static-analysis correction within the existing contribution scope; no separate scope decision is required. It does not change the otool parser covered by #4979.

Contract and boundary impact

  • Semantic owner / earliest changed stage: expandPrefix in src/domain/apple/dyldPaths.ts, before candidate path lookup.
  • CLI and MCP/tool catalog: existing commands and schemas; corrected resolution values.
  • Provider/platform: shared static artifact resolver; no external analysis engine or platform-specific API added.
  • Evidence/provenance: retain exact install names, rpaths, and resolved image paths.
  • Target authority/cleanup: existing read-only inspection and containment; tests own their temporary files and use the repository cleanup fixture.
  • Generated metadata, package and installation: no changes.

Expected product effects:

  • Read existing files or captured data.

Evidence and regression coverage

Executed on Ubuntu 22.04.5 x86_64, Node.js 24.18.0 and npm 11.16.0:

  • With the new tests and original implementation at 58d6043303e722115f1da18b9505c24abeeab423: 6 failed, 105 passed across the domain and CLI files. Failures are resolution assertions.
  • After the fix and synchronization with upstream 799e8265b254e225dc1dabdd25e56f0ab7f86bd3: 131 passed across the domain, CLI and MCP files.
  • A separate built CLI run on source-owned synthetic Mach-O files changed both resolutions from undetermined / null to the exact existing paths:
[
  {
    "install_name": "@loader_path/lib\u2028core.dylib",
    "resolution": {"status": "resolved", "image": "Contents/MacOS/lib\u2028core.dylib"}
  },
  {
    "install_name": "@rpath/libsearch.dylib",
    "resolution": {"status": "resolved", "image": "Contents/MacOS/Libraries\u2029Nested/libsearch.dylib"}
  }
]
  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity and source provenance remain preserved.
  • Unsupported and uncertain outcomes remain visible; lookalike tokens stay undetermined.

Validation performed

  • npm ci — passed with the pinned toolchain.
  • npm run test:focused -- src/domain/apple/dylibResolution.test.ts tests/boundary/cli/dylibResolutionCli.test.ts tests/boundary/mcp/dylibResolutionMcp.test.ts — 131 passed; required runtime/skill build passed.
  • npm run check — passed: typecheck, lint/module boundaries, formatting, knip, metadata and architecture guards. Lint still reports warnings.
  • npm run verify:test-discovery — all 1,714 test files discovered exactly once.
  • git diff --check — passed.

The first static check caught an overlong enclosing test-group callback after adding the cases. Moving the new tests to the existing top-level style resolved it; the final checks above passed.

Compatibility, safety, and release

No API, schema, dependency or release-metadata changes. Synthetic files were read by the built CLI and the production artifact resolver; fixture programs were never executed. This establishes static resolution on Linux. Actual macOS dyld loading, Windows filesystem execution and Hopper/Ghidra were not exercised. The existing MCP boundary suite passed; no live external MCP client was tested.

Author readiness

Human owner: @Doribelove

  • 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.
  • Scope and authority remain within existing static inspection.
  • The PR has one focused outcome and a Conventional Commit title.
  • Related issue is linked.
  • Tests cover changed behavior and token-boundary controls.
  • No public contracts or generated documentation require changes.
  • Representative CLI output is included.
  • The human owner has completed the final review and readiness declaration.

@Doribelove
Doribelove marked this pull request as ready for review October 20, 2026 06:30
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-20T06:30:46.819527Z 7866bed Draft marked ready
ℹ️ 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.

@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 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Fixes dyld path expansion by letting the suffix contain line terminators without changing the token grammar.

  • Apple dylib paths resolve even when their names contain line breaks.

Reviews (1) · Last reviewed commit: "fix(apple): preserve line terminators in..." · Reviewed by Greptile

@x1mm4nu3l

Copy link
Copy Markdown

Replayed 7866bed983 on main c374c2fe7, Linux/Node 24.18.0. Five line-terminator cases plus the public CLI Mach-O-bundle case fail on main; all 111 dylib-resolution tests pass with the patch. This covers the lookalike-token refusals, symlink/escape handling and caller cancellation reasons too. The reader retains the load-command path bytes, so dotAll fixes the expansion boundary rather than rewriting filenames. Actual loading by macOS dyld remains unverified.

@morluto
morluto merged commit bd2a84c into morluto:main Oct 22, 2026
4 of 5 checks passed
@morluto

morluto commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Thanks for the dyld path fix, @Doribelove, and welcome to REA. Preserving line terminators in @loader_path and @executable_path suffixes lets dependency tracing resolve the actual filenames, and the CLI regression covers the Unicode separator case.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Dylib path expansion rejects line terminators in dependency names and rpaths

3 participants