feat(native): inspect API boundaries with evidence

This commit is contained in:
morluto
2026-07-25 14:29:28 +00:00
parent 5184816199
commit 521139d4a5
39 changed files with 1382 additions and 63 deletions
+63 -1
View File
@@ -13,6 +13,7 @@ import {
ghidraFunctionClassification,
ghidraFunctionDossier,
ghidraFunctionIdentity,
ghidraNativeApiBoundary,
ghidraReferenceEdge,
} from "./fixtures/ghidraFunction.js";
@@ -153,7 +154,35 @@ describe("Ghidra function-analysis boundary values", () => {
});
expect(
parseGhidraFunctionResult("analyze_function", ghidraFunctionDossier()),
).toMatchObject({ ok: true });
).toMatchObject({
ok: true,
value: {
native_api: {
available: true,
provenance: "ghidra-high-function",
return_type: {
data_type: "int",
confidence: "medium",
},
jump_tables: [
{
dispatch_address: "0x401010",
data_sources: [{ address: "0x403000" }],
mappings: [
{
target_address: "0x401020",
data_addresses: ["0x403000"],
},
],
},
],
pseudocode: {
classification: "decompiler-generated-non-source",
compilable: false,
},
},
},
});
});
it.each(malformedOutputs())(
@@ -174,6 +203,11 @@ const malformedOutputs = (): Array<
if (typeof dossier !== "object" || dossier === null || Array.isArray(dossier))
throw new TypeError("Ghidra dossier fixture is invalid");
const edge = ghidraReferenceEdge();
const nativeApi = ghidraNativeApiBoundary();
const jumpTable = nativeApi.jump_tables[0];
const mapping = jumpTable?.mappings[0];
if (jumpTable === undefined || mapping === undefined)
throw new TypeError("Ghidra native API fixture is invalid");
return [
["non-canonical address", "procedure_callers", ["401000"]],
[
@@ -201,6 +235,34 @@ const malformedOutputs = (): Array<
instruction_scan_truncated: false,
},
],
[
"missing native API boundary",
"analyze_function",
Object.fromEntries(
Object.entries(dossier).filter(([key]) => key !== "native_api"),
),
],
[
"non-canonical native API target",
"analyze_function",
{
...dossier,
native_api: {
...nativeApi,
jump_tables: [
{
...jumpTable,
mappings: [
{
...mapping,
target_address: "401020",
},
],
},
],
},
},
],
[
"Hopper local provenance",
"analyze_function",