Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
579ecbd032 | ||
|
|
4758ba30b6 |
@@ -8,4 +8,10 @@ export function assertLinuxPackageProviderFailure(execution: {
|
|||||||
export function verifyPackagePlatform(input: {
|
export function verifyPackagePlatform(input: {
|
||||||
readonly cli: string;
|
readonly cli: string;
|
||||||
readonly environment: Readonly<Record<string, string | undefined>>;
|
readonly environment: Readonly<Record<string, string | undefined>>;
|
||||||
|
readonly platform?: string;
|
||||||
|
readonly runCommand?: (
|
||||||
|
command: string,
|
||||||
|
arguments_: readonly string[],
|
||||||
|
environment: Readonly<Record<string, string | undefined>>,
|
||||||
|
) => Promise<string>;
|
||||||
}): Promise<void>;
|
}): Promise<void>;
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
import { json, run, runWithStatus } from "./lib/verify-package-core.mjs";
|
import { json, run, runWithStatus } from "./lib/verify-package-core.mjs";
|
||||||
|
|
||||||
/** Run platform-specific deep-analysis smoke tests. */
|
/** Run platform-specific deep-analysis smoke tests. */
|
||||||
export async function verifyPackagePlatform({ cli, environment }) {
|
export async function verifyPackagePlatform({
|
||||||
if (process.platform === "linux") {
|
cli,
|
||||||
|
environment,
|
||||||
|
platform = process.platform,
|
||||||
|
runCommand = run,
|
||||||
|
}) {
|
||||||
|
if (platform === "linux") {
|
||||||
const unsupportedExecution = await runWithStatus(
|
const unsupportedExecution = await runWithStatus(
|
||||||
cli,
|
cli,
|
||||||
["analyze", process.execPath, "--json"],
|
["analyze", process.execPath, "--json"],
|
||||||
@@ -11,25 +16,27 @@ export async function verifyPackagePlatform({ cli, environment }) {
|
|||||||
assertLinuxPackageProviderFailure(unsupportedExecution);
|
assertLinuxPackageProviderFailure(unsupportedExecution);
|
||||||
} else {
|
} else {
|
||||||
const overview = json(
|
const overview = json(
|
||||||
await run(cli, ["analyze", process.execPath, "--json"], environment),
|
await runCommand(
|
||||||
|
cli,
|
||||||
|
["analyze", process.execPath, "--json"],
|
||||||
|
environment,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
if (
|
if (!hasPositiveProcedureCount(overview))
|
||||||
overview.operation !== "binary_overview" ||
|
|
||||||
overview.normalized_result?.procedure_count < 1
|
|
||||||
)
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`packaged Hopper-backed analyze CLI failed: ${JSON.stringify(overview)}`,
|
`packaged Hopper-backed analyze CLI failed: ${JSON.stringify(overview)}`,
|
||||||
);
|
);
|
||||||
const inspected = json(
|
const inspected = json(
|
||||||
await run(cli, ["inspect", process.execPath, "--json"], environment),
|
await runCommand(
|
||||||
|
cli,
|
||||||
|
["inspect", process.execPath, "--json"],
|
||||||
|
environment,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
if (
|
if (!hasPositiveProcedureCount(inspected))
|
||||||
inspected.operation !== "binary_overview" ||
|
|
||||||
inspected.normalized_result?.procedure_count < 1
|
|
||||||
)
|
|
||||||
throw new Error("packaged inspect CLI failed");
|
throw new Error("packaged inspect CLI failed");
|
||||||
const functionResult = json(
|
const functionResult = json(
|
||||||
await run(
|
await runCommand(
|
||||||
cli,
|
cli,
|
||||||
["function", process.execPath, "0x1000", "--json"],
|
["function", process.execPath, "0x1000", "--json"],
|
||||||
environment,
|
environment,
|
||||||
@@ -44,7 +51,7 @@ export async function verifyPackagePlatform({ cli, environment }) {
|
|||||||
`packaged function CLI failed: ${JSON.stringify(functionResult)}`,
|
`packaged function CLI failed: ${JSON.stringify(functionResult)}`,
|
||||||
);
|
);
|
||||||
const xrefs = json(
|
const xrefs = json(
|
||||||
await run(
|
await runCommand(
|
||||||
cli,
|
cli,
|
||||||
["xrefs", process.execPath, "0x1000", "--json"],
|
["xrefs", process.execPath, "0x1000", "--json"],
|
||||||
environment,
|
environment,
|
||||||
@@ -56,7 +63,7 @@ export async function verifyPackagePlatform({ cli, environment }) {
|
|||||||
)
|
)
|
||||||
throw new Error(`packaged xrefs CLI failed: ${JSON.stringify(xrefs)}`);
|
throw new Error(`packaged xrefs CLI failed: ${JSON.stringify(xrefs)}`);
|
||||||
const trace = json(
|
const trace = json(
|
||||||
await run(
|
await runCommand(
|
||||||
cli,
|
cli,
|
||||||
["trace", process.execPath, "fixture", "--json"],
|
["trace", process.execPath, "fixture", "--json"],
|
||||||
environment,
|
environment,
|
||||||
@@ -93,3 +100,10 @@ export const assertLinuxPackageProviderFailure = (execution) => {
|
|||||||
`packaged Linux Hopper verification did not fail closed: ${JSON.stringify(failure)}`,
|
`packaged Linux Hopper verification did not fail closed: ${JSON.stringify(failure)}`,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const hasPositiveProcedureCount = (result) =>
|
||||||
|
typeof result === "object" &&
|
||||||
|
result !== null &&
|
||||||
|
result.operation === "binary_overview" &&
|
||||||
|
Number.isInteger(result.normalized_result?.procedure_count) &&
|
||||||
|
result.normalized_result.procedure_count > 0;
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { TOOL_CONTRACTS } from "./toolContracts.js";
|
import { TOOL_CONTRACTS } from "./toolContracts.js";
|
||||||
import { TOOL_EFFECTS, annotationsFromEffects } from "./toolEffects.js";
|
import {
|
||||||
|
TOOL_EFFECTS,
|
||||||
|
annotationsFromEffects,
|
||||||
|
type ToolEffects,
|
||||||
|
} from "./toolEffects.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Descriptions that name running, launching, executing, starting, installing,
|
* Descriptions that name running, launching, executing, starting, installing,
|
||||||
@@ -148,8 +152,19 @@ describe("tool effects", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("derives destructiveHint from each destructive effect alone", () => {
|
it("derives destructiveHint from each destructive effect alone", () => {
|
||||||
const base = TOOL_EFFECTS["binary_session"];
|
// Keep annotation algebra independent of any operation's audited effects.
|
||||||
if (base === undefined) throw new Error("binary_session is unaudited");
|
const base: ToolEffects = {
|
||||||
|
mutatesTarget: false,
|
||||||
|
mutatesSession: false,
|
||||||
|
writesFilesystem: false,
|
||||||
|
launchesProcess: false,
|
||||||
|
accessesNetwork: false,
|
||||||
|
changesUiState: false,
|
||||||
|
mayDiscardData: false,
|
||||||
|
executesForeignCode: false,
|
||||||
|
mutatesDevice: false,
|
||||||
|
idempotent: true,
|
||||||
|
};
|
||||||
expect(annotationsFromEffects(base)).toEqual({
|
expect(annotationsFromEffects(base)).toEqual({
|
||||||
readOnlyHint: true,
|
readOnlyHint: true,
|
||||||
destructiveHint: false,
|
destructiveHint: false,
|
||||||
|
|||||||
@@ -605,7 +605,7 @@ export const TOOL_EFFECTS: Readonly<Record<string, ToolEffects>> = {
|
|||||||
mayDiscardData: true,
|
mayDiscardData: true,
|
||||||
idempotent: false,
|
idempotent: false,
|
||||||
}),
|
}),
|
||||||
binary_session: effects(),
|
binary_session: effects({ launchesProcess: true }),
|
||||||
export_evidence_bundle: effects({
|
export_evidence_bundle: effects({
|
||||||
writesFilesystem: true,
|
writesFilesystem: true,
|
||||||
mayDiscardData: true,
|
mayDiscardData: true,
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import { describe, expect, it } from "vitest";
|
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 = {
|
const missingDisplay = {
|
||||||
code: "provider_unavailable",
|
code: "provider_unavailable",
|
||||||
@@ -22,6 +25,37 @@ const execution = (failure: unknown, status = 1) => ({
|
|||||||
stdout: JSON.stringify(failure),
|
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", () => {
|
describe("packaged Linux failure verification", () => {
|
||||||
it("accepts the unsupported fixture build or an exact missing display dependency", () => {
|
it("accepts the unsupported fixture build or an exact missing display dependency", () => {
|
||||||
expect(() =>
|
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