Skip to content

fix(ghidra): encode Java probe output as UTF-8 - #2206

Merged
morluto merged 3 commits into
morluto:mainfrom
Ha1baraA11:pr/rea-2204
Oct 12, 2026
Merged

morluto merged 3 commits into
morluto:mainfrom
Ha1baraA11:pr/rea-2204

Conversation

@Ha1baraA11

Copy link
Copy Markdown
Contributor

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 12, 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-12T16:39:15.837904Z cb1dc30 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: 62c49e8c10

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/ghidra/GhidraInstallation.ts Resolved
@morluto

morluto commented Oct 12, 2026

Copy link
Copy Markdown
Owner

You have good taste in Anime Ha1bara.
Case closed!

@morluto
morluto merged commit 59be866 into morluto:main Oct 12, 2026
31 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 12, 2026
3 tasks done
@Ha1baraA11

Copy link
Copy Markdown
Contributor Author

Haha, case closed indeed!
Thanks for the kind words and for merging the PR!

@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 2026
@morluto morluto added the provider: ghidra Analysis provider / engine: ghidra label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Ghidra provider stays unavailable when JAVA_HOME contains non-ASCII characters on Windows

2 participants