fix(secrets)!: 로컬 비밀 기본값을 __LOCAL_DEV_ 규칙에 맞추고 가림 약속을 구현과 맞춘다
로컬 비밀 기본값(compose·lane·application-local의 DB 비밀번호, MinIO root, Keycloak admin)이 __LOCAL_DEV_ 접두어 규칙을 따르지 않아 prod sentinel 검사가 그 값을 알아보지 못한다. secrets-classification.yaml은 구현 없는 masking_rule full_except_last_4를 약속하고, full로 적은 키 일부 (salt·PEM·HMAC/signing key, URI 사용자 정보)를 LogMaskingPatterns가 가리지 않는다. required_test는 없는 시험 이름이다. IP 신뢰 설정을 두 문서가 다르게 적는다(application-local은 framework, rate-limiting은 native). - 기본값을 __LOCAL_DEV_db_password__·__LOCAL_DEV_minio_root__· __LOCAL_DEV_keycloak_admin__로 바꾼다. - masking_rule을 full|userinfo|none 셋으로 줄이고, LogMaskingPatterns의 키 목록을 넓히고 URI userinfo와 여러 줄 PEM 블록 가림을 더한다. 시험이 masking_rule 어휘, required_test 클래스 존재, full·userinfo 행이 실제로 가려지는지 본다. 버린 안: full_except_last_4 구현(끝 네 자리를 남길 값이 없다). - IP 신뢰는 native + 내부 proxy 목록 하나로 적는다. 위험: 로컬 compose 볼륨이 옛 비밀번호로 만들어졌으면 DB 접속이 실패한다 (docs/upgrade/2026-11-round9-observability.md 6행). 운영 값은 바뀌지 않는다. 검증: 위와 같은 desktop 실행(묶음 셋을 합친 트리) rc=0. Refs: RR9-02-10, RR9-02-12, RR9-02-13 BREAKING CHANGE: 로컬 compose·lane의 비밀 기본값이 바뀐다. 옛 볼륨은 지우거나 env로 옛 값을 준다(docs/upgrade/2026-11-round9-observability.md 6~7행).
This commit is contained in:
@@ -80,7 +80,7 @@ Gradle·Docker는 desktop에서 돈다(`docs/work/operate.md` 4.1절). 명령은
|
||||
- 공개 경로·보안 체인을 바꿨으면 `./gradlew verifyPublicPathSnapshot`. 스냅숏 갱신은 리뷰 뒤 `-PapprovePublicPathChange`. — `docs/work/reference/gates.md` 2절
|
||||
- JWT·JWKS·CORS 경계: `:adapter:inbound:web:webSecurityBoundaryTest`(skip 거부), 오류 디스패치는 `JwtChainErrorDispatchIT`(web `systemTest`).
|
||||
- 권한 구조: `./gradlew :app-bootstrap:architectureTest`(`ApplicationBoundaryArchitectureTest`, `RequiresPermissionProxyabilityTest`, `ForbiddenApiArchitectureTest`).
|
||||
- 비밀·로그: app-bootstrap `test`의 `SecretsClassificationRegistryTest`, `PiiTokenBodyForbiddenContractTest`, `SqlLoggingForbiddenContractTest`, `ManagementActuatorSecurityContractTest` → `scripts/verify.sh leaf :app-bootstrap`
|
||||
- 비밀·로그: `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`)
|
||||
- DB 역할: `:adapter:outbound:persistence-jpa:postgresqlSecurityBaselineIntegrationTest`, `:adapter:outbound:persistence-jpa:jpaPlatformSecurityTest`
|
||||
- 정적 분석: `qualityCheck`(SpotBugs + FindSecBugs, PR의 `ci` 안).
|
||||
- 취약점: workflow `vulnerabilities` job(`scripts/ci/trivy-scan.sh`). desktop에서는 이미 설치된 trivy로만 돌린다. 없으면 못 돌림으로 적는다. — `docs/work/reference/gates.md` 3절 (다)
|
||||
|
||||
+5
-5
@@ -106,7 +106,7 @@ services:
|
||||
# these; a service that selects the relational capability does.
|
||||
APP_DATASOURCE_URL: "jdbc:postgresql://db:5432/${POSTGRES_DB:-ca_skeleton}"
|
||||
APP_DATASOURCE_USERNAME: "${APP_DATASOURCE_USERNAME:-ca_skeleton}"
|
||||
APP_DATASOURCE_PASSWORD: "${APP_DATASOURCE_PASSWORD:-ca_skeleton}"
|
||||
APP_DATASOURCE_PASSWORD: "${APP_DATASOURCE_PASSWORD:-__LOCAL_DEV_db_password__}"
|
||||
# ---- Read-only root filesystem (D2) -------------------------------------
|
||||
# The application must write only to the tmpfs mount declared below.
|
||||
# /tmp — Tomcat basedir (see -Dserver.tomcat.basedir=/tmp in Dockerfile).
|
||||
@@ -160,7 +160,7 @@ services:
|
||||
environment:
|
||||
POSTGRES_DB: "${POSTGRES_DB:-ca_skeleton}"
|
||||
POSTGRES_USER: "${APP_DATASOURCE_USERNAME:-ca_skeleton}"
|
||||
POSTGRES_PASSWORD: "${APP_DATASOURCE_PASSWORD:-ca_skeleton}"
|
||||
POSTGRES_PASSWORD: "${APP_DATASOURCE_PASSWORD:-__LOCAL_DEV_db_password__}"
|
||||
TZ: "UTC"
|
||||
volumes:
|
||||
- type: volume
|
||||
@@ -339,7 +339,7 @@ services:
|
||||
command: ["server", "/data"]
|
||||
environment:
|
||||
MINIO_ROOT_USER: "${MINIO_ROOT_USER:-caskeleton}"
|
||||
MINIO_ROOT_PASSWORD: "${MINIO_ROOT_PASSWORD:-caskeleton-local}"
|
||||
MINIO_ROOT_PASSWORD: "${MINIO_ROOT_PASSWORD:-__LOCAL_DEV_minio_root__}"
|
||||
volumes:
|
||||
- type: volume
|
||||
source: caskeleton-minio-data
|
||||
@@ -368,7 +368,7 @@ services:
|
||||
environment:
|
||||
MINIO_ENDPOINT: "http://minio:9000"
|
||||
MINIO_ROOT_USER: "${MINIO_ROOT_USER:-caskeleton}"
|
||||
MINIO_ROOT_PASSWORD: "${MINIO_ROOT_PASSWORD:-caskeleton-local}"
|
||||
MINIO_ROOT_PASSWORD: "${MINIO_ROOT_PASSWORD:-__LOCAL_DEV_minio_root__}"
|
||||
MINIO_BUCKET: "${MINIO_BUCKET:-ca-skeleton-objects}"
|
||||
volumes:
|
||||
- type: bind
|
||||
@@ -390,7 +390,7 @@ services:
|
||||
entrypoint: ["/bin/bash", "/opt/keycloak-entrypoint/entrypoint.sh"]
|
||||
environment:
|
||||
KC_BOOTSTRAP_ADMIN_USERNAME: "${KEYCLOAK_ADMIN:-admin}"
|
||||
KC_BOOTSTRAP_ADMIN_PASSWORD: "${KEYCLOAK_ADMIN_PASSWORD:-admin}"
|
||||
KC_BOOTSTRAP_ADMIN_PASSWORD: "${KEYCLOAK_ADMIN_PASSWORD:-__LOCAL_DEV_keycloak_admin__}"
|
||||
KC_HEALTH_ENABLED: "true"
|
||||
volumes:
|
||||
- type: bind
|
||||
|
||||
@@ -15,9 +15,14 @@
|
||||
# RR-07-04). 비밀값만 본다: 이 파일의 `secret` 행(SecretSourceValidator.CLASSIFIED_SECRETS,
|
||||
# SecretsClassificationRegistryTest가 1:1로 묶음), 모듈이 기여한 비밀, `secret://…/<VAR>` 참조가
|
||||
# 가리키는 변수. HOSTNAME·앱 이름 같은 비밀이 아닌 값은 보지 않는다 (review 2026-11-04 RR2-04-01).
|
||||
# - 가림(masking) 기본 = `full_except_last_4` (feature-secrets-config-source-contract 2026-05-22:
|
||||
# "full mask except last 4 chars for non-secret tokens" — 비밀이 아닌 토큰은 끝 4자만 남기고 가린다).
|
||||
# 진짜 secret(password/private key)은 `full`.
|
||||
# - `masking_rule`은 그 값이 로그에 나타났을 때 Layer 1 가림(`LogMaskingPatterns`, JSON·pattern 로그 공통)이
|
||||
# 하는 일이다. 값 셋만 쓴다(`SecretsClassificationRegistryTest`가 묶음):
|
||||
# full — 값 전체. 비밀 이름(password·secret·token·api key 등)의 key=value와 Authorization 값을 가린다.
|
||||
# 한 줄 값은 다음 공백·따옴표·구분자까지, PEM 블록은 여러 줄이어도 BEGIN~END 사이 전체다.
|
||||
# 진짜 secret(password/private key/HMAC key)은 이것이다.
|
||||
# userinfo — URI의 사용자 정보 비밀번호(`scheme://user:****@host`). 접속 URI 행이다.
|
||||
# none — 가리지 않는다.
|
||||
# - `required_test`는 그 행의 약속을 지키는 app-bootstrap 시험 클래스 이름이다(같은 시험이 클래스가 있는지 본다).
|
||||
# - 이름 접미사는 보조 신호다 (feature-secrets-config-source-contract: "_TOKEN, _KEY, _PASSWORD").
|
||||
# - public-config 항목은 env-keys.yaml에서 직접 정의되며 본 파일에는 reference row만 둠.
|
||||
|
||||
@@ -39,7 +44,7 @@ secrets:
|
||||
owner_branch: feature-secrets-config-source-contract
|
||||
masking_rule: full
|
||||
compatibility_impact: breaking
|
||||
required_test: secrets-contract:db-password-no-leak-in-actuator
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: SPRING_MAIL_PASSWORD
|
||||
# source: notification/fileserver techlead review H2 — Spring Mail이 직접 읽는 자격 증명이라 APP_* 별칭을 두지
|
||||
@@ -53,7 +58,7 @@ secrets:
|
||||
owner_branch: 2026-09-21-notification-review-remediation
|
||||
masking_rule: full
|
||||
compatibility_impact: additive
|
||||
required_test: secrets-contract:smtp-password-no-leak
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: APP_CACHE_REDIS_PASSWORD
|
||||
# source: feature-secrets-config-source-contract 2026-05-22
|
||||
@@ -69,7 +74,7 @@ secrets:
|
||||
owner_branch: feature-secrets-config-source-contract
|
||||
masking_rule: full
|
||||
compatibility_impact: breaking
|
||||
required_test: secrets-contract:redis-password-no-leak
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: APP_CACHE_REDIS_TRUST_PEM
|
||||
# 공개 CA bundle 내용이지만 무결성이 중요하고, 마운트된 환경이 준다.
|
||||
@@ -81,7 +86,7 @@ secrets:
|
||||
owner_branch: redis-production-capability
|
||||
masking_rule: full
|
||||
compatibility_impact: additive
|
||||
required_test: secrets-contract:redis-trust-reference-no-leak
|
||||
required_test: SecretsClassificationRegistryTest
|
||||
|
||||
- name: APP_CACHE_REDIS_KEY_HMAC_SECRET
|
||||
# 바뀌지 않는 캐시 key HMAC 자료. Redis 인증 자격 증명과 다르다.
|
||||
@@ -95,7 +100,7 @@ secrets:
|
||||
owner_branch: codex-phase-a-ci-recovery
|
||||
masking_rule: full
|
||||
compatibility_impact: breaking
|
||||
required_test: secrets-contract:redis-key-hmac-no-leak
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: APP_RATE_LIMIT_REDIS_PASSWORD
|
||||
# coordination role 전용 Redis 자격 증명. 캐시 Redis에서 물려받지 않는다.
|
||||
@@ -109,7 +114,7 @@ secrets:
|
||||
owner_branch: redis-distributed-rate-limit
|
||||
masking_rule: full
|
||||
compatibility_impact: additive
|
||||
required_test: secrets-contract:rate-limit-redis-password-no-leak
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: APP_RATE_LIMIT_REDIS_TRUST_PEM
|
||||
# coordination role CA bundle 내용. 무결성이 중요하지만 자격 증명 자료는 아니다.
|
||||
@@ -121,7 +126,7 @@ secrets:
|
||||
owner_branch: redis-production-capability
|
||||
masking_rule: full
|
||||
compatibility_impact: additive
|
||||
required_test: secrets-contract:rate-limit-redis-trust-reference-no-leak
|
||||
required_test: SecretsClassificationRegistryTest
|
||||
|
||||
- name: APP_RATE_LIMIT_REDIS_KEY_HMAC_SECRET
|
||||
# rate-limit 대상과 정책 개정에 쓰는, 바뀌지 않는 비공개 key 파생 자료.
|
||||
@@ -135,7 +140,7 @@ secrets:
|
||||
owner_branch: redis-distributed-rate-limit
|
||||
masking_rule: full
|
||||
compatibility_impact: additive
|
||||
required_test: secrets-contract:rate-limit-redis-key-hmac-no-leak
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: APP_SESSION_REDIS_PASSWORD
|
||||
# session role 전용 ACL 자격 증명. 캐시나 coordination과 몰래 함께 쓰지 않는다.
|
||||
@@ -149,7 +154,7 @@ secrets:
|
||||
owner_branch: redis-production-capability
|
||||
masking_rule: full
|
||||
compatibility_impact: additive
|
||||
required_test: secrets-contract:session-redis-password-no-leak
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: APP_SESSION_REDIS_TRUST_PEM
|
||||
# session role CA bundle 내용. 무결성이 중요하지만 자격 증명 자료는 아니다.
|
||||
@@ -161,7 +166,7 @@ secrets:
|
||||
owner_branch: redis-production-capability
|
||||
masking_rule: full
|
||||
compatibility_impact: additive
|
||||
required_test: secrets-contract:session-redis-trust-reference-no-leak
|
||||
required_test: SecretsClassificationRegistryTest
|
||||
|
||||
- name: APP_SESSION_REDIS_KEY_HMAC_SECRET
|
||||
# 가명 Redis session key에 쓰는, 바뀌지 않는 비공개 파생 자료.
|
||||
@@ -175,7 +180,7 @@ secrets:
|
||||
owner_branch: redis-production-capability
|
||||
masking_rule: full
|
||||
compatibility_impact: additive
|
||||
required_test: secrets-contract:session-redis-key-hmac-no-leak
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: APP_IDEMPOTENCY_REDIS_KEY_HMAC_SECRET
|
||||
# owner-safe 요청 replay key가 tenant·scope·요청 식별자를 드러내면 안 된다.
|
||||
@@ -189,7 +194,7 @@ secrets:
|
||||
owner_branch: redis-production-capability-completion
|
||||
masking_rule: full
|
||||
compatibility_impact: additive
|
||||
required_test: secrets-contract:idempotency-redis-key-hmac-no-leak
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: APP_LEASE_REDIS_KEY_HMAC_SECRET
|
||||
# 효율 lease의 자원·소유자 scope는 전용 파생 key를 쓴다.
|
||||
@@ -203,7 +208,7 @@ secrets:
|
||||
owner_branch: redis-production-capability-completion
|
||||
masking_rule: full
|
||||
compatibility_impact: additive
|
||||
required_test: secrets-contract:lease-redis-key-hmac-no-leak
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: APP_PRIVACY_PSEUDONYMIZATION_SALT
|
||||
# source: feature-data-retention-privacy-contract 2026-05-22
|
||||
@@ -218,7 +223,7 @@ secrets:
|
||||
owner_branch: feature-data-retention-privacy-contract
|
||||
masking_rule: full
|
||||
compatibility_impact: breaking
|
||||
required_test: secrets-contract:pseudonymization-salt-rotation
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
# === 2등급: sensitive-config (토큰이 든 URL이나 노출을 제한할 id) ===
|
||||
|
||||
@@ -235,7 +240,7 @@ secrets:
|
||||
owner_branch: worktree-notification-platform
|
||||
masking_rule: full
|
||||
compatibility_impact: behavior-change
|
||||
required_test: secrets-contract:notification-contact-encryption-no-leak
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: APP_NOTIFICATION_PLATFORM_CONTACT_LOOKUP_HMAC_KEY
|
||||
# 연락처의 blind index. 조회에 평문이 필요 없게 한다.
|
||||
@@ -250,7 +255,7 @@ secrets:
|
||||
owner_branch: worktree-notification-platform
|
||||
masking_rule: full
|
||||
compatibility_impact: behavior-change
|
||||
required_test: secrets-contract:notification-contact-lookup-hmac-no-leak
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: APP_NOTIFICATION_PLATFORM_CALLBACK_SIGNING_KEY
|
||||
# provider가 전달 결과를 보내는 callback URL에 서명한다.
|
||||
@@ -265,7 +270,7 @@ secrets:
|
||||
owner_branch: worktree-notification-platform
|
||||
masking_rule: full
|
||||
compatibility_impact: behavior-change
|
||||
required_test: secrets-contract:notification-callback-signing-no-leak
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: APP_NOTIFICATION_PLATFORM_PROVIDER_CREDENTIAL_KEY
|
||||
# 저장된 provider 자격 증명(그 자체가 비밀)을 암호화한다.
|
||||
@@ -280,7 +285,7 @@ secrets:
|
||||
owner_branch: worktree-notification-platform
|
||||
masking_rule: full
|
||||
compatibility_impact: behavior-change
|
||||
required_test: secrets-contract:notification-provider-credential-no-leak
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: APP_NOTIFICATION_PLATFORM_PAYLOAD_ENCRYPTION_KEY
|
||||
# 저장된 알림 변수와 보관한 callback 본문을 암호화한다.
|
||||
@@ -295,7 +300,7 @@ secrets:
|
||||
owner_branch: worktree-notification-platform
|
||||
masking_rule: full
|
||||
compatibility_impact: behavior-change
|
||||
required_test: secrets-contract:notification-payload-encryption-no-leak
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: APP_NOTIFICATION_PLATFORM_PROVIDER_REQUEST_LOOKUP_HMAC_KEY
|
||||
# provider 쪽 식별자인 provider request id의 key 있는 hash.
|
||||
@@ -310,7 +315,7 @@ secrets:
|
||||
owner_branch: worktree-notification-platform
|
||||
masking_rule: full
|
||||
compatibility_impact: behavior-change
|
||||
required_test: secrets-contract:notification-provider-request-lookup-hmac-no-leak
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: APP_NOTIFICATION_PLATFORM_CALLBACK_FINGERPRINT_HMAC_KEY
|
||||
# callback 본문의 key 있는 fingerprint. replay를 찾는 데 쓴다.
|
||||
@@ -325,35 +330,7 @@ secrets:
|
||||
owner_branch: worktree-notification-platform
|
||||
masking_rule: full
|
||||
compatibility_impact: behavior-change
|
||||
required_test: secrets-contract:notification-callback-fingerprint-hmac-no-leak
|
||||
|
||||
- name: APP_NOTIFICATION_SLACK_WEBHOOK_URL
|
||||
# source: feature-integration-adapter-templates 2026-05-22
|
||||
# "Slack | disabled optional module | notification failure policy"
|
||||
# Slack webhook URL은 token을 path에 포함하므로 sensitive-config (URL 형태이지만 secret과 동급 취급)
|
||||
classification: sensitive-config
|
||||
source: secret-manager
|
||||
rotation_policy: manual
|
||||
prod_default: null
|
||||
dev_sentinel_prefix: __LOCAL_DEV_
|
||||
owner_branch: feature-secrets-config-source-contract
|
||||
masking_rule: full_except_last_4
|
||||
compatibility_impact: breaking
|
||||
required_test: secrets-contract:slack-webhook-no-leak
|
||||
|
||||
- name: APP_SECURITY_GOOGLE_OAUTH_CLIENT_ID
|
||||
# source: feature-secrets-config-source-contract 2026-05-22
|
||||
# "sensitive-config" 등급 (id이지만 노출 제한)
|
||||
# + feature-integration-adapter-templates "Google Email | disabled optional module"
|
||||
classification: sensitive-config
|
||||
source: mounted-env
|
||||
rotation_policy: manual
|
||||
prod_default: null
|
||||
dev_sentinel_prefix: __LOCAL_DEV_
|
||||
owner_branch: feature-secrets-config-source-contract
|
||||
masking_rule: full_except_last_4
|
||||
compatibility_impact: behavior-change
|
||||
required_test: secrets-contract:google-oauth-client-id-masked
|
||||
required_test: SecretSourceValidatorTest
|
||||
|
||||
- name: APP_DATASOURCE_USERNAME
|
||||
# source: feature-secrets-config-source-contract 2026-05-22 — "sensitive-config" 등급
|
||||
@@ -364,9 +341,9 @@ secrets:
|
||||
prod_default: null
|
||||
dev_sentinel_prefix: __LOCAL_DEV_
|
||||
owner_branch: feature-secrets-config-source-contract
|
||||
masking_rule: full_except_last_4
|
||||
masking_rule: none
|
||||
compatibility_impact: breaking
|
||||
required_test: secrets-contract:datasource-username-masked-in-actuator
|
||||
required_test: SecretsClassificationRegistryTest
|
||||
|
||||
- name: SPRING_MONGODB_URI
|
||||
# MongoDB URI에는 사용자 이름·비밀번호가 들어 있을 수 있어 public config로 로그에 남기면 안 된다.
|
||||
@@ -377,9 +354,9 @@ secrets:
|
||||
prod_default: null
|
||||
dev_sentinel_prefix: __LOCAL_DEV_
|
||||
owner_branch: persistence-mongo-runtime-remediation
|
||||
masking_rule: full_except_last_4
|
||||
masking_rule: userinfo
|
||||
compatibility_impact: additive
|
||||
required_test: secrets-contract:mongodb-uri-masked
|
||||
required_test: LogMaskingPatternsTest
|
||||
|
||||
- name: APP_DATASOURCE_URL
|
||||
# source: feature-secrets-config-source-contract 2026-05-22 — JDBC URL은 host/db 포함하므로 sensitive-config
|
||||
@@ -390,20 +367,12 @@ secrets:
|
||||
prod_default: null
|
||||
dev_sentinel_prefix: __LOCAL_DEV_
|
||||
owner_branch: feature-secrets-config-source-contract
|
||||
masking_rule: full_except_last_4
|
||||
masking_rule: userinfo
|
||||
compatibility_impact: breaking
|
||||
required_test: secrets-contract:datasource-url-masked-in-actuator
|
||||
required_test: LogMaskingPatternsTest
|
||||
|
||||
# === 1등급: public-config (참조만 — 행 전체는 env-keys.yaml에 있다) ===
|
||||
|
||||
- name: APP_PROFILE
|
||||
# source: feature-env-driven-runtime-configuration — public-config 등급 참조
|
||||
classification: public-config
|
||||
source: application-yml
|
||||
owner_branch: feature-env-driven-runtime-configuration
|
||||
masking_rule: none
|
||||
reference: env-keys.yaml#APP_PROFILE
|
||||
|
||||
- name: APP_NAME
|
||||
# source: feature-env-driven-runtime-configuration — public-config 등급 참조
|
||||
classification: public-config
|
||||
@@ -412,14 +381,6 @@ secrets:
|
||||
masking_rule: none
|
||||
reference: env-keys.yaml#APP_NAME
|
||||
|
||||
- name: SERVER_PORT
|
||||
# source: feature-env-driven-runtime-configuration — Spring 자체 키, public-config 등급 참조
|
||||
classification: public-config
|
||||
source: application-yml
|
||||
owner_branch: feature-env-driven-runtime-configuration
|
||||
masking_rule: none
|
||||
reference: env-keys.yaml#SERVER_PORT
|
||||
|
||||
- name: SPRING_PROFILES_ACTIVE
|
||||
# source: feature-env-driven-runtime-configuration — Spring 자체 키, public-config 등급 참조
|
||||
classification: public-config
|
||||
|
||||
@@ -15,7 +15,7 @@ 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).
|
||||
4. 클라이언트 IP 해석: `APP_SERVER_FORWARD_HEADERS_STRATEGY=native` + Tomcat `server.tomcat.remoteip.internal-proxies`(신뢰하는 프록시의 IP 정규식)로 `getRemoteAddr()` 하나를 쓴다. limiter는 그 값만 읽고 따로 고르는 IP 모드가 없다(옛 `APP_RATE_LIMIT_CLIENT_IP_MODE`는 지웠다, `docs/capability-status.md`). `framework`는 모든 peer의 `X-Forwarded-*`를 믿어 호출자가 자기 IP를 고를 수 있으니 쓰지 않는다(`src/bootstrap/app/src/main/resources/config/server.yml`).
|
||||
|
||||
자세한 키는 `docs/registries/env-keys.yaml`의 `APP_RATE_LIMIT_*`, 모듈 기본값은 `src/adapter/outbound/cache-redis/src/main/resources/config/module-defaults/cache-redis.yml`.
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# 업그레이드 안내 — 2026-11 관측 registry·로그 내용·로컬 비밀 기본값
|
||||
|
||||
- 범위: 2026-11-12 전체 리뷰의 로그 내용 묶음을 고친 변경. 로그 줄이 원본 경로·SQL·요청 값을 덜 싣게 했다.
|
||||
- 근거: 2026-11-12 전체 리뷰(`docs/reviews/2026-11-12-round9-review/`)의 RR9-02-09·15·21·22·26
|
||||
- 범위: 2026-11-12 전체 리뷰의 로그 내용 묶음과 비밀·IP 문서 묶음을 고친 변경. 로그 줄이 원본 경로·SQL·요청 값을 덜
|
||||
싣게 했고, 로컬 비밀 기본값을 `__LOCAL_DEV_` 규칙에 맞췄다.
|
||||
- 근거: 2026-11-12 전체 리뷰(`docs/reviews/2026-11-12-round9-review/`)의 RR9-02-09·10·12·13·15·21·22·26
|
||||
|
||||
## 1. 누가 읽나
|
||||
|
||||
@@ -17,6 +18,8 @@ compose로 개발하는 사람이다.
|
||||
| 3 | outbox relay·파일 서버 정리 작업의 실패 줄은 분류된 실패를 `ServerFailureLog` 모양으로 남긴다(persistence 실패는 원인 사슬 없이, 그 밖의 carrier는 client 쪽 코드여도 stack과 함께). `composition:outbox-relay`가 `shared-contract`에 기댄다(registry edge 추가) | `gradle/modules.json`을 자기 쪽에서 고친 서비스는 그 edge를 받는다 | 의존 검사가 실패한다 | registry를 바꾼 서비스 |
|
||||
| 4 | JSON 로그의 `profile` 칸은 줄을 쓸 때의 해석된 profile이다(`ResolvedProfileJsonProvider`). `customFields`에는 `app`만 남았다 | `logback-spring.xml`을 복사해 고친 서비스는 같은 provider 줄을 넣는다 | `profile`이 환경 변수 값에 머문다 | logback 설정을 바꾼 서비스 |
|
||||
| 5 | web `HeaderSanitizer`(로그용 헤더 가림 공개 유틸리티)와 그 시험을 지웠다. 운영 코드가 부르지 않았고, 요청 로그는 헤더를 싣지 않는다 | 그 클래스를 부르던 서비스는 자기 코드로 옮긴다(마지막으로 있던 커밋은 `docs/capability-status.md` 제거 표) | 컴파일이 실패한다 | `HeaderSanitizer`를 부르던 서비스 |
|
||||
| 6 | 로컬 비밀 기본값이 `__LOCAL_DEV_` 접두어다: DB 비밀번호 `__LOCAL_DEV_db_password__`(compose·lane·`application-local.yml`), MinIO root `__LOCAL_DEV_minio_root__`, Keycloak admin `__LOCAL_DEV_keycloak_admin__`. prod에서 이 값이면 기동이 실패한다 | 옛 기본값으로 만든 로컬 volume(Postgres `caskeleton-db-data`, MinIO `caskeleton-minio-data`)이 있으면 저장소 루트 `.env`(compose 보간과 `bootRun`이 읽는 파일)에 옛 값을 `APP_DATASOURCE_PASSWORD`·`MINIO_ROOT_PASSWORD`로 두거나 volume을 지우고 다시 만든다(`docker compose down -v`). Keycloak은 volume이 없어 컨테이너를 다시 만들면 새 비밀번호로 들어간다 | 로컬 앱이 DB 인증에 실패하고 `minio-init`이 bucket을 만들지 못한다 | 로컬 compose를 쓰는 사람 |
|
||||
| 7 | `docs/registries/secrets-classification.yaml`의 `masking_rule`은 `full`·`userinfo`·`none`뿐이다(`full_except_last_4`는 구현이 없었다). Layer 1 가림이 salt·PEM·HMAC/signing/encryption/credential/private key 이름, 여러 줄 PEM 블록 전체, URI 사용자 정보 비밀번호(`scheme://user:****@host`)도 가린다. `required_test`는 app-bootstrap 시험 폴더에 있는 시험 클래스 이름이어야 한다(옛 `secrets-contract:*` 표지는 안 된다). 쓰지 않는 행 넷(`APP_PROFILE`, `SERVER_PORT`, `APP_NOTIFICATION_SLACK_WEBHOOK_URL`, `APP_SECURITY_GOOGLE_OAUTH_CLIENT_ID`)을 지웠다 | 자기 행에 `full_except_last_4`를 쓴 서비스는 `full`이나 `userinfo`로, `secrets-contract:*`는 시험 클래스 이름으로 바꾼다 | `SecretsClassificationRegistryTest`가 실패한다 | registry에 행을 더한 서비스 |
|
||||
|
||||
## 3. 바뀌지 않은 것
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ run_lane() {
|
||||
#
|
||||
# The database credentials are additionally *exported*, because two different mechanisms have to
|
||||
# agree on them. The application reads this file; the `db` service takes its POSTGRES_USER and
|
||||
# POSTGRES_PASSWORD from Compose interpolation — `${APP_DATASOURCE_PASSWORD:-ca_skeleton}` — and
|
||||
# POSTGRES_PASSWORD from Compose interpolation — `${APP_DATASOURCE_PASSWORD:-__LOCAL_DEV_db_password__}` — and
|
||||
# interpolation reads the process environment and the project .env file, never a service's
|
||||
# env_file. So the application got the generated password and the database got the literal
|
||||
# default, and no lane whose overlay did not happen to restate the value could ever authenticate.
|
||||
|
||||
@@ -323,6 +323,9 @@ relay 조립(`OutboxRelayAutoConfiguration`, 스케줄러·metrics·leader token
|
||||
- **시크릿 값만 가리고 키/스킴은 남긴다.** `token=abc123` → `token=****`,
|
||||
`Authorization: Bearer eyJ...` → `Authorization: Bearer ****`처럼 동작한다. 키와 인증 스킴(`Bearer`
|
||||
등)을 남기는 이유는 진단할 때 "어떤 종류의 자격증명이 있었는지"는 알아야 하기 때문이다.
|
||||
- **URI의 사용자 정보 비밀번호와 PEM 블록도 가린다.** `jdbc:postgresql://app:pw@db` → `jdbc:postgresql://app:****@db`
|
||||
(사용자 이름은 남긴다, secrets registry의 `userinfo` 규칙). `-----BEGIN …-----`부터 `-----END …-----`까지(키·인증서)는
|
||||
여러 줄이어도 본문 전체를 가리고 두 경계 줄만 남긴다. 같은 라벨의 END가 없으면 끝까지 가린다.
|
||||
- **정규식 마스킹은 보증이 아니라 심층 방어(defence-in-depth)의 보조 수단이다.** 1차 방어선은
|
||||
"로거가 애초에 본문/페이로드를 받지 않도록 설계한 것"(`FailOpenDependencyLogger`)이고, 이 정규식은
|
||||
그걸 빠져나간 누출을 잡는 그물이다. 키 접두어 없는 Base64URL 블롭 같은 난독화된 형태는 놓칠 수
|
||||
|
||||
@@ -47,7 +47,7 @@ services:
|
||||
environment:
|
||||
PGHOST: "db"
|
||||
PGUSER: "${APP_DATASOURCE_USERNAME:-ca_skeleton}"
|
||||
PGPASSWORD: "${APP_DATASOURCE_PASSWORD:-ca_skeleton}"
|
||||
PGPASSWORD: "${APP_DATASOURCE_PASSWORD:-__LOCAL_DEV_db_password__}"
|
||||
PGDATABASE: "${POSTGRES_DB:-ca_skeleton}"
|
||||
CAPABILITY_STREAMS: "${CAPABILITY_STREAMS:-}"
|
||||
volumes:
|
||||
@@ -82,7 +82,7 @@ services:
|
||||
environment:
|
||||
PGHOST: "db"
|
||||
PGUSER: "${APP_DATASOURCE_USERNAME:-ca_skeleton}"
|
||||
PGPASSWORD: "${APP_DATASOURCE_PASSWORD:-ca_skeleton}"
|
||||
PGPASSWORD: "${APP_DATASOURCE_PASSWORD:-__LOCAL_DEV_db_password__}"
|
||||
PGDATABASE: "${POSTGRES_DB:-ca_skeleton}"
|
||||
CAPABILITY_STREAMS: "${CAPABILITY_STREAMS:-}"
|
||||
volumes:
|
||||
@@ -176,7 +176,7 @@ services:
|
||||
environment:
|
||||
MINIO_ENDPOINT: "http://minio:9000"
|
||||
MINIO_ROOT_USER: "${MINIO_ROOT_USER:-caskeleton}"
|
||||
MINIO_ROOT_PASSWORD: "${MINIO_ROOT_PASSWORD:-caskeleton-local}"
|
||||
MINIO_ROOT_PASSWORD: "${MINIO_ROOT_PASSWORD:-__LOCAL_DEV_minio_root__}"
|
||||
MINIO_BUCKET: "${MINIO_BUCKET:-ca-skeleton-objects}"
|
||||
volumes:
|
||||
- type: bind
|
||||
|
||||
+30
-3
@@ -7,7 +7,11 @@ import net.logstash.logback.mask.ValueMasker;
|
||||
|
||||
/**
|
||||
* SSOT for secret-masking regex rules (shared by the JSON-encoder and pattern-layout paths). See
|
||||
* README for the design rationale.
|
||||
* README for the design rationale. The rules are the {@code masking_rule} values of {@code
|
||||
* docs/registries/secrets-classification.yaml}: {@code full} (rules 0–3) and {@code userinfo} (rule
|
||||
* 4). Rule 1 knows the secret names that registry uses — password, secret, token, api key, salt,
|
||||
* PEM, and HMAC/signing/encryption/credential/private keys — so a {@code NAME=value} of any {@code
|
||||
* full} row is masked; {@code SecretsClassificationRegistryTest} checks every such row.
|
||||
*/
|
||||
public final class LogMaskingPatterns {
|
||||
|
||||
@@ -22,11 +26,20 @@ public final class LogMaskingPatterns {
|
||||
|
||||
private static final List<Rule> RULES =
|
||||
List.of(
|
||||
// 0. A PEM block, multi-line included: rule 1 alone stops at the first space and would
|
||||
// mask only "-----BEGIN". The armour lines stay so a line still says what it held.
|
||||
// A block cut short (no END with its own label) is masked to the end of the text: what
|
||||
// follows the armour is key material either way.
|
||||
new Rule(
|
||||
Pattern.compile(
|
||||
"(-----BEGIN ([A-Z0-9 ]{1,40})-----)[\\s\\S]*?(-----END \\2-----|\\z)"),
|
||||
"$1" + MASK + "$3"),
|
||||
// 1. key=value / "key":"value" secrets — keep the key + separator, mask the value.
|
||||
new Rule(
|
||||
Pattern.compile(
|
||||
"(?i)(password|passwd|pwd|secret|token|api[_-]?key|access[_-]?token"
|
||||
+ "|refresh[_-]?token|client[_-]?secret)("
|
||||
+ "|refresh[_-]?token|client[_-]?secret|salt|pem"
|
||||
+ "|(?:hmac|signing|encryption|credential|private)[_-]?key)("
|
||||
+ SEP
|
||||
+ ")("
|
||||
+ VALUE
|
||||
@@ -38,7 +51,21 @@ public final class LogMaskingPatterns {
|
||||
"(?i)(authorization" + SEP + ")((?:bearer|basic|negotiate)\\s+)?(" + VALUE + ")"),
|
||||
"$1$2" + MASK),
|
||||
// 3. Standalone bearer token not preceded by an "authorization" key.
|
||||
new Rule(Pattern.compile("(?i)(bearer\\s+)([A-Za-z0-9._~+/=-]{8,})"), "$1" + MASK));
|
||||
new Rule(Pattern.compile("(?i)(bearer\\s+)([A-Za-z0-9._~+/=-]{8,})"), "$1" + MASK),
|
||||
// 4. The password in a URI's userinfo (jdbc:postgresql://app:pw@db, mongodb+srv://…),
|
||||
// the secrets registry's "userinfo" rule. The user name stays, so a line still says
|
||||
// which account connected (review 2026-11-12: the rule was declared, nothing did it).
|
||||
new Rule(
|
||||
// The password ends at the first '@' that a host[:port] and a delimiter follow, so a
|
||||
// raw '@', '/', '#' or '?' in it is masked too, and an '@' later in a path or query
|
||||
// is not taken for one. "user:8080/" is a port, not a password. The password is
|
||||
// bounded and never crosses another "://", so a long line stays linear.
|
||||
Pattern.compile(
|
||||
"(?i)(?<![a-z0-9+.-])([a-z][a-z0-9+.-]*://[^:/@\\s\"']*:)"
|
||||
+ "(?!\\d{1,5}(?:[/?#\\s]|$))"
|
||||
+ "((?:(?!://)[^\\s\"]){1,256}?)(@)"
|
||||
+ "(?=[a-z0-9.-]+(?::\\d+)?(?:[/?#,;\\s\"']|$))"),
|
||||
"$1" + MASK + "$3"));
|
||||
|
||||
private LogMaskingPatterns() {}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ spring:
|
||||
# H2 is still available and now has to be asked for: `./gradlew :app-bootstrap:bootRunH2`.
|
||||
url: ${APP_DATASOURCE_URL:jdbc:postgresql://localhost:5433/ca_skeleton}
|
||||
username: ${APP_DATASOURCE_USERNAME:ca_skeleton}
|
||||
password: ${APP_DATASOURCE_PASSWORD:ca_skeleton}
|
||||
password: ${APP_DATASOURCE_PASSWORD:__LOCAL_DEV_db_password__}
|
||||
driver-class-name: ${APP_DATASOURCE_DRIVER:org.postgresql.Driver}
|
||||
hikari:
|
||||
maximum-pool-size: 10
|
||||
@@ -118,7 +118,9 @@ server:
|
||||
port: ${APP_SERVER_PORT:8080}
|
||||
shutdown: graceful
|
||||
# No proxy in front of a local run, so trusting X-Forwarded-* would let a caller forge its own
|
||||
# client IP. dev/prod sit behind a load balancer and set this to framework via env.
|
||||
# client IP. dev/prod behind a load balancer set APP_SERVER_FORWARD_HEADERS_STRATEGY=native and
|
||||
# list their proxies' IPs (a regex) in server.tomcat.remoteip.internal-proxies — never framework,
|
||||
# which believes every peer (config/server.yml).
|
||||
forward-headers-strategy: none
|
||||
tomcat:
|
||||
threads:
|
||||
|
||||
+65
@@ -3,7 +3,9 @@ package dev.caskeleton.bootstrap.contract;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import dev.caskeleton.bootstrap.contract.support.RepositoryContractResources;
|
||||
import dev.caskeleton.bootstrap.logging.LogMaskingPatterns;
|
||||
import dev.caskeleton.bootstrap.runtime.SecretSourceValidator;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@@ -11,6 +13,7 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
@@ -115,4 +118,66 @@ class SecretsClassificationRegistryTest {
|
||||
.isIn(VALID_TIERS);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName(
|
||||
"masking_rule 은 LogMaskingPatterns 가 하는 셋(full·userinfo·none)뿐이다 — 구현 없는 규칙을 약속하지 않는다")
|
||||
void everyMaskingRuleIsOneTheMaskingLayerImplements() {
|
||||
// when
|
||||
Set<Object> rules = new LinkedHashSet<>();
|
||||
registryRows.forEach(row -> rules.add(row.get("masking_rule")));
|
||||
|
||||
// then
|
||||
assertThat(rules).isSubsetOf("full", "userinfo", "none");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("required_test 는 app-bootstrap 시험 폴더에 있는 시험 클래스 이름이다")
|
||||
void everyRequiredTestNamesATestClassThatExists() throws IOException {
|
||||
// given
|
||||
Path tests =
|
||||
RepositoryContractResources.fromSystemProperty()
|
||||
.requireTrackedDirectory("src/bootstrap/app/src/test/java");
|
||||
Set<String> classNames = new LinkedHashSet<>();
|
||||
try (Stream<Path> files = Files.walk(tests)) {
|
||||
files
|
||||
.map(path -> path.getFileName().toString())
|
||||
.filter(name -> name.endsWith("Test.java"))
|
||||
.forEach(name -> classNames.add(name.substring(0, name.length() - ".java".length())));
|
||||
}
|
||||
|
||||
// when
|
||||
Set<Object> named = new LinkedHashSet<>();
|
||||
registryRows.stream()
|
||||
.map(row -> row.get("required_test"))
|
||||
.filter(java.util.Objects::nonNull)
|
||||
.forEach(named::add);
|
||||
|
||||
// then
|
||||
assertThat(classNames).containsAll(named.stream().map(String::valueOf).toList());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("masking_rule 이 full 인 행의 NAME=값 과 userinfo 행의 URI 비밀번호는 Layer 1 가림이 실제로 가린다")
|
||||
void everyMaskingRuleIsHonouredByTheMaskingLayer() {
|
||||
// given
|
||||
String secret = "s3cr3t-Value-1234";
|
||||
|
||||
// when
|
||||
List<String> leaked = new java.util.ArrayList<>();
|
||||
for (Map<String, Object> row : registryRows) {
|
||||
String name = String.valueOf(row.get("name"));
|
||||
Object rule = row.get("masking_rule");
|
||||
String line =
|
||||
"full".equals(rule)
|
||||
? name + "=" + secret
|
||||
: "userinfo".equals(rule) ? "scheme://user:" + secret + "@host/db" : null;
|
||||
if (line != null && LogMaskingPatterns.mask(line).contains(secret)) {
|
||||
leaked.add(name);
|
||||
}
|
||||
}
|
||||
|
||||
// then
|
||||
assertThat(leaked).isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
+93
@@ -2,7 +2,11 @@ package dev.caskeleton.bootstrap.logging;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
/**
|
||||
* Guards the Redaction Layer 1 secret catalog (feature-log-management-contract 테스트 계약:
|
||||
@@ -76,4 +80,93 @@ class LogMaskingPatternsTest {
|
||||
Object number = 42;
|
||||
assertThat(LogMaskingPatterns.valueMasker().mask(null, number)).isSameAs(number);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource(
|
||||
delimiter = '|',
|
||||
value = {
|
||||
"connecting to jdbc:postgresql://app:hunter2@db:5432/ca | connecting to jdbc:postgresql://app:****@db:5432/ca",
|
||||
"uri=mongodb+srv://reader:s3cr3t-pw@cluster0.example.net/app | uri=mongodb+srv://reader:****@cluster0.example.net/app",
|
||||
"redis://default:pw@cache:6379 | redis://default:****@cache:6379",
|
||||
"redis://:pw@cache:6379 | redis://:****@cache:6379",
|
||||
"jdbc:postgresql://app:it's-a-secret@db/ca | jdbc:postgresql://app:****@db/ca",
|
||||
"jdbc:postgresql://app:p@ss@db:5432/ca | jdbc:postgresql://app:****@db:5432/ca",
|
||||
"redis://default:Ab/cd+ef@cache:6379 | redis://default:****@cache:6379",
|
||||
"redis://default:P#ssw0rd@cache:6379 | redis://default:****@cache:6379",
|
||||
"redis://default:pa?ss@cache:6379 | redis://default:****@cache:6379",
|
||||
"redis://u:pw@h,redis://u2:pw2@h2 | redis://u:****@h,redis://u2:****@h2",
|
||||
"mongodb://u:p@h1:27017,h2:27017/db | mongodb://u:****@h1:27017,h2:27017/db"
|
||||
})
|
||||
@DisplayName("URI 사용자 정보의 비밀번호를 가리고 사용자 이름은 남긴다(secrets registry 의 userinfo 규칙)")
|
||||
void masksThePasswordInAUrisUserinfo(String line, String masked) {
|
||||
assertThat(LogMaskingPatterns.mask(line)).isEqualTo(masked);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("PEM 블록은 여러 줄이어도 BEGIN·END 사이를 모두 가린다 — 첫 공백에서 멈추지 않는다")
|
||||
void masksAWholePemBlockAcrossLines() {
|
||||
// given
|
||||
String line =
|
||||
"trust_pem=-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASC\nSECRETBODY\n"
|
||||
+ "-----END PRIVATE KEY----- loaded";
|
||||
|
||||
// when
|
||||
String masked = LogMaskingPatterns.mask(line);
|
||||
|
||||
// then
|
||||
assertThat(masked)
|
||||
.doesNotContain("MIIEvQIBADANBgkqhkiG9w0BAQEFAASC", "SECRETBODY")
|
||||
.contains("-----END PRIVATE KEY----- loaded");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("END 가 없는 PEM 블록은 BEGIN 줄만 남기고 끝까지 가린다")
|
||||
void masksAPemBlockCutShortToTheEnd() {
|
||||
// when
|
||||
String masked =
|
||||
LogMaskingPatterns.mask(
|
||||
"key=-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASC\nSECRETBODY");
|
||||
|
||||
// then
|
||||
assertThat(masked).isEqualTo("key=-----BEGIN PRIVATE KEY-----****");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("다른 라벨의 END 만 있는 PEM 블록도 BEGIN 줄만 남기고 끝까지 가린다")
|
||||
void masksAPemBlockClosedUnderAnotherLabelToTheEnd() {
|
||||
// when
|
||||
String masked =
|
||||
LogMaskingPatterns.mask(
|
||||
"-----BEGIN RSA PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASC\n"
|
||||
+ "-----END PRIVATE KEY-----\nSECRETBODY");
|
||||
|
||||
// then
|
||||
assertThat(masked).isEqualTo("-----BEGIN RSA PRIVATE KEY-----****");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("공백 없는 긴 줄도 가림 규칙이 선형으로 끝난다 — 줄 길이의 제곱으로 느려지지 않는다")
|
||||
void aLongLineWithoutSpacesIsMaskedInLinearTime() {
|
||||
// given
|
||||
String line = "a://:".repeat(32_000) + "http://h:1/".repeat(15_000) + "a".repeat(40_000);
|
||||
|
||||
// when
|
||||
long started = System.nanoTime();
|
||||
LogMaskingPatterns.mask(line);
|
||||
long elapsedMillis = (System.nanoTime() - started) / 1_000_000;
|
||||
|
||||
// then
|
||||
assertThat(elapsedMillis).as("masking a 365 KB line").isLessThan(1_000);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(
|
||||
strings = {
|
||||
"calling https://api.example.com:8443/v1/things",
|
||||
"calling https://api.example.com:8443/v1/users?email=a@b.example",
|
||||
"GET http://localhost:8080/v1/users/alice@example.com"
|
||||
})
|
||||
void aUriWithoutUserinfoIsUntouched(String line) {
|
||||
assertThat(LogMaskingPatterns.mask(line)).isSameAs(line);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user