fix(contracts)!: require observed provider output metadata
Reject omitted segment bounds, procedure classification and body facts, unresolved-call observations, dossier facets, and Ghidra parameter flow metadata. Providers emit explicit nulls for unsupported facets. Verify those unknowns in the real Hopper workflow. BREAKING CHANGE: Provider analysis outputs must explicitly supply metadata previously repaired with defaults; unsupported nullable facets must be reported as null.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import type { JsonValue } from "../domain/jsonValue.js";
|
||||
import { jsonValueSchema } from "../domain/jsonValue.js";
|
||||
import { functionDossierSchema } from "../domain/hopperValues.js";
|
||||
import {
|
||||
parseGhidraFunctionResult,
|
||||
@@ -37,6 +38,54 @@ describe("Ghidra function-analysis result values", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it.each(["block_membership", "parameters", "parameter_uses"])(
|
||||
"rejects a value-flow result missing %s",
|
||||
(field) => {
|
||||
const dossier = ghidraFunctionDossier();
|
||||
if (
|
||||
typeof dossier !== "object" ||
|
||||
dossier === null ||
|
||||
Array.isArray(dossier)
|
||||
)
|
||||
throw new TypeError("Ghidra dossier fixture is invalid");
|
||||
const flow = dossier.native_value_flow;
|
||||
if (typeof flow !== "object" || flow === null || Array.isArray(flow))
|
||||
throw new TypeError("Ghidra p-code fixture is invalid");
|
||||
if (!Array.isArray(flow.operations))
|
||||
throw new TypeError("Ghidra operation fixture is invalid");
|
||||
const incompleteFlow =
|
||||
field === "block_membership"
|
||||
? {
|
||||
...flow,
|
||||
operations: flow.operations.map((operation, index) =>
|
||||
index !== 0 ||
|
||||
typeof operation !== "object" ||
|
||||
operation === null ||
|
||||
Array.isArray(operation)
|
||||
? operation
|
||||
: Object.fromEntries(
|
||||
Object.entries(operation).filter(
|
||||
([key]) => key !== field,
|
||||
),
|
||||
),
|
||||
),
|
||||
}
|
||||
: Object.fromEntries(
|
||||
Object.entries(flow).filter(([key]) => key !== field),
|
||||
);
|
||||
|
||||
expect(
|
||||
parseGhidraFunctionResult(
|
||||
"analyze_function",
|
||||
jsonValueSchema.parse({
|
||||
...dossier,
|
||||
native_value_flow: incompleteFlow,
|
||||
}),
|
||||
),
|
||||
).toMatchObject({ ok: false, error: { _tag: "AnalysisOutputError" } });
|
||||
},
|
||||
);
|
||||
|
||||
it("rejects p-code relationships that refer to omitted operation IDs", () => {
|
||||
const dossier = ghidraFunctionDossier();
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user