From c5ab7a39838177857410fa56a71e2480725a5cda Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 6 Nov 2026 05:18:09 +0900 Subject: [PATCH] =?UTF-8?q?fix(ci):=20FE-GATE-027=EC=9D=B4=20advisory=20?= =?UTF-8?q?=EA=B2=80=EC=82=AC=EB=A5=BC=20=EC=8A=B9=EC=9D=B8=EB=B3=B4?= =?UTF-8?q?=EB=8B=A4=20=EB=A8=BC=EC=A0=80=20=EB=8F=8C=EB=A6=B0=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FE-GATE-027은 `check:release-admission`을 먼저, `scan:dependency-advisories` 를 뒤에 돈다. `ci:gate`는 처음 실패한 명령에서 멈춘다. 그래서 공개 대상 승인이 거절된 run에는 advisory 기록(`artifacts/security/ dependency-advisories.json`)이 생기지 않는다. 운영 문서는 release 산출물이 결과와 상관없이 이 기록을 싣는다고 적는다. 명령 순서를 scan → 승인으로 바꾼다. scan은 막지 않는 신호라 항상 exit 0이고, 승인 판정과 gate 결과는 그대로다. 문서 두 곳(한국어·영어)에 올라가는 것은 그 run에 생긴 파일이고, 승인이 거절돼도 기록이 있으며, FE-GATE-015가 실패하면 FE-GATE-027이 돌지 않아 기록이 없다고 적는다. gate 모양이 바뀌어 계약 기준선의 `gateShapeSha256`을 다시 적었다(owner DongHyeonka, reason에 1106/13-01, 개수는 그대로). 생성 workflow는 명령 순서를 담지 않아 바뀌지 않는다. 버린 대안: (a) 문서만 고치기 — 거절된 run에서 신호가 한 run 늦는 것이 남는다. (c) scan을 always 단계로 따로 빼기 — 계약 단계와 workflow가 바뀌어 이 결함에 비해 크다. 위험·한계: 승인 전에 pnpm audit이 돌아 거절되는 run이 최대 120초(scan timeout) 늦게 끝난다. scan이 정책 파일을 못 읽어 죽으면 이제 승인이 돌지 않는다(전에도 gate는 실패했다). FE-GATE-015가 실패한 run에는 여전히 기록이 없다. 실제 runner의 upload가 없는 파일을 건너뛰는지는 미확인이다. 제품이 `config/ci/contract-baseline.json`을 자기 값으로 다시 적어 두었다면 받은 뒤 다시 적어야 한다. 새 digest는 jq로 계산했다. 같은 계산이 바꾸기 전 기준선(7bebafe6…)을 그대로 재현했다. 검증: desktop batch에서 확인. `node scripts/run-vitest.ts run tests/system/ci-runner/ci-evidence-freshness.test.ts tests/unit/dependency-advisories.test.ts` — 새 "writes the advisory record when the release admission refuses the candidate"와 바꾼 "runs before the release admission (FE-GATE-027) ..."가 수정 전 계약에서 실패하고 수정 뒤 통과한다. `check:ci`, 13-R1 C. Refs: 1106/13-01 --- config/ci/contract-baseline.json | 4 +- config/ci/gates.json | 4 +- docs/operations/ci-quality-gates.md | 15 ++++- scripts/scan-dependency-advisories.ts | 3 +- .../ci-runner/ci-evidence-freshness.test.ts | 63 +++++++++++++++++++ tests/unit/dependency-advisories.test.ts | 8 ++- 6 files changed, 87 insertions(+), 10 deletions(-) diff --git a/config/ci/contract-baseline.json b/config/ci/contract-baseline.json index b05954bf..7e1243d0 100644 --- a/config/ci/contract-baseline.json +++ b/config/ci/contract-baseline.json @@ -1,11 +1,11 @@ { "schemaVersion": 1, "owner": "DongHyeonka", - "reason": "1105/12-01: FE-GATE-013 hostRequirements are part of the reviewed gate shape", + "reason": "1106/13-01: FE-GATE-027 runs the advisory scan before the release admission", "gates": 27, "commands": 100, "commandReferences": 104, "artifacts": 110, "stages": 5, - "gateShapeSha256": "7bebafe65d528be6a59d4bb70edd2cad99455b2b49087e4a46b83d77bfd163de" + "gateShapeSha256": "7f6f3d975c62c022d6a6f8b5f39562f73de9ca0f22aa3d086ac28959e50fa93e" } diff --git a/config/ci/gates.json b/config/ci/gates.json index 31175c46..500fca74 100644 --- a/config/ci/gates.json +++ b/config/ci/gates.json @@ -2209,8 +2209,8 @@ "id": "FE-GATE-027", "name": "release-admission", "commandIds": [ - "check-release-admission", - "scan-dependency-advisories" + "scan-dependency-advisories", + "check-release-admission" ], "logArtifactId": "artifact-artifacts-quality-gates-FE-GATE-027-txt", "evidenceArtifactIds": [ diff --git a/docs/operations/ci-quality-gates.md b/docs/operations/ci-quality-gates.md index 7a34e9ab..ebb83275 100644 --- a/docs/operations/ci-quality-gates.md +++ b/docs/operations/ci-quality-gates.md @@ -168,7 +168,11 @@ Producer는 게시 전에 manifest가 선언한 exact member set과 각 byte dig 검증하고 archive SHA-256을 job output으로 고정한다. 같은 job은 마지막 단계에서 FE-GATE-015·027의 gate log와 evidence, `scan:dependency-advisories` 기록을 후보와 다른 이름(`immutable-gate-evidence--`)으로 성공·실패와 상관없이 -올린다(1105/13-01). `ci:gate`는 명령 출력을 gate log에만 쓰고 콘솔에는 한 줄만 +올린다(1105/13-01). 올라가는 것은 그 run에 생긴 파일이다. `ci:gate`는 처음 실패한 +명령에서 멈추므로 FE-GATE-027은 막지 않는 advisory 검사를 승인보다 먼저 돌린다. +그래서 승인이 거절된 run에도 advisory 기록이 있다(1106/13-01). FE-GATE-015가 +실패하면 FE-GATE-027이 돌지 않으므로 그 run에는 FE-GATE-027의 log와 advisory +기록이 없다. `ci:gate`는 명령 출력을 gate log에만 쓰고 콘솔에는 한 줄만 남기므로, release 단계의 실패 이유는 이 산출물에서 읽는다. 후보 archive의 member set은 그대로다. Vulnerability/provenance provider job은 같은 archive를 각각 내려받아 output SHA-256과 exact member set을 @@ -528,7 +532,8 @@ Repository variables required by higher tiers: job runs FE-GATE-015 and then FE-GATE-027, and FE-GATE-027 refuses the candidate when `APP_PROFILE` is set and differs from `RELEASE_TARGET`. Both are repository-wide variables, so set them together for each release. - FE-GATE-027 then runs `scan:dependency-advisories` (1103/13-03). It applies + FE-GATE-027 runs `scan:dependency-advisories` first and the admission after + it (1103/13-03, 1106/13-01). It applies `config/security/vulnerability-policy.json` and its exceptions to the registry's advisory report for the lockfile (pnpm's audit command with `--json`) and writes the result to the gate log @@ -540,7 +545,11 @@ Repository variables required by higher tiers: The job console shows only one PASS/FAIL line per gate, so the immutable_build job uploads both gates' logs and evidence and this record as the run artifact `immutable-gate-evidence--`, whether the job - passed or failed (1105/13-01). Read why FE-GATE-015 or FE-GATE-027 failed, + passed or failed (1105/13-01). It holds the files the run produced. `ci:gate` + stops at the first command that fails, and the scan runs before the + admission, so a run whose admission was refused still has the advisory + record. When FE-GATE-015 fails, FE-GATE-027 does not run, and the run has + neither its log nor the record. Read why FE-GATE-015 or FE-GATE-027 failed, and the advisory status, there. `renovate.json` opens security update PRs once a Renovate runner is attached; a dependency update re-approves the dependency baseline in the same change diff --git a/scripts/scan-dependency-advisories.ts b/scripts/scan-dependency-advisories.ts index 14621e2e..622a7525 100644 --- a/scripts/scan-dependency-advisories.ts +++ b/scripts/scan-dependency-advisories.ts @@ -9,7 +9,8 @@ import { /** * 1103/13-03. Release-stage signal for known dependency advisories - * (FE-GATE-027, next to the release admission of the candidate). It runs + * (FE-GATE-027, before the release admission of the candidate, so a refused + * candidate still leaves the record: 1106/13-01). It runs * `pnpm audit --json` over the lockfile and applies * config/security/vulnerability-policy.json with its exceptions, the policy the * production promotion provider is held to. The result is a line in the gate diff --git a/tests/system/ci-runner/ci-evidence-freshness.test.ts b/tests/system/ci-runner/ci-evidence-freshness.test.ts index 56d67614..37467f91 100644 --- a/tests/system/ci-runner/ci-evidence-freshness.test.ts +++ b/tests/system/ci-runner/ci-evidence-freshness.test.ts @@ -6,6 +6,7 @@ import path from "node:path"; import { afterEach, describe, expect, it } from "vitest"; import { loadCiGateContract } from "../../../scripts/contracts/ci-gates.ts"; +import { DEPENDENCY_ADVISORIES_RECORD_PATH } from "../../../scripts/lib/dependency-advisories.ts"; import { FIXTURE_PNPM_ENVIRONMENT } from "../../../scripts/lib/fixture-node-modules.ts"; // F-12. The temp roots have a package.json but no node_modules or lockfile. @@ -184,3 +185,65 @@ describe("CI-runner gate output budget", () => { ); }, 20_000); }); + +// 1106/13-01. ci:gate stops at the first command that fails. FE-GATE-027 ran +// the admission first, so a refused candidate left no advisory record, and the +// release evidence the operations guide points to had none. The two package +// scripts are stand-ins: the admission refuses, the scan writes its record. +describe("CI-runner FE-GATE-027 advisory record", () => { + it("writes the advisory record when the release admission refuses the candidate", async () => { + const root = await mkdtemp(path.join(tmpdir(), "ci-gate-refused-admission-")); + temporaryRoots.push(root); + await mkdir(path.join(root, "config/ci"), { recursive: true }); + await mkdir(path.join(root, path.dirname(DEPENDENCY_ADVISORIES_RECORD_PATH)), { + recursive: true, + }); + const contract = JSON.parse( + JSON.stringify(await loadCiGateContract(process.cwd())), + ) as Record; + const gate = contract.gates.find( + (entry: Record) => entry.id === "FE-GATE-027", + ); + const logArtifact = contract.artifacts.find( + (entry: Record) => entry.id === gate.logArtifactId, + ); + const packageDocument = JSON.parse( + await readFile("package.json", "utf8"), + ) as { scripts: Record }; + packageDocument.scripts["check:release-admission"] = + `node -e "process.stderr.write('release admission refused for production: fixture'),process.exit(1)"`; + packageDocument.scripts["scan:dependency-advisories"] = + `node -e 'require("node:fs").writeFileSync(${JSON.stringify(DEPENDENCY_ADVISORIES_RECORD_PATH)}, "fixture record")'`; + await writeFile( + path.join(root, "config/ci/gates.json"), + `${JSON.stringify(contract)}\n`, + ); + await writeFile( + path.join(root, "config/ci/contract-baseline.json"), + await readFile("config/ci/contract-baseline.json"), + ); + await writeFile( + path.join(root, "package.json"), + `${JSON.stringify(packageDocument)}\n`, + ); + + const result = spawnSync( + process.execPath, + [path.resolve("scripts/run-ci-gate.ts"), "FE-GATE-027"], + { + cwd: root, + encoding: "utf8", + env: { ...process.env, ...FIXTURE_PNPM_ENVIRONMENT, CI: "false" }, + timeout: 15_000, + }, + ); + + expect(result.status, result.stderr).toBe(1); + expect( + await readFile(path.join(root, logArtifact.path), "utf8"), + ).toContain("release admission refused for production: fixture"); + expect( + await readFile(path.join(root, DEPENDENCY_ADVISORIES_RECORD_PATH), "utf8"), + ).toBe("fixture record"); + }, 20_000); +}); diff --git a/tests/unit/dependency-advisories.test.ts b/tests/unit/dependency-advisories.test.ts index a0f51329..44eaea6d 100644 --- a/tests/unit/dependency-advisories.test.ts +++ b/tests/unit/dependency-advisories.test.ts @@ -96,7 +96,11 @@ describe("dependency advisory summary (1103/13-03)", () => { } }); - it("runs at release admission (FE-GATE-027) and never fails the gate by itself", async () => { + // 1106/13-01. ci:gate stops at the first command that fails. With the scan + // after the admission, a refused run had no advisory record, while the + // operations guide says the release evidence carries it. The scan never + // fails, so running it first leaves the admission verdict as it was. + it("runs before the release admission (FE-GATE-027) and never fails the gate by itself", async () => { const contract = JSON.parse(await readFile("config/ci/gates.json", "utf8")) as { gates: { id: string; commandIds: string[] }[]; commands: { id: string; script: string }[]; @@ -104,7 +108,7 @@ describe("dependency advisory summary (1103/13-03)", () => { const scripts = (contract.gates.find(({ id }) => id === "FE-GATE-027")?.commandIds ?? []).map( (commandId) => contract.commands.find(({ id }) => id === commandId)?.script, ); - expect(scripts).toEqual(["check:release-admission", "scan:dependency-advisories"]); + expect(scripts).toEqual(["scan:dependency-advisories", "check:release-admission"]); const source = await readFile("scripts/scan-dependency-advisories.ts", "utf8"); expect(source).not.toMatch(/process\.exit(?:Code)?\s*(?:=|\()\s*[1-9]/u); });