Share parser modes and collision-free composite keys, enforce architecture guards, and consolidate redundant unit assertions into filesystem, CLI, MCP, and producer-backed workflows. Preserve concurrent upstream boundary fixes and exclude legacy Objective-C class-name bookkeeping labels. Validation: source/composition suites (3358 passing), focused canonical digest and MCP checks, typecheck/lint, Knip, formatting, architecture guards, and real Foundation archive and Apple legacy simulator CLI/MCP verification. No real Hopper, Ghidra, or IDA verification claim.
74 lines
2.3 KiB
TypeScript
74 lines
2.3 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(["%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");
|
|
});
|