fix(ci): immutable_build가 gate 로그와 advisory 기록을 항상 올린다
문제: ci:gate는 명령 출력을 artifacts/quality/gates/FE-GATE-<NNN>.txt에만 쓰고 콘솔에는 PASS/FAIL 한 줄만 남긴다(scripts/run-ci-gate.ts). release 단계 job immutable_build는 후보 tar만, 그것도 성공했을 때만 올린다. 그래서 실제 run에서 FE-GATE-015·027이 왜 실패했는지와 FE-GATE-027이 쓰는 artifacts/security/dependency-advisories.json(1103/13-03의 신호)이 runner 작업 디렉터리와 함께 사라진다. 다른 gate job은 artifacts/를 if: always()로 올린다. 고른 방법: - config/ci/gates.json의 immutable_build 마지막에 upload 단계를 더한다. transfer ID는 immutable-gate-evidence, 이름은 immutable-gate-evidence-<run>-<attempt>, always: true. 대상은 FE-GATE-015·027의 log와 evidence 산출물(gate 순서)과 advisory 기록 7개다. FE-GATE-015의 verification.json 등은 후보가 만들어지지 않으면 후보 안에도 없으므로 같이 올린다. - 계약(scripts/contracts/ci-gates.ts)이 이 단계를 고정한다. immutable_build의 단계 목록에 upload 하나가 늘고, 이 upload가 always이고 마지막 단계이며 경로가 "job이 도는 gate의 log·evidence 경로 + advisory 기록"과 같아야 한다. 경로는 계약의 artifact 등록에서 계산하므로 log 경로가 바뀌면 함께 따라온다. advisory 기록은 gate evidence가 아니라(막지 않는 신호) 경로를 scripts/lib/dependency-advisories.ts의 상수로 옮기고 scan 스크립트도 그 상수를 쓴다. - 후보 archive의 member set, 후보 upload(always 없음), 하위 job의 download는 그대로다. 생성 workflow를 generator 출력과 같게 손으로 고쳤다. 버린 대안: - immutable_build도 artifacts/ 전체를 올림: 다른 job과 같지만 후보 증거가 두 이름으로 나가 어느 것이 승격 대상인지 흐려진다. 필요한 파일만 고정했다. - ci:gate가 실패한 명령의 마지막 N줄을 콘솔에 씀(리뷰 대안 c, d의 콘솔 한 줄 포함): 모든 job에 걸리고 provider 출력의 비밀 노출과 로그 상한을 다시 따져야 한다. 담당 지시 범위(업로드) 밖이라 이번에 하지 않았다. 위험·한계: - checkout·install 단계에서 실패하면 올릴 파일이 없어 이 단계도 if-no-files-found: error로 실패한다. job은 이미 실패한 뒤라 결과는 같다. merge·release job의 upload도 같은 동작이다. - 실제 Gitea runner에서 stage=release를 돌려 산출물이 남는지는 확인하지 못했다(runner 없음). 확인한 것은 계약·생성 workflow까지다. - 콘솔에는 여전히 한 줄만 나온다. 사람이 산출물을 열어야 이유를 본다. 검증: desktop batch에서 확인 - node scripts/run-vitest.ts run tests/unit/ci-workflow-generation.test.ts - corepack pnpm check:ci, check:types, lint, verify:documentation Refs: 1105/13-01, 1103/13-03
This commit is contained in:
@@ -4,6 +4,7 @@ import path from "node:path";
|
||||
|
||||
import { z } from "zod";
|
||||
|
||||
import { DEPENDENCY_ADVISORIES_RECORD_PATH } from "../lib/dependency-advisories.ts";
|
||||
import { PROMOTION_FORMULA } from "../lib/promotion-readiness.ts";
|
||||
import {
|
||||
RELEASE_CANDIDATE_EVIDENCE_PATHS,
|
||||
@@ -952,7 +953,7 @@ function validateContractSemantics(
|
||||
const expectedStepKinds: Readonly<Record<string, readonly CiWorkflowStep["kind"][]>> = {
|
||||
merge_gate: ["checkout", "setup-node", "frozen-install", "browser-install", "run-gate", "upload"],
|
||||
release_gate: ["checkout", "setup-node", "frozen-install", "browser-install", "run-gate", "upload"],
|
||||
immutable_build: ["checkout", "setup-node", "frozen-install", "run-gate", "archive-candidate", "upload"],
|
||||
immutable_build: ["checkout", "setup-node", "frozen-install", "run-gate", "archive-candidate", "upload", "upload"],
|
||||
vulnerability_provider: ["checkout", "setup-node", "frozen-install", "download", "run-provider", "validate-provider-evidence", "upload"],
|
||||
provenance_provider: ["checkout", "setup-node", "frozen-install", "download", "run-provider", "validate-provider-evidence", "upload"],
|
||||
promotion: ["checkout", "setup-node", "frozen-install", "download", "download", "download", "verify-promotion", "upload", "cleanup-promotion"],
|
||||
@@ -1150,6 +1151,29 @@ function validateContractSemantics(
|
||||
validateCanonicalStepFields(contract, issue);
|
||||
}
|
||||
|
||||
const IMMUTABLE_GATE_EVIDENCE_TRANSFER_ID = "immutable-gate-evidence";
|
||||
|
||||
/**
|
||||
* 1105/13-01. What immutable_build uploads besides the candidate: the log and
|
||||
* evidence artifacts of each gate it runs, in gate order, then the advisory
|
||||
* record of scan:dependency-advisories (FE-GATE-027), which is not a gate
|
||||
* evidence artifact because it never blocks.
|
||||
*/
|
||||
function immutableGateEvidencePaths(
|
||||
contract: Pick<z.infer<typeof ciGateContractBaseSchema>, "artifacts" | "gates">,
|
||||
immutable: Pick<z.infer<typeof jobSchema>, "gateIds">,
|
||||
): string[] {
|
||||
const paths = immutable.gateIds.flatMap((gateId) => {
|
||||
const gate = contract.gates.find(({ id }) => id === gateId);
|
||||
return gate
|
||||
? [gate.logArtifactId, ...gate.evidenceArtifactIds].flatMap((artifactId) =>
|
||||
contract.artifacts.filter(({ id }) => id === artifactId).map(({ path: artifactPath }) => artifactPath),
|
||||
)
|
||||
: [];
|
||||
});
|
||||
return [...new Set([...paths, DEPENDENCY_ADVISORIES_RECORD_PATH])];
|
||||
}
|
||||
|
||||
function validateCanonicalStepFields(
|
||||
contract: z.infer<typeof ciGateContractBaseSchema>,
|
||||
issue: (message: string, path?: PropertyKey[]) => void,
|
||||
@@ -1168,6 +1192,26 @@ function validateCanonicalStepFields(
|
||||
) {
|
||||
issue("immutable archive and upload fields must remain linked");
|
||||
}
|
||||
// 1105/13-01. ci:gate writes command output only to the gate log and prints
|
||||
// one PASS/FAIL line, and this job uploaded only the candidate, on success.
|
||||
// Why FE-GATE-015 or FE-GATE-027 failed, and the advisory record FE-GATE-027
|
||||
// writes, went with the runner's workspace. A separate transfer, always and
|
||||
// last, carries them; the candidate archive's member set stays as it is.
|
||||
const gateEvidence = immutable?.steps.find(
|
||||
(step) => step.kind === "upload" && step.transferId === IMMUTABLE_GATE_EVIDENCE_TRANSFER_ID,
|
||||
);
|
||||
if (
|
||||
!immutable ||
|
||||
gateEvidence?.kind !== "upload" ||
|
||||
gateEvidence.always !== true ||
|
||||
immutable.steps.at(-1) !== gateEvidence ||
|
||||
JSON.stringify(gateEvidence.paths) !== JSON.stringify(immutableGateEvidencePaths(contract, immutable))
|
||||
) {
|
||||
issue(
|
||||
"immutable_build must upload its gates' logs and evidence and the dependency advisory record " +
|
||||
`as ${IMMUTABLE_GATE_EVIDENCE_TRANSFER_ID}, with always, as its last step`,
|
||||
);
|
||||
}
|
||||
|
||||
const providerExpectations = {
|
||||
vulnerability_provider: {
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import { validateVulnerabilityReport } from "./supply-chain.ts";
|
||||
|
||||
/**
|
||||
* Where scan:dependency-advisories writes its record. 1105/13-01: the
|
||||
* immutable_build job uploads it on every outcome (scripts/contracts/ci-gates.ts).
|
||||
*/
|
||||
export const DEPENDENCY_ADVISORIES_RECORD_PATH = "artifacts/security/dependency-advisories.json";
|
||||
|
||||
/**
|
||||
* 1103/13-03. The vulnerability verdict belongs to the external provider of
|
||||
* the production promotion (signed, independent of the build). Without a
|
||||
|
||||
@@ -2,7 +2,10 @@ import { spawnSync } from "node:child_process";
|
||||
import { createHash } from "node:crypto";
|
||||
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
|
||||
import { summarizeDependencyAdvisories } from "./lib/dependency-advisories.ts";
|
||||
import {
|
||||
DEPENDENCY_ADVISORIES_RECORD_PATH,
|
||||
summarizeDependencyAdvisories,
|
||||
} from "./lib/dependency-advisories.ts";
|
||||
|
||||
/**
|
||||
* 1103/13-03. Release-stage signal for known dependency advisories
|
||||
@@ -17,7 +20,7 @@ import { summarizeDependencyAdvisories } from "./lib/dependency-advisories.ts";
|
||||
* result is UNVERIFIED, not PASS. The signed verdict of the vulnerability
|
||||
* provider stays the only one that decides a promotion.
|
||||
*/
|
||||
const RECORD_PATH = "artifacts/security/dependency-advisories.json";
|
||||
const RECORD_PATH = DEPENDENCY_ADVISORIES_RECORD_PATH;
|
||||
|
||||
const [policy, exceptions, lockfile] = await Promise.all([
|
||||
readFile("config/security/vulnerability-policy.json", "utf8").then((text) => JSON.parse(text) as Record<string, unknown>),
|
||||
|
||||
Reference in New Issue
Block a user