[PR #1198] [MERGED] fix(ghidra): report NativeAOT host and target refusals as unsupported, not failures #2711

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

📋 Pull Request Information

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

Base: main ← Head: fix/ghidra-extension-unsupported-host


📝 Commits (2)

  • 42c276a fix(ghidra): report NativeAOT host and target refusals as unsupported, not failures
  • f198993 fix(ghidra): keep the NativeAOT target refusal's own recovery advice

📊 Changes

5 files changed (+109 additions, -37 deletions)

View changed files

📝 src/domain/analysisErrorCore.ts (+4 -1)
📝 src/domain/analysisErrorPresentation.ts (+4 -1)
📝 src/ghidra/extensions/GhidraExtensions.test.ts (+52 -22)
📝 src/ghidra/extensions/GhidraExtensions.ts (+39 -11)
📝 src/ghidra/extensions/nativeaot/NativeAotAdapter.ts (+10 -2)

📄 Description

Summary

With REA_GHIDRA_NATIVEAOT_JAR set on macOS, ordinary Ghidra analysis is refused before Ghidra starts, because the NativeAOT adapter supports only Linux hosts. That refusal is intended. But it was reported as execution_failure, "Analysis could not complete. Retry once; if it continues, run rea doctor", although retrying or running doctor (which reports Ghidra healthy) cannot change the host. The actionable reason was buried in details.diagnostics.

Fixes #1185

Change

  • GhidraExtensionAdapter.unsupportedReason now returns { constraint: "host" | "target", reason }, so the resolver can tell the two refusals apart. The NativeAOT adapter keeps its exact reasons.
  • resolveGhidraExtensions maps a refusal to the existing typed errors:
    • host → AnalysisCapabilityUnavailableError("ghidra", "resolve_analysis_profile", reason), projected as capability_unavailable / unsupported_provider. Message and remediation are the adapter's reason ("NativeAOT recovery is verified on Linux only; omit REA_GHIDRA_NATIVEAOT_JAR for ordinary native analysis.").
    • target (on Linux: not an x86-64 ELF or native PE, or a managed PE/CLI) → AnalysisUnsupportedTargetError("resolve_analysis_profile", target.path, reason), projected as unsupported_target with the target path.
  • Missing, empty, non-JAR, or changing JAR files on a supported host are still ProviderAdapterError with extension/path diagnostics, as the issue asks.

validateGhidraExtensionProfile (the client-side re-check) uses the refusal's reason as before.

Tests

src/ghidra/extensions/GhidraExtensions.test.ts:

  • A darwin host projects to capability_unavailable, non-retryable, with message and remediation naming the Linux-only constraint and the JAR to omit (fails on main).
  • An arm64 ELF on Linux projects to unsupported_target with the target path and reason.
  • The existing PE/CLI test now reads reason from the typed unsupported-target error.
  • The JAR-file failure tests are unchanged and still expect provider diagnostics.

Verification

  • npm run check:fast, npm run jscpd
  • npm run test:focused -- every test mentioning resolve_analysis_profile or NativeAOT (5 files, 63 passed)

Not verified against a real Ghidra installation (none on this machine). The refusal happens before any Ghidra process or JAR read, and only its error type changes.

🤖 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/1198 **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-extension-unsupported-host` --- ### 📝 Commits (2) - [`42c276a`](https://github.com/morluto/rea/commit/42c276af1ec02473a7b6700a31292aae9e53d53e) fix(ghidra): report NativeAOT host and target refusals as unsupported, not failures - [`f198993`](https://github.com/morluto/rea/commit/f198993f418e6aaa9755e7e6413abcb27c6cd684) fix(ghidra): keep the NativeAOT target refusal's own recovery advice ### 📊 Changes **5 files changed** (+109 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/analysisErrorCore.ts` (+4 -1) 📝 `src/domain/analysisErrorPresentation.ts` (+4 -1) 📝 `src/ghidra/extensions/GhidraExtensions.test.ts` (+52 -22) 📝 `src/ghidra/extensions/GhidraExtensions.ts` (+39 -11) 📝 `src/ghidra/extensions/nativeaot/NativeAotAdapter.ts` (+10 -2) </details> ### 📄 Description ## Summary With `REA_GHIDRA_NATIVEAOT_JAR` set on macOS, ordinary Ghidra analysis is refused before Ghidra starts, because the NativeAOT adapter supports only Linux hosts. That refusal is intended. But it was reported as `execution_failure`, "Analysis could not complete. Retry once; if it continues, run `rea doctor`", although retrying or running doctor (which reports Ghidra healthy) cannot change the host. The actionable reason was buried in `details.diagnostics`. Fixes #1185 ## Change - `GhidraExtensionAdapter.unsupportedReason` now returns `{ constraint: "host" | "target", reason }`, so the resolver can tell the two refusals apart. The NativeAOT adapter keeps its exact reasons. - `resolveGhidraExtensions` maps a refusal to the existing typed errors: - **host** → `AnalysisCapabilityUnavailableError("ghidra", "resolve_analysis_profile", reason)`, projected as `capability_unavailable` / `unsupported_provider`. Message and remediation are the adapter's reason ("NativeAOT recovery is verified on Linux only; omit REA_GHIDRA_NATIVEAOT_JAR for ordinary native analysis."). - **target** (on Linux: not an x86-64 ELF or native PE, or a managed PE/CLI) → `AnalysisUnsupportedTargetError("resolve_analysis_profile", target.path, reason)`, projected as `unsupported_target` with the target path. - Missing, empty, non-JAR, or changing JAR files on a supported host are still `ProviderAdapterError` with `extension`/`path` diagnostics, as the issue asks. `validateGhidraExtensionProfile` (the client-side re-check) uses the refusal's `reason` as before. ## Tests `src/ghidra/extensions/GhidraExtensions.test.ts`: - A `darwin` host projects to `capability_unavailable`, non-retryable, with message and remediation naming the Linux-only constraint and the JAR to omit (fails on `main`). - An arm64 ELF on Linux projects to `unsupported_target` with the target path and reason. - The existing PE/CLI test now reads `reason` from the typed unsupported-target error. - The JAR-file failure tests are unchanged and still expect provider diagnostics. ## Verification - `npm run check:fast`, `npm run jscpd` - `npm run test:focused --` every test mentioning `resolve_analysis_profile` or NativeAOT (5 files, 63 passed) Not verified against a real Ghidra installation (none on this machine). The refusal happens before any Ghidra process or JAR read, and only its error type changes. 🤖 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:22 +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#2711
No description provided.