feat(native): expose typed incoming references at exact addresses (#1715)
This commit is contained in:
@@ -113,6 +113,7 @@ export const resolveGhidraAnalysisProfile = async (
|
||||
string_inventory_evidence: "defined-data-coverage-v1",
|
||||
location_resolution: "explicit-address-exact-entry-symbol-first-v3",
|
||||
instruction_flow_evidence: "decoded-return-pcode-v1",
|
||||
instruction_references: "exact-address-incoming-v1",
|
||||
function_boundary_observations: "ghidra-terminal-call-limitations-v1",
|
||||
no_return_repair:
|
||||
installation.platform === "win32"
|
||||
|
||||
@@ -172,6 +172,45 @@ describe("Ghidra function-analysis result values", () => {
|
||||
});
|
||||
|
||||
describe("Ghidra compact reference provenance", () => {
|
||||
it("distinguishes incoming references, examined emptiness and unavailable coverage at data addresses", () => {
|
||||
const instruction = {
|
||||
...compactInstruction(),
|
||||
address: "ram:00402000",
|
||||
status: "data",
|
||||
procedure: null,
|
||||
};
|
||||
const reference = {
|
||||
...compactReference(),
|
||||
source_address: "ram:00401000",
|
||||
target_address: instruction.address,
|
||||
type: "WRITE",
|
||||
call: false,
|
||||
data: true,
|
||||
write: true,
|
||||
};
|
||||
for (const incoming of [
|
||||
{},
|
||||
{ incoming_references: null },
|
||||
{ incoming_references: [] },
|
||||
{ incoming_references: [reference] },
|
||||
{ incoming_references: [{ ...reference, primary: null, source: null }] },
|
||||
]) {
|
||||
const expected = { ...instruction, ...incoming };
|
||||
const parsed = parseFunctionValueFixture(
|
||||
"inspect_native_instruction",
|
||||
expected,
|
||||
);
|
||||
if (!parsed.ok) throw parsed.error;
|
||||
expect(parsed.value).toEqual(expected);
|
||||
}
|
||||
expect(
|
||||
parseFunctionValueFixture("inspect_native_instruction", {
|
||||
...instruction,
|
||||
incoming_references: [{ ...reference, primary: "false" }],
|
||||
}),
|
||||
).toMatchObject({ ok: false, error: { _tag: "AnalysisOutputError" } });
|
||||
});
|
||||
|
||||
const operations = [
|
||||
["inspect_native_instruction", compactInstruction],
|
||||
["resolve_native_call_targets", compactCallTargets],
|
||||
|
||||
@@ -4,6 +4,7 @@ import { createTestBinarySession } from "../../tests/fixtures/binarySession.js";
|
||||
import { parseConfig } from "../config/parseConfig.js";
|
||||
import type { BinaryTarget } from "../domain/binaryTargetTypes.js";
|
||||
import { functionDossierSchema } from "../domain/hopperValues.js";
|
||||
import { createAnalysisProfile } from "../domain/analysisProfile.js";
|
||||
import { ghidraFunctionDossier } from "../domain/ghidraValues.fixture.js";
|
||||
import { err, ok } from "../domain/result.js";
|
||||
import { silentLogger } from "../logger.js";
|
||||
@@ -130,6 +131,41 @@ const open = async (session: ReturnType<typeof fixture>["session"]) => {
|
||||
};
|
||||
|
||||
describe("Ghidra snapshot cache", () => {
|
||||
it("refuses snapshots whose profile predates typed incoming references", async () => {
|
||||
const initial = fixture();
|
||||
await open(initial.session);
|
||||
const snapshot = initial.session.exportAnalysisSnapshot();
|
||||
if (!snapshot.ok) throw snapshot.error;
|
||||
await initial.session.close();
|
||||
const profile = snapshot.value.binding.analysis_profile;
|
||||
expect(profile.parameters.instruction_references).toBe(
|
||||
"exact-address-incoming-v1",
|
||||
);
|
||||
const legacy = {
|
||||
...snapshot.value,
|
||||
binding: {
|
||||
...snapshot.value.binding,
|
||||
analysis_profile: createAnalysisProfile(
|
||||
profile.provider,
|
||||
Object.fromEntries(
|
||||
Object.entries(profile.parameters).filter(
|
||||
([key]) => key !== "instruction_references",
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
};
|
||||
const replay = fixture();
|
||||
const imported = replay.session.importAnalysisSnapshot(legacy);
|
||||
if (!imported.ok) throw imported.error;
|
||||
expect(await replay.session.previewTarget(TARGET)).toMatchObject({
|
||||
ok: false,
|
||||
error: { _tag: "EvidenceIntegrityError" },
|
||||
});
|
||||
expect(replay.calls).toEqual([]);
|
||||
await replay.session.close();
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ operation: "analyze_function", parameters: { procedure: "0x1000" } },
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user