Deliver complete Evidence directly through MCP with required nullable analysis profiles and immutable per-server delivery settings. Bind selected environments at construction and require typed cleanup outcomes with retained retry ownership. Remove test-only routing, duplicate session and snapshot metadata, producer-field repairs, and ambiguous provider arguments. Separate artifact byte identity from occurrence classification and retain typed source-map and partial native facts across CLI, MCP, and verifier consumers. BREAKING CHANGE: obsolete Evidence envelopes, session aliases, incomplete snapshots, and missing normalized producer facts are no longer accepted.
86 lines
2.7 KiB
TypeScript
86 lines
2.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
GhidraHeadlessLauncher,
|
|
ghidraHeadlessCommand,
|
|
ghidraHeadlessJavaOptions,
|
|
} from "./GhidraLauncher.js";
|
|
import { ghidraJavaEnvironment } from "./GhidraInstallation.js";
|
|
|
|
describe("Ghidra headless JVM environment", () => {
|
|
it("passes Windows paths with spaces to Java's environment parser", () => {
|
|
expect(
|
|
ghidraHeadlessJavaOptions(
|
|
"C:\\REA Runtime\\home",
|
|
"C:\\REA Runtime\\tmp",
|
|
"win32",
|
|
),
|
|
).toEqual({
|
|
JDK_JAVA_OPTIONS:
|
|
'"-Duser.home=C:\\REA Runtime\\home" "-Djava.io.tmpdir=C:\\REA Runtime\\tmp" "-XX:-UsePerfData"',
|
|
GHIDRA_HEADLESS_JAVA_OPTIONS: "",
|
|
});
|
|
});
|
|
|
|
it.each(["linux", "darwin"] as const)(
|
|
"passes %s isolated JVM paths through direct argv instead of script options",
|
|
(platform) => {
|
|
expect(
|
|
ghidraHeadlessJavaOptions("/tmp/rea/home", "/tmp/rea/tmp", platform),
|
|
).toEqual({
|
|
JDK_JAVA_OPTIONS: "",
|
|
GHIDRA_HEADLESS_JAVA_OPTIONS: "",
|
|
});
|
|
},
|
|
);
|
|
|
|
it.each(["%TEMP%", 'quote"', "amp&", "line\n", "nul\0"])(
|
|
"rejects interpreter metacharacters in either Windows JVM path: %s",
|
|
(suffix) => {
|
|
for (const [home, temp] of [
|
|
[`C:\\runtime\\${suffix}`, "C:\\runtime\\tmp"],
|
|
["C:\\runtime\\home", `C:\\runtime\\${suffix}`],
|
|
] as const)
|
|
expect(() => ghidraHeadlessJavaOptions(home, temp, "win32")).toThrow(
|
|
/metacharacters/u,
|
|
);
|
|
},
|
|
);
|
|
});
|
|
|
|
it("uses selected mixed-case Windows PATH and ComSpec through direct launch boundaries", () => {
|
|
const environment = {
|
|
Path: "C:\\selected\\tools",
|
|
ComSpec: "C:\\selected\\cmd.exe",
|
|
SystemRoot: "C:\\selected-windows",
|
|
};
|
|
const launcher = new GhidraHeadlessLauncher({
|
|
environment,
|
|
platform: "win32",
|
|
analyzeHeadlessPath: "C:\\ghidra\\support\\analyzeHeadless.bat",
|
|
bridgeScriptPath: "C:\\rea\\bridge.py",
|
|
});
|
|
environment.ComSpec = "C:\\changed\\cmd.exe";
|
|
expect(
|
|
ghidraHeadlessCommand({
|
|
environment: launcher.options.environment,
|
|
platform: "win32",
|
|
analyzeHeadlessPath: launcher.options.analyzeHeadlessPath,
|
|
arguments: [],
|
|
}).command,
|
|
).toBe("C:\\selected\\cmd.exe");
|
|
expect(ghidraJavaEnvironment("C:\\jdk", environment, "win32")).toMatchObject({
|
|
PATH: "C:\\jdk\\bin;C:\\selected\\tools",
|
|
COMSPEC: "C:\\changed\\cmd.exe",
|
|
SYSTEMROOT: "C:\\selected-windows",
|
|
});
|
|
expect(
|
|
ghidraHeadlessCommand({
|
|
environment: { SYSTEMROOT: "C:\\selected-windows" },
|
|
platform: "win32",
|
|
analyzeHeadlessPath: launcher.options.analyzeHeadlessPath,
|
|
arguments: [],
|
|
}).command,
|
|
).toBe("C:\\selected-windows\\System32\\cmd.exe");
|
|
});
|