fix(ida): preserve native coverage and verify returned values (#2324)
Reject native callee successes without an explicit truncation marker while preserving provider failure reasons. Verify positive procedure inventory/search and function-result parity in the real-provider lane; support independent string/xref oracles and label their absence as unverified. Verified with Windows IDA Pro 9.3: eight normal production CLI/MCP checks passed, and six real-provider response-fault cases reproduced old false positives and validated the correction. Windows IDA Free was not used. No personal paths or license registration information are included. Repair inconsistent complete-file Ghidra test probe sizes after the shared ELF-header validation change, deriving sizes from the fixture buffers. Reproduced the three failures before the correction; 115 related installation/doctor and ELF tests pass afterward. Runtime parsing and installation behavior are unchanged; no real-Ghidra verification is claimed. 207 focused IDA tests and static/documentation checks passed. Automated review completed on d1e0b1095 without findings. CI run 38327862093 passed all 36 jobs, including Windows, all six test shards, coverage/timing, and real Apple CLI/MCP workflows. 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