diff --git a/src/ghidra/GhidraInstallation.test.ts b/src/ghidra/GhidraInstallation.test.ts index 7ba8772982..822e9cee47 100644 --- a/src/ghidra/GhidraInstallation.test.ts +++ b/src/ghidra/GhidraInstallation.test.ts @@ -665,6 +665,48 @@ describe("Ghidra installation rejection diagnostics", () => { }); }); +describe("Ghidra native decompiler remediation", () => { + it.each([ + ["darwin", "x64", "installation.md#missing-macos-native-decompiler"], + ["darwin", "arm64", "installation.md#macos-arm64-native-decompiler"], + ["linux", "arm64", "installation.md#ghidra"], + ["linux", "x64", undefined], + ] as const)( + "points a missing %s/%s decompiler to how to build it", + async (platform, architecture, instructions) => { + const result = await inspectGhidraInstallation( + { + resourceOwner: inspectionResources.owner, + installDir: INSTALL, + platform, + architecture, + environment: {}, + }, + host({ + executable: (path) => path === HEADLESS, + probeJava: () => + javaProbeOk({ + ...JAVA, + osArch: architecture === "arm64" ? "aarch64" : "amd64", + osName: platform === "darwin" ? "Mac OS X" : "Linux", + }), + }), + ); + const check = result.checks.find( + (candidate) => + candidate.name === "native_decompiler" && + candidate.status === "failed", + ); + expect(check).toMatchObject({ code: "executable_missing" }); + if (check?.status !== "failed") + throw new Error("Expected a failed native_decompiler check"); + if (instructions === undefined) + expect(check.remediation).not.toContain("Official Ghidra release"); + else expect(check.remediation).toContain(instructions); + }, + ); +}); + describe("Ghidra configuration directory identity", () => { it.each([ [ diff --git a/src/ghidra/GhidraInstallation.ts b/src/ghidra/GhidraInstallation.ts index 554510b42d..48bd43725d 100644 --- a/src/ghidra/GhidraInstallation.ts +++ b/src/ghidra/GhidraInstallation.ts @@ -980,10 +980,25 @@ const nativeDecompilerCheck = ({ remediation: compatibility?.status === "incompatible" ? compatibility.remediation - : `Provide an executable Ghidra/Features/Decompiler/os/${NATIVE_PLATFORMS[platform]?.[architecture] ?? ""}/${platform === "win32" ? "decompile.exe" : "decompile"}, or its build/os equivalent. REA does not build or install native tools.`, + : `Provide an executable Ghidra/Features/Decompiler/os/${NATIVE_PLATFORMS[platform]?.[architecture] ?? ""}/${platform === "win32" ? "decompile.exe" : "decompile"}, or its build/os equivalent.${nativeDecompilerBuildHint(platform, architecture)} REA does not build or install native tools.`, }); }; +/** + * Where to get a decompiler that official release archives omit. Ghidra's + * official archives ship no macOS decompiler, and may ship none for Linux + * arm64; the archive's decompiler source builds it. + */ +const nativeDecompilerBuildHint = ( + platform: NodeJS.Platform, + architecture: NodeJS.Architecture, +): string => + platform === "darwin" && (architecture === "x64" || architecture === "arm64") + ? ` Official Ghidra release archives include no macOS decompiler; build it from the archive's decompiler source as described in docs/getting-started/installation.md#${architecture === "arm64" ? "macos-arm64-native-decompiler" : "missing-macos-native-decompiler"}.` + : platform === "linux" && architecture === "arm64" + ? " Official Ghidra release archives may not include a Linux arm64 decompiler; build Ghidra's native components for this host as described in docs/getting-started/installation.md#ghidra." + : ""; + /** * Whether a JVM os.name value selects the host platform's native OS directory. * Unknown values never align with the validated host directory; admission