test(hopper): cover verified Linux rejection

This commit is contained in:
N0zoM1z0
2026-07-14 21:15:06 +00:00
parent e27f635b73
commit e67d77c8c9
2 changed files with 128 additions and 99 deletions
+32 -3
View File
@@ -170,6 +170,21 @@ try {
throw new Error("packaged artifact inventory CLI failed"); throw new Error("packaged artifact inventory CLI failed");
// prettier-ignore // prettier-ignore
await verifyPackagedInvestigation({ cli, workspace, evidenceRoot, artifactArchive, environment }); await verifyPackagedInvestigation({ cli, workspace, evidenceRoot, artifactArchive, environment });
if (process.platform === "linux") {
const unsupportedExecution = await runWithStatus(
cli,
["analyze", process.execPath, "--json"],
environment,
);
const unsupported = json(unsupportedExecution.stdout);
if (
unsupportedExecution.status !== 1 ||
unsupported.details?.failure_code !== "unsupported_hopper_build"
)
throw new Error(
`packaged Linux Hopper verification did not fail closed: ${JSON.stringify(unsupported)}`,
);
} else {
const overview = json( const overview = json(
await run(cli, ["analyze", process.execPath, "--json"], environment), await run(cli, ["analyze", process.execPath, "--json"], environment),
); );
@@ -236,6 +251,7 @@ try {
); );
if (trace.operation !== "trace_feature") if (trace.operation !== "trace_feature")
throw new Error(`packaged trace CLI failed: ${JSON.stringify(trace)}`); throw new Error(`packaged trace CLI failed: ${JSON.stringify(trace)}`);
}
const capabilities = json( const capabilities = json(
await run(cli, ["capabilities", "--json"], environment), await run(cli, ["capabilities", "--json"], environment),
); );
@@ -247,6 +263,7 @@ try {
providers.providers.some(({ id }) => typeof id !== "string") providers.providers.some(({ id }) => typeof id !== "string")
) )
throw new Error("packaged providers CLI failed"); throw new Error("packaged providers CLI failed");
if (process.platform !== "linux") {
const searchResult = json( const searchResult = json(
await run( await run(
cli, cli,
@@ -261,6 +278,7 @@ try {
throw new Error( throw new Error(
`packaged search CLI failed: ${JSON.stringify(searchResult)}`, `packaged search CLI failed: ${JSON.stringify(searchResult)}`,
); );
}
const referenceImport = json( const referenceImport = json(
await run( await run(
cli, cli,
@@ -478,15 +496,25 @@ try {
); );
if (opened.isError === true) if (opened.isError === true)
throw new Error("packaged MCP could not open a binary"); throw new Error("packaged MCP could not open a binary");
await prompts.verifyPromptCompletion(client, mcpOptions, true); await prompts.verifyPromptCompletion(
client,
mcpOptions,
process.platform !== "linux",
);
const current = await client.callTool( const current = await client.callTool(
{ name: "current_document", arguments: {} }, { name: "current_document", arguments: {} },
mcpOptions, mcpOptions,
); );
if (process.platform === "linux") {
if ( if (
current.isError === true || current.isError !== true ||
json(prompts.mcpText(current)).normalized_result !== "fixture" !prompts
.mcpText(current)
.includes("not supported for unattended Linux analysis")
) )
throw new Error("packaged Linux MCP did not reject an unpinned Hopper");
} else {
if (json(prompts.mcpText(current)).normalized_result !== "fixture")
throw new Error("packaged MCP bridge call failed"); throw new Error("packaged MCP bridge call failed");
const batch = await client.callTool( const batch = await client.callTool(
{ name: "batch_decompile", arguments: { addresses: ["0x1000"] } }, { name: "batch_decompile", arguments: { addresses: ["0x1000"] } },
@@ -502,6 +530,7 @@ try {
batchResult?.items?.[0]?.pseudocode !== "return 0;" batchResult?.items?.[0]?.pseudocode !== "return 0;"
) )
throw new Error("packaged MCP structured batch result failed"); throw new Error("packaged MCP structured batch result failed");
}
const closed = await client.callTool( const closed = await client.callTool(
{ name: "close_binary", arguments: {} }, { name: "close_binary", arguments: {} },
mcpOptions, mcpOptions,
+2 -2
View File
@@ -37,7 +37,7 @@ describe("production stdio runtime", () => {
name: "current_document", name: "current_document",
arguments: {}, arguments: {},
}); });
expect(result.isError).not.toBe(true); expect(result.isError === true).toBe(process.platform === "linux");
} finally { } finally {
await client.close(); await client.close();
await transport.close(); await transport.close();
@@ -53,7 +53,7 @@ describe("production stdio runtime", () => {
mode: "mcp", mode: "mcp",
layer: "server", layer: "server",
tool: "current_document", tool: "current_document",
status: "ok", status: process.platform === "linux" ? "error" : "ok",
}), }),
); );
expect(stderr).not.toContain("HOPPER_LOADER_ARGS_JSON"); expect(stderr).not.toContain("HOPPER_LOADER_ARGS_JSON");