fix(native): distinguish batch selectors from resolved entries
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
/** Verify batch selector/entry separation against real source-owned Ghidra functions. */
|
||||
export async function verifyGhidraBatchIdentity(call, names) {
|
||||
const leaf = names.find((item) =>
|
||||
item.value.endsWith("rea_ghidra_inventory_leaf"),
|
||||
);
|
||||
assert.ok(leaf, "Source fixture lacks a leaf procedure");
|
||||
const listing = await call("read_function_instructions", {
|
||||
procedure: leaf.address,
|
||||
});
|
||||
const interior = listing.instructions[1]?.split(": ")[0];
|
||||
assert.ok(interior, "Source fixture lacks an interior instruction");
|
||||
const name = await call("address_name", { address: leaf.address });
|
||||
const selectors = [leaf.address, interior, leaf.value, "0x0"];
|
||||
const result = await call("batch_decompile", { addresses: selectors });
|
||||
assert.equal(result.total, 4);
|
||||
assert.equal(result.succeeded, 3);
|
||||
assert.equal(result.failed, 1);
|
||||
for (let index = 0; index < 3; index++) {
|
||||
const item = result.items[index];
|
||||
assert.equal(item.address, selectors[index]);
|
||||
assert.equal(item.status, "ok");
|
||||
assert.deepEqual(item.procedure, {
|
||||
status: "resolved",
|
||||
address: leaf.address,
|
||||
name,
|
||||
});
|
||||
assert.equal(item.pseudocode, result.items[0].pseudocode);
|
||||
}
|
||||
assert.equal(result.items[3].status, "error");
|
||||
assert.equal(result.items[3].procedure.status, "unknown");
|
||||
assert.ok(result.items[3].procedure.error.code);
|
||||
return {
|
||||
entry: leaf.address,
|
||||
interior,
|
||||
selectors_preserved: true,
|
||||
identical_resolved_code: true,
|
||||
partial_failure_retained: true,
|
||||
};
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import { verifyGhidraTargetAdmission } from "./real-ghidra-target-admission.mjs"
|
||||
import { verifyGhidraLargeResults } from "./real-ghidra-large-results.mjs";
|
||||
import { verifyGhidraEntryAliases } from "./real-ghidra-entry-aliases.mjs";
|
||||
import { verifyGhidraNamespaceAnnotations } from "./real-ghidra-namespace-annotations.mjs";
|
||||
import { verifyGhidraBatchIdentity } from "./real-ghidra-batch-identity.mjs";
|
||||
|
||||
/** Probe real Ghidra location, annotation and error contracts through public adapters. */
|
||||
export async function verifyGhidraBoundaries(
|
||||
@@ -157,6 +158,7 @@ export async function verifyGhidraBoundaries(
|
||||
/Annotations require a local function entry/u,
|
||||
);
|
||||
const names = await call("list_names");
|
||||
const batchIdentity = await verifyGhidraBatchIdentity(call, names);
|
||||
const leaf = names.find((item) =>
|
||||
item.value.endsWith("rea_ghidra_inventory_leaf"),
|
||||
);
|
||||
@@ -766,6 +768,7 @@ export async function verifyGhidraBoundaries(
|
||||
missing_and_nonregular_source_rejected: true,
|
||||
imported_source_identity_retained: true,
|
||||
equivalent_instruction_address_spellings: true,
|
||||
batch_procedure_identity: batchIdentity,
|
||||
qualified_annotation_name_roundtrip: true,
|
||||
imported_entry_alias_selection: true,
|
||||
oversized_result_retention_and_complete_export: true,
|
||||
|
||||
Reference in New Issue
Block a user