[PR #3081] [CLOSED] fix(ghidra): discover an installed Ghidra from a launcher on PATH #5600

Closed
opened 2026-10-31 01:07:52 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3081
Author: @0xLLVEL
Created: 10/14/2026
Status: ❌ Closed

Base: main ← Head: fix/ghidra-path-discovery


📝 Commits (1)

  • 8ca6948 fix(ghidra): discover an installed Ghidra from a launcher on PATH

📊 Changes

2 files changed (+180 additions, -3 deletions)

View changed files

📝 src/ghidra/GhidraInstallation.test.ts (+104 -0)
📝 src/ghidra/GhidraInstallation.ts (+76 -3)

📄 Description

Summary

rea doctor reports a Ghidra that is installed and reachable on PATH as not_configured, because installation discovery read only GHIDRA_INSTALL_DIR. On a distribution that links the launcher into PATH — the reporter's CachyOS box has /usr/bin/ghidra -> /opt/ghidra/ghidraRun, owned by ghidra 12.1.2-2.1 — the installation is never found, every Ghidra provider check fails, and the remediation only mentions the variable.

This covers the PATH-discovery half of #3008 (suggestion 2). It deliberately does not cover suggestion 1 (reporting a provider row for every advertised tool surface), which touches DoctorProviderIds.ts, doctorRuntime.ts, and composition/binary.ts.

Refs #3008

Problem and expected behavior

Smallest trigger: a Ghidra release extracted to /opt/ghidra, with /usr/bin/ghidra linked at its ghidraRun, and GHIDRA_INSTALL_DIR unset.

Violated invariant: a provider that is genuinely installed and runnable on the host should not be reported as absent. The reporter confirmed that setting GHIDRA_INSTALL_DIR=/opt/ghidra flips the same host to configured=true, available=true, providerVersion=12.1.2, so only the discovery step is missing.

Expected: installation coordinates resolve a ghidra launcher on PATH to its canonical release root and inspect it exactly as an explicit GHIDRA_INSTALL_DIR would.

Change and scope

  • GhidraInstallationHost gains an optional resolvePathExecutable(name, environment) seam. An omitted seam leaves discovery dependent on GHIDRA_INSTALL_DIR alone, so existing callers and tests keep their behavior.
  • discoveredInstallDir runs only when options.installDir is absent, and only when the caller-selected environment actually supplies a PATH. It resolves ghidra, ghidraRun, ghidra.bat, ghidraRun.bat in that order and takes the canonical launcher's parent directory.
  • The system host implements the seam by walking PATH entries, requiring the entry to be an executable file, and returning the resolved real path so a linked launcher resolves to the release root the launcher belongs to.
  • An explicit GHIDRA_INSTALL_DIR still wins; the seam is not consulted at all in that case.
  • A launcher whose parent directory holds no Ghidra application properties is rejected by the existing installation check rather than trusted, so a stray ghidra on PATH cannot become a provider. Verified below.
  • The not_configured detail and remediation now mention PATH so an operator is told the launcher is a supported route.

Not included: any provider-row reporting for other tool surfaces (see Summary), and any change to setup, registration, or the Hopper and IDA lanes.

Contribution scope: not applicable — an ordinary fix within existing boundaries; no target execution, injection, mutation, or protection recovery.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/ghidra/GhidraInstallation.ts, installation-coordinate resolution. Earliest changed stage is provider installation discovery, upstream of doctor projection and of provider selection.
  • Contribution scope fit and linked maintainer decision: not applicable; ordinary fix within existing boundaries.
  • CLI and MCP/tool-catalog contract: no new tool, no schema change, no catalog change. rea doctor keeps the same check names (configuration, installation, version, headless, native_decompiler, java); only the configuration failure detail and remediation strings, and the reported install_dir on a PATH-only host, change.
  • Provider, bridge, target-format, or platform compatibility: Ghidra lane only, on the platforms already accepted by the native-platform table. POSIX probes ghidra and ghidraRun; Windows additionally probes the .bat launchers. Hopper and IDA are untouched.
  • Evidence, artifact, provenance, or reconstruction contract: none; this is host discovery, not target evidence.
  • Target selection, authority, upstream behavior, and cleanup details: none. The seam is read-only — it opens executables for reading and does not launch Ghidra, mutate the host, or write configuration.
  • Generated metadata, package, or installation impact: none; no generated catalog or skill content is affected.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: six cases in a new Ghidra PATH discovery block in src/ghidra/GhidraInstallation.test.ts — discovery through a linked launcher; explicit GHIDRA_INSTALL_DIR preferred with the seam proven unconsulted; a launcher whose directory holds no release rejected as executable_missing; no PATH seam stays not_configured; absent or empty PATH stays not_configured; and a Windows launcher resolved under the inspected platform.
  • Base reproduction or other evidence: on base 242e2b000, a release root placed on PATH yields installDir=null and configuration: failed — GHIDRA_INSTALL_DIR is not set. With this change the same host yields installDir=<release root>, configuration: passed, installation: passed. A stray launcher directory on PATH yields installation: failed, confirming an untrusted directory is not adopted. Executed against the real system host on Windows x64.
  • User-visible CLI/MCP output: the configuration check on a PATH-only host moves from failed to passing; when nothing is found the detail becomes GHIDRA_INSTALL_DIR is not set and no Ghidra launcher was found on PATH.
  • Remaining proof gaps: no live, licensed Ghidra was contacted on a Linux distribution, so the symlinked-launcher path is covered by the unit seam and by real-path resolution on a real file, not by a real ghidra package install. Symlink creation is unavailable unprivileged on this Windows host, so the Windows live check used a release root placed on PATH directly.

Validation performed

  • npm run typecheck — pass.
  • npm run check:fast (typecheck + lint) — pass.
  • npx vitest run src/ghidra/GhidraInstallation.test.ts src/ghidra/GhidraDoctor.test.ts — 80 passed (69 + 11).
  • npx vitest run src/ghidra/ — 13 failures in GhidraAnalysisSeeds, GhidraLanguageOverride, GhidraPowerPcProfile, and GhidraSnapshotCache. Confirmed pre-existing: stashing this change and re-running the same four files on base 242e2b000 produces the identical 4 failed files and 13 failed tests. None of those files touch installation discovery.
  • Live Windows x64 check against the real system host, three scenarios (baseline / release root on PATH / stray launcher on PATH) — observed results as described above.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Existing GHIDRA_INSTALL_DIR registrations behave identically; the seam is optional.
  • Real Hopper/Ghidra, browser, or OS coverage: Windows x64 live, three scenarios. No live Ghidra engine was launched; installation discovery is read-only and stops short of launching Ghidra, matching the existing doctor boundary.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: PATH-derived directories are treated as untrusted input. The derived root must still satisfy every existing check, including application properties, the headless launcher, the native-decompiler format and architecture probe, and the Java bounds, before a provider reports available. The seam reads executables only and never executes a discovered launcher.

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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/3081 **Author:** [@0xLLVEL](https://github.com/0xLLVEL) **Created:** 10/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/ghidra-path-discovery` --- ### 📝 Commits (1) - [`8ca6948`](https://github.com/morluto/rea/commit/8ca69488eac73e10a733e955a320fe131ff8e87c) fix(ghidra): discover an installed Ghidra from a launcher on PATH ### 📊 Changes **2 files changed** (+180 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/ghidra/GhidraInstallation.test.ts` (+104 -0) 📝 `src/ghidra/GhidraInstallation.ts` (+76 -3) </details> ### 📄 Description ## Summary `rea doctor` reports a Ghidra that is installed and reachable on `PATH` as `not_configured`, because installation discovery read only `GHIDRA_INSTALL_DIR`. On a distribution that links the launcher into PATH — the reporter's CachyOS box has `/usr/bin/ghidra -> /opt/ghidra/ghidraRun`, owned by `ghidra 12.1.2-2.1` — the installation is never found, every Ghidra provider check fails, and the remediation only mentions the variable. This covers the PATH-discovery half of #3008 (suggestion 2). It deliberately does **not** cover suggestion 1 (reporting a provider row for every advertised tool surface), which touches `DoctorProviderIds.ts`, `doctorRuntime.ts`, and `composition/binary.ts`. Refs #3008 ## Problem and expected behavior Smallest trigger: a Ghidra release extracted to `/opt/ghidra`, with `/usr/bin/ghidra` linked at its `ghidraRun`, and `GHIDRA_INSTALL_DIR` unset. Violated invariant: a provider that is genuinely installed and runnable on the host should not be reported as absent. The reporter confirmed that setting `GHIDRA_INSTALL_DIR=/opt/ghidra` flips the same host to `configured=true, available=true, providerVersion=12.1.2`, so only the discovery step is missing. Expected: installation coordinates resolve a `ghidra` launcher on PATH to its canonical release root and inspect it exactly as an explicit `GHIDRA_INSTALL_DIR` would. ## Change and scope - `GhidraInstallationHost` gains an optional `resolvePathExecutable(name, environment)` seam. An omitted seam leaves discovery dependent on `GHIDRA_INSTALL_DIR` alone, so existing callers and tests keep their behavior. - `discoveredInstallDir` runs only when `options.installDir` is absent, and only when the caller-selected environment actually supplies a PATH. It resolves `ghidra`, `ghidraRun`, `ghidra.bat`, `ghidraRun.bat` in that order and takes the canonical launcher's parent directory. - The system host implements the seam by walking PATH entries, requiring the entry to be an executable file, and returning the resolved real path so a linked launcher resolves to the release root the launcher belongs to. - An explicit `GHIDRA_INSTALL_DIR` still wins; the seam is not consulted at all in that case. - A launcher whose parent directory holds no Ghidra application properties is rejected by the existing `installation` check rather than trusted, so a stray `ghidra` on PATH cannot become a provider. Verified below. - The `not_configured` detail and remediation now mention PATH so an operator is told the launcher is a supported route. Not included: any provider-row reporting for other tool surfaces (see Summary), and any change to setup, registration, or the Hopper and IDA lanes. Contribution scope: not applicable — an ordinary fix within existing boundaries; no target execution, injection, mutation, or protection recovery. ## Contract and boundary impact - Semantic owner and earliest changed stage: `src/ghidra/GhidraInstallation.ts`, installation-coordinate resolution. Earliest changed stage is provider installation discovery, upstream of doctor projection and of provider selection. - Contribution scope fit and linked maintainer decision: not applicable; ordinary fix within existing boundaries. - CLI and MCP/tool-catalog contract: no new tool, no schema change, no catalog change. `rea doctor` keeps the same check names (`configuration`, `installation`, `version`, `headless`, `native_decompiler`, `java`); only the `configuration` failure detail and remediation strings, and the reported `install_dir` on a PATH-only host, change. - Provider, bridge, target-format, or platform compatibility: Ghidra lane only, on the platforms already accepted by the native-platform table. POSIX probes `ghidra` and `ghidraRun`; Windows additionally probes the `.bat` launchers. Hopper and IDA are untouched. - Evidence, artifact, provenance, or reconstruction contract: none; this is host discovery, not target evidence. - Target selection, authority, upstream behavior, and cleanup details: none. The seam is read-only — it opens executables for reading and does not launch Ghidra, mutate the host, or write configuration. - Generated metadata, package, or installation impact: none; no generated catalog or skill content is affected. Expected effects: - [ ] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: six cases in a new `Ghidra PATH discovery` block in `src/ghidra/GhidraInstallation.test.ts` — discovery through a linked launcher; explicit `GHIDRA_INSTALL_DIR` preferred with the seam proven unconsulted; a launcher whose directory holds no release rejected as `executable_missing`; no PATH seam stays `not_configured`; absent or empty PATH stays `not_configured`; and a Windows launcher resolved under the inspected platform. - Base reproduction or other evidence: on base `242e2b000`, a release root placed on PATH yields `installDir=null` and `configuration: failed — GHIDRA_INSTALL_DIR is not set`. With this change the same host yields `installDir=<release root>`, `configuration: passed`, `installation: passed`. A stray launcher directory on PATH yields `installation: failed`, confirming an untrusted directory is not adopted. Executed against the real system host on Windows x64. - User-visible CLI/MCP output: the `configuration` check on a PATH-only host moves from failed to passing; when nothing is found the detail becomes `GHIDRA_INSTALL_DIR is not set and no Ghidra launcher was found on PATH`. - Remaining proof gaps: no live, licensed Ghidra was contacted on a Linux distribution, so the symlinked-launcher path is covered by the unit seam and by real-path resolution on a real file, not by a real `ghidra` package install. Symlink creation is unavailable unprivileged on this Windows host, so the Windows live check used a release root placed on PATH directly. ## Validation performed - `npm run typecheck` — pass. - `npm run check:fast` (typecheck + lint) — pass. - `npx vitest run src/ghidra/GhidraInstallation.test.ts src/ghidra/GhidraDoctor.test.ts` — 80 passed (69 + 11). - `npx vitest run src/ghidra/` — 13 failures in `GhidraAnalysisSeeds`, `GhidraLanguageOverride`, `GhidraPowerPcProfile`, and `GhidraSnapshotCache`. Confirmed pre-existing: stashing this change and re-running the same four files on base `242e2b000` produces the identical 4 failed files and 13 failed tests. None of those files touch installation discovery. - Live Windows x64 check against the real system host, three scenarios (baseline / release root on PATH / stray launcher on PATH) — observed results as described above. ## Compatibility, safety, and release - Breaking changes or migration steps: none. Existing `GHIDRA_INSTALL_DIR` registrations behave identically; the seam is optional. - Real Hopper/Ghidra, browser, or OS coverage: Windows x64 live, three scenarios. No live Ghidra engine was launched; installation discovery is read-only and stops short of launching Ghidra, matching the existing doctor boundary. - Package or release metadata impact: none. - Security, privacy, process, or containment review: PATH-derived directories are treated as untrusted input. The derived root must still satisfy every existing check, including application properties, the headless launcher, the native-decompiler format and architecture probe, and the Java bounds, before a provider reports available. The seam reads executables only and never executes a discovered launcher. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:07:52 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5600
No description provided.