chore(release): harden package artifacts
This commit is contained in:
@@ -14,6 +14,8 @@ import { promisify } from "node:util";
|
||||
import { Client } from "@modelcontextprotocol/client";
|
||||
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
|
||||
|
||||
// Exercise the packed artifact in isolated HOME and prefix directories so the
|
||||
// verifier cannot mutate real MCP registrations or rely on checkout-only files.
|
||||
const exec = promisify(execFile);
|
||||
const root = process.cwd();
|
||||
const workspace = await mkdtemp(join(tmpdir(), "rea-package-"));
|
||||
@@ -23,6 +25,16 @@ try {
|
||||
tarball = (
|
||||
await exec("npm", ["pack", "--silent"], { cwd: root })
|
||||
).stdout.trim();
|
||||
const packedFiles = (
|
||||
await exec("tar", ["-tf", join(root, tarball)])
|
||||
).stdout.split("\n");
|
||||
if (
|
||||
packedFiles.some(
|
||||
(path) => path.includes("__pycache__") || path.endsWith(".pyc"),
|
||||
)
|
||||
) {
|
||||
throw new Error("package contained generated Python bytecode");
|
||||
}
|
||||
const prefix = join(workspace, "prefix");
|
||||
const home = join(workspace, "home");
|
||||
const fakeBin = join(workspace, "bin");
|
||||
|
||||
@@ -10,9 +10,11 @@ import { TOOL_CONTRACTS } from "../dist/contracts/toolContracts.js";
|
||||
const execFileAsync = promisify(execFile);
|
||||
const timeout = 180_000;
|
||||
const hopperProcessPrefix = "/Applications/Hopper Disassembler.app/Contents/";
|
||||
// Snapshot bundle processes so cleanup terminates only Hopper processes this
|
||||
// verifier caused to appear, never an instance the user already had running.
|
||||
const hopperProcessesBefore = await hopperProcessIds();
|
||||
const sessionsBefore = new Set(
|
||||
(await readdir("/tmp")).filter((name) => name.startsWith("bbm-")),
|
||||
(await readdir("/tmp")).filter((name) => name.startsWith("rea-")),
|
||||
);
|
||||
|
||||
const textValue = (result) => {
|
||||
@@ -163,7 +165,7 @@ try {
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
const sessionsAfter = (await readdir("/tmp")).filter(
|
||||
(name) => name.startsWith("bbm-") && !sessionsBefore.has(name),
|
||||
(name) => name.startsWith("rea-") && !sessionsBefore.has(name),
|
||||
);
|
||||
if (sessionsAfter.length > 0) {
|
||||
throw new Error("The MCP runtime leaked a bridge session directory");
|
||||
|
||||
Reference in New Issue
Block a user