정리 4단계의 R2 검사는 등록부를 쓰는 7곳만 봤다. 그 밖에 루트 이름을 담은 목록이 코드 15파일에 19개 따로 있어, 루트 항목 하나를 옮기면 여전히 여러 곳을 같이 고쳐야 했다. - 등록부에 집합 12개를 더했다. 사본 복사에서 건너뛰는 항목 셋 (checkout·provider·공급망 fixture), fixture 코드 범위, pnpm 매니페스트, Playwright 설정, visual 증거, 문서 입력, 에이전트 하네스, tsconfig 묶음 셋. 각 집합 설명에 읽는 파일을 적었다. - 사본이 건너뛰는 node_modules·dist·.tmp 같은 추적 안 하는 항목은 종류 untracked(optional)로 적는다. 추적 파일이 있으면 시험이 실패한다. - 19개 목록이 모두 집합을 고른다. 집합의 원소는 전과 같아 동작은 바뀌지 않는다. - R2 시험이 추적되는 코드 파일 전체를 본다. 루트 항목(이나 그 안 경로)만 담은 문자열 배열에 추적되는 루트 이름이 둘 이상이면 실패. 인자 목록은 `--` 뒤만 본다. main의 옛 목록 18개를 이 검사가 잡는 것을 확인했다. - 집합마다 selectRepositoryPaths·selectRepositoryEntries로 고르는 코드가 있는지 본다. 문서를 복사하지 않는 제거 drill(FE-GATE-020)은 문서 시험(REMOVAL_FIXTURE_DOCUMENT_TESTS)을 지우는데, 집합 셋 (agent-harness·documentation-inputs·feature-typecheck)은 그 시험만 읽는다. 시험이 이 셋을 적어 두고, 문서 시험이 지워진 사본에서만 셋이 비는 것을 허용한다. 셋이 바뀌면 전체 checkout에서 실패한다. - 파서가 kinds·sets 설명과 코드의 목록이 같은지 본다. - .gitignore 주석이 a11y 기록을 아직 artifacts/ 아래라고 적던 것을 고쳤다(정리 3단계에서 docs/로 옮김). 검증(desktop): test:unit, check:types, check:ci, lint, verify:documentation. repository-layout 시험을 문서 없는 제거 사본과 feature-scaffold 사본에서도 돌렸고, 집합 하나의 읽는 곳을 지우면 두 곳 모두 실패한다.
163 lines
5.6 KiB
TypeScript
163 lines
5.6 KiB
TypeScript
import { spawnSync } from "node:child_process";
|
|
import { cp, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
|
|
import { expect, it } from "vitest";
|
|
|
|
import {
|
|
captureCiCandidateArchive,
|
|
withVerifiedCapturedCandidate,
|
|
} from "../../scripts/lib/ci-candidate-archive.ts";
|
|
import { verifyArchivedLocalEvidence } from "../../scripts/lib/local-release-evidence.ts";
|
|
import {
|
|
RELEASE_CANDIDATE_EVIDENCE_PATHS,
|
|
RELEASE_CANDIDATE_MANIFEST_PATH,
|
|
releaseCandidateManifestSchema,
|
|
} from "../../scripts/lib/release-candidate.ts";
|
|
import {
|
|
FIXTURE_PNPM_ENVIRONMENT,
|
|
linkFixtureNodeModules,
|
|
} from "../../scripts/lib/fixture-node-modules.ts";
|
|
import { selectRepositoryPaths } from "../../scripts/lib/repository-layout.ts";
|
|
|
|
it(
|
|
"builds a real candidate assessment and passes the default archived verifier from the captured archive",
|
|
async () => {
|
|
const sourceRoot = process.cwd();
|
|
const fixtureRoot = await mkdtemp(path.join(tmpdir(), "security-followup-producer-"));
|
|
try {
|
|
await cp(sourceRoot, fixtureRoot, {
|
|
recursive: true,
|
|
filter: (source) => {
|
|
const relative = path.relative(sourceRoot, source);
|
|
if (!relative) return true;
|
|
const first = relative.split(path.sep)[0];
|
|
return !selectRepositoryPaths("supply-chain-fixture-skip").includes(first ?? "");
|
|
},
|
|
});
|
|
await cp(path.join(sourceRoot, "artifacts"), path.join(fixtureRoot, "artifacts"), {
|
|
recursive: true,
|
|
});
|
|
await rm(path.join(fixtureRoot, "artifacts/release"), {
|
|
recursive: true,
|
|
force: true,
|
|
});
|
|
await linkFixtureNodeModules(fixtureRoot, sourceRoot);
|
|
const git = spawnSync("git", ["show", "-s", "--format=%H%n%ct", "HEAD"], {
|
|
cwd: sourceRoot,
|
|
encoding: "utf8",
|
|
});
|
|
expect(git.status, git.stderr).toBe(0);
|
|
const [revision, sourceDateEpoch] = git.stdout.trim().split(/\r?\n/u);
|
|
const build = spawnSync(
|
|
"corepack",
|
|
["pnpm", "build:release-candidate"],
|
|
{
|
|
cwd: fixtureRoot,
|
|
encoding: "utf8",
|
|
timeout: 120_000,
|
|
maxBuffer: 32 * 1024 * 1024,
|
|
env: {
|
|
...process.env,
|
|
...FIXTURE_PNPM_ENVIRONMENT,
|
|
CI: "true",
|
|
VITE_BUILD_ID: "security-followup-integration",
|
|
VITE_COMMIT_SHA: revision,
|
|
RELEASE_ID: "security-followup-integration",
|
|
SOURCE_DATE_EPOCH: sourceDateEpoch,
|
|
CI_RUNNER_IMAGE: `fixture@sha256:${"a".repeat(64)}`,
|
|
},
|
|
},
|
|
);
|
|
expect(build.status, `${build.stdout}\n${build.stderr}`).toBe(0);
|
|
const manifest = releaseCandidateManifestSchema.parse(
|
|
JSON.parse(
|
|
await readFile(path.join(fixtureRoot, RELEASE_CANDIDATE_MANIFEST_PATH), "utf8"),
|
|
) as unknown,
|
|
);
|
|
const archivePath = path.join(fixtureRoot, "candidate.tar.gz");
|
|
const archived = spawnSync(
|
|
"/usr/bin/tar",
|
|
[
|
|
"--sort=name",
|
|
"--mtime=@0",
|
|
"--owner=0",
|
|
"--group=0",
|
|
"--numeric-owner",
|
|
"-czf",
|
|
archivePath,
|
|
"dist",
|
|
...RELEASE_CANDIDATE_EVIDENCE_PATHS,
|
|
RELEASE_CANDIDATE_MANIFEST_PATH,
|
|
],
|
|
{ cwd: fixtureRoot, encoding: "utf8" },
|
|
);
|
|
expect(archived.status, archived.stderr).toBe(0);
|
|
const archiveBytes = await readFile(archivePath);
|
|
const expectedSha256 = await import("node:crypto").then(({ createHash }) =>
|
|
createHash("sha256").update(archiveBytes).digest("hex"),
|
|
);
|
|
const captured = await captureCiCandidateArchive({ archivePath, expectedSha256 });
|
|
const verified = await withVerifiedCapturedCandidate({
|
|
captured,
|
|
verify: ({ extractionRoot, manifest: extractedManifest }) =>
|
|
verifyArchivedLocalEvidence({
|
|
extractionRoot,
|
|
expectedManifest: extractedManifest,
|
|
}),
|
|
});
|
|
|
|
expect(manifest.files).toContainEqual(
|
|
expect.objectContaining({
|
|
path: "artifacts/security/local-evidence-assessment.json",
|
|
}),
|
|
);
|
|
expect(verified).toEqual(
|
|
expect.objectContaining({
|
|
status: "PASS",
|
|
identity: expect.objectContaining({ sourceRevision: revision }),
|
|
failures: [],
|
|
}),
|
|
);
|
|
|
|
const outsideRoot = await mkdtemp(path.join(tmpdir(), "security-followup-outside-"));
|
|
try {
|
|
await mkdir(path.join(outsideRoot, "config/security"), { recursive: true });
|
|
await writeFile(
|
|
path.join(outsideRoot, "config/security/dependency-policy.json"),
|
|
'{"contradictoryCheckoutCanary":"FAIL"}\n',
|
|
);
|
|
const outsideVerification = spawnSync(
|
|
process.execPath,
|
|
[
|
|
path.join(sourceRoot, "scripts/verify-archived-local-evidence.ts"),
|
|
"--archive",
|
|
archivePath,
|
|
"--sha256",
|
|
expectedSha256,
|
|
],
|
|
{
|
|
cwd: outsideRoot,
|
|
encoding: "utf8",
|
|
timeout: 120_000,
|
|
maxBuffer: 32 * 1024 * 1024,
|
|
},
|
|
);
|
|
expect(
|
|
outsideVerification.status,
|
|
`${outsideVerification.stdout}\n${outsideVerification.stderr}`,
|
|
).toBe(0);
|
|
expect(outsideVerification.stdout).toContain(
|
|
"Archived local evidence verification: PASS",
|
|
);
|
|
} finally {
|
|
await rm(outsideRoot, { recursive: true, force: true });
|
|
}
|
|
} finally {
|
|
await rm(fixtureRoot, { recursive: true, force: true });
|
|
}
|
|
},
|
|
150_000,
|
|
);
|