[PR #1222] [MERGED] fix(ghidra): do not run Java from a relative JAVA_HOME in doctor and setup #2733

Closed
opened 2026-10-17 21:09:37 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/1222
Author: @kaoru0822-kitauji
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/ghidra-relative-java-probe


📝 Commits (1)

  • c3f1698 fix(ghidra): do not run Java from a relative JAVA_HOME in doctor and setup

📊 Changes

2 files changed (+39 additions, -4 deletions)

View changed files

📝 src/ghidra/GhidraInstallation.test.ts (+30 -0)
📝 src/ghidra/GhidraInstallation.ts (+9 -4)

📄 Description

Follow-up to #1200, addressing its unresolved Codex review finding.

Problem

#1200 made the Ghidra installation inspection reject a relative GHIDRA_INSTALL_DIR or JAVA_HOME, because REA's configuration parser (and so the MCP server and analysis) accepts only absolute paths. However, installationCoordinates probes Java before any check runs: it calls host.probeJava("<JAVA_HOME>/bin/java", …), and the system host implements that probe with spawnSync.

So with JAVA_HOME=./jdk, rea doctor and rea setup executed ./jdk/bin/java from the current directory, then reported JAVA_HOME must be absolute. An empty JAVA_HOME ran bin/java the same way.

Reproduced with the built CLI. A planted ./jdk/bin/java that touches a marker file:

cd <dir containing jdk/bin/java>
GHIDRA_INSTALL_DIR=/opt/ghidra-absent JAVA_HOME=./jdk rea doctor --format json
build ./jdk/bin/java executed configuration check
main yes JAVA_HOME must be absolute
this branch no JAVA_HOME must be absolute

Change

installationCoordinates probes Java only when JAVA_HOME is unset (PATH discovery, which is intended) or absolute for the inspected platform. Otherwise the Java observation is unknown. The configuration check still reports the rejection and its remediation, as before.

Reading files under a relative GHIDRA_INSTALL_DIR (application.properties, executable bits) is unchanged. Those reads do not execute anything, and the configuration check already rejects that path.

Verification

  • npx vitest run src/ghidra/GhidraInstallation.test.ts src/ghidra/GhidraDoctor.test.ts: 43 passed. The new cases (./jdk and "" on Linux, jdk on Windows) fail on main because the probe runs.
  • npm run check:changed: typecheck, lint and 93 affected tests passed.
  • Real CLI comparison of main and this branch: see the table above.

No real Ghidra verification was performed (no Ghidra installation on this host). The change affects only the pre-launch installation inspection.

🤖 Generated with Claude Code


🔄 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/1222 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/ghidra-relative-java-probe` --- ### 📝 Commits (1) - [`c3f1698`](https://github.com/morluto/rea/commit/c3f169823f690371ecfdd2d1b3b07a5749438cf1) fix(ghidra): do not run Java from a relative JAVA_HOME in doctor and setup ### 📊 Changes **2 files changed** (+39 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/ghidra/GhidraInstallation.test.ts` (+30 -0) 📝 `src/ghidra/GhidraInstallation.ts` (+9 -4) </details> ### 📄 Description Follow-up to #1200, addressing its unresolved Codex review finding. ## Problem #1200 made the Ghidra installation inspection reject a relative `GHIDRA_INSTALL_DIR` or `JAVA_HOME`, because REA's configuration parser (and so the MCP server and analysis) accepts only absolute paths. However, `installationCoordinates` probes Java before any check runs: it calls `host.probeJava("<JAVA_HOME>/bin/java", …)`, and the system host implements that probe with `spawnSync`. So with `JAVA_HOME=./jdk`, `rea doctor` and `rea setup` executed `./jdk/bin/java` from the current directory, then reported `JAVA_HOME must be absolute`. An empty `JAVA_HOME` ran `bin/java` the same way. Reproduced with the built CLI. A planted `./jdk/bin/java` that touches a marker file: ``` cd <dir containing jdk/bin/java> GHIDRA_INSTALL_DIR=/opt/ghidra-absent JAVA_HOME=./jdk rea doctor --format json ``` | build | `./jdk/bin/java` executed | configuration check | | --- | --- | --- | | main | yes | `JAVA_HOME must be absolute` | | this branch | no | `JAVA_HOME must be absolute` | ## Change `installationCoordinates` probes Java only when `JAVA_HOME` is unset (PATH discovery, which is intended) or absolute for the inspected platform. Otherwise the Java observation is unknown. The configuration check still reports the rejection and its remediation, as before. Reading files under a relative `GHIDRA_INSTALL_DIR` (application.properties, executable bits) is unchanged. Those reads do not execute anything, and the configuration check already rejects that path. ## Verification - `npx vitest run src/ghidra/GhidraInstallation.test.ts src/ghidra/GhidraDoctor.test.ts`: 43 passed. The new cases (`./jdk` and `""` on Linux, `jdk` on Windows) fail on main because the probe runs. - `npm run check:changed`: typecheck, lint and 93 affected tests passed. - Real CLI comparison of main and this branch: see the table above. No real Ghidra verification was performed (no Ghidra installation on this host). The change affects only the pre-launch installation inspection. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-17 21:09:37 +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#2733
No description provided.