Preserve boundary diagnostics, resolve procedure names before bare hex addresses, and launch the inspected JVM directly on macOS for verifiable startup cancellation. Keep private socket paths within host limits and retain ownership when cleanup is incomplete. Exercise the fixes through real CLI/MCP Ghidra workflows and provider-boundary integration tests, replacing redundant unit coverage.
83 lines
2.8 KiB
TypeScript
83 lines
2.8 KiB
TypeScript
import { expect, it } from "vitest";
|
|
|
|
import { logCliCommand } from "../../../src/cliLogging.js";
|
|
import { analysisErrorProjectionSchema } from "../../../src/contracts/errorSchemas.js";
|
|
import { GhidraRequestQueue } from "../../../src/ghidra/GhidraRequestQueue.js";
|
|
import { bindGhidraSessionFailure } from "../../../src/ghidra/GhidraSessionError.js";
|
|
import { silentLogger } from "../../../src/logger.js";
|
|
import { connectGhidraMcp } from "./ghidraMcpHarness.js";
|
|
|
|
it("preserves queue failure diagnostics through the provider, CLI adapter and SDK MCP transport", async () => {
|
|
const token = "fixture-authentication-token";
|
|
const cause = Object.assign(
|
|
new TypeError(
|
|
`Decode failed ${token}: /tmp/password-fixture http://localhost/secret?token=public-value`,
|
|
),
|
|
{ code: "EDECODE" },
|
|
);
|
|
const failure = bindGhidraSessionFailure(
|
|
() => ({
|
|
target_path: "/tmp/public-fixture",
|
|
target_sha256: "a".repeat(64),
|
|
}),
|
|
(value) => value.replaceAll(token, "[REDACTED]"),
|
|
);
|
|
const queue = new GhidraRequestQueue(
|
|
async () => {
|
|
throw cause;
|
|
},
|
|
failure,
|
|
() => Promise.resolve(),
|
|
);
|
|
const harness = await connectGhidraMcp(
|
|
"ghidra-failure-diagnostics",
|
|
(operation, input, options) => queue.run(operation, input, options ?? {}),
|
|
);
|
|
const previousExitCode = process.exitCode;
|
|
try {
|
|
const cli = await logCliCommand(silentLogger, "inspect", async () => {
|
|
const result = await harness.session.execute("list_procedures", {
|
|
document: null,
|
|
});
|
|
if (!result.ok) throw result.error;
|
|
return result.value.result;
|
|
});
|
|
expect(process.exitCode).toBe(1);
|
|
const parsed = analysisErrorProjectionSchema.parse(cli);
|
|
expect(parsed).toMatchObject({
|
|
code: "execution_failure",
|
|
details: {
|
|
diagnostics: {
|
|
target_path: "/tmp/public-fixture",
|
|
failure_kind: "protocol",
|
|
failure_message:
|
|
"Ghidra serial request execution rejected unexpectedly",
|
|
failure_cause: {
|
|
name: "TypeError",
|
|
code: "EDECODE",
|
|
message:
|
|
"Decode failed [REDACTED]: /tmp/password-fixture http://localhost/secret?token=public-value",
|
|
},
|
|
},
|
|
},
|
|
});
|
|
const mcp = await harness.mcp.callTool({
|
|
name: "list_procedures",
|
|
arguments: {},
|
|
});
|
|
expect(mcp.isError).toBe(true);
|
|
expect(mcp.structuredContent).toMatchObject({ error: parsed });
|
|
expect(mcp.content).toContainEqual(
|
|
expect.objectContaining({
|
|
type: "text",
|
|
text: expect.stringContaining("EDECODE"),
|
|
}),
|
|
);
|
|
expect(JSON.stringify(mcp)).not.toContain(token);
|
|
expect(JSON.stringify(mcp)).not.toContain(cause.stack);
|
|
} finally {
|
|
process.exitCode = previousExitCode;
|
|
await harness.close();
|
|
}
|
|
}, 30_000);
|