fix(ida): preserve native coverage and verify returned values
Reject native callee successes without an explicit truncation marker while preserving producer error reasons. Require positive procedure inventory/search results and compare normalized function results with the CLI/MCP dossier. Add caller-selected string and xref oracles; explicitly report those behaviors as unverified when no independent oracle is supplied. Verified with Windows IDA Pro 9.3 and the native MCP plugin on the unchanged public fixture. Eight production checks passed with a literal independently confirmed in fixture bytes and an xref source address identified from main assembly matching the C source. A response-only loopback proxy reproduced the earlier verifier passing empty inventories/xrefs; the corrected verifier rejected those results, empty strings and omitted callee markers. This used IDA Pro, not Windows IDA Free. No personal paths or license registration information are included. Validation: 207 focused tests, serial static checks, architecture guards, discovery and docs checks passed. Public-entry regressions use an explicitly simulated native provider and owned process supervision; they do not establish real-engine behavior. Follow-up to #1544.
This commit is contained in:
@@ -18,6 +18,8 @@ const { values } = parseArgs({
|
||||
procedure: { type: "string", default: "rea_fixture_add" },
|
||||
"second-procedure": { type: "string" },
|
||||
"second-marker": { type: "string" },
|
||||
"expected-string": { type: "string" },
|
||||
"expected-xref": { type: "string" },
|
||||
"package-root": { type: "string" },
|
||||
report: { type: "string" },
|
||||
},
|
||||
@@ -34,6 +36,8 @@ if (
|
||||
throw new Error(
|
||||
"IDA verification requires --second-procedure and a nonempty --second-marker together; choose a marker unique to the second function's pseudocode.",
|
||||
);
|
||||
if (values["expected-string"] === "" || values["expected-xref"] === "")
|
||||
throw new Error("IDA verification oracles must be nonempty.");
|
||||
const packageRoot = resolve(
|
||||
values["package-root"] ?? fileURLToPath(new URL("..", import.meta.url)),
|
||||
);
|
||||
@@ -47,12 +51,14 @@ const [
|
||||
{ functionDossierSchema },
|
||||
{ readIdaConfiguration },
|
||||
{ createIdaMcpConnection },
|
||||
{ idaAddressSchema },
|
||||
] = await Promise.all([
|
||||
importBuilt("contracts/toolContracts.js"),
|
||||
importBuilt("domain/evidence.js"),
|
||||
importBuilt("domain/hopperValues.js"),
|
||||
importBuilt("ida/IdaConfiguration.js"),
|
||||
importBuilt("ida/IdaMcpConnection.js"),
|
||||
importBuilt("ida/IdaProtocolValues.js"),
|
||||
]);
|
||||
const registration = readIdaConfiguration(process.env.REA_IDA_MCP_CONFIG);
|
||||
if (!registration.ok) throw registration.error;
|
||||
@@ -79,7 +85,12 @@ const report = {
|
||||
config.protocol ?? (config.mode === "attached" ? "legacy" : "modern"),
|
||||
checks: [],
|
||||
observations: [],
|
||||
unverified: [],
|
||||
};
|
||||
const expectedXref =
|
||||
values["expected-xref"] === undefined
|
||||
? undefined
|
||||
: idaAddressSchema.parse(values["expected-xref"]);
|
||||
let phase = "target admission";
|
||||
const workspaces = new Set();
|
||||
const databases = new Set();
|
||||
@@ -184,12 +195,85 @@ const mcp = async (cliDossier) => {
|
||||
["search_procedures", { pattern: dossier.procedure.name }],
|
||||
["procedure_pseudo_code", { procedure: dossier.procedure.address }],
|
||||
["read_function_instructions", { procedure: dossier.procedure.address }],
|
||||
["search_strings", { pattern: "a.b", mode: "literal" }],
|
||||
[
|
||||
"search_strings",
|
||||
{
|
||||
pattern: values["expected-string"] ?? "a.b",
|
||||
mode: "literal",
|
||||
case_sensitive: true,
|
||||
},
|
||||
],
|
||||
["xrefs", { address: dossier.procedure.address }],
|
||||
]) {
|
||||
const result = await call(name, args);
|
||||
observe(result);
|
||||
const value = observe(result);
|
||||
switch (name) {
|
||||
case "list_procedures":
|
||||
case "search_procedures":
|
||||
assert.ok(
|
||||
value.some(
|
||||
(item) =>
|
||||
item.address === dossier.procedure.address &&
|
||||
item.value === dossier.procedure.name,
|
||||
),
|
||||
`${name} omitted the resolved procedure.`,
|
||||
);
|
||||
break;
|
||||
case "procedure_address":
|
||||
assert.equal(value, dossier.procedure.address);
|
||||
break;
|
||||
case "procedure_assembly":
|
||||
assert.equal(value, dossier.assembly.join("\n"));
|
||||
break;
|
||||
case "procedure_pseudo_code":
|
||||
assert.equal(value, dossier.pseudocode);
|
||||
break;
|
||||
case "procedure_callers":
|
||||
case "procedure_callees": {
|
||||
const expected =
|
||||
name === "procedure_callers" ? dossier.callers : dossier.callees;
|
||||
assert.deepEqual(
|
||||
[...value].sort(),
|
||||
expected.map((item) => item.address).sort(),
|
||||
);
|
||||
break;
|
||||
}
|
||||
case "read_function_instructions":
|
||||
assert.deepEqual(value.procedure.address, dossier.procedure.address);
|
||||
assert.deepEqual(value.instructions, dossier.assembly);
|
||||
break;
|
||||
case "list_strings":
|
||||
case "search_strings":
|
||||
if (values["expected-string"] !== undefined)
|
||||
assert.ok(
|
||||
value.some((item) =>
|
||||
item.value.includes(values["expected-string"]),
|
||||
),
|
||||
`${name} omitted the expected literal.`,
|
||||
);
|
||||
break;
|
||||
case "xrefs":
|
||||
if (expectedXref !== undefined)
|
||||
assert.ok(
|
||||
value.includes(expectedXref),
|
||||
"xrefs omitted the expected source address.",
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (values["expected-string"] === undefined)
|
||||
report.unverified.push(
|
||||
"String inventory/search correctness: no independent expected literal supplied.",
|
||||
);
|
||||
else
|
||||
report.checks.push(
|
||||
"string inventory and literal search contain the expected literal",
|
||||
);
|
||||
if (expectedXref === undefined)
|
||||
report.unverified.push(
|
||||
"Xref correctness: no independent expected source address supplied.",
|
||||
);
|
||||
else report.checks.push("xrefs contain the expected source address");
|
||||
if (values["second-procedure"] !== undefined) {
|
||||
const secondAddress = observe(
|
||||
await call("procedure_address", {
|
||||
@@ -231,10 +315,10 @@ const mcp = async (cliDossier) => {
|
||||
await call("close_binary", {});
|
||||
opened = false;
|
||||
report.checks.push(
|
||||
"one MCP connection, target selection, analysis/search/xrefs, invalid input, and close",
|
||||
"one MCP connection, positive procedure inventory/search, contract-valid tool results, invalid input, and close",
|
||||
);
|
||||
report.checks.push(
|
||||
"CLI/MCP function identity, pseudocode, assembly, and raw Evidence parity",
|
||||
"CLI/MCP function identity, pseudocode, assembly, instructions, and relationship parity",
|
||||
);
|
||||
} finally {
|
||||
const completedPhase = phase;
|
||||
@@ -300,6 +384,7 @@ try {
|
||||
passed: report.passed,
|
||||
mode: report.mode,
|
||||
checks: report.checks,
|
||||
unverified: report.unverified,
|
||||
...(report.passed
|
||||
? {}
|
||||
: {
|
||||
|
||||
Reference in New Issue
Block a user