fix(ci): align diagnostic regressions and format merged changes
This commit is contained in:
@@ -195,11 +195,16 @@ it("distinguishes an unreported Java version from an unsupported old version", a
|
||||
);
|
||||
await chmod(join(unresolvedHome, "bin", "java"), 0o700);
|
||||
await expect(
|
||||
inspectJadxAvailability({ REA_JADX_MCP_JAR: jar, JAVA_HOME: unresolvedHome }),
|
||||
inspectJadxAvailability({
|
||||
REA_JADX_MCP_JAR: jar,
|
||||
JAVA_HOME: unresolvedHome,
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
status: "unavailable",
|
||||
code: "version_unresolved",
|
||||
reason: expect.stringContaining("did not report a parseable java.base version"),
|
||||
reason: expect.stringContaining(
|
||||
"did not report a parseable java.base version",
|
||||
),
|
||||
diagnostics: { stdout: "jdk.compiler@21\n", java_major: null },
|
||||
});
|
||||
|
||||
|
||||
@@ -7,11 +7,15 @@ const execute = promisify(execFile);
|
||||
|
||||
const runCli = async (arguments_: readonly string[]) => {
|
||||
try {
|
||||
const result = await execute(process.execPath, ["scripts/rea.mjs", ...arguments_], {
|
||||
cwd: process.cwd(),
|
||||
env: { ...process.env, REA_LOG_LEVEL: "silent" },
|
||||
timeout: 15_000,
|
||||
});
|
||||
const result = await execute(
|
||||
process.execPath,
|
||||
["scripts/rea.mjs", ...arguments_],
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
env: { ...process.env, REA_LOG_LEVEL: "silent" },
|
||||
timeout: 15_000,
|
||||
},
|
||||
);
|
||||
return { exitCode: 0, ...result };
|
||||
} catch (cause: unknown) {
|
||||
if (
|
||||
@@ -46,5 +50,7 @@ it("shows MCP doctor help without starting a server and keeps option errors acti
|
||||
|
||||
const invalid = await runCli(["mcp", "doctor", "--not-an-option"]);
|
||||
expect(invalid.exitCode).toBe(1);
|
||||
expect(invalid.stdout).toContain("Unknown mcp doctor option: --not-an-option");
|
||||
expect(invalid.stdout).toContain(
|
||||
"Unknown mcp doctor option: --not-an-option",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -201,61 +201,63 @@ describe("Ghidra headless launcher", () => {
|
||||
it.skipIf(process.platform !== "win32")(
|
||||
"keeps authority in a private descriptor and isolates Ghidra state through the batch launcher",
|
||||
async () => {
|
||||
vi.stubEnv("GHIDRA_JAVA_OPTIONS", "-javaagent:/unapproved/agent.jar");
|
||||
vi.stubEnv("JAVA_TOOL_OPTIONS", "-Duser.home=/unapproved/home");
|
||||
vi.stubEnv("JDK_JAVA_OPTIONS", "-XX:MaxRAMPercentage=99");
|
||||
vi.stubEnv("_JAVA_OPTIONS", "-Xmx99G");
|
||||
const parent = await createTestTempDirectory("rea-launcher-test-");
|
||||
const runtime = await createGhidraTestRuntime(parent);
|
||||
runtimes.push(runtime);
|
||||
const runtimeRoot = runtime.path;
|
||||
const token = "secret-token-that-must-not-leak";
|
||||
const javaHome = "C:\\Java\\jdk-21";
|
||||
const launcher = new GhidraHeadlessLauncher({
|
||||
analyzeHeadlessPath: fixturePath,
|
||||
// POSIX follows the real inspected-JVM route; Windows uses the official
|
||||
// batch script because its launcher contract differs.
|
||||
platform: "win32",
|
||||
javaHome,
|
||||
bridgeScriptPath: "/package/bridge/ReaGhidraBridge.java",
|
||||
});
|
||||
const launched = await launcher.launch({
|
||||
runtimeRoot,
|
||||
transport: "unix-socket",
|
||||
endpointPath: join(runtimeRoot, "bridge.sock"),
|
||||
token,
|
||||
runId: "d6fcbb66-e829-4ff6-a535-0035aec63139",
|
||||
targetPath: "/tmp/fixture",
|
||||
targetSha256: "b".repeat(64),
|
||||
providerVersion: "12.1.4",
|
||||
profileDigest: "a".repeat(64),
|
||||
});
|
||||
if (!launched.ok) throw launched.error;
|
||||
const capturePath = join(runtimeRoot, "launch-capture.json");
|
||||
await vi.waitFor(() => access(`${capturePath}.ready`), { timeout: 10_000 });
|
||||
const capture = launchCaptureSchema.parse(
|
||||
JSON.parse(await readFile(capturePath, "utf8")),
|
||||
);
|
||||
const encodedArguments = JSON.stringify(capture.arguments);
|
||||
const encodedEnvironment = JSON.stringify(capture.environment);
|
||||
expect(encodedArguments).not.toContain(token);
|
||||
expect(encodedEnvironment).not.toContain(token);
|
||||
expect(capture).toMatchObject({
|
||||
...(process.platform === "win32" ? {} : { descriptor_mode: 0o600 }),
|
||||
descriptor_has_token: true,
|
||||
});
|
||||
expectIsolatedEnvironment(capture.environment, runtimeRoot, javaHome);
|
||||
expect(capture.environment.GHIDRA_HEADLESS_JAVA_OPTIONS).toBe(
|
||||
"",
|
||||
);
|
||||
if (process.platform !== "win32")
|
||||
expect(
|
||||
(await stat(join(runtimeRoot, "ownership.json"))).mode & 0o777,
|
||||
).toBe(0o600);
|
||||
vi.stubEnv("GHIDRA_JAVA_OPTIONS", "-javaagent:/unapproved/agent.jar");
|
||||
vi.stubEnv("JAVA_TOOL_OPTIONS", "-Duser.home=/unapproved/home");
|
||||
vi.stubEnv("JDK_JAVA_OPTIONS", "-XX:MaxRAMPercentage=99");
|
||||
vi.stubEnv("_JAVA_OPTIONS", "-Xmx99G");
|
||||
const parent = await createTestTempDirectory("rea-launcher-test-");
|
||||
const runtime = await createGhidraTestRuntime(parent);
|
||||
runtimes.push(runtime);
|
||||
const runtimeRoot = runtime.path;
|
||||
const token = "secret-token-that-must-not-leak";
|
||||
const javaHome = "C:\\Java\\jdk-21";
|
||||
const launcher = new GhidraHeadlessLauncher({
|
||||
analyzeHeadlessPath: fixturePath,
|
||||
// POSIX follows the real inspected-JVM route; Windows uses the official
|
||||
// batch script because its launcher contract differs.
|
||||
platform: "win32",
|
||||
javaHome,
|
||||
bridgeScriptPath: "/package/bridge/ReaGhidraBridge.java",
|
||||
});
|
||||
const launched = await launcher.launch({
|
||||
runtimeRoot,
|
||||
transport: "unix-socket",
|
||||
endpointPath: join(runtimeRoot, "bridge.sock"),
|
||||
token,
|
||||
runId: "d6fcbb66-e829-4ff6-a535-0035aec63139",
|
||||
targetPath: "/tmp/fixture",
|
||||
targetSha256: "b".repeat(64),
|
||||
providerVersion: "12.1.4",
|
||||
profileDigest: "a".repeat(64),
|
||||
});
|
||||
if (!launched.ok) throw launched.error;
|
||||
const capturePath = join(runtimeRoot, "launch-capture.json");
|
||||
await vi.waitFor(() => access(`${capturePath}.ready`), {
|
||||
timeout: 10_000,
|
||||
});
|
||||
const capture = launchCaptureSchema.parse(
|
||||
JSON.parse(await readFile(capturePath, "utf8")),
|
||||
);
|
||||
const encodedArguments = JSON.stringify(capture.arguments);
|
||||
const encodedEnvironment = JSON.stringify(capture.environment);
|
||||
expect(encodedArguments).not.toContain(token);
|
||||
expect(encodedEnvironment).not.toContain(token);
|
||||
expect(capture).toMatchObject({
|
||||
...(process.platform === "win32" ? {} : { descriptor_mode: 0o600 }),
|
||||
descriptor_has_token: true,
|
||||
});
|
||||
expectIsolatedEnvironment(capture.environment, runtimeRoot, javaHome);
|
||||
expect(capture.environment.GHIDRA_HEADLESS_JAVA_OPTIONS).toBe("");
|
||||
if (process.platform !== "win32")
|
||||
expect(
|
||||
(await stat(join(runtimeRoot, "ownership.json"))).mode & 0o777,
|
||||
).toBe(0o600);
|
||||
|
||||
const cleaned = await launched.value.cleanup?.();
|
||||
expect(cleaned).toMatchObject({ cleaned: true });
|
||||
await expect(access(join(runtimeRoot, "project"))).resolves.toBeUndefined();
|
||||
const cleaned = await launched.value.cleanup?.();
|
||||
expect(cleaned).toMatchObject({ cleaned: true });
|
||||
await expect(
|
||||
access(join(runtimeRoot, "project")),
|
||||
).resolves.toBeUndefined();
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user