fix(build)!: 공개 경로 스냅숏 비교 lane이 기준선을 다시 쓰지 않는다 #75

Merged
donghyeon.kang merged 1 commits from fix/public-path-snapshot-read-only into main 2026-11-21 07:23:44 +00:00
9 changed files with 92 additions and 18 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ paths:
Gradle·Docker는 desktop에서 돈다(`docs/work/operate.md` 4.1절). 명령은 저장소 루트에서다.
- 공개 경로·보안 체인을 바꿨으면 `./gradlew verifyPublicPathSnapshot`. 스냅숏 갱신은 리뷰 뒤 `-PapprovePublicPathChange`. — `docs/work/reference/gates.md` 2절
- 공개 경로·보안 체인을 바꿨으면 `./gradlew verifyPublicPathSnapshot`. 스냅숏 갱신은 리뷰 뒤 `./gradlew updatePublicPathSnapshot -PapprovePublicPathChange`(verify는 승인 속성이 있으면 실패한다). — `docs/work/reference/gates.md` 2절
- JWT·JWKS·CORS 경계: `:adapter:inbound:web:webSecurityBoundaryTest`(skip 거부), 오류 디스패치는 `JwtChainErrorDispatchIT`(web `systemTest`).
- 권한 구조: `./gradlew :app-bootstrap:architectureTest`(`ApplicationBoundaryArchitectureTest`, `RequiresPermissionProxyabilityTest`, `ForbiddenApiArchitectureTest`).
- 비밀·로그: `SecretsClassificationRegistryTest`와 `ManagementActuatorSecurityContractTest`의 registry 메서드(`document-contract` → `:app-bootstrap:documentContractTest`), `SqlLoggingForbiddenContractTest`(`repository-contract` → `:app-bootstrap:repositoryContractTest`), `PiiTokenBodyForbiddenContractTest`의 `requestLoggingHasNoBodyCapturePath`(`repository-contract`), `PiiTokenBodyForbiddenContractTest`·`ManagementActuatorSecurityContractTest`의 나머지(app-bootstrap `test` → `scripts/verify.sh leaf :app-bootstrap`)
+1 -1
View File
@@ -46,7 +46,7 @@ JMH benchmark는 커뮤니티 플러그인 `me.champeau.jmh`를 쓴다. `ca.qual
| `ca.jmh-benchmarks` | `me.champeau.jmh` |
| build-tools `ca.jpa-evidence`, `ca.jpa-qualification`(+ `junit` 증거 읽기) | 소유자 결정 4: persistence-jpa `JpaReadinessRegistryTest`, 인용한 시나리오를 모두 요구하고 건너뛰기를 거절하는 readiness lane, `src/adapter/outbound/persistence-jpa/release/release-registry.json`을 묶는 leaf의 `jpaReleaseQualification` |
| build-tools `ca.config-contract` | 바꾸지 않고 여기로 옮겼다 |
| `ca.public-path-snapshot` | app-bootstrap `PublicPathSnapshotTest`(lane `publicPathSnapshotTest`, 루트 별칭 `verifyPublicPathSnapshot`) |
| `ca.public-path-snapshot` | app-bootstrap `PublicPathSnapshotTest`(비교 lane `publicPathSnapshotTest`, 루트 별칭 `verifyPublicPathSnapshot`; 갱신 `publicPathSnapshotUpdate`, 루트 별칭 `updatePublicPathSnapshot`) |
| `ca.archive-hygiene` | 치울 것이 없다: leaf 버전이 더는 revision을 싣지 않으니 낡은 추적 가능 jar가 생기지 않는다 |
| `ca.developer-bootstrap` | `scripts/bootstrap-local.sh` |
| `JpaAdopterApiSurfaceTest`(persistence-jpa의 정규식 import 검사) | `ca.api-surface` `adopterBaseline` |
+7 -1
View File
@@ -280,12 +280,18 @@ strictLaneStages {
}
// The deny-by-default public path baseline: app-bootstrap's approval-test lane under its old name.
// `-PapprovePublicPathChange` rewrites the baseline after review.
// It only compares, and fails when the build sets approvePublicPathChange. After review,
// `updatePublicPathSnapshot -PapprovePublicPathChange` rewrites the baseline.
tasks.register('verifyPublicPathSnapshot') {
group = 'verification'
description = 'Fails when the public path surface (default, profile overrides, filter-chain permitAll and securityMatcher statements) drifts from docs/security/public-paths-snapshot.txt.'
dependsOn ':app-bootstrap:publicPathSnapshotTest'
}
tasks.register('updatePublicPathSnapshot') {
group = 'verification'
description = 'Rewrites docs/security/public-paths-snapshot.txt from the current public path surface after review. Requires -PapprovePublicPathChange.'
dependsOn ':app-bootstrap:publicPathSnapshotUpdate'
}
// The checks that only matter for a release artifact. Not `ci` again: a release tag is cut from a
// main commit that the pull-request gate and the main stage already ran on (review BUILD-중복-6).
+7 -2
View File
@@ -167,8 +167,13 @@ Checkstyle은 파싱된 파일에 같은 질문을 하고, leaf 단위로 돈다
넓어진 pattern) 스냅숏이 바뀐다.
- **못 보는 것.** 운영자가 배포 env(`SECURITY_PUBLIC_PATHS`)로 준 값, 그리고 matcher를 상수나 변수로 다른 줄에서
만든 경우의 그 값(문장 글자만 본다). 그런 변경은 리뷰가 본다.
- **승인 방법.** 리뷰가 변경을 받은 뒤 `./gradlew verifyPublicPathSnapshot -PapprovePublicPathChange`로 스냅숏을 다시
쓰고 함께 커밋한다. 플래그 없이 돌리면 비교만 한다.
- **승인 방법.** 리뷰가 변경을 받은 뒤 `./gradlew updatePublicPathSnapshot -PapprovePublicPathChange`로 스냅숏을 다시
쓰고 함께 커밋한다. 쓰는 것은 이 태스크(`:app-bootstrap:publicPathSnapshotUpdate`)뿐이고, 승인 속성이 없으면
쓰기 전에 실패한다. `verifyPublicPathSnapshot`은 비교만 하고, 빌드에 `approvePublicPathChange`가 있으면 어디서
왔든(`-P`, `gradle.properties`, `ORG_GRADLE_PROJECT_` 환경 변수, `GRADLE_OPTS`의 `-Dorg.gradle.project.`) 실패한다.
쓰는 lane이 자기가 쓴 파일과 비교하면 늘 통과하기 때문이다. 같은 이유로 비교 lane은 시험의 쓰기 스위치
(`publicpath.snapshot.write`)를 `false`로 고정하고, 상속한 `JAVA_TOOL_OPTIONS`·`JDK_JAVA_OPTIONS`·`_JAVA_OPTIONS`에
그 스위치가 있으면 실패한다. API surface 태스크(`verify…`·`update…`)와 같은 모양이다.
- **결정 — 무엇을 스냅숏하나.** 기동한 `SecurityFilterChain`의 matcher를 reflection으로 읽는 안은 Spring 버전마다
깨진다(`permitAll` matcher가 `RequestMatcherDelegatingAuthorizationManager`의 private 필드에 있다). 그래서 설정의
기본값과 소스의 `permitAll` 문장을 글자로 고정한다.
+1 -1
View File
@@ -397,7 +397,7 @@ web 경로의 `W/`는 `src/adapter/inbound/web/src/main/java/dev/caskeleton/adap
| `jpaReleaseQualification`(루트) | persistence-jpa 같은 이름 태스크 | `release.yml` `jpa-release-gate` |
| `JpaAdopterApiSurfaceTest` | `:adapter:outbound:persistence-jpa:verifyJpaApiSurface` adopter 검사 | `ci`(leaf `check`) |
| `verifyEnvKeys`(build-tools) | build-logic `ca.config-contract`, 태스크 동일 | `mainCheck`(`configContractCheck`) |
| `verifyPublicPathSnapshot`/`updatePublicPathSnapshot`(플러그인) | `:app-bootstrap:publicPathSnapshotTest`(루트 별칭 `verifyPublicPathSnapshot`) + 렌더링 단위 테스트 3개(`test`) | `mainCheck`, `releaseCheck`, `ci`(단위) |
| `verifyPublicPathSnapshot`/`updatePublicPathSnapshot`(플러그인) | `:app-bootstrap:publicPathSnapshotTest`(루트 별칭 `verifyPublicPathSnapshot`, 비교만) + 갱신 `:app-bootstrap:publicPathSnapshotUpdate`(루트 별칭 `updatePublicPathSnapshot`) + 렌더링 단위 테스트 3개(`test`) | `mainCheck`, `releaseCheck`, `ci`(단위) |
| `verifyNoStaleTraceableJars` | 해당 없음 — leaf jar 이름에 revision이 없어 stale jar가 생기지 않음 | — |
| `GrpcStableReleaseGate`/`GrpcAdvancedPromotionGate` | 게이트에 연결된 적 없음(자기 테스트만). release `grpc-stable-release-gate` job은 그대로 | — |
| notification evidence·env registry·mongo lane 계약(`test`) | `notificationDocumentContractTest`·`notificationEnvironmentContractTest`·`mongoDocumentContractTest` | `mainCheck` |
+1 -1
View File
@@ -2,7 +2,7 @@
# SSOT: app.security.public-paths default in src/bootstrap/app/src/main/resources/config/security.yml
# -> SecurityConfig permitAll(); anyRequest authenticated. An operator's own SECURITY_PUBLIC_PATHS
# overrides it at run time and is outside this snapshot.
# Update only after review with: ./gradlew verifyPublicPathSnapshot -PapprovePublicPathChange
# Update only after review with: ./gradlew updatePublicPathSnapshot -PapprovePublicPathChange
/v1/healthcheck
# Profile overrides of app.security.public-paths
profile local: /api/healthcheck
@@ -1,7 +1,8 @@
# 업그레이드 안내 — 2026-11 공개 경로 스냅숏과 관리 포트
- 범위: 공개 경로 스냅숏(`docs/security/public-paths-snapshot.txt`)이 보는 범위를 넓힌 변경과, compose가 관리 포트·JMX를
publish하던 줄을 지운 변경. 앱이 여는 경로와 기본 설정은 바뀌지 않았다.
- 범위: 공개 경로 스냅숏(`docs/security/public-paths-snapshot.txt`)이 보는 범위를 넓힌 변경, 스냅숏을 다시 쓰는 일을
비교 lane에서 떼어 낸 변경(2026-11-21), compose가 관리 포트·JMX를 publish하던 줄을 지운 변경. 앱이 여는 경로와 기본
설정은 바뀌지 않았다.
- 근거: 2026-11-12 전체 리뷰(`docs/reviews/2026-11-12-round9-review/`)의 공개 경로·관리 포트 발견
## 1. 누가 읽나
@@ -14,10 +15,11 @@ compose lane으로 JVM을 원격 JMX로 보던 사람이다.
| # | 할 일 | 안 하면 | 해당 서비스 |
| --- | --- | --- | --- |
| 1 | merge 뒤 `./gradlew verifyPublicPathSnapshot`을 돌린다. 실패하면 스냅숏에 새로 든 두 절(profile이 덮는 값, filter chain의 `permitAll`·`securityMatcher` 문장)을 읽고, 의도한 공개면 `./gradlew verifyPublicPathSnapshot -PapprovePublicPathChange`로 다시 쓴 파일을 보안 리뷰와 함께 커밋한다 | `mainCheck`·`releaseCheck`의 `:app-bootstrap:publicPathSnapshotTest`가 실패한다 | 자기 chain이나 profile 덮어쓰기가 있는 서비스 |
| 1 | merge 뒤 `./gradlew verifyPublicPathSnapshot`을 돌린다. 실패하면 스냅숏에 새로 든 두 절(profile이 덮는 값, filter chain의 `permitAll`·`securityMatcher` 문장)을 읽고, 의도한 공개면 `./gradlew updatePublicPathSnapshot -PapprovePublicPathChange`로 다시 쓴 파일을 보안 리뷰와 함께 커밋한다 | `mainCheck`·`releaseCheck`의 `:app-bootstrap:publicPathSnapshotTest`가 실패한다 | 자기 chain이나 profile 덮어쓰기가 있는 서비스 |
| 2 | Kubernetes 배포는 `MANAGEMENT_SERVER_ADDRESS`를 pod IP에서 닿는 주소(예: `0.0.0.0`과 NetworkPolicy)로 두거나 같은 pod의 sidecar로 읽는다. 기본값 `127.0.0.1`은 2026-11-12 main 병합(관리 포트 loopback 고정)부터다 | kubelet 프로브가 관리 포트에 닿지 않아 liveness 실패로 재시작하고 readiness가 오지 않는다. Prometheus도 못 읽는다 | Kubernetes 배포 |
| 3 | compose에서 관리 포트를 호스트로 읽던 명령(`curl localhost:9001/...`)을 `docker compose exec app wget -qO- http://localhost:9001/actuator/health`로 바꾼다 | 호스트 포트가 없어 연결이 거절된다. 지운 publish 줄도 컨테이너 loopback에 닿지 않아 원래 아무것도 답하지 않았다 | compose로 띄우는 사람 |
| 4 | dev lane에서 원격 JMX(9999) 대신 `docker compose exec app jcmd 1 <명령>`(`VM.flags`, `Thread.print`, `JFR.start`)을 쓴다 | 9999 연결이 거절된다 | dev lane으로 JVM을 보던 사람 |
| 5 | 스냅숏을 다시 쓸 때는 `./gradlew updatePublicPathSnapshot -PapprovePublicPathChange`를 쓴다. `approvePublicPathChange`를 `gradle.properties`(저장소나 `GRADLE_USER_HOME`), `ORG_GRADLE_PROJECT_approvePublicPathChange` 환경 변수, `GRADLE_OPTS`, CI·스크립트의 `verifyPublicPathSnapshot` 명령에 두었다면 지운다 | `verifyPublicPathSnapshot`·`mainCheck`·`releaseCheck`의 `:app-bootstrap:publicPathSnapshotTest`가 「read-only」로 실패한다. 전에는 그 속성이 있으면 스냅숏을 다시 쓰고 통과했다 | 스냅숏을 승인하는 명령을 스크립트로 둔 서비스, 승인 속성을 상시로 켜 둔 서비스 |
## 3. 바뀐 것
@@ -25,4 +27,6 @@ compose lane으로 JVM을 원격 JMX로 보던 사람이다.
운영 코드의 `permitAll`·`securityMatcher` 문장. 알림 callback chain과 actuator chain이 셋째 절에 든다.
- 스냅숏이 못 보는 것은 운영자가 배포 env(`SECURITY_PUBLIC_PATHS`)로 준 값과, matcher를 상수나 변수로 다른 줄에서
만든 경우의 그 값이다. 그런 변경은 리뷰가 본다(`docs/build.md` 「`verifyPublicPathSnapshot`」).
- 스냅숏을 쓰는 것은 `updatePublicPathSnapshot`(`:app-bootstrap:publicPathSnapshotUpdate`)뿐이고 승인 속성이 없으면 쓰기 전에
실패한다. 비교 lane은 승인 속성을 보면 실패한다. 전에는 비교 lane이 그 속성을 보면 스냅숏을 먼저 쓰고 자기와 비교했다.
- dev lane의 원격 JMX는 인증·TLS 없이 열려 있었고 `jmxremote.host`가 없어 모든 인터페이스에 묶였다. 그래서 지웠다.
+60 -3
View File
@@ -499,15 +499,23 @@ springBoot {
// The deny-by-default public path baseline (docs/security/public-paths-snapshot.txt) is an approval
// test beside the security configuration it pins, not a build-logic plugin (review BUILD-O3-5). The
// root `verifyPublicPathSnapshot` names this lane; `-PapprovePublicPathChange` rewrites the baseline
// after review instead of comparing it.
// root `verifyPublicPathSnapshot` names this lane, and the lane only compares. Recording a reviewed
// change is a task of its own, `publicPathSnapshotUpdate` below (root `updatePublicPathSnapshot`),
// the same split as the API surface tasks. The lane used to rewrite the baseline whenever the build
// had `approvePublicPathChange`, and then compared the file with itself: one line in a
// gradle.properties or an ORG_GRADLE_PROJECT_ variable turned the gate into a pass (2026-11-21).
def publicPathChangeApproved = project.hasProperty('approvePublicPathChange')
def publicPathWriteProperty = 'publicpath.snapshot.write'
strictTestLanes {
lane('publicPathSnapshotTest') {
tag = 'public-path-snapshot'
description = 'Compares the public path surface (default, profile overrides, filter-chain permit statements) with the reviewed baseline.'
rejectSkipped = true
mainStage()
systemProperty 'publicpath.snapshot.write', project.hasProperty('approvePublicPathChange') ? 'true' : 'false'
// Pinned off, not left unset: the JVM reads JAVA_TOOL_OPTIONS and JDK_JAVA_OPTIONS before
// the -D that Gradle passes, so the pin wins over a switch hidden there. _JAVA_OPTIONS comes
// after it and wins (measured 2026-11-21), so the doFirst below also rejects all three.
systemProperty publicPathWriteProperty, 'false'
}
}
// The snapshot also lists every filter-chain statement that permits requests, in any leaf, and the
@@ -519,6 +527,55 @@ tasks.named('publicPathSnapshotTest', Test) {
}).withPathSensitivity(PathSensitivity.RELATIVE)
.ignoreEmptyDirectories()
.withPropertyName('securitySourcesAndBaseline')
// A main-stage lane runs every time (never up to date, never from the cache), so this check
// runs in every mainCheck and releaseCheck, wherever the property comes from.
doFirst { running ->
if (publicPathChangeApproved) {
throw new GradleException(
"${running.path} is read-only, and this build sets approvePublicPathChange (-P,"
+ ' a gradle.properties, ORG_GRADLE_PROJECT_approvePublicPathChange, or'
+ ' -Dorg.gradle.project.approvePublicPathChange in GRADLE_OPTS). Record a'
+ ' reviewed change with ./gradlew updatePublicPathSnapshot'
+ ' -PapprovePublicPathChange and keep the property out of every other build.')
}
def write = String.valueOf(running.systemProperties[publicPathWriteProperty])
if (write != 'false') {
throw new GradleException(
"${running.path} is read-only, but its test JVM would get ${publicPathWriteProperty}=${write}"
+ ' from this project\'s build instead of the pinned false. Only'
+ ' publicPathSnapshotUpdate writes the baseline; delete the override.')
}
def inherited = ['JAVA_TOOL_OPTIONS', 'JDK_JAVA_OPTIONS', '_JAVA_OPTIONS'].findAll { name ->
[running.environment[name], System.getenv(name)].any { value ->
value != null && String.valueOf(value).contains(publicPathWriteProperty)
}
}
if (inherited) {
throw new GradleException(
"${running.path} is read-only, but ${inherited.join(', ')} would hand its test JVM"
+ " ${publicPathWriteProperty}. Only publicPathSnapshotUpdate writes the"
+ ' baseline; remove the option from the environment.')
}
}
}
// Writes the baseline from the current surface: the same tagged test with the write switch on. It
// is in no stage and never up to date, and it refuses to run without the approval property.
tasks.register('publicPathSnapshotUpdate', Test) {
group = 'verification'
description = 'Rewrites docs/security/public-paths-snapshot.txt from the current public path surface. Run after review, through the root updatePublicPathSnapshot -PapprovePublicPathChange.'
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
useJUnitPlatform { includeTags 'public-path-snapshot' }
systemProperty publicPathWriteProperty, 'true'
outputs.upToDateWhen { false }
outputs.doNotCacheIf('it writes the committed baseline, which is not a task output') { true }
doFirst { running ->
if (!publicPathChangeApproved) {
throw new GradleException(
"${running.path} rewrites docs/security/public-paths-snapshot.txt. Review the change,"
+ ' then run ./gradlew updatePublicPathSnapshot -PapprovePublicPathChange.')
}
}
}
tasks.register('stageDockerJar', Sync) {
@@ -22,9 +22,11 @@ import org.junit.jupiter.api.Test;
* <p>An approval test rather than the build-logic {@code ca.public-path-snapshot} plugin it
* replaced (review 2026-09-24 BUILD-O3-5): the rule is about this composition root's shipped
* security configuration, so it lives beside it. The repository comparison runs in the main-stage
* lane {@code publicPathSnapshotTest} (root alias {@code verifyPublicPathSnapshot}); approving a
* reviewed change is {@code ./gradlew verifyPublicPathSnapshot -PapprovePublicPathChange}, which
* rewrites the baseline instead of comparing. The rendering cases run in {@code test}.
* lane {@code publicPathSnapshotTest} (root alias {@code verifyPublicPathSnapshot}), which only
* compares and fails when the build carries the approval property. Approving a reviewed change is
* {@code ./gradlew updatePublicPathSnapshot -PapprovePublicPathChange}: the task {@code
* publicPathSnapshotUpdate} runs this test with {@code publicpath.snapshot.write=true}, and only
* that task writes the baseline. The rendering cases run in {@code test}.
*/
class PublicPathSnapshotTest {
@@ -44,7 +46,7 @@ class PublicPathSnapshotTest {
# SSOT: app.security.public-paths default in src/bootstrap/app/src/main/resources/config/security.yml
# -> SecurityConfig permitAll(); anyRequest authenticated. An operator's own SECURITY_PUBLIC_PATHS
# overrides it at run time and is outside this snapshot.
# Update only after review with: ./gradlew verifyPublicPathSnapshot -PapprovePublicPathChange
# Update only after review with: ./gradlew updatePublicPathSnapshot -PapprovePublicPathChange
""";
@Test
@@ -68,7 +70,7 @@ class PublicPathSnapshotTest {
assertThat(committed)
.as(
"the deny-by-default public path surface changed, so a protected endpoint may now be"
+ " public. Review it, then run ./gradlew verifyPublicPathSnapshot"
+ " public. Review it, then run ./gradlew updatePublicPathSnapshot"
+ " -PapprovePublicPathChange")
.isEqualTo(rendered);
}