mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-16 05:00:59 +08:00
- Pin GNU runtime packs to glibc 2.36 Zig targets and reject incompatible imports. - Provision verified Zig builds and exercise published artifacts on Debian Bookworm. Fixes #349 Co-authored-by: Cruel <383999+Cruel@users.noreply.github.com>
33 lines
1.3 KiB
JavaScript
33 lines
1.3 KiB
JavaScript
import { readFile, readdir } from "node:fs/promises";
|
|
import { join, relative, sep } from "node:path";
|
|
|
|
export async function assertArtifactsExcludeStrings(root, forbiddenStrings) {
|
|
if (!Array.isArray(forbiddenStrings)) {
|
|
throw new Error("runtime-pack forbidden artifact strings must be an array");
|
|
}
|
|
if (forbiddenStrings.length === 0) return;
|
|
if (forbiddenStrings.some((value) => typeof value !== "string" || value.length === 0)) {
|
|
throw new Error("runtime-pack forbidden artifact strings must be non-empty strings");
|
|
}
|
|
const forbidden = forbiddenStrings.map((value) => ({ value, bytes: Buffer.from(value) }));
|
|
const visit = async (directory) => {
|
|
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
|
const path = join(directory, entry.name);
|
|
if (entry.isDirectory()) {
|
|
await visit(path);
|
|
continue;
|
|
}
|
|
if (!entry.isFile()) continue;
|
|
const bytes = await readFile(path);
|
|
const match = forbidden.find((candidate) => bytes.includes(candidate.bytes));
|
|
if (match !== undefined) {
|
|
const artifact = relative(root, path).split(sep).join("/");
|
|
throw new Error(
|
|
`runtime-pack artifact ${artifact} contains forbidden symbol family ${match.value}`,
|
|
);
|
|
}
|
|
}
|
|
};
|
|
await visit(root);
|
|
}
|