Repository navigation
fix(native): preserve whitespace in otool load-command strings - #3430
Closed
bharadwajdaya wants to merge 1 commit into
Closed
bharadwajdaya wants to merge 1 commit into
bharadwajdaya wants to merge 1 commit into
Conversation
otool prints dylib install names and rpaths as `<key> %s (offset %u)` with exactly one separator space around the recorded string. The parser trimmed the value and stripped the offset suffix with `\s+`, so a valid install name such as " leading.dylib " became "leading.dylib" in both the dependency inventory and the raw load-command fields. Parse these offset-suffixed string fields by their exact format and strip only the single-space offset suffix. Fixes morluto#3384 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
[Medium impact] The PR appears safe to merge; no actionable defects were found. SummaryPreserves surrounding whitespace in Mach-O strings at the owning parser.
No actionable issues were found. Tests were inspected but not run. The live supersession check was blocked because GitHub credentials were unavailable. Reviews (1) · Last reviewed commit: "fix(native): preserve whitespace in otoo..." · Reviewed by Greptile |
2 tasks done
11 of 12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3384.
inspect-machostripped surrounding whitespace from dylib install names, so the validLC_LOAD_DYLIBname" leading.dylib "was reported as"leading.dylib"while the import source kept the spaced name. With this change the dependency path and the raw load-commandnamekeep the recorded bytes.Problem and expected behavior
otool prints load-command strings as
<key> %s (offset %u), with exactly one separator space on each side of the recorded string.parseFieldtrimmed the value (dropping leading spaces), andstripOffsetSuffixremoved the suffix with\s+\(offset\s+\d+\)(dropping trailing spaces). Leading and trailing whitespace is part of the install name, can change loader resolution, and must survive per AGENTS.md identity/source-value preservation.Change and scope
src/native/parsers/otool.ts:name/pathfields that end in(offset N)are parsed by their exact otool format, without trimming the value.stripOffsetSuffixnow removes only the single-space(offset N)suffix. This keeps normalization at the owning parser (the only producer ofdependencies[].path), so no consumer changes are needed.version 2.dylibfrom being misread as aname versionkey, since the exact field match runs before the generic key regex.LC_RPATHpathgets the same treatment in raw fields, since otool prints it in the same format.Contract and boundary impact
Semantic owner and earliest changed stage:
otoolload-command parser (parseOtoolLoadCommands).Contribution scope fit and linked maintainer decision: focused bug fix inside existing boundaries; not applicable.
CLI and MCP/tool-catalog contract: unchanged schema; values now preserve whitespace.
Provider, bridge, target-format, or platform compatibility: macOS
otooloutput only.Evidence, artifact, provenance, or reconstruction contract: dependency path and raw load-command fields now match native output.
Target selection, authority, upstream behavior, and cleanup details: not applicable.
Generated metadata, package, or installation impact: none.
Read existing files or captured data.
Evidence and regression coverage
nativeLoadKinds.golden.test.ts—preserves dependency install-name whitespacefor a spaced name and an ordinary-name control, checkingdependencies[].pathand the rawname/pathfields.1 failed | 49 passed) and the control passes.check:prgate; Linux/Windows otool equivalents not exercised.Validation performed
npm run test:focused -- tests/boundary/providers/native/native{LoadKinds,LoadText,Inventory,MachoHeader,TextRobustness}*.test.ts— 5 files, 103 tests passednpm run check:fast— typecheck and lint passednode scripts/rea.mjs inspect-macho consumer --json— exit 0, spaced install name preserved (output above)Compatibility, safety, and release
otool/clang.Author readiness
Human owner: @bharadwajdaya
Before merge
type(scope): outcome.🤖 Generated with Claude Code