fix(release): 공개 대상 승인이 예시·테스트용 예약 이름을 거절한다 (1101/13-02)
문제 staging·production 프로필은 `https://api.example.com/`, `https://telemetry.example.com/v1/events`를 싣고 텔레메트리를 켠다. 공개 대상 승인(FE-GATE-027)은 https와 비공개 호스트만 보므로 프로필을 고치지 않은 production 빌드가 `production ADMITTED`로 통과한다. 모든 API 호출이 실패하고 이벤트는 프로젝트가 소유하지 않은 도메인으로 간다. CI 계약은 immutable_build의 env를 APP_PROFILE·RELEASE_TARGET로 고정해 RUNTIME_*를 넘길 수 없는데, README 변수 표는 이를 적지 않고 운영 예시는 `api.example.com`을 그대로 쓴다. 고른 방법 - publicEndpointViolations에 예약 이름 거절을 더한다. RFC 2606·6761의 `example.com`·`example.net`·`example.org`와 그 하위, `.example`, `.invalid`, `.test`. 비공개 호스트와 겹치면 비공개 사유 하나만 낸다. - README 운영 예시의 URL을 `<your-api-origin>/` 같은 빈칸으로 바꾼다. - README 변수 표와 본문에 CI에서 endpoint를 바꾸는 방법은 프로필 파일을 커밋하는 것 하나라고 적는다. - 테스트 fixture의 공개 endpoint를 예약되지 않은 이름으로 바꾸고, 프로필을 고치지 않은 빌드는 두 위반, endpoint를 준 빌드는 승인되는 것을 고정한다. 버린 대안 - 프로필 기본값을 비워 스키마가 빌드를 막게 하기: 더 확실하지만 프로필이 예시로 읽히지 않고 네 프로필을 같이 바꿔야 한다. 리뷰 대안 비교에서 승인 규칙 한 곳이 더 작다고 봤다. - 리뷰 13-02 (3)의 괄호("13-01 배포 슬롯에 RUNTIME_* 허용 목록")는 하지 않았다. RUNTIME_*는 빌드 때 쓰이는 값이고, 슬롯은 승격 뒤 배포 job이라 거기서 넘겨도 이미 만든 후보에 닿지 않는다. 위험·한계 - 템플릿을 그대로 쓰는 프로젝트(이 repo 포함)가 APP_PROFILE=production으로 immutable_build를 돌리면 FE-GATE-027이 새로 실패한다(의도). - `*.test` 같은 이름을 실제 운영 endpoint로 쓰는 프로젝트는 없다고 본다. 검증 - RED: node scripts/run-vitest.ts run tests/unit/deployment-admission.test.ts 2 failed / 22 passed. "refuses names reserved for examples and tests" (`expected [] to deeply equal [...]`), "refuses a public build from the unedited profile on both endpoints"(`staging: expected [] to deeply equal [ 'API_BASE_URL', 'TELEMETRY_ENDPOINT' ]`) - GREEN: 같은 파일 24 passed. feature-override-diagnostics, documentation-readiness 포함 29 passed - 실험 E-A 재실행: APP_PROFILE=production VITE_BUILD_ID=rel-prod-a RELEASE_ID=rel-a 빌드 뒤 RELEASE_TARGET=production 승인 rc=1, API_BASE_URL·TELEMETRY_ENDPOINT 두 위반으로 거절 - tsc(app, test) 0, eslint 바뀐 파일 0, verify-documentation-readiness PASS_SCOPED Refs: docs/reviews/2026-11-01-maturity-review/13-build-release-supply-chain.md 13-02
This commit is contained in:
@@ -41,8 +41,8 @@ Build and deploy variables, lowest precedence first:
|
||||
| Variable | Sets | Default |
|
||||
| --- | --- | --- |
|
||||
| `APP_PROFILE` | which `config/runtime/<profile>.json` is used | `local`; an empty value fails the build |
|
||||
| `RUNTIME_API_BASE_URL` | `API_BASE_URL`, overriding the profile | the profile value |
|
||||
| `RUNTIME_TELEMETRY_ENDPOINT` | `TELEMETRY_ENDPOINT`, overriding the profile | the profile value |
|
||||
| `RUNTIME_API_BASE_URL` | `API_BASE_URL`, overriding the profile; the CI workflow cannot pass it (see below) | the profile value |
|
||||
| `RUNTIME_TELEMETRY_ENDPOINT` | `TELEMETRY_ENDPOINT`, overriding the profile; the CI workflow cannot pass it (see below) | the profile value |
|
||||
| `VITE_BUILD_ID` | `BUILD_ID` in the runtime config and the release manifest | `local-build` |
|
||||
| `RELEASE_ID` | `RELEASE_ID` in the runtime config and the release manifest | `local-release` |
|
||||
| `RELEASE_TARGET` | the environment FE-GATE-027 admits the build to; must equal `APP_PROFILE` | none; admission refuses without it |
|
||||
@@ -52,14 +52,23 @@ admission reads (`scripts/verify-documentation-readiness.ts`).
|
||||
|
||||
Only the two `RUNTIME_*` values can differ from the reviewed profile. Anything
|
||||
else changes by editing the profile file. Staging and production reject demo
|
||||
auth and non-HTTPS endpoints.
|
||||
auth, non-HTTPS endpoints and the names reserved for examples and tests
|
||||
(`example.com`, `example.net`, `example.org` and their subdomains, `.example`,
|
||||
`.invalid`, `.test`). The shipped `staging` and `production` profiles use
|
||||
`*.example.com`, so admission refuses them until a project sets its own
|
||||
endpoints.
|
||||
|
||||
A production build and its admission check:
|
||||
In CI the only way to set the endpoints is to commit them to
|
||||
`config/runtime/<profile>.json`. The CI contract binds just `APP_PROFILE` and
|
||||
`RELEASE_TARGET` to the build job (`scripts/contracts/ci-gates.ts`), so a
|
||||
`RUNTIME_*` repository variable never reaches the build.
|
||||
|
||||
A local production build and its admission check:
|
||||
|
||||
```bash
|
||||
APP_PROFILE=production \
|
||||
RUNTIME_API_BASE_URL=https://api.example.com/ \
|
||||
RUNTIME_TELEMETRY_ENDPOINT=https://telemetry.example.com/v1/events \
|
||||
RUNTIME_API_BASE_URL=<your-api-origin>/ \
|
||||
RUNTIME_TELEMETRY_ENDPOINT=<your-telemetry-endpoint> \
|
||||
VITE_BUILD_ID=<unique build id> RELEASE_ID=<unique release id> \
|
||||
corepack pnpm build
|
||||
APP_PROFILE=production RELEASE_TARGET=production corepack pnpm check:release-admission
|
||||
|
||||
@@ -127,10 +127,30 @@ function publicEndpointViolations(
|
||||
field,
|
||||
reason: `${url.hostname} is not reachable from a user's browser`,
|
||||
});
|
||||
} else if (isReservedExampleHost(url.hostname)) {
|
||||
violations.push({
|
||||
field,
|
||||
reason: `${url.hostname} is a name reserved for examples and tests; set the project's endpoint in config/runtime`,
|
||||
});
|
||||
}
|
||||
return violations;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1101/13-02. RFC 2606 and RFC 6761 reserve these names for documentation and
|
||||
* tests. The staging and production profiles ship `*.example.com` endpoints,
|
||||
* so a host here is a template value nobody replaced, the most common
|
||||
* configuration to escape after a developer one.
|
||||
*/
|
||||
function isReservedExampleHost(hostname: string): boolean {
|
||||
const host = hostname.toLowerCase().replace(/\.$/u, "");
|
||||
return (
|
||||
["example.com", "example.net", "example.org"].some(
|
||||
(domain) => host === domain || host.endsWith(`.${domain}`),
|
||||
) || /\.(?:example|invalid|test)$/u.test(host)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Q-6.7-10. The one list of loopback hosts (in `URL.hostname` form) on which
|
||||
* a REST or browser RPC provider may use plain `http:`.
|
||||
|
||||
@@ -17,7 +17,7 @@ import { generateRuntimeConfig } from "../../scripts/generate-runtime-config.ts"
|
||||
|
||||
const PRODUCTION_ARTIFACT: AdmissionInput = Object.freeze({
|
||||
APP_ENV: "production",
|
||||
API_BASE_URL: "https://api.example.com/",
|
||||
API_BASE_URL: "https://api.my-product.kr/",
|
||||
REQUEST_TIMEOUT_MS: 10_000,
|
||||
MAX_RETRY_ATTEMPTS: 2,
|
||||
TELEMETRY_ENABLED: false,
|
||||
@@ -112,13 +112,16 @@ describe("deployment admission", () => {
|
||||
|
||||
it("permits a routable public host", () => {
|
||||
for (const host of [
|
||||
"https://api.172.16.example.com/",
|
||||
"https://api.172.16.my-product.kr/",
|
||||
"https://100.128.0.1/",
|
||||
"https://100.63.255.255/",
|
||||
"https://[2001:db8::1]/",
|
||||
"https://[fec0::1]/",
|
||||
"https://internal.example.com/",
|
||||
"https://local.example.com/",
|
||||
"https://internal.my-product.kr/",
|
||||
"https://local.my-product.kr/",
|
||||
"https://myexample.com/",
|
||||
"https://example.com.my-product.kr/",
|
||||
"https://tested.kr/",
|
||||
]) {
|
||||
expect(
|
||||
findAdmissionViolations("production", {
|
||||
@@ -130,6 +133,29 @@ describe("deployment admission", () => {
|
||||
}
|
||||
});
|
||||
|
||||
// 1101/13-02. RFC 2606 and RFC 6761 reserve these names for examples and
|
||||
// tests, so an endpoint on one is a template value that was never replaced.
|
||||
it("refuses names reserved for examples and tests", () => {
|
||||
for (const host of [
|
||||
"https://example.com/",
|
||||
"https://api.example.com/",
|
||||
"https://telemetry.staging.example.net/",
|
||||
"https://example.org./",
|
||||
"https://api.example/",
|
||||
"https://api.invalid/",
|
||||
"https://desktop.test/",
|
||||
"https://API.EXAMPLE.COM/",
|
||||
]) {
|
||||
const violations = findAdmissionViolations("production", {
|
||||
...PRODUCTION_ARTIFACT,
|
||||
API_BASE_URL: host,
|
||||
} as AdmissionInput);
|
||||
expect(violations, host).toEqual([
|
||||
{ field: "API_BASE_URL", reason: expect.stringContaining("reserved") },
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
it("refuses a placeholder identity on a public target", () => {
|
||||
for (const buildId of ["local-build", "local", "dev", "unknown", ""]) {
|
||||
const violations = findAdmissionViolations("production", {
|
||||
@@ -152,6 +178,17 @@ describe("deployment admission", () => {
|
||||
});
|
||||
});
|
||||
|
||||
const IDENTITY = Object.freeze({
|
||||
VITE_BUILD_ID: "20260815.42",
|
||||
RELEASE_ID: "r-2026.08.15-1",
|
||||
});
|
||||
// What a project commits to its profile; RUNTIME_* stands in for the edit here.
|
||||
const PROJECT_ENDPOINTS = Object.freeze({
|
||||
...IDENTITY,
|
||||
RUNTIME_API_BASE_URL: "https://api.my-product.kr/",
|
||||
RUNTIME_TELEMETRY_ENDPOINT: "https://telemetry.my-product.kr/v1/events",
|
||||
});
|
||||
|
||||
describe("runtime config profiles", () => {
|
||||
it("ships one valid profile per deployment target", async () => {
|
||||
const files = (await readdir("config/runtime")).sort();
|
||||
@@ -174,12 +211,23 @@ describe("runtime config profiles", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("produces an admissible document for every public target", async () => {
|
||||
// 1101/13-02. The public profiles ship example endpoints. A project that
|
||||
// starts from the template and builds without editing them must be refused.
|
||||
it("refuses a public build from the unedited profile on both endpoints", async () => {
|
||||
for (const target of ["staging", "production"] as const) {
|
||||
const config = await generateRuntimeConfig(target, {
|
||||
VITE_BUILD_ID: "20260815.42",
|
||||
RELEASE_ID: "r-2026.08.15-1",
|
||||
});
|
||||
const config = await generateRuntimeConfig(target, IDENTITY);
|
||||
expect(
|
||||
findAdmissionViolations(target, config as unknown as AdmissionInput).map(
|
||||
(violation) => violation.field,
|
||||
),
|
||||
target,
|
||||
).toEqual(["API_BASE_URL", "TELEMETRY_ENDPOINT"]);
|
||||
}
|
||||
});
|
||||
|
||||
it("admits a public build once the project supplies its endpoints", async () => {
|
||||
for (const target of ["staging", "production"] as const) {
|
||||
const config = await generateRuntimeConfig(target, PROJECT_ENDPOINTS);
|
||||
expect(
|
||||
findAdmissionViolations(target, config as unknown as AdmissionInput),
|
||||
).toEqual([]);
|
||||
@@ -247,10 +295,7 @@ describe("runtime config profiles", () => {
|
||||
] as const)("admits a production artifact under APP_PROFILE=%s only when it names the target", async (profile, status) => {
|
||||
const root = await mkdtemp(path.join(tmpdir(), "release-admission-profile-"));
|
||||
try {
|
||||
const config = await generateRuntimeConfig("production", {
|
||||
VITE_BUILD_ID: "20260815.42",
|
||||
RELEASE_ID: "r-2026.08.15-1",
|
||||
});
|
||||
const config = await generateRuntimeConfig("production", PROJECT_ENDPOINTS);
|
||||
await mkdir(path.join(root, "dist"), { recursive: true });
|
||||
await writeFile(path.join(root, "dist/config.json"), JSON.stringify(config));
|
||||
const result = spawnSync(
|
||||
@@ -280,10 +325,7 @@ describe("checking an edited copy of the deployed runtime config", () => {
|
||||
) {
|
||||
const root = await mkdtemp(path.join(tmpdir(), "release-admission-copy-"));
|
||||
try {
|
||||
const deployed = await generateRuntimeConfig("production", {
|
||||
VITE_BUILD_ID: "20260815.42",
|
||||
RELEASE_ID: "r-2026.08.15-1",
|
||||
});
|
||||
const deployed = await generateRuntimeConfig("production", PROJECT_ENDPOINTS);
|
||||
await writeFile(path.join(root, "deployed.json"), JSON.stringify(deployed));
|
||||
await writeFile(path.join(root, "edited.json"), JSON.stringify(edit(deployed)));
|
||||
const result = spawnSync(
|
||||
@@ -326,7 +368,7 @@ describe("checking an edited copy of the deployed runtime config", () => {
|
||||
it.each([
|
||||
["BUILD_ID", "20260815.43"],
|
||||
["RELEASE_ID", "r-2026.08.15-2"],
|
||||
["API_BASE_URL", "https://other.example.org/"],
|
||||
["API_BASE_URL", "https://other.my-product.kr/"],
|
||||
])("refuses a copy that changes %s, which only a build may change", async (field, value) => {
|
||||
const result = await check((deployed) => ({ ...deployed, [field]: value }));
|
||||
expect(result.status).toBe(1);
|
||||
|
||||
Reference in New Issue
Block a user