Merge pull request #1222 from morluto/fix/ghidra-relative-java-probe

fix(ghidra): do not run Java from a relative JAVA_HOME in doctor and setup
This commit is contained in:
Kaoru0822 authored and GitHub committed 2026-10-09 01:04:53 -07:00
commit 04a516b1e3
2 files changed
+39 -4

No files matched your search

+30
View File
@@ -413,6 +413,36 @@ describe("Ghidra configuration paths", () => {
},
);
it.each([
["linux", "./jdk"],
["linux", ""],
["win32", "jdk"],
] as const)(
"does not run Java from a relative JAVA_HOME (%s %o)",
(platform, javaHome) => {
const probed: string[] = [];
const result = inspectGhidraInstallation(
{
installDir: platform === "win32" ? WINDOWS_INSTALL : INSTALL,
javaHome,
platform,
architecture: "x64",
},
host({
probeJava: (command) => {
probed.push(command);
return JAVA;
},
}),
);
expect(probed).toEqual([]);
expect(result).toMatchObject({
status: "unavailable",
rejection: { code: "not_configured" },
});
},
);
it("judges absolute paths by the inspected platform", () => {
const result = inspectGhidraInstallation(
{ installDir: "C:\\ghidra", platform: "win32", architecture: "x64" },
+9 -4
View File
@@ -292,10 +292,15 @@ const installationCoordinates = (
? undefined
: ghidraApplicationProperties(properties),
javaCommand,
java: host.probeJava(
javaCommand,
ghidraJavaEnvironment(options.javaHome, process.env, platform),
),
// The configuration check rejects a relative JAVA_HOME. Probing it would
// run whatever `bin/java` the current directory holds.
java:
options.javaHome === undefined || path.isAbsolute(options.javaHome)
? host.probeJava(
javaCommand,
ghidraJavaEnvironment(options.javaHome, process.env, platform),
)
: undefined,
};
};