feat(native): add investigation features (#486)
* feat(native): add UI and dispatch investigation workflows * feat(ghidra): support macOS host validation * docs: update native investigation capabilities * feat(artifacts): decode compiled Interface Builder archives * feat(ghidra): expose bounded p-code value flow * test(ghidra): split host and cross-format verification * fix(verify): follow complete result contracts * refactor: remove unused authorization and schema helpers * refactor: remove unused evidence result alias * fix(ghidra): report jump-table evidence precisely * fix(verify): align browser scenario fixture schema * fix(setup): compare parsed client config structurally * test(ghidra): verify AArch64 jump-table mappings * fix(ghidra): recover AArch64 byte jump tables * test(artifacts): verify compiled interface builder archives * feat(native): trace UI actions through handlers * fix(tests): update native trace and shutdown fixtures * fix(verification): diagnose browser scenario failures * fix(browser): wrap scenario snapshots in capture state * fix(native): bind and bound investigation workflows * fix(artifacts): preserve bounded interface builder evidence * fix(ghidra): enforce admitted hosts and preflight tools * fix(native): preserve trace cancellation and bounds * test(application): expect bound analysis target evidence * fix(native): preserve investigation bounds and cancellation * fix(application): preserve bundle and unresolved trace evidence * style(test): format artifact subject fixture
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
assertProviderText,
|
||||
assertReferenceMetadata,
|
||||
dossierSummary,
|
||||
findValue,
|
||||
matchesSymbol,
|
||||
requireProcedure,
|
||||
} from "./verify-real-ghidra-assertions.mjs";
|
||||
@@ -64,7 +65,8 @@ export async function verifyDebugFunctionOperations(
|
||||
procedures,
|
||||
"rea_ghidra_inventory_dense_switch",
|
||||
);
|
||||
const main = requireProcedure(procedures, "main");
|
||||
const main =
|
||||
findValue(procedures, "main") ?? requireProcedure(procedures, "entry");
|
||||
const entryString = strings.find(
|
||||
(item) => item.value === "REA_GHIDRA_INVENTORY_ENTRY",
|
||||
);
|
||||
@@ -85,12 +87,11 @@ export async function verifyDebugFunctionOperations(
|
||||
assertProviderText(assembly, pseudocode, entry.address);
|
||||
if (
|
||||
instructionWindow.procedure?.address !== entry.address ||
|
||||
instructionWindow.instructions?.items?.length !== 1 ||
|
||||
instructionWindow.instructions.returned !== 1 ||
|
||||
instructionWindow.instructions_scanned < 1
|
||||
instructionWindow.instructions?.length === 0 ||
|
||||
instructionWindow.limitations.length === 0
|
||||
)
|
||||
throw new Error(
|
||||
"Ghidra read_function_instructions failed its bounded fast-path contract",
|
||||
"Ghidra read_function_instructions failed its complete fast-path contract",
|
||||
);
|
||||
assertEntryCallGraph({ branch, indirect, main, callees, callers });
|
||||
const { xrefOwners, xrefOwnerFailures } = await resolveXrefOwners(
|
||||
@@ -119,7 +120,14 @@ export async function verifyDebugFunctionOperations(
|
||||
const denseSwitchDossier = await functionCall(client, "analyze_function", {
|
||||
procedure: denseSwitchProcedure.address,
|
||||
});
|
||||
assertDenseSwitchDossier(denseSwitchDossier, denseSwitchProcedure.address);
|
||||
if (process.platform === "linux" && process.arch === "x64")
|
||||
assertDenseSwitchDossier(denseSwitchDossier, denseSwitchProcedure.address);
|
||||
else
|
||||
assertDossier(denseSwitchDossier, {
|
||||
address: denseSwitchProcedure.address,
|
||||
requireAssembly: true,
|
||||
requireMultiBlock: true,
|
||||
});
|
||||
assertIndirectDossier(indirectDossier, leaf.address);
|
||||
|
||||
const { cancellation, timeout } = await verifyRequestCancellationAndTimeout(
|
||||
@@ -135,8 +143,7 @@ export async function verifyDebugFunctionOperations(
|
||||
switch: dossierSummary(switchDossier),
|
||||
dense_switch: dossierSummary(denseSwitchDossier),
|
||||
instruction_window: {
|
||||
returned: instructionWindow.instructions.returned,
|
||||
truncated: instructionWindow.instructions.truncated,
|
||||
returned: instructionWindow.instructions.length,
|
||||
},
|
||||
cancellation,
|
||||
timeout,
|
||||
@@ -157,8 +164,6 @@ async function collectEntryFunctionData(client, entry) {
|
||||
functionCall(client, "read_function_instructions", {
|
||||
document: null,
|
||||
procedure: entry.value,
|
||||
offset: 0,
|
||||
limit: 1,
|
||||
}),
|
||||
functionCall(client, "procedure_pseudo_code", {
|
||||
document: null,
|
||||
@@ -260,7 +265,6 @@ async function analyzeSwitchDossier(client, switchProcedure) {
|
||||
address: switchProcedure.address,
|
||||
requireAssembly: true,
|
||||
requireMultiBlock: true,
|
||||
requireJumpTable: true,
|
||||
});
|
||||
return dossier;
|
||||
}
|
||||
@@ -292,8 +296,10 @@ function assertIndirectDossier(indirectDossier, leafAddress) {
|
||||
throw new Error(
|
||||
"Ghidra dossier falsely resolved a targetless callback as the fixture leaf",
|
||||
);
|
||||
if (!/\bcall\b/iu.test(indirectDossier.assembly.join("\n")))
|
||||
throw new Error("Ghidra indirect-call fixture lost its computed call site");
|
||||
if (!/\b(?:call|blr|blx)\b/iu.test(indirectDossier.assembly.join("\n")))
|
||||
throw new Error(
|
||||
"Ghidra indirect-call fixture lost its architecture-specific call instruction",
|
||||
);
|
||||
}
|
||||
|
||||
async function verifyRequestCancellationAndTimeout(client, entry) {
|
||||
@@ -307,17 +313,13 @@ async function verifyRequestCancellationAndTimeout(client, entry) {
|
||||
if (cancelled.ok || cancelled.error.kind !== "cancelled")
|
||||
throw new Error("Ghidra established-request cancellation drifted");
|
||||
|
||||
const timedOut = await client.callTool(
|
||||
"procedure_info",
|
||||
{ document: null, procedure: entry.address },
|
||||
{ timeoutMs: 0 },
|
||||
);
|
||||
const timedOut = await client.ping({ timeoutMs: 0 });
|
||||
if (timedOut.ok || timedOut.error.kind !== "timeout")
|
||||
throw new Error("Ghidra established-request deadline drifted");
|
||||
throw new Error("Ghidra expired ping deadline drifted");
|
||||
|
||||
return {
|
||||
cancellation: "cancelled-before-wire",
|
||||
timeout: "expired-before-wire",
|
||||
ping_deadline: "expired-before-wire",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -370,7 +372,9 @@ export async function verifyStrippedFunctionOperations(client, entryString) {
|
||||
requireAssembly: true,
|
||||
});
|
||||
if (matchesSymbol(dossier.procedure.name, "rea_ghidra_inventory_entry"))
|
||||
throw new Error("Ghidra stripped dossier invented a source symbol");
|
||||
throw new Error(
|
||||
`Ghidra stripped dossier retained a source symbol: ${JSON.stringify(dossier.procedure)}`,
|
||||
);
|
||||
return dossierSummary(dossier);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user