fix(ghidra): qualify defined-string search coverage
Carry defined-data scope through list and search Evidence and bind it into the analysis profile so older snapshots cannot replay unqualified results. Clarify the tool contract and document known-address byte/reference inspection. Validation: 36 focused tests, check:fast, docs:check, and real Ghidra 12.1.4 CLI/stdio MCP on macOS arm64. The Rust Mach-O fixture contains the phrase and Ghidra defines it; the reported Linux ELF omission was not reproduced. Fixes #1659
This commit is contained in:
@@ -3,7 +3,66 @@ import { expect, it } from "vitest";
|
||||
import { jsonValueSchema } from "../../../src/domain/jsonValue.js";
|
||||
import { ok } from "../../../src/domain/result.js";
|
||||
import { ghidraFunctionIdentity } from "../../../src/domain/ghidraValues.fixture.js";
|
||||
import { connectGhidraMcp } from "./ghidraMcpHarness.js";
|
||||
import { connectGhidraMcp, sessionEvidence } from "./ghidraMcpHarness.js";
|
||||
|
||||
it("retains defined-string coverage in empty and matching search Evidence", async () => {
|
||||
let output = jsonValueSchema.parse([]);
|
||||
const harness = await connectGhidraMcp("ghidra-string-coverage", () =>
|
||||
Promise.resolve(ok(output)),
|
||||
);
|
||||
try {
|
||||
for (const request of [
|
||||
{ name: "list_strings", arguments: {} },
|
||||
{ name: "search_strings", arguments: { pattern: "projection" } },
|
||||
{
|
||||
name: "search_strings",
|
||||
arguments: { pattern: "projection.*", mode: "regex" },
|
||||
},
|
||||
]) {
|
||||
const reply = await harness.mcp.callTool(request);
|
||||
expect(reply.isError).not.toBe(true);
|
||||
const evidence = sessionEvidence(
|
||||
harness.session,
|
||||
reply.structuredContent,
|
||||
);
|
||||
expect(evidence.normalized_result).toEqual([]);
|
||||
expect(evidence.analysis_profile?.parameters).toMatchObject({
|
||||
string_inventory_evidence: "defined-data-coverage-v1",
|
||||
});
|
||||
expect(evidence.limitations).toContainEqual(
|
||||
expect.stringMatching(
|
||||
/Only Ghidra-defined string Data.*empty search does not establish/u,
|
||||
),
|
||||
);
|
||||
}
|
||||
output = jsonValueSchema.parse([
|
||||
{ address: "0x401000", value: "projection cache ignored" },
|
||||
]);
|
||||
const matched = await harness.mcp.callTool({
|
||||
name: "search_strings",
|
||||
arguments: { pattern: "projection" },
|
||||
});
|
||||
const evidence = sessionEvidence(
|
||||
harness.session,
|
||||
matched.structuredContent,
|
||||
);
|
||||
expect(evidence.normalized_result).toEqual(output);
|
||||
expect(evidence.limitations).toContainEqual(
|
||||
expect.stringContaining("Completeness applies to that inventory"),
|
||||
);
|
||||
output = jsonValueSchema.parse([]);
|
||||
const procedures = await harness.mcp.callTool({
|
||||
name: "search_procedures",
|
||||
arguments: { pattern: "projection" },
|
||||
});
|
||||
expect(
|
||||
sessionEvidence(harness.session, procedures.structuredContent)
|
||||
.limitations,
|
||||
).not.toContainEqual(expect.stringContaining("Ghidra-defined string Data"));
|
||||
} finally {
|
||||
await harness.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects contradictory provider output before emitting MCP Evidence", async () => {
|
||||
const bytes = {
|
||||
|
||||
Reference in New Issue
Block a user