test(ghidra): check retained historical snapshot evidence (#8381)

* test(ghidra): check retained historical snapshot evidence

* test(ghidra): select historical observations by address
This commit is contained in:
morluto authored and GitHub committed 2026-11-05 17:37:29 +08:00
1 parent 15107aa81b
commit 0aaa582977
1 file changed
+21 -19
+21 -19
View File
@@ -9,7 +9,7 @@ import { join } from "node:path";
import { parseAnalysisSnapshot } from "../../dist/domain/analysisSnapshot.js";
import { parseEvidenceBundle } from "../../dist/domain/evidenceBundle.js";
/** Keep mutable Ghidra observations out of immutable snapshots across target opens. */
/** Keep live Ghidra edits distinct from historical Evidence across snapshots. */
export async function verifyGhidraSnapshotLifecycle(
client,
target,
@@ -93,18 +93,21 @@ export async function verifyGhidraSnapshotLifecycle(
const bundle = parseEvidenceBundle(
JSON.parse(await readFile(bundlePath, "utf8")),
);
assert.ok(
bundle.records.some(
(record) => record.operation === "annotate_native_function",
),
const annotation = bundle.records.find(
(record) =>
record.operation === "annotate_native_function" &&
record.normalized_result.annotations.name === edited.procedure.name &&
record.normalized_result.annotations.address ===
edited.procedure.address,
);
assert.ok(
bundle.records.some(
(record) =>
record.operation === "inspect_native_api" &&
record.normalized_result.procedure.name === edited.procedure.name,
),
const editedApi = bundle.records.find(
(record) =>
record.operation === "inspect_native_api" &&
record.normalized_result.procedure.name === edited.procedure.name &&
record.normalized_result.procedure.address === edited.procedure.address,
);
assert.ok(annotation);
assert.ok(editedApi);
await call("close_binary");
await call("open_binary", {
@@ -124,14 +127,13 @@ export async function verifyGhidraSnapshotLifecycle(
const fresh = parseAnalysisSnapshot(
JSON.parse(await readFile(freshPath, "utf8")),
);
assert.ok(
!fresh.evidence_bundle.records.some(
(record) =>
record.operation === "annotate_native_function" ||
(record.operation === "inspect_native_api" &&
record.normalized_result.procedure.name === edited.procedure.name),
),
);
for (const historical of [annotation, editedApi])
assert.deepEqual(
fresh.evidence_bundle.records.find(
(record) => record.evidence_id === historical.evidence_id,
),
historical,
);
await call("open_binary", {
path: target.path,
provider_id: "ghidra",