merge: complete immutable release verification

This commit is contained in:
donghyeon-ka
2026-07-25 21:45:02 +09:00
2 changed files with 25 additions and 5 deletions
+13 -4
View File
@@ -7,6 +7,11 @@ const securityPolicy = JSON.parse(
await readFile("config/hosting/security-headers.json", "utf8"), await readFile("config/hosting/security-headers.json", "utf8"),
); );
const baseUrl = process.env.HOSTING_BASE_URL; const baseUrl = process.env.HOSTING_BASE_URL;
const distFiles = (await readdir("dist", { recursive: true })).map(String);
const publicSourceMaps = distFiles.filter((file) => file.endsWith(".map"));
const publicServiceWorkers = distFiles.filter((file) =>
/(?:^|\/)(?:service-worker|sw)(?:[.-][^/]*)?\.js$/i.test(file),
);
/** @type {Record<string, Record<string, string>>} */ /** @type {Record<string, Record<string, string>>} */
let responses; let responses;
@@ -81,15 +86,19 @@ results.push({
surface: "sourceMap", surface: "sourceMap",
header: "public", header: "public",
expected: false, expected: false,
observed: cachePolicy.surfaces.sourceMap.public, observed: publicSourceMaps.length > 0,
passed: cachePolicy.surfaces.sourceMap.public === false, passed:
cachePolicy.surfaces.sourceMap.public === false &&
publicSourceMaps.length === 0,
}); });
results.push({ results.push({
surface: "serviceWorker", surface: "serviceWorker",
header: "enabled", header: "enabled",
expected: false, expected: false,
observed: cachePolicy.surfaces.serviceWorker.enabled, observed: publicServiceWorkers.length > 0,
passed: cachePolicy.surfaces.serviceWorker.enabled === false, passed:
cachePolicy.surfaces.serviceWorker.enabled === false &&
publicServiceWorkers.length === 0,
}); });
const passed = results.every((result) => result.passed); const passed = results.every((result) => result.passed);
+12 -1
View File
@@ -2,7 +2,10 @@ import { createHash } from "node:crypto";
import { mkdir, readFile, writeFile } from "node:fs/promises"; import { mkdir, readFile, writeFile } from "node:fs/promises";
import { verifyCompatibilityTuple } from "../src/application/policies/compatibility.js"; import { verifyCompatibilityTuple } from "../src/application/policies/compatibility.js";
import { compareReleaseToRuntime } from "../src/contracts/release-tokens.js"; import {
compareReleaseToRuntime,
RELEASE_TOKEN_REGISTRY,
} from "../src/contracts/release-tokens.js";
const fixturesDocument = const fixturesDocument =
/** @type {{ /** @type {{
@@ -38,6 +41,14 @@ const actualAssetManifestHash = createHash("sha256")
const artifactComparison = compareReleaseToRuntime(release, runtimeConfig); const artifactComparison = compareReleaseToRuntime(release, runtimeConfig);
const artifactMismatches = [...artifactComparison.mismatches]; const artifactMismatches = [...artifactComparison.mismatches];
for (const token of Object.keys(RELEASE_TOKEN_REGISTRY)) {
if (typeof release[token] !== "string" || release[token].length === 0) {
artifactMismatches.push(`releaseToken:${token}`);
}
}
if (!Number.isFinite(Date.parse(release.builtAt))) {
artifactMismatches.push("releaseToken:builtAtFormat");
}
if (release.assetManifestHash !== actualAssetManifestHash) { if (release.assetManifestHash !== actualAssetManifestHash) {
artifactMismatches.push("assetManifestContent"); artifactMismatches.push("assetManifestContent");
} }