feat(supply-chain): list the packages the bundle ships and state what each proof covers (13-12)

The module inventory named dependency modules external:<file>, so no artifact
said which package versions reach the public bundle. It now records
npm:<name>@<version> ids and a packages list. supply-chain.md states what the
SBOM, bundle list and provenance prove, and one SBOM scope mismatch (scheduler).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-25 23:19:41 +09:00
co-authored by Claude Opus 5.5
parent a5dc851e0d
commit 331ec84037
5 changed files with 106 additions and 4 deletions
+21
View File
@@ -39,6 +39,27 @@ Changing it requires `DEPENDENCY_BASELINE_OWNER` and
`DEPENDENCY_BASELINE_REASON`; editing the digest or hardcoding an empty diff is
rejected.
## 무엇을 증명하고 무엇을 증명하지 않는가
리뷰 13-12. 산출물마다 증명 범위가 다르다. 아래 "증명하지 못하는 것"을 증명된
것으로 읽지 않는다.
| 산출물 | 증명하는 것 | 증명하지 못하는 것 |
|---|---|---|
| SBOM(`artifacts/release/sbom.cdx.json`) | lockfile에 고정된 설치 그래프(`pnpm list --depth Infinity`, `scripts/generate-supply-chain.ts`)와 각 패키지의 sha512 integrity, license | 배포물에 실제로 들어간 부분 집합, 취약점 없음 |
| 번들 패키지 목록(`artifacts/quality/vite-module-inventory.json`의 `packages`) | 배포 번들에 모듈이 하나 이상 들어간 패키지의 `name@version`. Vite가 번들에 넣은 모듈에서 바로 만든다(`scripts/lib/vite-module-inventory.ts`) | 패키지 안의 어떤 코드가 실행되는지, 취약점 없음 |
| local provenance(`artifacts/release/provenance.json`) | dist digest, lockfile, source set, SBOM digest가 서로 맞음 | 빌드 과정이 변조되지 않았음, 빌드한 주체. 서명이 없는 자기 보고다(`builder.id`가 `local:`, `invocationId`가 `LOCAL_UNSIGNED`). `predicateType`이 SLSA provenance v1이어도 SLSA 수준을 뜻하지 않는다 |
| 외부 provenance 서명 | 지정 키 보유자가 이 run, source revision, 후보 digest를 보고 서명함 | 빌드 job 자체의 격리, provider가 성실히 검사했음 |
| 외부 vulnerability 서명 | provider가 이 lockfile·dist에 대해 결과를 주장함 | 오프라인 DB의 최신성, 누락 없음 |
번들 패키지 목록은 SBOM의 production 항목에 모두 들어 있어야 한다. 2026-09-25
기준으로 한 건이 어긋난다. `scheduler@0.27.0`은 `react-dom`의 의존성이라 번들에
들어가지만, SBOM과 `config/security/dependency-baseline.json`은 이것을
`development`로 분류한다. `pnpm list` JSON이 production 트리 아래에서 이 패키지를
다시 보여 주지 않고, 그래서 `scripts/lib/supply-chain.ts`의 순회가 development
경로에서만 이것을 만난다. 분류를 고치면 dependency baseline을 다시 승인해야 하므로
(`update:dependency-baseline`) 이 문서에 알려진 차이로 남긴다.
## External promotion controls
Promotion reads the provider files named by `VULNERABILITY_REPORT_PATH` and
+2
View File
@@ -152,6 +152,8 @@ export const moduleInventoryArtifactSchema = z
})
.strict(),
),
// 13-12: `name@version` of every package with a module in the bundle.
packages: z.array(z.string().regex(/^(?:@[^/@]+\/)?[^/@]+@[^/@]+$/u)),
})
.strict();
+49 -1
View File
@@ -1,3 +1,4 @@
import { readFileSync } from "node:fs";
import path from "node:path";
import type { Plugin } from "vite";
@@ -39,6 +40,7 @@ export function viteModuleInventoryPlugin(
{
schemaVersion: 1,
chunks,
packages: bundledPackages(chunks),
},
null,
2,
@@ -48,7 +50,41 @@ export function viteModuleInventoryPlugin(
};
}
function normalizeModuleId(
/**
* 13-12. The `name@version` of every package with at least one module in the
* emitted bundle: what the public release actually ships, as opposed to the
* SBOM, which lists the whole installed graph.
*/
export function bundledPackages(chunks: readonly ModuleInventoryChunk[]): string[] {
const packages = new Set<string>();
for (const chunk of chunks) {
for (const module of chunk.modules) {
const match = /^npm:((?:@[^/]+\/)?[^/@]+@[^/]+)\//u.exec(module);
if (match?.[1]) packages.add(match[1]);
}
}
return [...packages].sort();
}
const packageManifests = new Map<string, Readonly<{ name: string; version: string }>>();
function installedPackage(directory: string): Readonly<{ name: string; version: string }> {
let manifest = packageManifests.get(directory);
if (!manifest) {
const parsed = JSON.parse(readFileSync(path.join(directory, "package.json"), "utf8")) as {
name?: unknown;
version?: unknown;
};
if (typeof parsed.name !== "string" || typeof parsed.version !== "string") {
throw new TypeError(`bundled package has no name/version: ${directory}`);
}
manifest = Object.freeze({ name: parsed.name, version: parsed.version });
packageManifests.set(directory, manifest);
}
return manifest;
}
export function normalizeModuleId(
moduleId: string,
repositoryRoot: string,
): string {
@@ -56,6 +92,18 @@ function normalizeModuleId(
if (!path.isAbsolute(withoutQuery)) {
return withoutQuery.replaceAll("\\", "/");
}
// 13-12: a dependency module keeps its package identity, read from the
// package.json of the directory it was resolved into.
const file = withoutQuery.replaceAll("\\", "/");
const marker = "/node_modules/";
const at = file.lastIndexOf(marker);
if (at >= 0) {
const segments = file.slice(at + marker.length).split("/");
const nameLength = segments[0]?.startsWith("@") ? 2 : 1;
const directory = file.slice(0, at + marker.length) + segments.slice(0, nameLength).join("/");
const { name, version } = installedPackage(directory);
return `npm:${name}@${version}/${segments.slice(nameLength).join("/")}`;
}
const relative = path.relative(repositoryRoot, withoutQuery);
return relative.startsWith("..")
? `external:${path.basename(withoutQuery)}`
+3 -3
View File
@@ -63,7 +63,7 @@ const buildManifest = {
describe("release artifact contracts", () => {
it("verifies confined build outputs and the raw module inventory bytes", async () => {
const moduleInventoryBytes = Buffer.from(
'{"schemaVersion":1,"chunks":[]}\n',
'{"schemaVersion":1,"chunks":[],"packages":[]}\n',
);
const files = new Map<string, Buffer>([
["/repo/dist/.vite/manifest.json", Buffer.from("{}\n")],
@@ -158,7 +158,7 @@ describe("release artifact contracts", () => {
it("rejects a nested symlink that resolves inside the repository but outside dist", async () => {
const moduleInventoryBytes = Buffer.from(
'{"schemaVersion":1,"chunks":[]}\n',
'{"schemaVersion":1,"chunks":[],"packages":[]}\n',
);
const mismatches = await verifyBuildManifestOutputs(
{
@@ -183,7 +183,7 @@ describe("release artifact contracts", () => {
it("allows a legal dist child whose name begins with two dots", async () => {
const moduleInventoryBytes = Buffer.from(
'{"schemaVersion":1,"chunks":[]}\n',
'{"schemaVersion":1,"chunks":[],"packages":[]}\n',
);
const files = new Map<string, Buffer>([
["/repo/dist/.vite/manifest.json", Buffer.from("{}\n")],
+31
View File
@@ -0,0 +1,31 @@
import { readFileSync, realpathSync } from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
import { bundledPackages, normalizeModuleId } from "../../scripts/lib/vite-module-inventory.ts";
// 13-12. The inventory recorded dependency modules as `external:<file name>`,
// so nothing listed which package versions ship in the public bundle.
describe("vite module inventory", () => {
const root = process.cwd();
const zodCore = realpathSync(path.join(root, "node_modules/zod/v4/core/core.js"));
const zodVersion = (
JSON.parse(readFileSync(path.join(root, "node_modules/zod/package.json"), "utf8")) as { version: string }
).version;
it("names a dependency module by package and version", () => {
expect(normalizeModuleId(zodCore, root)).toBe(`npm:zod@${zodVersion}/v4/core/core.js`);
expect(normalizeModuleId(path.join(root, "src/bootstrap/main.tsx"), root)).toBe("src/bootstrap/main.tsx");
expect(normalizeModuleId("\0vite/preload-helper.js", root)).toBe("vite/preload-helper.js");
});
it("lists each bundled package once", () => {
expect(
bundledPackages([
{ fileName: "a.js", modules: ["npm:zod@4.4.3/v4/core/core.js", "src/a.ts"] },
{ fileName: "b.js", modules: ["npm:@tanstack/query-core@5.0.0/build/a.js", "npm:zod@4.4.3/index.js"] },
]),
).toEqual(["@tanstack/query-core@5.0.0", "zod@4.4.3"]);
});
});