mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-22 05:59:31 +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>
32 lines
1.4 KiB
TypeScript
32 lines
1.4 KiB
TypeScript
import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { expect, test } from "vitest";
|
|
import { assertArtifactsExcludeStrings } from "../scripts/artifact-policy.mjs";
|
|
|
|
test("accepts artifacts whose imports stay within the declared libc floor", async () => {
|
|
const root = await mkdtemp(join(tmpdir(), "scriptc-artifact-policy-"));
|
|
try {
|
|
await writeFile(join(root, "runtime.o"), Buffer.from("strtol\0__isoc99_sscanf\0"));
|
|
await expect(assertArtifactsExcludeStrings(root, ["__isoc23_", "__ubsan_"])).resolves.toBeUndefined();
|
|
} finally {
|
|
await rm(root, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
test.each([
|
|
["__isoc23_sscanf", "__isoc23_"],
|
|
["__ubsan_handle_add_overflow", "__ubsan_"],
|
|
])("rejects the %s import in nested runtime artifacts", async (symbol, family) => {
|
|
const root = await mkdtemp(join(tmpdir(), "scriptc-artifact-policy-"));
|
|
try {
|
|
await mkdir(join(root, "release", "runtime"), { recursive: true });
|
|
await writeFile(join(root, "release", "runtime", "scr_lib.o"), Buffer.from(`${symbol}\0`));
|
|
await expect(assertArtifactsExcludeStrings(root, ["__isoc23_", "__ubsan_"])).rejects.toThrow(
|
|
`runtime-pack artifact release/runtime/scr_lib.o contains forbidden symbol family ${family}`,
|
|
);
|
|
} finally {
|
|
await rm(root, { recursive: true, force: true });
|
|
}
|
|
});
|