[PR #2206] [MERGED] fix(ghidra): encode Java probe output as UTF-8 #5082

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2206
Author: @Ha1baraA11
Created: 10/12/2026
Status: ✅ Merged
Merged: 10/12/2026
Merged by: @morluto

Base: main ← Head: pr/rea-2204


📝 Commits (3)

  • 62c49e8 fix(ghidra): encode Java probe output as UTF-8
  • 6eeda57 fix(ghidra): preserve Unicode Java homes across supported JDKs
  • cb1dc30 test(ghidra): verify snapshot rejection without matching prose

📊 Changes

7 files changed (+102 additions, -15 deletions)

View changed files

📝 .github/workflows/ci.yml (+1 -0)
📝 scripts/ci/scopes.mjs (+1 -0)
📝 scripts/lib/real-ghidra-snapshot-lifecycle.mjs (+2 -7)
📝 src/ghidra/GhidraInstallation.test.ts (+4 -1)
📝 src/ghidra/GhidraInstallation.ts (+10 -1)
➕ tests/boundary/filesystem/ghidraJavaProbe.test.ts (+82 -0)
📝 tests/composition/analysis-sessions/binarySession.test.ts (+2 -6)

📄 Description

Summary

  • Encode the Ghidra Java settings probe's stdout and stderr as UTF-8 so a non-ASCII Windows JAVA_HOME is read correctly.

Fixes #2204

Problem and expected behavior

The probe asks Node to decode Java output as UTF-8, but the JVM's standard streams can use the Windows native encoding unless their encodings are set. A new Issue timeline report demonstrates the result in raw bytes: the environment-derived install path remains valid UTF-8, while the JVM-derived java.home contains four U+FFFD replacements for a two-character folder name. The reporter also observes rea analyze fail with provider_unavailable, while the same JDK works after moving JAVA_HOME to an ASCII path. The probe should preserve the path and admit the installed full JDK.

Change and scope

  • Pass -Dstdout.encoding=UTF-8 and -Dstderr.encoding=UTF-8 to the Ghidra installation properties probe.
  • Add regression coverage that verifies both flags are passed when a Java response contains a non-ASCII Windows JDK path.
  • The change is limited to installation discovery; normal Ghidra launch arguments are unchanged.

Contract and boundary impact

  • Semantic owner and earliest changed stage: GhidraInstallation, during Java provider admission.
  • CLI and MCP/tool-catalog contract: no contract or output shape changes.
  • Provider, bridge, target-format, or platform compatibility: no change to supported Ghidra/JDK versions; the probe reads the reported Java home consistently.
  • Evidence, artifact, provenance, or reconstruction contract: unchanged.
  • Process execution, authorization, cleanup, or containment impact: the same bounded Java probe runs with explicit UTF-8 stdout/stderr encodings.

Evidence and regression coverage

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
  • Tests added or updated: npm run test:focused -- src/ghidra/GhidraInstallation.test.ts (46 passed); npm run check:fast (typecheck and lint passed).
  • Base reproduction or other evidence: the reporter's raw-byte capture distinguishes the corrupted JVM-derived path from the intact environment-derived path. The regression test also failed against the base because the probe omitted both encoding flags (45 passed, 1 failed), and passes with this change. The test supplies a mocked non-ASCII Windows path; it does not emulate Windows' active code page.
  • User-visible CLI/MCP output (if applicable): none.
  • Remaining proof gaps: the patch's test uses a mocked child-process response; this macOS host did not rerun the fix on Windows or against a real Ghidra installation.

For evidence-bearing changes: no evidence contract or artifact format changes.

Validation performed

  • npm ci — passed with Node.js 24.18.0 and npm 11.16.0.
  • npm run test:focused -- src/ghidra/GhidraInstallation.test.ts — 46 passed.
  • npm run check:fast — typecheck and lint passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: no Windows-host or real-Ghidra run by this patch; the regression test covers the Java probe arguments on macOS.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new process or environment access; the existing Java probe receives two output-encoding options.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • 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/2206 **Author:** [@Ha1baraA11](https://github.com/Ha1baraA11) **Created:** 10/12/2026 **Status:** ✅ Merged **Merged:** 10/12/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `pr/rea-2204` --- ### 📝 Commits (3) - [`62c49e8`](https://github.com/morluto/rea/commit/62c49e8c10deb80809a1d45b5fc989ec2592d64d) fix(ghidra): encode Java probe output as UTF-8 - [`6eeda57`](https://github.com/morluto/rea/commit/6eeda575a3e0745676fab3a90a6bbe302344eec7) fix(ghidra): preserve Unicode Java homes across supported JDKs - [`cb1dc30`](https://github.com/morluto/rea/commit/cb1dc3078b435202824bc6e0e0b563c1f37cdc8d) test(ghidra): verify snapshot rejection without matching prose ### 📊 Changes **7 files changed** (+102 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/ci.yml` (+1 -0) 📝 `scripts/ci/scopes.mjs` (+1 -0) 📝 `scripts/lib/real-ghidra-snapshot-lifecycle.mjs` (+2 -7) 📝 `src/ghidra/GhidraInstallation.test.ts` (+4 -1) 📝 `src/ghidra/GhidraInstallation.ts` (+10 -1) ➕ `tests/boundary/filesystem/ghidraJavaProbe.test.ts` (+82 -0) 📝 `tests/composition/analysis-sessions/binarySession.test.ts` (+2 -6) </details> ### 📄 Description ## Summary - Encode the Ghidra Java settings probe's stdout and stderr as UTF-8 so a non-ASCII Windows `JAVA_HOME` is read correctly. Fixes #2204 ## Problem and expected behavior The probe asks Node to decode Java output as UTF-8, but the JVM's standard streams can use the Windows native encoding unless their encodings are set. A new Issue timeline report demonstrates the result in raw bytes: the environment-derived install path remains valid UTF-8, while the JVM-derived `java.home` contains four U+FFFD replacements for a two-character folder name. The reporter also observes `rea analyze` fail with `provider_unavailable`, while the same JDK works after moving `JAVA_HOME` to an ASCII path. The probe should preserve the path and admit the installed full JDK. ## Change and scope - Pass `-Dstdout.encoding=UTF-8` and `-Dstderr.encoding=UTF-8` to the Ghidra installation properties probe. - Add regression coverage that verifies both flags are passed when a Java response contains a non-ASCII Windows JDK path. - The change is limited to installation discovery; normal Ghidra launch arguments are unchanged. ## Contract and boundary impact - Semantic owner and earliest changed stage: `GhidraInstallation`, during Java provider admission. - CLI and MCP/tool-catalog contract: no contract or output shape changes. - Provider, bridge, target-format, or platform compatibility: no change to supported Ghidra/JDK versions; the probe reads the reported Java home consistently. - Evidence, artifact, provenance, or reconstruction contract: unchanged. - Process execution, authorization, cleanup, or containment impact: the same bounded Java probe runs with explicit UTF-8 stdout/stderr encodings. ## Evidence and regression coverage - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. - Tests added or updated: `npm run test:focused -- src/ghidra/GhidraInstallation.test.ts` (46 passed); `npm run check:fast` (typecheck and lint passed). - Base reproduction or other evidence: the reporter's raw-byte capture distinguishes the corrupted JVM-derived path from the intact environment-derived path. The regression test also failed against the base because the probe omitted both encoding flags (45 passed, 1 failed), and passes with this change. The test supplies a mocked non-ASCII Windows path; it does not emulate Windows' active code page. - User-visible CLI/MCP output (if applicable): none. - Remaining proof gaps: the patch's test uses a mocked child-process response; this macOS host did not rerun the fix on Windows or against a real Ghidra installation. For evidence-bearing changes: no evidence contract or artifact format changes. ## Validation performed - `npm ci` — passed with Node.js 24.18.0 and npm 11.16.0. - `npm run test:focused -- src/ghidra/GhidraInstallation.test.ts` — 46 passed. - `npm run check:fast` — typecheck and lint passed. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: no Windows-host or real-Ghidra run by this patch; the regression test covers the Java probe arguments on macOS. - Package or release metadata impact: none. - Security, privacy, process, or containment review: no new process or environment access; the existing Java probe receives two output-encoding options. ## Review checklist - [x] This PR addresses a concrete problem or an agreed enhancement. - [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:03:33 +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#5082
No description provided.