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.
81 lines
2.8 KiB
TypeScript
81 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", {});
|
|
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);
|