fix(package-verifier): reject overview responses without a procedure count (#2936)
* fix(package-verifier): reject overview responses without a procedure count The analyze and inspect checks compared procedure_count with `< 1`, and an absent or null normalized_result makes that comparison false, so a binary_overview response without its required result passed the platform smoke check. Require an integer procedure count before the positive-count comparison. * test(package-verifier): cover malformed overview receipts --------- Co-authored-by: REA Maintenance <76467478+morluto@users.noreply.github.com>
This commit is contained in:
co-authored by
REA Maintenance
parent
64041e3072
commit
4758ba30b6
@@ -1,6 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { assertLinuxPackageProviderFailure } from "../../../scripts/verify-package-platform.mjs";
|
||||
import {
|
||||
assertLinuxPackageProviderFailure,
|
||||
verifyPackagePlatform,
|
||||
} from "../../../scripts/verify-package-platform.mjs";
|
||||
|
||||
const missingDisplay = {
|
||||
code: "provider_unavailable",
|
||||
@@ -22,6 +25,37 @@ const execution = (failure: unknown, status = 1) => ({
|
||||
stdout: JSON.stringify(failure),
|
||||
});
|
||||
|
||||
const overview = (procedure_count?: unknown, operation = "binary_overview") => ({
|
||||
operation,
|
||||
...(procedure_count === undefined
|
||||
? {}
|
||||
: { normalized_result: { procedure_count } }),
|
||||
});
|
||||
|
||||
const verifyMacOS = async (
|
||||
analyze: unknown,
|
||||
inspect: unknown,
|
||||
): Promise<void> => {
|
||||
const outputs: Readonly<Record<string, unknown>> = {
|
||||
analyze,
|
||||
inspect,
|
||||
function: {
|
||||
operation: "analyze_function",
|
||||
provider: { id: "hopper" },
|
||||
normalized_result: { procedure: { address: "0x1000" } },
|
||||
},
|
||||
xrefs: { operation: "xrefs", normalized_result: ["0x1000"] },
|
||||
trace: { operation: "trace_feature" },
|
||||
};
|
||||
await verifyPackagePlatform({
|
||||
cli: "fixture-cli",
|
||||
environment: {},
|
||||
platform: "darwin",
|
||||
runCommand: async (_cli, arguments_) =>
|
||||
JSON.stringify(outputs[arguments_[0]!]) ?? "",
|
||||
});
|
||||
};
|
||||
|
||||
describe("packaged Linux failure verification", () => {
|
||||
it("accepts the unsupported fixture build or an exact missing display dependency", () => {
|
||||
expect(() =>
|
||||
@@ -71,3 +105,29 @@ describe("packaged Linux failure verification", () => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe("packaged analyze and inspect result guards", () => {
|
||||
it("accepts positive integer procedure counts for both commands", async () => {
|
||||
await verifyMacOS(overview(1), overview(2));
|
||||
});
|
||||
|
||||
const malformed = [
|
||||
["missing result", undefined],
|
||||
["null result", null],
|
||||
["missing normalized count", overview()],
|
||||
["zero count", overview(0)],
|
||||
["non-integer count", overview(1.5)],
|
||||
["wrong operation", overview(2, "other_operation")],
|
||||
] as const;
|
||||
|
||||
it.each(["analyze", "inspect"] as const)(
|
||||
"rejects malformed %s results before trusting the package",
|
||||
async (command) => {
|
||||
for (const [label, invalid] of malformed) {
|
||||
const analyze = command === "analyze" ? invalid : overview(4);
|
||||
const inspect = command === "inspect" ? invalid : overview(4);
|
||||
await expect(verifyMacOS(analyze, inspect), label).rejects.toThrow();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user