From 10789bc4c1de2611baff34026e4e24e9b38cf407 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Fri, 20 Nov 2026 23:58:01 -0500 Subject: [PATCH] test(ida): consolidate relationship routing and coverage checks (#12995) --- src/ida/IdaCallGraph.test.ts | 4 - src/ida/IdaCalleeRelationships.test.ts | 120 ++++++------------ .../providers/ida/calleeRelationships.test.ts | 21 ++- 3 files changed, 56 insertions(+), 89 deletions(-) diff --git a/src/ida/IdaCallGraph.test.ts b/src/ida/IdaCallGraph.test.ts index 11b05887d6..4e3d7e7418 100644 --- a/src/ida/IdaCallGraph.test.ts +++ b/src/ida/IdaCallGraph.test.ts @@ -200,10 +200,6 @@ describe("reading root callees from the processor-neutral call graph", () => { describe("call graph coverage and failure handling", () => { it.each([ ["truncated", { truncated: true }], - [ - "per_func_capped below the edge cap", - { per_func_capped: true, max_edges_per_func: 200 }, - ], ["limit_reason", { limit_reason: "edges" }], ])("reports a graph flagged by %s as truncated", async (_label, extra) => { const result = await readGraph([call("0x1000", "0x20")], extra); diff --git a/src/ida/IdaCalleeRelationships.test.ts b/src/ida/IdaCalleeRelationships.test.ts index 024a06da65..1bbae7d2d2 100644 --- a/src/ida/IdaCalleeRelationships.test.ts +++ b/src/ida/IdaCalleeRelationships.test.ts @@ -11,7 +11,6 @@ import { graphRow, removeCallGraphSessions, } from "../../tests/fixtures/idaCallGraph.js"; -import { UNRECOGNIZED_CALLEE_LIMITATION } from "./IdaCallGraph.js"; import { IDA_LIMITATIONS } from "./IdaProviderCapabilities.js"; import { IdaSessionClient } from "./IdaSessionClient.js"; @@ -36,39 +35,6 @@ const callees = async (client: IdaSessionClient) => { return result.value; }; -describe("headless IDA callee edges on non-x86 targets", () => { - it("uses the neutral call graph as the sole callee source on non-x86 targets", async () => { - const { client } = await session({ - callees: [ - { addr: "0x4000", name: "bogus_non_x86_match", type: "internal" }, - ], - callgraph: graphRow([ - edge("0x1000", "0x2000"), - edge("0x1000", "0x3000"), - edge("0x2000", "0x4000"), - ]), - }); - try { - const execution = await callees(client); - - expect( - execution.result, - "the root edges are observed and the child edge is ignored", - ).toEqual(["0x2000", "0x3000"]); - expect( - execution.limitations, - "calls to non-function targets remain unknown", - ).toContain(UNRECOGNIZED_CALLEE_LIMITATION); - expect( - observedTools(execution.rawResult), - "non-x86 callees is never queried", - ).not.toContain("callees"); - } finally { - expect((await client.close()).ok).toBe(true); - } - }); -}); - describe("headless IDA call graph availability and cancellation", () => { it("takes the call graph path for a universal target whose loaded slice is unknown", async () => { const { client, producer } = await session( @@ -120,57 +86,43 @@ describe("headless IDA call graph availability and cancellation", () => { }); describe("headless IDA callee edges on x86 targets", () => { - it("keeps the requests, result, limitations and observations of an x86 read unchanged", async () => { - const { client, producer } = await session( - { - callees: [ - { addr: "0x2000", name: "imported_puts", type: "external" }, - { addr: "0x3000", name: "printf_stub", type: "internal" }, - ], - }, - "x86_64", - ); - try { - const execution = await callees(client); + it.each([ + { + label: "external and internal callees", + rows: [ + { addr: "0x2000", name: "imported_puts", type: "external" }, + { addr: "0x3000", name: "printf_stub", type: "internal" }, + ], + addresses: ["0x2000", "0x3000"], + tools: ["lookup_funcs", "callees", "lookup_funcs"], + }, + { + label: "an explicitly complete empty reply", + rows: [], + addresses: [], + tools: ["lookup_funcs", "callees"], + }, + ])( + "reads only the x86 callee source for $label", + async ({ rows, addresses, tools }) => { + const { client, producer } = await session({ callees: rows }, "x86_64"); + try { + const execution = await callees(client); - expect( - execution.result, - "externals come first, then resolved internals, exactly as before", - ).toEqual(["0x2000", "0x3000"]); - expect( - execution.limitations, - "exactly the provider's own limitations, nothing added on x86", - ).toEqual([...IDA_LIMITATIONS]); - expect( - producer.calls.filter(({ name }) => name === "callees"), - ).toMatchObject([{ args: { addrs: ["0x1000"], limit: 500 } }]); - expect( - observedTools(execution.rawResult), - "the raw observations hold no call graph row", - ).toEqual(["lookup_funcs", "callees", "lookup_funcs"]); - } finally { - expect((await client.close()).ok).toBe(true); - } - }); - - it("keeps an empty x86 callees reply an observed empty list without any limitation", async () => { - const { client, producer } = await session({ callees: [] }, "x86_64"); - try { - const execution = await callees(client); - - expect(execution.result, "nothing is added").toEqual([]); - expect( - execution.limitations, - "no completeness warning on a trustworthy x86 target", - ).toEqual([...IDA_LIMITATIONS]); - expect( - producer.calls.some(({ name }) => name === "callgraph"), - "no call graph request even for an empty reply", - ).toBe(false); - } finally { - expect((await client.close()).ok).toBe(true); - } - }); + expect(execution.result).toEqual(addresses); + expect(execution.relationshipCoverage).toMatchObject({ + status: "complete", + }); + expect(execution.limitations).toEqual([...IDA_LIMITATIONS]); + expect( + producer.calls.filter(({ name }) => name === "callees"), + ).toMatchObject([{ args: { addrs: ["0x1000"], limit: 500 } }]); + expect(observedTools(execution.rawResult)).toEqual(tools); + } finally { + expect((await client.close()).ok).toBe(true); + } + }, + ); it("does not use the call graph for the native attached profile on an ARM target", async () => { const { root, target } = await createIdaTarget("arm64"); diff --git a/tests/boundary/providers/ida/calleeRelationships.test.ts b/tests/boundary/providers/ida/calleeRelationships.test.ts index e510d2e629..87dde805ed 100644 --- a/tests/boundary/providers/ida/calleeRelationships.test.ts +++ b/tests/boundary/providers/ida/calleeRelationships.test.ts @@ -32,7 +32,14 @@ const armSession = () => }); it("refuses direct callers and keeps caller coverage unknown in an ARM64 dossier", async () => { - const { client } = await armSession(); + const { client, producer } = await callGraphSession({ + callees: [{ addr: "0x4000", name: "bogus_callee", type: "external" }], + callgraph: graphRow([ + edge("0x1000", "0x2000"), + edge("0x1000", "0x3000"), + edge("0x2000", "0x4000"), + ]), + }); try { const declared = idaCapabilities(IDA_COMPATIBILITY_PROFILES.modern, false); const callers = declared.find( @@ -71,6 +78,13 @@ it("refuses direct callers and keeps caller coverage unknown in an ARM64 dossier callers: [], callees: [{ address: "0x2000" }, { address: "0x3000" }], }); + expect(requestedRoots(producer)).toEqual(["0x1000"]); + expect(producer.calls.map(({ name }) => name)).not.toContain("callees"); + expect(result.value.rawResult).toMatchObject({ + observations: expect.arrayContaining([ + expect.objectContaining({ tool: "callgraph" }), + ]), + }); } finally { await client.close(); } @@ -358,6 +372,11 @@ it("preserves an explicit root cap below the edge limit through every relationsh }); if (!direct.ok) throw direct.error; expect(direct.value.limitations).toContain(limitation); + expect(direct.value.relationshipCoverage).toMatchObject({ + status: "partial", + limitations: [limitation], + limited_directions: ["callees"], + }); expect(direct.value.result).toEqual(["0x2000"]); const application = new EnhancedTools(client); const graph = await application.executeValidated({