fix(security): W4 red team 백엔드 발견(관리포트 노출·admin @Valid)을 고친다 #12
@@ -36,6 +36,7 @@
|
||||
- [ ] 컨트롤러는 변환만 한다. repository·엔티티를 모른다.
|
||||
- [ ] 경로는 lowerCamel 복수형(AIP-122). 생성은 201 + `Location`.
|
||||
- [ ] 도메인 규칙을 DTO bean validation에 다시 쓰지 않았다.
|
||||
- [ ] 엔드포인트를 더했으면 **요청률 제한**을 어디서 거는지(ingress/app) 배포 설계에 있다. 앱 기본 off·켜는 법은 [docs/security/rate-limiting.md](../security/rate-limiting.md).
|
||||
|
||||
## 조립·권한
|
||||
|
||||
|
||||
@@ -86,6 +86,21 @@ env_keys:
|
||||
compatibility_impact: behavior-change
|
||||
required_test: actuator-contract:management-port-separated
|
||||
|
||||
- name: MANAGEMENT_SERVER_ADDRESS
|
||||
# source: W4 red team BE-CONFIG-001 2026-11-11 — management.server.address was unset, so the
|
||||
# actuator connector bound every interface; health/prometheus/info (permitAll) were reachable
|
||||
# unauthenticated off-loopback. Default to loopback; remote scraping sets this explicitly.
|
||||
type: string
|
||||
default: 127.0.0.1
|
||||
allowed_values: null
|
||||
classification: public-config
|
||||
required: false
|
||||
reload_policy: restart-only
|
||||
owner_branch: feature-management-actuator-security-contract
|
||||
validation: host_or_ip_address
|
||||
compatibility_impact: behavior-change
|
||||
required_test: actuator-contract:management-address-loopback
|
||||
|
||||
- name: APP_SERVER_SHUTDOWN
|
||||
# source: feature-env-driven-runtime-configuration D2 (2026-06-05) — APP_ 통일
|
||||
# (server.shutdown 방식. graceful은 처리 중인 요청을 끝내고 내린다)
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# 백엔드 템플릿 red team 보안 리뷰 (2026-11-11)
|
||||
|
||||
- 범위·승인: 소유자 승인(W4) 아래 desktop에 띄운 이 템플릿과 그 의존 컨테이너만 공격. 운영·Gitea·남의 서비스는 대상 아님. DoS 없음.
|
||||
- 방법(반복 캠페인): 공격 표면 목록(전 capability) → OWASP API Security Top 10(2023)·Top 10(2021)·ASVS L2 × 진입점 행렬 → 정적(gitleaks·semgrep·trivy·checkov)·수동 코드 추적(inbound→sink)·동적(bootRunH2 + ss + actuator curl + ZAP baseline + nuclei) → 발견 → 막는 시험(RED→GREEN).
|
||||
- 대상 커밋: main `66eaa982`(공격), 수정은 `claude/t2b-relayout-e435ee` 위.
|
||||
|
||||
## 요약
|
||||
열린 발견 0. 두 매퍼·역직렬화·주입·SSRF·경로 traversal·JWT·GraphQL·헤더·CORS·에러 노출은 모두 단단함을 확인(정적 checkov 0·trivy HIGH/CRIT 0, 동적 ZAP 실제 경보 0·nuclei 0). 템플릿은 이미 여러 보안 리뷰를 거쳐 견고하며, 아래 발견은 **파생 서비스가 물려받는 약한 기본값/일관성** 중심이다.
|
||||
|
||||
| id | 심각도 | 분야 | 상태 |
|
||||
|---|---|---|---|
|
||||
| BE-CONFIG-001 | medium | config | **고침** |
|
||||
| BE-INPUT-002 | info | input | **고침** |
|
||||
| BE-INPUT-001 | info(재분류) | input | by-design(오탐) — 문서화 |
|
||||
|
||||
## 발견
|
||||
|
||||
### BE-CONFIG-001 (medium) — 관리 포트가 모든 인터페이스 바인딩 → actuator 무인증 노출
|
||||
- **위치:** `src/bootstrap/app/src/main/resources/config/observability.yml`(관리 커넥터), `.../management/security/ManagementSecurityConfig.java`(health/info/prometheus permitAll).
|
||||
- **재현:** `management.server.address` 미설정 → Spring이 관리 커넥터를 모든 인터페이스에 바인딩. 동적 확인(bootRunH2): `ss -tlnp`가 `*:9001`, `curl :9001/actuator/health·info·prometheus`=200 무인증(env·heapdump·beans=401). compose의 `127.0.0.1:9001` publish는 Docker 호스트만 막고, 같은 compose 네트워크 형제 컨테이너·NetworkPolicy 없는 k8s/bare는 못 막는다.
|
||||
- **영향:** 컨테이너/파드 네트워크의 누구에게나 무인증 정보 노출. info가 build group/artifact/version·capabilities, prometheus가 disk 경로·free/total·JVM·http.server.requests uri 태그(API 표면 열거)를 유출. 쓰기/침해 경로는 없어 medium.
|
||||
- **고침:** `management.server.address: ${MANAGEMENT_SERVER_ADDRESS:127.0.0.1}`로 loopback 기본. 원격 스크레이프는 명시 opt-in. env-keys 등록 + 막는 계약 시험 `actuator-contract:management-address-loopback`(RED: address 빼면 실패, GREEN: 통과). 커밋 `ad3d00c8`.
|
||||
|
||||
### BE-INPUT-002 (info) — admin reconcile의 @RequestBody에 @Valid 누락
|
||||
- **위치:** `src/adapter/inbound/web-fileserver/.../admin/FileserverAdminController.java` `reconcileOrphans`.
|
||||
- **재현/영향:** 다른 다섯 핸들러와 달리 @Valid 없음. 현재 OrphanReconcileHttpRequest에 제약이 없어 무해하나, 나중에 제약을 더하면 조용히 무시되는 잠재 함정(검증 우회 부류). admin 평면·/internal·게이트됨.
|
||||
- **고침:** @Valid 추가 + 이 컨트롤러의 모든 @RequestBody가 @Valid를 갖는지 반사 막는 시험. RED→GREEN 확인. 커밋 `3ecddad0`.
|
||||
|
||||
### BE-INPUT-001 (재분류: by-design, 오탐)
|
||||
- 초기 의심: XML 매퍼가 CBOR 매퍼의 scalar-coercion 잠금을 빠뜨려 표현별 엄격성 불일치.
|
||||
- **검증 결과 오탐:** XML은 textual 포맷이라 숫자·불리언 필드도 String 토큰(`<count>5</count>`)으로 들어온다. CBOR의 `String→Fail` 잠금을 XML에 쓰면 모든 숫자/불리언 바인딩이 깨지며, 기존 시험 `WebCodecMapperTest.xmlRoundTripPreservesWireTypes`(int count 바인딩)가 그걸 고정해 순진한 fix는 이미 막혀 있다. @Valid 제약이 바인딩 뒤 모든 표현에 돌고 FAIL_ON_UNKNOWN_PROPERTIES·SecureXmlInputFactory도 적용되므로 검증 우회가 아니다.
|
||||
- **처리:** 코드는 올바르다. 왜 CoercionConfig를 두지 않는지 주석으로 못 박아 미래의 잘못된 "parity fix"를 막음(커밋 `3bb9f52f`). 취약점 아님.
|
||||
|
||||
## 소유자 결정 칸
|
||||
- **BE-OBS-A (API4 Unrestricted Resource Consumption):** 요청률 제한(`APP_RATE_LIMIT_ENABLED`)이 기본 OFF다. 구조적 bound(업로드/다운로드/메시지/GraphQL complexity/연결/deadline)는 많으나 요청 **빈도** 제한은 배포(ingress)에 의존한다. 결정: (a) 템플릿 기본을 안전하게(fail-closed redis provider 켬) 둘지, (b) "ingress/gateway에서 rate-limit 필수"를 운영 문서·게이트로 강제할지. red team 권장: 요청률은 ingress 책임이 맞으나, 그 요구를 운영 매뉴얼에 명시하고 릴리스 체크에 넣기를 권한다.
|
||||
|
||||
## 기준표 커버리지
|
||||
OWASP API Top 10(2023)·Top 10(2021)·ASVS L2 핵심 장 × 진입점 행렬을 채웠다(방법/근거/결과). BE-CONFIG-001(API8/A05/V14) 외 전 항목 PASS. 동적 "전 capability"(graphql/grpc/websocket/fileserver 켠 조합)·schemathesis·역할별 인가 행렬은 Round 2에서 채운다(별도 기록).
|
||||
|
||||
## 회귀
|
||||
세 수정 모두 막는 시험을 더했고 desktop에서 RED→GREEN·무회귀를 확인했다. red team 장치(plugins/redteam)를 다시 돌려 같은 발견이 다시 나오지 않음을 릴리스 전 확인한다.
|
||||
@@ -0,0 +1,26 @@
|
||||
# 요청률 제한 (rate limiting) — 기본 OFF, ingress 책임
|
||||
|
||||
- 결정: 소유자, 2026-11-12 (W4 red team BE-OBS-A).
|
||||
|
||||
## 자세(posture)
|
||||
|
||||
이 템플릿은 **요청 빈도(rate) 제한을 앱에서 기본으로 켜지 않는다**(`APP_RATE_LIMIT_ENABLED` 기본 `false`). 요청률 제한은 **ingress/gateway의 책임**이다. 파생 서비스는 앞단(ingress-nginx·API gateway·CDN·WAF)에서 IP·클라이언트·경로별 요청률을 건다.
|
||||
|
||||
이것은 보호가 없다는 뜻이 아니다. 앱은 **크기/양 bound**를 이미 강제한다: 업로드/다운로드 크기·range 수, 메시지 payload(64KB), GraphQL complexity(10000)·page-size(100)·depth/alias, gRPC 메시지(1MiB)·deadline, 연결 수(WS 1000)·send-buffer. 빠진 것은 **요청 빈도** 한 축이고, 그것은 앞단이 서비스 전체(여러 인스턴스) 기준으로 보는 게 맞다.
|
||||
|
||||
## 앞단에서 안 거는 배포라면 — 앱 내 limiter 켜기
|
||||
|
||||
redis 기반 limiter를 쓸 수 있다(fail-closed):
|
||||
|
||||
1. 모듈을 런타임에 둔다: `runtimeOnly project(':adapter:outbound:cache-redis')`.
|
||||
2. `APP_REDIS_ENABLED=true` + redis 접속(`APP_*_REDIS_*`).
|
||||
3. `APP_RATE_LIMIT_ENABLED=true`, `APP_RATE_LIMIT_PROVIDER=redis`, `APP_RATE_LIMIT_FAILURE_POLICY=fail-closed`.
|
||||
4. 클라이언트 IP 해석: 운영 정본은 `APP_SERVER_FORWARD_HEADERS_STRATEGY=native` + Tomcat `remoteip.internal-proxies`로 `getRemoteAddr()` 하나를 쓴다. `APP_RATE_LIMIT_CLIENT_IP_MODE`의 XFF-왼쪽 모드는 호출자가 위조할 수 있으니 신뢰 프록시 체인이 설 때만 쓴다(docs/capability-status.md, I-5a·NEW-10c).
|
||||
|
||||
자세한 키는 `docs/registries/env-keys.yaml`의 `APP_RATE_LIMIT_*`, 모듈 기본값은 `src/adapter/outbound/cache-redis/src/main/resources/config/module-defaults/cache-redis.yml`.
|
||||
|
||||
## 파생 서비스가 정할 것 (릴리스 전 확인)
|
||||
|
||||
- 이 서비스의 요청률 제한을 **어디서** 거는가(ingress / app / 둘 다)를 배포 설계에 적는다.
|
||||
- ingress에서 건다면 그 규칙(IP·경로·버스트)을 배포 repo에 둔다. 앱에서 건다면 위 4단계 + redis 용량.
|
||||
- 둘 다 안 걸면 그것이 의식적 결정임을 적는다(내부 전용·앞단 보호 있음 등).
|
||||
@@ -117,6 +117,7 @@ ssh desktop 'cd ~/workspace/<작업 이름> && git add -A && git write-tree'
|
||||
- 파생 서비스의 동기화는 루트 `CLAUDE.md`를 걸러낸다. 그래서 파생 서비스는 자기 `CLAUDE.md`에 `@AGENTS.md` 한 줄을 두고, 지도(`AGENTS.md`)에서 `docs/work/README.md`를 가리켜야 한다. `docs/work/`는 걸러지지 않는다.
|
||||
- `.claude/`의 추적 파일(`settings.json`의 권한과 훅, `rules/`, `skills/`, `agents/`)은 함께 넘어간다. 훅 본체는 `scripts/hooks/`다. 한 설정 단계에서 deny된 도구는 다른 단계(`settings.local.json`, 사용자 설정)의 allow로 풀리지 않는다(Claude Code 권한 문서 「Settings precedence」). 파생 서비스가 `.env` 읽기 차단 같은 권한을 바꾸려면 그 파일을 자기 repo에서 고친다.
|
||||
- 파생 서비스 쪽 병합과 그 게이트는 그 repo의 일이다. 템플릿 세션이 파생 서비스 repo를 고치지 않는다.
|
||||
- 파생 서비스는 **요청률 제한을 어디서 거는지** 배포 설계에 정한다: 앱은 기본 off(요청 빈도는 ingress/gateway 책임), 앞단에서 안 걸면 앱 내 redis limiter를 켠다. 자세와 켜는 법은 [docs/security/rate-limiting.md](../security/rate-limiting.md)(W4 BE-OBS-A).
|
||||
|
||||
## 5. 완료 기준
|
||||
|
||||
|
||||
+14
@@ -77,6 +77,20 @@ public final class WebXmlMapperFactory {
|
||||
return XmlMapper.builder(factory)
|
||||
.enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
|
||||
.disable(MapperFeature.ALLOW_COERCION_OF_SCALARS)
|
||||
// Deliberately NOT the CBOR mapper's withCoercionConfig(String->Fail, Textual
|
||||
// Integer->Fail).
|
||||
// XML is a textual format: every scalar — a numeric or boolean DTO field included — arrives
|
||||
// as a String token (<count>5</count>). Forbidding String-shaped input there would reject
|
||||
// all
|
||||
// numeric/boolean binding, and WebCodecMapperTest.xmlRoundTripPreservesWireTypes (which
|
||||
// binds
|
||||
// `int count`) pins exactly that. The parity a reader might expect with the CBOR profile is
|
||||
// not a strictness bypass: FAIL_ON_UNKNOWN_PROPERTIES and the SecureXmlInputFactory
|
||||
// hardening
|
||||
// apply here too, @Valid constraints run post-binding on every representation, and binding
|
||||
// "5"->int is XML's normal semantics, not the type confusion the CBOR lockdown guards
|
||||
// against.
|
||||
// (W4 red team BE-INPUT-001: the divergence is by design, not an omission.)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -113,7 +113,8 @@ public class FileserverAdminController {
|
||||
path = "/internal/fileserver/orphans:reconcile",
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE,
|
||||
produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public OrphanReconcileReport reconcileOrphans(@RequestBody OrphanReconcileHttpRequest request) {
|
||||
public OrphanReconcileReport reconcileOrphans(
|
||||
@Valid @RequestBody OrphanReconcileHttpRequest request) {
|
||||
return reconcileOrphans.handle(toCommand(request, contextFactory.current()));
|
||||
}
|
||||
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package dev.caskeleton.adapter.inbound.web.fileserver.admin;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* W4 red team BE-INPUT-002 — every {@code @RequestBody} on the admin controller must also carry
|
||||
* {@code @Valid}.
|
||||
*
|
||||
* <p>{@code reconcileOrphans} shipped a {@code @RequestBody} without {@code @Valid}, unlike every
|
||||
* sibling handler (relocate/force-delete/…). Harmless today because {@code
|
||||
* OrphanReconcileHttpRequest} declares no Bean Validation constraints — but the moment one is added
|
||||
* (a {@code @Min} on the limit, a {@code @NotBlank} on the reason), it would be silently ignored,
|
||||
* exactly the validation-bypass class this template otherwise guards against. This pins the
|
||||
* convention for the whole admin plane so the gap cannot reopen.
|
||||
*/
|
||||
class FileserverAdminControllerRequestBodyValidationTest {
|
||||
|
||||
@Test
|
||||
void everyRequestBodyParameterAlsoCarriesValid() {
|
||||
List<String> offenders = new ArrayList<>();
|
||||
for (Method method : FileserverAdminController.class.getDeclaredMethods()) {
|
||||
for (Parameter parameter : method.getParameters()) {
|
||||
if (parameter.isAnnotationPresent(RequestBody.class)
|
||||
&& !parameter.isAnnotationPresent(Valid.class)) {
|
||||
offenders.add(method.getName() + "(" + parameter.getType().getSimpleName() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
assertThat(offenders)
|
||||
.as(
|
||||
"admin @RequestBody handlers without @Valid would silently drop any Bean Validation "
|
||||
+ "constraint added to their DTO later (BE-INPUT-002)")
|
||||
.isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -340,7 +340,9 @@ def repositoryRootForContractTests = rootProject.projectDir
|
||||
def repositoryContractExcludes = ['**/build/**', '**/.gradle/**', '**/node_modules/**', '.claude/worktrees/**']
|
||||
def repositoryContractInputs = files(
|
||||
fileTree(repositoryRootForContractTests) {
|
||||
include '.gitea/**', '.github/**', 'compose/**', 'scripts/**', '*.yml', '*.yaml', '*.example', '.tool-versions'
|
||||
// docs/registries/** are machine contracts, not prose: a malformed registry must fail
|
||||
// the pull request (RegistrySchemaPullRequestGateTest), so the lane reruns when one changes.
|
||||
include '.gitea/**', '.github/**', 'compose/**', 'scripts/**', '*.yml', '*.yaml', 'docs/registries/**', '*.example', '.tool-versions'
|
||||
exclude '**/*.md'
|
||||
exclude repositoryContractExcludes
|
||||
},
|
||||
|
||||
@@ -27,6 +27,11 @@ management:
|
||||
# endpoints are not exposed on the same socket as the app API. Default: 9001.
|
||||
server:
|
||||
port: ${MANAGEMENT_SERVER_PORT:9001}
|
||||
# W4 red team BE-CONFIG-001: an unset address binds every interface, so health/prometheus/info
|
||||
# (permitAll, no auth mechanism) are reachable unauthenticated from any pod/host on the network —
|
||||
# a separate PORT is not a separate NETWORK. Pin the bind to loopback by default; a deployment
|
||||
# that scrapes remotely sets MANAGEMENT_SERVER_ADDRESS explicitly (or scrapes via a loopback sidecar).
|
||||
address: ${MANAGEMENT_SERVER_ADDRESS:127.0.0.1}
|
||||
endpoints:
|
||||
web:
|
||||
# D2: production allowlist — only safe, scrape-friendly endpoints are exposed. The actuator
|
||||
|
||||
+10
@@ -278,6 +278,16 @@ class ContractRegistrySchemaGovernanceTest {
|
||||
required_test: test:metric
|
||||
""",
|
||||
"compatibility_impact");
|
||||
// A row that simply OMITS compatibility_impact must fail with the same descriptive error, not a
|
||||
// NullPointerException from Set.of(...).contains(null) (W4 BE-CONFIG-001 stranded this field).
|
||||
assertInvalidUniversalMetric(
|
||||
tempDir.resolve("missing-compatibility"),
|
||||
"""
|
||||
- name: metric
|
||||
owner_branch: owner
|
||||
required_test: test:metric
|
||||
""",
|
||||
"compatibility_impact");
|
||||
assertInvalidUniversalMetric(
|
||||
tempDir.resolve("blank-required-test"),
|
||||
"""
|
||||
|
||||
+35
@@ -7,6 +7,7 @@ import dev.caskeleton.bootstrap.contract.support.ShippedConfiguration;
|
||||
import dev.caskeleton.shared.error.Category;
|
||||
import dev.caskeleton.shared.error.OperationalError;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -36,6 +37,8 @@ import org.yaml.snakeyaml.Yaml;
|
||||
* env-keys.yaml).
|
||||
* <li>{@code actuator-contract:management-port-separated} — management.server.port=9001 ≠
|
||||
* server.port=8080.
|
||||
* <li>{@code actuator-contract:management-address-loopback} — management.server.address defaults
|
||||
* to a loopback address (BE-CONFIG-001).
|
||||
* <li>{@code actuator-contract:exposure-policy} — env/configprops/heapdump/threaddump/shutdown
|
||||
* NOT in include set.
|
||||
* <li>{@code actuator-contract:show-details-never} — health show-details = never. The actuator
|
||||
@@ -222,6 +225,38 @@ class ManagementActuatorSecurityContractTest {
|
||||
.isEqualTo("${MANAGEMENT_SERVER_PORT:9001}");
|
||||
}
|
||||
|
||||
// ---- actuator-contract:management-address-loopback (BE-CONFIG-001) ----
|
||||
// A separate management PORT is not a separate NETWORK: with management.server.address unset,
|
||||
// Spring binds the actuator connector to every interface, so health/prometheus/info (permitAll,
|
||||
// no auth mechanism) answer any pod/host on the network. application.yml must pin the bind to a
|
||||
// loopback default so the posture holds without depending on Compose publish or a NetworkPolicy.
|
||||
@Test
|
||||
void applicationYmlManagementAddressPinsLoopbackDefault() throws Exception {
|
||||
Map<String, Object> mgmt = managementSubtree();
|
||||
Object address = nested(mgmt, "server", "address");
|
||||
|
||||
assertThat(address)
|
||||
.as(
|
||||
"application.yml must pin management.server.address — unset binds all interfaces "
|
||||
+ "(BE-CONFIG-001): health/prometheus/info reachable unauthenticated off-loopback")
|
||||
.isNotNull();
|
||||
|
||||
// Keep it env-driven (${MANAGEMENT_SERVER_ADDRESS:<default>}) so a remote-scrape deployment can
|
||||
// opt in, and require the shipped DEFAULT to be a loopback address.
|
||||
String expr = String.valueOf(address);
|
||||
assertThat(expr)
|
||||
.as(
|
||||
"management.server.address must stay env-driven ${MANAGEMENT_SERVER_ADDRESS:<loopback>}")
|
||||
.startsWith("${MANAGEMENT_SERVER_ADDRESS:")
|
||||
.endsWith("}");
|
||||
String defaultValue = expr.substring(expr.indexOf(':') + 1, expr.length() - 1);
|
||||
assertThat(InetAddress.getByName(defaultValue).isLoopbackAddress())
|
||||
.as(
|
||||
"management.server.address default must be a loopback address, but was: "
|
||||
+ defaultValue)
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void applicationYmlPinsShowDetailsNeverAndShutdownDisabled() {
|
||||
Map<String, Object> mgmt = managementSubtree();
|
||||
|
||||
+8
-2
@@ -206,13 +206,19 @@ final class RegistryGovernanceCatalog {
|
||||
return;
|
||||
}
|
||||
Object compatibilityImpact = row.get("compatibility_impact");
|
||||
if (!LEGAL_COMPATIBILITY_IMPACT.contains(compatibilityImpact)) {
|
||||
// A missing field is null; Set.of(...).contains(null) throws NPE, so a row that simply omits
|
||||
// compatibility_impact must be caught here rather than surfacing as a cryptic
|
||||
// NullPointerException
|
||||
// (W4 BE-CONFIG-001: MANAGEMENT_SERVER_PORT lost this field to a misplaced sibling row).
|
||||
if (compatibilityImpact == null || !LEGAL_COMPATIBILITY_IMPACT.contains(compatibilityImpact)) {
|
||||
throw new IllegalArgumentException(
|
||||
definition.fileName()
|
||||
+ " row "
|
||||
+ identity
|
||||
+ " compatibility_impact must be one of "
|
||||
+ LEGAL_COMPATIBILITY_IMPACT);
|
||||
+ LEGAL_COMPATIBILITY_IMPACT
|
||||
+ ", but was "
|
||||
+ compatibilityImpact);
|
||||
}
|
||||
requireNonBlankString(definition, identity, row, "required_test");
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package dev.caskeleton.bootstrap.contract;
|
||||
|
||||
import dev.caskeleton.bootstrap.contract.support.RepositoryContractResources;
|
||||
import java.nio.file.Path;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Pull-request gate for the contract-registry schema.
|
||||
*
|
||||
* <p>{@link ContractRegistrySchemaGovernanceTest} owns the registry schema — every universal row
|
||||
* must carry a legal {@code compatibility_impact} and a non-blank {@code required_test} — but it is
|
||||
* tagged {@code document-contract}, so it runs only in the main stage. A malformed registry (W4 red
|
||||
* team BE-CONFIG-001 inserted {@code MANAGEMENT_SERVER_ADDRESS} mid-row and stranded {@code
|
||||
* MANAGEMENT_SERVER_PORT}'s {@code compatibility_impact} and {@code required_test} onto it)
|
||||
* therefore passes {@code prCheck} and fails only after merge, in {@code mainCheck} — found after
|
||||
* the merge it should have blocked.
|
||||
*
|
||||
* <p>This runs the identical fail-closed {@link RegistryGovernanceCatalog} validation in the {@code
|
||||
* repository-contract} lane, so the same defect blocks the pull request instead of landing on main.
|
||||
* {@code docs/registries/**} is wired as a repository-contract input (this leaf's build.gradle) so
|
||||
* the lane reruns whenever a registry changes rather than passing on a stale up-to-date result.
|
||||
*/
|
||||
@Tag("repository-contract")
|
||||
class RegistrySchemaPullRequestGateTest {
|
||||
|
||||
@Test
|
||||
void everyContractRegistryPassesSchemaGovernanceBeforeMerge() throws Exception {
|
||||
Path registriesDir =
|
||||
RepositoryContractResources.fromSystemProperty().requireTrackedDirectory("docs/registries");
|
||||
RegistryGovernanceCatalog.validate(registriesDir);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user