Files
scriptc/packages/runtime-pack-common/scripts/artifact-policy.mjs
Chris TateandCruel f5ed014cc7 Preserve glibc 2.36 runtime compatibility (#365)
- 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>
2026-09-20 22:36:10 -05:00

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);
}