Skip to content

fix(paths): select caller paths through symlinks and .. as the filesystem does - #4067

Merged
kaoru0822-kitauji merged 3 commits into
mainfrom
fix/3864-symlink-parent-paths
Oct 15, 2026
Merged

kaoru0822-kitauji merged 3 commits into
mainfrom
fix/3864-symlink-parent-paths

Conversation

@kaoru0822-kitauji

@kaoru0822-kitauji kaoru0822-kitauji commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #3864, fixes #3911, fixes #3912. On POSIX, a caller path such as link/../sample, where link is a directory symlink, makes the filesystem follow link first and then apply ... REA made caller paths absolute with path.resolve, which collapses link/.. lexically. As a result, several commands inspected, hashed or launched a sibling file and returned internally consistent, successful Evidence about the wrong artifact. This PR moves that step into one owner that never changes which file a path names.

Problem and expected behavior

I reproduced this on main with the built CLI and a real Mach-O (gh):

  • target/sample is a copy of gh.
  • The sibling ./sample is the same copy with one byte appended.
  • link -> target/child.
command link/../sample (relative) $PWD/link/../sample (absolute)
inspect-go-binary sibling 2ba6b7… ✗ sibling ✗
inspect-rust-binary sibling ✗ sibling ✗
inspect-with-objdump … file_headers sibling ✗ sibling ✗
inspect-macho, list-architectures, inspect-signature sibling ✗ intended ✓

The intended file is db2578…. Every command exited 0 in every case.

There are two lexical producers:

  1. Relative paths: CLI adapters (resolve(args.path)) and parseBinaryTarget (resolve(cwd, input)) build the absolute path lexically.
  2. Absolute paths: they are re-resolved lexically in the Go and Rust CLI adapters, the objdump and Rizin command builders, RizinDebugSessionManager launch, and ReverseEngineeringService, which hashes objdump and Rizin inputs. Because of the builders and the service, the objdump and Rizin bug also reaches MCP callers.

Change and scope

  • New src/filesystem/callerPath.ts exports absoluteCallerPath(path, { cwd?, platform? }):
    • POSIX: a relative path is prefixed with the working directory (a relative cwd is made absolute the same way). Only interior . segments and repeated separators are removed, which never change the named file. A trailing / or /. keeps its directory requirement as one trailing /. Every .. is kept, so the filesystem resolves symlinks and .. in order. ./module.wasm from /app is /app/module.wasm; link/../x stays /app/link/../x.
    • Win32: keeps win32.resolve, because Windows resolves .. lexically, so that normalization is exact there.
  • All of the producers above now call it, and their now-unused resolve/isAbsolute imports are removed:
    • 13 CLI sites in the binaryDiagnostics, capture, coreBinary, evm, firmware (input and output directory), go, rust, signal, sqlite and wasm command modules;
    • parseBinaryTarget, ReverseEngineeringService, objdumpCommand, rizinCommand and the Rizin debug launch;
    • the WASM --glue_paths/--candidate_paths lists, snapshotFirmware (firmware input) and SafeOutputTree.create (extraction output root). These were review follow-ups: the CLI conversion alone did not reach these owners. SafeOutputTree uses host path syntax; its platform argument selects only the name policy.
  • Evidence local_path now keeps the caller's spelling (for example …/link/../sample) when the provider reports it. It no longer reports a different file's path.
  • Remaining cleanup, not changed here because these sites are outside the reported binary-inspection paths and each needs its own verification:
    • JsonFiles, EvidenceBundleFiles and JavaScriptRecoveryService still call resolve(path) on caller-selected JSON, bundle and source paths.

Contract and boundary impact

  • Semantic owner and earliest changed stage: absoluteCallerPath owns conversion of a caller-selected local path to an absolute path. The CLI adapters, target resolution, provider command builders and the hashing service consume it.

  • Contribution scope fit and linked maintainer decision: a bug fix within the existing boundaries; not applicable.

  • CLI and MCP/tool-catalog contract: schemas unchanged. The same request now selects the file the filesystem names.

  • Provider, bridge, target-format, or platform compatibility:

    • POSIX: behavior changes only for paths with a parent component (..) after a symlink, or with ./duplicate separators, which are now passed through unnormalized.
    • Windows: unchanged.
  • Evidence, artifact, provenance, or reconstruction contract:

    • Subject digest, artifact facts and local_path now describe the selected file.
    • Rizin debug launch_provenance.resolved_path now records the absolute path actually launched, which names the same file as caller_selected_path.
  • Target selection, authority, upstream behavior, and cleanup details: the Rizin debug launch no longer starts a sibling program for such a path. There is no other change to execution authority.

  • Generated metadata, package, or installation impact: none.

  • Read existing files or captured data.

  • Launch or attach to a process. (Only the existing Rizin debug launch path; this PR changes which path it receives.)

Evidence and regression coverage

  • Tests added or updated:
    • New tests/boundary/cli/callerPathSymlinkParentCli.test.ts (POSIX): public CLI runs of inspect-go-binary, inspect-rust-binary and inspect-pe-resources with relative and absolute link/../… spellings, asserting the selected file's SHA-256. It uses the repository's Go and PE resource fixture writers.
    • New tests/boundary/filesystem/callerPath.test.ts: POSIX and win32 helper semantics, including which spellings are normalized.
    • New tests/boundary/filesystem/symlinkParentOwners.test.ts (POSIX): snapshotFirmware digests target/image.bin for link/../image.bin, and SafeOutputTree.create("…/link/../out") creates target/out and not ./out. Both fail on the previous commit.
    • src/wasm/WabtOutput.test.ts: a CLI-selected ./module.wasm keeps an exact local-path-candidate glue match against a competing /other/module.wasm. This fails with the first version of the helper.
    • RizinDebugSessionReviewRegressions.test.ts (3 cases) and rizinDebuggerCancellationMcp.test.ts derived their expected resolved_path with lexical resolve. They now derive it from the owner.
  • Base reproduction: with main's src restored, the new CLI test fails in both cases. Go selects the sibling, and PE resources selects exactly the sibling digest predicted in [Bug] PE resource inspection changes the selected file after a symlink parent component #3911 (9a251f9f…). With the fix, both pass.
  • User-visible CLI output after the fix, same layout, real gh copy: every command in the table above selects db2578… for both spellings. execute-rizin-command is unavailable on this host (no Rizin), and gh is not a PE file.
  • Timing, macOS arm64, median of 5 runs, built CLI:
run inspect-go-binary link/../sample inspect-go-binary target/sample inspect-macho link/../sample inspect-macho target/sample
main 414 ms, 62,695 bytes, wrong file 406 ms, 62,723 bytes 1,054 ms, 25,940 bytes, wrong file 1,118 ms, 25,947 bytes
fix (run 1) 496 ms, 62,727 bytes, correct 473 ms, 62,723 bytes 946 ms, 25,947 bytes, correct 930 ms, 25,947 bytes
fix (run 2) 385 ms 387 ms 997 ms 933 ms

The helper does a string check and a concatenation. The spread between the two fixed runs (385–496 ms) is host noise; this is not a performance change. Output for the link/../ spelling grows by 4 bytes, because local_path keeps the caller's spelling instead of the collapsed sibling path.

  • Remaining proof gaps:
    • Rizin and GNU objdump command lines were verified through tests and the objdump CLI run, not with a real Rizin install.
    • The Windows behavior is covered only by the helper's win32 unit case.
    • The sites listed under remaining cleanup are unverified.

Validation performed

  • npm run test:focused -- tests/boundary/filesystem/callerPath.test.ts tests/boundary/cli/callerPathSymlinkParentCli.test.ts — 4 passed. The CLI test against main's src: 2 failed, as expected.
  • npx vitest run tests/boundary/cli tests/boundary/providers tests/boundary/filesystem tests/boundary/native src/application tests/acceptance/goBinaryCli.test.ts tests/acceptance/rustBinaryCli.test.ts tests/acceptance/applications/peResources.test.ts — 465 files: 5,294 passed, 3 failed. All three were the Rizin expectations described above; after updating them the file passes (15 passed).
  • npx vitest run tests/boundary/mcp tests/acceptance — 231 files: 1,249 passed, 1 failed. It was the Rizin MCP expectation described above; after updating it the file passes (3 passed).
  • After the review follow-up: npx vitest run tests/boundary/cli tests/boundary/providers tests/boundary/filesystem tests/boundary/native tests/boundary/mcp tests/boundary/firmware src/application src/wasm tests/acceptance — 700 files, 6,562 passed, 93 skipped, 0 failed. Linux-only firmware integration cases were skipped on this host.
  • npm run check:fast — passed. npm run knip — clean.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Requests that previously selected the wrong file now select the one the caller named.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS arm64 with real native tools (otool, lipo, codesign, objdump). No Linux or Windows host runs.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: this closes a path where evidence and a debugger launch could be bound to a file other than the one selected. No new process or network effects.

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.

🤖 Generated with Claude Code

CLI adapters, binary target resolution, the reverse-engineering service
and the objdump and Rizin command builders made caller-selected paths
absolute with path.resolve, which collapses `link/..` lexically. On
POSIX the filesystem follows `link` first, so these commands inspected,
hashed or launched a different file and returned internally consistent
Evidence for it.

absoluteCallerPath now owns that step: on POSIX it prefixes a relative
path with the working directory and keeps an absolute path as spelled;
on Windows, where `..` resolves lexically, it keeps win32.resolve.

Fixes #3864
Fixes #3911
Fixes #3912

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kaoru0822-kitauji kaoru0822-kitauji added the track:perf Performance track PRs (issues & perf loop) label Oct 15, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

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 ✅ Completed 2026-10-15T11:06:08.316306Z 1653bb5 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c92a375dc5

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/wasmCommands.ts Outdated
Comment on lines 68 to 71
path: absoluteCallerPath(args.path),
glue_paths: options.glue_paths?.map((path) => resolve(path)),
candidate_paths: options.candidate_paths?.map((path) =>
resolve(path),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve all caller-selected WASM paths

When --glue-paths or --candidate-paths contains a POSIX path such as link/../asset, only the primary module path avoids lexical normalization; these two mappings still use resolve, so WABT can read the lexical sibling and emit its digest and evidence as a caller-selected glue module or candidate. Apply absoluteCallerPath to both lists as well.

AGENTS.md reference: AGENTS.md:L13-L13

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid, fixed in a384b89. Root cause: this PR converted only the primary module path, but --glue_paths and --candidate_paths are caller-selected paths with the same producer. Both lists now go through absoluteCallerPath, and wasmCommands no longer imports resolve. Validated with the affected suites below. WABT is not installed on this host, so there was no real WABT run.

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with a non-blocking regression in WASM glue links for ordinary parent references.

Findings

  1. P2 WASM links become ambiguous ▶
Fix with agent prompt
### Issue 1
src/wasm/WasmGlueAdapter.ts:47-55
With glue at `/app/sub/glue.js` containing `fetch("../module.wasm")`, this comparison builds `/app/sub/../module.wasm`. That cannot equal the selected candidate `/app/module.wasm`, even when `sub` is an ordinary directory. If `/other/module.wasm` is also selected, both files now appear as `basename-candidates`; previously only `/app/module.wasm` matched.

Compare filesystem-resolved file identities without collapsing symlink parents, while keeping the caller’s spelling in the output. Add this ordinary parent-reference case alongside the symlink test.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR moves caller-selected paths through absoluteCallerPath so POSIX follows symlinks before applying ...

  • Caller paths keep the file named through POSIX symlinks.
  • Inspection evidence and debug records follow the selected file.
  • Firmware extraction creates its output at the selected path.
  • WASM glue references match the module path callers selected.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Caller-selected path] --> B[absoluteCallerPath]
  B --> C[Keep POSIX parent components]
  B --> D[Keep trailing directory requirement]
  C --> E[Filesystem selects file]
  D --> E
  B --> F[WASM path-string comparison]
  F --> G[Different spellings fall back to filenames]
Loading

Reviews (3) · Last reviewed commit: "fix: keep directory requirements and rel..." · Reviewed by Greptile

Comment thread src/cli/firmwareCommands.ts Resolved
Comment thread src/cli/wasmCommands.ts Resolved
Review follow-up. The CLI already passed firmware and WASM paths through
absoluteCallerPath, but snapshotFirmware and SafeOutputTree.create
re-resolved them lexically, and the WASM glue and candidate lists still
used resolve, so those inputs could still select a sibling file or
create output beside the intended directory.

absoluteCallerPath now also drops `.` segments and repeated or trailing
separators on POSIX, which never change the named file, so selected
paths such as `./module.wasm` keep matching their glue references
exactly. Every `..` is still left for the filesystem.

SafeOutputTree keeps host path syntax; its platform argument selects only
the Windows name policy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/filesystem/callerPath.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a384b892b0

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/filesystem/callerPath.ts Outdated
}: { readonly cwd?: string; readonly platform?: NodeJS.Platform } = {},
): string => {
if (platform === "win32") return win32.resolve(cwd, path);
const absolute = posix.isAbsolute(path) ? path : `${cwd}/${path}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve relative caller cwd before preserving path

On POSIX, parseBinaryTarget("sample", { cwd: "fixtures" }) now passes /fixtures/sample to the filesystem, whereas the prior resolve(cwd, input) correctly selected <process.cwd()>/fixtures/sample. cwd is an unconstrained string in BinaryTargetResolverOptions, so callers that use a relative working directory receive an unrelated root path or ENOENT; make the supplied cwd absolute (without normalizing its .. components) before appending a relative input.

AGENTS.md reference: AGENTS.md:L13-L13

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid, fixed in 1653bb5. Root cause: the helper used a non-absolute cwd as if it were absolute. A relative cwd is now made absolute first, through the same owner and without collapsing .., before the path is appended. The helper test covers cwd: "fixtures/../x".

Comment thread src/cli/wasmCommands.ts
Comment on lines +69 to 73
absoluteCallerPath(path),
),
candidate_paths: options.candidate_paths?.map((path) =>
resolve(path),
absoluteCallerPath(path),
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve symlink semantics in WASM glue matching

When the CLI receives a glue path and WASM path such as link/../glue.js and link/../module.wasm, these mappings retain their symlink-sensitive spellings, but associateWasmGlue still computes a local literal with resolve(dirname(path), value) (src/wasm/WasmGlueAdapter.ts:44-47). That lexical resolve turns the reference into the sibling path, so fetch("./module.wasm") is only recorded as a basename match instead of local-path-candidate for the selected file; use the caller-path owner for that comparison too.

AGENTS.md reference: AGENTS.md:L13-L13

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid, fixed in 1653bb5. Root cause: associateWasmGlue was a second, lexical interpreter of the same caller-selected paths. It now compares absoluteCallerPath(value, { cwd: dirname(glue) }) with absoluteCallerPath(candidate) and still reports each candidate exactly as given. So ./ spellings and MCP-supplied absolute paths compare consistently, and link/../ is never collapsed onto a sibling. The new case selects link/../module.wasm and link/../glue.js with a competing /app/module.wasm, and asserts an exact local-path-candidate for the selected file only. It fails on the previous commit. Validation for this round: npx vitest run tests/boundary/cli tests/boundary/providers tests/boundary/filesystem tests/boundary/native tests/boundary/mcp tests/boundary/firmware src/application src/wasm tests/acceptance passed 700 files (6,565 tests passed, 93 skipped), plus npm run check:fast.

Review follow-up. absoluteCallerPath stripped a trailing `/` or `/.`, so
`file/` selected the regular file instead of failing with ENOTDIR; it
now keeps one trailing separator. A relative cwd option was appended to
the root; it is now made absolute without collapsing `..`. WASM glue
matching resolved local literals lexically, so a module selected through
`link/..` matched only by basename; the adapter now compares both sides
through absoluteCallerPath and still reports each candidate as given.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1653bb58f3

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +27 to +31
const segments = path
.split("/")
.filter((segment) => segment !== "" && segment !== ".");
const directory = /\/\.?$/u.test(path) && segments.length > 0;
return `/${segments.join("/")}${directory ? "/" : ""}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve leading double slashes in POSIX caller paths

On POSIX implementations that assign special semantics to a // root, this filter changes a caller-selected path such as //namespace/target into /namespace/target. Since this helper now feeds CLI inputs, provider command arguments, hashing, and output roots, those callers can again inspect or create resources in a different namespace; retain the leading double slash rather than treating it as a repeated interior separator.

AGENTS.md reference: AGENTS.md:L13-L13

Useful? React with 👍 / 👎.

Comment on lines +47 to +55
const target = local
? absoluteCallerPath(value, { cwd: dirname(path) })
: undefined;
const exact =
target === undefined
? []
: candidates.filter(
(candidate) => absoluteCallerPath(candidate) === target,
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 WASM links become ambiguous

With glue at /app/sub/glue.js containing fetch("../module.wasm"), this comparison builds /app/sub/../module.wasm. That cannot equal the selected candidate /app/module.wasm, even when sub is an ordinary directory. If /other/module.wasm is also selected, both files now appear as basename-candidates; previously only /app/module.wasm matched.

Compare filesystem-resolved file identities without collapsing symlink parents, while keeping the caller’s spelling in the output. Add this ordinary parent-reference case alongside the symlink test.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/wasm/WasmGlueAdapter.ts
Line: 47-55

Comment:
**WASM links become ambiguous**

With glue at `/app/sub/glue.js` containing `fetch("../module.wasm")`, this comparison builds `/app/sub/../module.wasm`. That cannot equal the selected candidate `/app/module.wasm`, even when `sub` is an ordinary directory. If `/other/module.wasm` is also selected, both files now appear as `basename-candidates`; previously only `/app/module.wasm` matched.

Compare filesystem-resolved file identities without collapsing symlink parents, while keeping the caller’s spelling in the output. Add this ordinary parent-reference case alongside the symlink test.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@kaoru0822-kitauji
kaoru0822-kitauji merged commit fc791bb into main Oct 15, 2026
41 checks passed
@kaoru0822-kitauji
kaoru0822-kitauji deleted the fix/3864-symlink-parent-paths branch October 15, 2026 12:19
all-black-493 added a commit to all-black-493/rea that referenced this pull request Oct 18, 2026
Resolve the conflicts with main at 32f0e51. No rebase or force-push.

- src/cli/wasmCommands.ts: keep the component command and take main's
  absoluteCallerPath (morluto#4067). The component path now uses it too, instead
  of path.resolve, so `link/../file` selects the file the filesystem
  names. Pass the command signal to finishAnalysisCommand, which main now
  requires (279c590).
- src/server/createServer.ts: keep main's rustBinary service and this
  PR's wasmComponent service in construction, shutdown and the tool
  context.
- tests/boundary/mcp/serverLifecycleMcp.test.ts: keep main's scenario
  capture service and this PR's component service in the shutdown test.
- src/wasm/WabtComponentRouting.ts: the component probe reads its header
  through main's withArtifactFileHandle, so a failed close is retained as
  a lease and its error resolves on retry, as main's WABT descriptor-retry
  test requires.
- tests/boundary/cli/callerPathSymlinkParentCli.test.ts: cover
  inspect-wasm-component through a symlink and `..`; it fails with
  path.resolve.
8rulerstar added a commit to 8rulerstar/rea that referenced this pull request Oct 19, 2026
…r tools

Follow main's absoluteCallerPath (morluto#4067) and pass the command signal to finishAnalysisCommand.
8rulerstar added a commit to 8rulerstar/rea that referenced this pull request Oct 19, 2026
…r tools

Follow main's absoluteCallerPath (morluto#4067) and pass the command signal to finishAnalysisCommand.
8rulerstar added a commit to 8rulerstar/rea that referenced this pull request Oct 19, 2026
Use absoluteCallerPath (morluto#4067) so a path with a symlink followed by .. names the same file the CLI and MCP inspect.
8rulerstar added a commit to 8rulerstar/rea that referenced this pull request Oct 19, 2026
Use absoluteCallerPath (morluto#4067) so a path with a symlink followed by .. names the same file the CLI and MCP inspect.
mvanhorn added a commit to mvanhorn/rea that referenced this pull request Oct 19, 2026
main replaced the node:path resolve import in binaryDiagnosticsCommands.ts
with absoluteCallerPath (morluto#4067), so the byte-entropy command's
resolve(args.path) no longer type-checks once the PR is merged with main.
Use absoluteCallerPath like the other commands, and add
src/filesystem/callerPath.ts matching main so the branch builds on its own.
gensokyo-dev added a commit that referenced this pull request Oct 19, 2026
…d methods (#3807)

* feat(il2cpp): inventory IL2CPP global-metadata images, types and methods

Add inspect_il2cpp_metadata (CLI inspect-il2cpp-metadata), a read-only
in-process decoder for unencrypted Unity global-metadata.dat version 39.
It reports header sections, serialized index widths, images, type
definitions (nesting from the nestedTypes section) and method names.

Unrecognized magic and other versions are unsupported; damaged headers,
overlapping sections, inconsistent record sizes, out-of-range indices and
invalid strings fail with a reason code and no partial success. MCP
detail summary retains the complete Evidence and pages rows through
inspect_analysis_view kind il2cpp-metadata.

Adds an opt-in verify:il2cpp:metadata -- --metadata PATH check.

* feat(il2cpp): deliver metadata summaries by default over MCP

A 112,232-method file produced a 10.5 MB complete response, above the
10 MiB stdio budget. Default MCP delivery is now the retained summary;
detail complete stays available, and the one-shot CLI requests it.

* fix(il2cpp): reject shifted strings, nesting cycles and method owner drift

Review fuzzing showed that moving the strings section offset by one byte
silently renamed every image, type and method. Name indices must now start
a string, which also bounds total decoding by the section size.

Nesting cycles and methods whose declaring type disagrees with the owning
type range are rejected instead of returned. Adds service, shutdown and
index-width coverage, and moves environment-specific measurements out of
the public guide and tool description.

* feat(il2cpp): decode global-metadata versions 29 and 31

Unity 2022.3 writes version 29 or 31 metadata: a 256-byte header of
(offset, size) pairs, fixed 4-byte indices, type records with
elementTypeIndex, and method records that gained returnParameterToken in
version 31. Record counts come from section sizes and must be whole.

Sections report a null count for these versions and index widths report
fixed-width-version. Image, type and method rows keep the same shape, and
the string, nesting and method-ownership checks apply to every version.

* fix(il2cpp): bound report size before serializing and tighten coverage

Rows share decoded names, so a 130 KB file could expand into gigabytes of
JSON before the 64 MiB budget check, ending in an internal RangeError. The
provider now refuses from a lower bound on the serialized rows first.

The decoder also rejects non-empty sections inside the header, methods
outside their declaring type's range and overlapping image type ranges, and
keeps a leading byte order mark in names. Layouts now carry one indexing
mode instead of two coupled flags, and the tool description explains
nested_type_start.

* fix(il2cpp): refuse oversized metadata before decoding rows

Address review findings on the IL2CPP metadata inventory:

- check a lower bound from header row counts before any row object is
  allocated, so a large rejected file no longer builds every row first;
- validate sealed parent Evidence and count its rows once per report
  instead of on every inspect_analysis_view page;
- decode version 39 fixtures with 2- and 4-byte type-definition,
  generic-container and parameter indices.

* docs(il2cpp): attach the decoder comment to readIl2cppMetadata

* fix(il2cpp): deliver complete rows by default like the other inspection tools

inspect_il2cpp_metadata defaulted to detail summary, the only inspection
tool to do so. Omitted detail now returns every row inline, as
inspect_artifact, decode_interface_builder and the capture tools do;
summary stays one argument away and the guide, CLI reference and skill
reference say to select it first for large games, whose complete MCP
delivery is refused at the stdio budget with retained Evidence.

* test(il2cpp): cover narrow-width -1 sentinels and fix the skill's default

An empty image stores its type start as the all-ones value of a one- or
two-byte index; the decoder reads it as -1, but no fixture exercised it,
so removing either conversion passed the suite. The fixture can now append
an empty image, and both widths decode it. The skill still described a
summary default; it now says to select summary first, as the guide does.

* docs(il2cpp): request summary explicitly in the summary example

* chore(il2cpp): hash the verifier metadata through owned file resources

* fix(il2cpp): count escaped name length without building the escaped string

* fix(il2cpp): keep the verifier's check failure and small-table last page

* feat(domain): count JSON string length without building the escaped string

* fix(il2cpp): keep descriptor cleanup owners and share the JSON length count

* test(domain): give the backslash case real backslashes

* fix(il2cpp): select the CLI path and finish the command like the other tools

Follow main's absoluteCallerPath (#4067) and pass the command signal to finishAnalysisCommand.

* fix(il2cpp): select the verifier input path like the CLI

Use absoluteCallerPath (#4067) so a path with a symlink followed by .. names the same file the CLI and MCP inspect.

* feat(il2cpp): add compact composable metadata queries

Retain source-indexed Evidence for filtered batch and field queries. Bound representation growth before serialization, yield decoding for cancellation, and share CLI Evidence publication with desktop inspection. Verify public Unity metadata against independent byte and managed-DLL oracles and exercise actual stdio SDK workflows.

* fix(il2cpp): retain the validated metadata header magic

* test(il2cpp): remove obsolete execution wording exception

* fix(artifacts): preserve export selection and completed source facts

---------

Co-authored-by: gensokyo-dev <[email protected]>
8rulerstar added a commit to 8rulerstar/rea that referenced this pull request Oct 19, 2026
…r tools

Follow main's absoluteCallerPath (morluto#4067) and pass the command signal to finishAnalysisCommand.
8rulerstar added a commit to 8rulerstar/rea that referenced this pull request Oct 19, 2026
Use absoluteCallerPath (morluto#4067) so a path with a symlink followed by .. names the same file the CLI and MCP inspect.
8rulerstar added a commit to 8rulerstar/rea that referenced this pull request Oct 20, 2026
…r tools

Follow main's absoluteCallerPath (morluto#4067) and pass the command signal to finishAnalysisCommand.
8rulerstar added a commit to 8rulerstar/rea that referenced this pull request Oct 20, 2026
Use absoluteCallerPath (morluto#4067) so a path with a symlink followed by .. names the same file the CLI and MCP inspect.
morluto added a commit that referenced this pull request Oct 22, 2026
…2331)

* feat(diagnostics): report a byte entropy profile for one local file

The diff adds the MCP tool inspect_byte_entropy and the CLI command
inspect-byte-entropy, both implemented by ByteEntropyService. One
absolute regular file is read offline into observed Evidence: file-wide
SHA-256 and Shannon entropy, then fixed blocks and adjacent runs for an
optional window, using a power-of-two block size from 256 to 65536
(default 4096), with high at 7.2 or above and low at 1.0 or below. A
window past EOF, a missing path, or a non-file is an input error; a size
or identity change during the read is an artifact-changed error; empty
input reports entropy 0; cancellation is honored before and during the
read. Summary detail retains the complete series and returns file
entropy, counts, and the ten longest runs for inspect_analysis_view,
while the registered effect remains read-only Evidence and the
diagnostics docs record the operation and its errors.

* fix(diagnostics): flag zero-size files as not shown empty

Generated files such as Linux /proc entries report size 0 while holding
content, so inspect_byte_entropy read nothing and returned an empty-looking
report. A file that reports size 0 now carries a limitation that the result
does not show the file is empty. The result stays a success because the
tool reads the declared size, which the file-stability checks depend on.

* fix(mcp): reject unsupported diagnostic summaries before inspection

* fix(ci): repair integrated checks and Hopper test baseline

* test(entropy): use shared MCP schema verification after merge

* fix(catalog): list inspect_byte_entropy under its own provider

Adding inspect_byte_entropy to BINARY_DIAGNOSTICS_TOOL_CONTRACTS put it
under pwntools-elf in the generated product catalog, because the
pwntools group took every binary diagnostics tool except
inspect_pe_resources. The service reports provider byte-entropy.

Add a BYTE_ENTROPY_PROVIDER identity beside PE_RESOURCES_PROVIDER, use
it in ByteEntropyService, give it its own catalog group, and name the
pwntools tools (inspect_binary_layout, inspect_recorded_crash)
explicitly so a new diagnostics tool is not attributed to pwntools by
default. The catalog test pins both groups.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KFTE4BHbGYzgf8Uhzcppdh

* fix(cli): resolve the byte-entropy path with absoluteCallerPath

main replaced the node:path resolve import in binaryDiagnosticsCommands.ts
with absoluteCallerPath (#4067), so the byte-entropy command's
resolve(args.path) no longer type-checks once the PR is merged with main.
Use absoluteCallerPath like the other commands, and add
src/filesystem/callerPath.ts matching main so the branch builds on its own.

* fix(diagnostics): retain entropy read cleanup ownership

* docs(diagnostics): explain entropy output capacity

* fix(diagnostics): preserve entropy cancellation outcomes

* fix(diagnostics): close the entropy input and warn on large reports

Public inspect_byte_entropy input now uses publicInputStrictObject before
detail is added, so unknown keys stay rejected on the advertised schema.
The tool description warns that complete output can become very large and
points callers to a shorter length or a larger block_size.

Co-authored-by: morluto <[email protected]>

* fix(diagnostics): keep byte-entropy registration mergeable with main

Register inspect_byte_entropy beside layout inspection and reject
unretained summaries before the file read, without editing workflows.

Co-authored-by: morluto <[email protected]>

* fix(diagnostics): register byte entropy with the shared tool options

Use toolRegistrationOptions so the handler typechecks on this branch and
on main, and still refuse unretained summaries before the file read.

Co-authored-by: morluto <[email protected]>

---------

Co-authored-by: Matt Van Horn <[email protected]>
Co-authored-by: morluto <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Kaoru0822 <[email protected]>
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: morluto <[email protected]>
@morluto morluto added the bug Something isn't working label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working track:perf Performance track PRs (issues & perf loop)

Projects

None yet

2 participants