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:
@@ -100,11 +100,7 @@ describe("native API inspection", () => {
|
||||
const value = ghidraFunctionDossier();
|
||||
if (typeof value !== "object" || value === null || Array.isArray(value))
|
||||
throw new TypeError("Ghidra dossier fixture is invalid");
|
||||
const dossier = functionDossierSchema.parse(
|
||||
Object.fromEntries(
|
||||
Object.entries(value).filter(([key]) => key !== "native_api"),
|
||||
),
|
||||
);
|
||||
const dossier = functionDossierSchema.parse({ ...value, native_api: null });
|
||||
|
||||
expect(projectNativeApiInspection(dossier)).toMatchObject({
|
||||
boundary: { available: false },
|
||||
|
||||
@@ -101,4 +101,30 @@ describe("typed native call routes", () => {
|
||||
error: { _tag: "AnalysisOutputError" },
|
||||
});
|
||||
});
|
||||
it("rejects omitted unresolved-call observations instead of claiming none", async () => {
|
||||
let calls = 0;
|
||||
const result = await readNativeCallRoutes(
|
||||
{
|
||||
execute: async () => {
|
||||
calls++;
|
||||
return ok(
|
||||
createAnalysisExecution(
|
||||
{
|
||||
reference_kinds_available: false,
|
||||
references: [],
|
||||
},
|
||||
provider,
|
||||
),
|
||||
);
|
||||
},
|
||||
},
|
||||
"0x1000",
|
||||
);
|
||||
|
||||
expect(result).toMatchObject({
|
||||
ok: false,
|
||||
error: { _tag: "AnalysisOutputError" },
|
||||
});
|
||||
expect(calls).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ import { err, ok } from "../../domain/result.js";
|
||||
import { AnalysisOutputError } from "../../domain/analysisErrorCore.js";
|
||||
|
||||
const referencesSchema = z.object({
|
||||
reference_kinds_available: z.boolean().optional(),
|
||||
reference_kinds_available: z.boolean(),
|
||||
references: z.array(
|
||||
z.object({
|
||||
source_address: z.string(),
|
||||
@@ -17,9 +17,9 @@ const referencesSchema = z.object({
|
||||
kind: referenceKindSchema,
|
||||
}),
|
||||
),
|
||||
unresolved_calls: z
|
||||
.array(z.object({ address: z.string(), reason: z.string() }))
|
||||
.default([]),
|
||||
unresolved_calls: z.array(
|
||||
z.object({ address: z.string(), reason: z.string() }),
|
||||
),
|
||||
});
|
||||
/** Prefer typed static call references, preserving computed targets and targetless sites. */
|
||||
export const readNativeCallRoutes = async (
|
||||
|
||||
@@ -67,6 +67,11 @@ const analysis: AnalysisOperationPort = {
|
||||
address: callee ? "0x2000" : "0x1000",
|
||||
name: callee ? "callee" : "caller",
|
||||
classification: null,
|
||||
body: {
|
||||
available: false,
|
||||
reason:
|
||||
"The provider did not report complete function body ranges.",
|
||||
},
|
||||
signature: null,
|
||||
locals: [],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user