fix(verify): remove stale mocked bridge package probe

This commit is contained in:
morluto
2026-10-09 05:53:52 +08:00
parent c3136064c7
commit 826583dd43
2 changed files with 13 additions and 64 deletions
+1 -1
View File
@@ -71,6 +71,6 @@ export async function verifyPackagePack({ root, workspace }) {
) {
throw new Error("package contained generated Python bytecode");
}
await verifyPackedBridge({ root, workspace, tarball, packedFiles });
await verifyPackedBridge({ workspace, tarball, packedFiles });
return { tarball };
}
+12 -63
View File
@@ -1,5 +1,4 @@
import { execFile } from "node:child_process";
import { readFile } from "node:fs/promises";
import { join } from "node:path";
import { promisify } from "node:util";
@@ -7,67 +6,17 @@ const exec = promisify(execFile);
const packedHopperBridge = "package/bridge/hopper_bridge.py";
const packedGhidraBridge = "package/bridge/ghidra/ReaGhidraBridge.java";
/** Verify regex search through the packaged production bridge. */
export async function verifyPackedBridge({
root,
workspace,
tarball,
packedFiles,
}) {
if (!packedFiles.includes(packedHopperBridge))
throw new Error("package omitted the Hopper bridge");
if (!packedFiles.includes(packedGhidraBridge))
throw new Error("package omitted the Ghidra bridge");
/** Check shipped bridge files; real-provider lanes verify runtime behavior. */
export async function verifyPackedBridge({ workspace, tarball, packedFiles }) {
for (const path of [packedHopperBridge, packedGhidraBridge]) {
if (!packedFiles.includes(path)) throw new Error(`package omitted ${path}`);
}
await exec("tar", ["-xf", tarball, "-C", workspace]);
const ghidraSource = await readFile(
join(workspace, packedGhidraBridge),
"utf8",
);
for (const commitment of [
"extends HeadlessScript",
'request.method.equals("ping")',
'request.method.equals("shutdown")',
'boolean readOnly = !descriptor.transport.equals("unix-socket")',
'result.addProperty("read_only", readOnly)',
'case "annotate_native_function"',
'currentProgram.startTransaction("REA function annotations")',
"currentProgram.endTransaction(transaction, commit)",
"analysisTimeoutOccurred()",
])
if (!ghidraSource.includes(commitment))
throw new Error(`packaged Ghidra bridge omitted ${commitment}`);
const probe = JSON.parse(
(
await exec("python3", [
join(root, "tests/fixtures/bridgeSearchProbe.py"),
join(workspace, packedHopperBridge),
JSON.stringify({
action: "search",
items: [
["0x1000", "REA_GHIDRA_INVENTORY_ENTRY"],
["0x2000", "unrelated"],
["0x3000", "REA_GHIDRA_LEAF_VALUE"],
],
params: {
pattern: "^REA_GHIDRA_(?:INVENTORY_ENTRY|LEAF_VALUE)$",
mode: "regex",
case_sensitive: true,
},
}),
])
).stdout,
);
const matches = probe.result;
if (
probe.ok !== true ||
!Array.isArray(matches) ||
matches.length !== 2 ||
matches[0]?.address !== "0x1000" ||
matches[0]?.value !== "REA_GHIDRA_INVENTORY_ENTRY" ||
matches[1]?.address !== "0x3000" ||
matches[1]?.value !== "REA_GHIDRA_LEAF_VALUE"
)
throw new Error(
`packaged Hopper bridge regex search drifted: ${JSON.stringify(probe)}`,
);
// Parse the actual packed Python source without loading Hopper globals or
// generating bytecode. This check has no dependency on test-only fixtures.
await exec("python3", [
"-c",
"import ast, pathlib, sys; p = pathlib.Path(sys.argv[1]); ast.parse(p.read_text(encoding='utf-8'), filename=str(p))",
join(workspace, packedHopperBridge),
]);
}