fix(ida): preserve non-x86 call edges and workflow uncertainty (#1906)

* test(ida): expect callee edges from the call graph on non-x86 targets

* fix(ida): read callee edges from the call graph on non-x86 targets

* test(ida): pin address order of call graph additions

* docs(ida): describe the call graph source for non-x86 callees

* test(ida): pin the x86 baseline, the call graph reader and its failure modes

* fix(ida): check the call graph root, scope truncation to the root and degrade without callgraph

* test(ida): expect managed PE off the x86 path, possible-truncation wording and a complete ARM64 traversal

* fix(ida): keep managed PE and x86 reads off the call graph path and qualify truncation

* test(ida): answer only expected leaf roots and assert the requested call graph roots

* test(ida): expect a call graph the producer cannot give consistently to fail the callee read

* fix(ida): fail the callee read when the call graph cannot be obtained consistently

* fix(ida): preserve call edge authority and workflow uncertainty

* fix(ida): preserve explicit root call graph caps

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
Mykola Dementiev
2026-10-12 04:10:22 +08:00
committed by GitHub
co-authored by morluto
parent c2cf7dcb86
commit 0ae38e1e31
17 changed files with 1410 additions and 32 deletions
+43 -5
View File
@@ -10,6 +10,7 @@ import {
functionInstructionWindowSchema,
} from "../domain/hopperValues.js";
import type { JsonValue } from "../domain/jsonValue.js";
import { readCallGraphCallees, unavailableCallGraph } from "./IdaCallGraph.js";
import type { IdaMcpConnection } from "./IdaMcpConnection.js";
import type { IdaOperation } from "./IdaProviderCapabilities.js";
import { IDA_LIMITATIONS } from "./IdaProviderCapabilities.js";
@@ -68,20 +69,26 @@ export class IdaOperationRunner {
private readonly connection: IdaMcpConnection,
private readonly protocol: "legacy" | "modern",
private readonly database?: string,
private readonly signal?: AbortSignal,
private readonly selectorOrigin?: "provider",
private readonly options: {
readonly signal?: AbortSignal | undefined;
readonly selectorOrigin?: "provider" | undefined;
/** False when the loaded processor may not be x86, so `callees` cannot be trusted alone. */
readonly x86Only?: boolean;
/** False when the upstream server does not advertise `callgraph`. */
readonly callGraphAvailable?: boolean;
} = {},
) {}
async call(
tool: string,
args: Readonly<Record<string, JsonValue>>,
): Promise<JsonValue> {
if (this.signal?.aborted) throw new AnalysisCancelledError(tool);
if (this.options.signal?.aborted) throw new AnalysisCancelledError(tool);
const scoped =
this.database === undefined ? args : { ...args, database: this.database };
const result = await this.connection.call(tool, scoped);
this.raw.push({ tool, arguments: scoped, result });
if (this.signal?.aborted) throw new AnalysisCancelledError(tool);
if (this.options.signal?.aborted) throw new AnalysisCancelledError(tool);
return result;
}
@@ -175,6 +182,33 @@ export class IdaOperationRunner {
return entry;
}
/** True only for modern callee reads on targets not proven x86-only; x86 reads never reach the graph code. */
private readsCallGraph(direction: "callers" | "callees"): boolean {
return (
this.protocol === "modern" &&
direction === "callees" &&
this.options.x86Only === false
);
}
/** Add processor-neutral function callees on targets where upstream `callees` is unsound. */
private async addCallGraphCallees(
fn: IdaFunction,
result: Map<string, ReturnType<typeof identity>>,
): Promise<void> {
const graph =
this.options.callGraphAvailable === false
? unavailableCallGraph("the upstream server does not advertise it")
: await readCallGraphCallees(
(tool, args) => this.call(tool, args),
fn.address,
);
this.limitations.push(...graph.limitations);
for (const callee of graph.callees)
if (!result.has(callee.address))
result.set(callee.address, identity({ ...callee, size: "unknown" }));
}
async strings(): Promise<{ address: string; value: string }[]> {
const result: { address: string; value: string }[] = [];
let offset: number | null = 0;
@@ -310,6 +344,10 @@ export class IdaOperationRunner {
): Promise<ReturnType<typeof identity>[]> {
const queries: string[] = [];
const result = new Map<string, ReturnType<typeof identity>>();
if (this.readsCallGraph(direction)) {
await this.addCallGraphCallees(fn, result);
return [...result.values()];
}
if (this.protocol === "legacy") {
const value = await this.call(
direction === "callers" ? "get_callers" : "get_callees",
@@ -388,7 +426,7 @@ export class IdaOperationRunner {
}
const fn = await this.resolve(
z.string().min(1).parse(parameters.procedure),
this.selectorOrigin === "provider" ? undefined : operation,
this.options.selectorOrigin === "provider" ? undefined : operation,
);
this.locations.push({ kind: "address", address: fn.address });
switch (operation) {