fix(ghidra): preserve Windows batch invocation semantics

This commit is contained in:
N0zoM1z0
2026-07-17 03:05:19 +09:00
committed by N0zoM1z0
parent 585f523891
commit 0ac418dd8b
33 changed files with 113 additions and 95 deletions
+10 -8
View File
@@ -28,6 +28,8 @@ const PROVIDER_VERSION = "12.1.2";
const TARGET_SHA256 = createHash("sha256")
.update(readFileSync(fixturePath))
.digest("hex");
const HOST_TRANSPORT: GhidraTransportKind =
process.platform === "win32" ? "authenticated-loopback-tcp" : "unix-socket";
type FixtureMode =
| "success"
@@ -99,9 +101,7 @@ const clientFor = (
launcher,
targetPath: fixturePath,
targetSha256: TARGET_SHA256,
...(options.transport === undefined
? {}
: { transport: options.transport }),
transport: options.transport ?? HOST_TRANSPORT,
providerVersion: PROVIDER_VERSION,
profileDigest: PROFILE_DIGEST,
startupTimeoutMs: options.startupTimeoutMs ?? 1_000,
@@ -138,9 +138,11 @@ describe("GhidraClient", () => {
},
},
});
expect(Buffer.byteLength(launcher.endpointPaths[0] ?? "")).toBeLessThan(
108,
);
if (HOST_TRANSPORT === "unix-socket")
expect(Buffer.byteLength(launcher.endpointPaths[0] ?? "")).toBeLessThan(
108,
);
else expect(launcher.endpointPaths[0]).toMatch(/bridge-endpoint\.json$/u);
});
it("completes the same authenticated handshake over loopback TCP", async () => {
@@ -393,7 +395,7 @@ describe("GhidraClient", () => {
expect(client.diagnostics()).toMatchObject({
runtime_root: launcher.runtimeRoots[0],
transport: "unix-socket",
transport: HOST_TRANSPORT,
endpoint_path: launcher.endpointPaths[0],
project_root: join(launcher.runtimeRoots[0] ?? "", "project"),
process_id: expect.any(Number),
@@ -414,7 +416,7 @@ describe("GhidraClient", () => {
if (result.ok) return;
const encoded = JSON.stringify(result.error.diagnostics);
expect(encoded).toContain(fixturePath);
expect(result.error.diagnostics.target_path).toBe(fixturePath);
expect(encoded).toContain(PROFILE_DIGEST);
expect(encoded).not.toContain(launcher.tokens[0] ?? "missing-token");
expect(events).toContainEqual(
+11 -7
View File
@@ -38,13 +38,17 @@ const host = (
describe("Ghidra installation inspection", () => {
it("clears inherited JVM option injection before probing Java", () => {
expect(
ghidraJavaEnvironment("/opt/jdk-21", {
PATH: "/usr/bin",
_JAVA_OPTIONS: "-Xmx99G",
JAVA_TOOL_OPTIONS: "-javaagent:/tmp/agent.jar",
JDK_JAVA_OPTIONS: "-XX:MaxRAMPercentage=99",
GHIDRA_JAVA_OPTIONS: "-Duser.home=/tmp/unapproved",
}),
ghidraJavaEnvironment(
"/opt/jdk-21",
{
PATH: "/usr/bin",
_JAVA_OPTIONS: "-Xmx99G",
JAVA_TOOL_OPTIONS: "-javaagent:/tmp/agent.jar",
JDK_JAVA_OPTIONS: "-XX:MaxRAMPercentage=99",
GHIDRA_JAVA_OPTIONS: "-Duser.home=/tmp/unapproved",
},
"linux",
),
).toMatchObject({
PATH: "/opt/jdk-21/bin:/usr/bin",
JAVA_HOME: "/opt/jdk-21",