From 92ce731e8d13e777099b6127bd1fc9dc340a0add Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 17:49:40 +0000 Subject: [PATCH] fix(container): convert compose.yaml and .gatekeeper.yaml to KYAML The template upgrade (#8) brought in the KYAML ratchet in estate-rules.yml ("Converted YAML stays KYAML"), which lists build/container/compose.yaml, compose.example.yaml and build/container/stapeln/.gatekeeper.yaml. This repository's own compose.yaml and .gatekeeper.yaml were still block-style YAML, so the ratchet fails on them (kyaml-format.sh --check: 2 of 2 not KYAML). Both files go through the pinned formatter (standards f0b3cd4 kyaml-format.sh, mikefarah yq 4.53.3, the checksums CI verifies). Names are unchanged, since the tools read these filenames. The parsed data is identical before and after (yq to JSON, byte-for-byte), and the comment count is unchanged (30 and 59). Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_0136P7Zm6f3TYUpUuzGd5KAQ --- build/container/compose.yaml | 197 ++++++++++------- build/container/stapeln/.gatekeeper.yaml | 257 +++++++++++++---------- 2 files changed, 262 insertions(+), 192 deletions(-) diff --git a/build/container/compose.yaml b/build/container/compose.yaml index a346297..a2df894 100644 --- a/build/container/compose.yaml +++ b/build/container/compose.yaml @@ -16,84 +16,119 @@ # # See https://compose-spec.io for the full specification. -services: - # ────────────────────────────────────────────────────────────────────── - # Primary application service - # ────────────────────────────────────────────────────────────────────── - "sholes": - build: - context: .. - dockerfile: build/container/Containerfile - image: "ghcr.io/hyperpolymath/sholes:latest" - ports: - - "8080:8080" - environment: - APP_HOST: "[::]" - APP_PORT: "8080" - APP_LOG_FORMAT: "json" - APP_DATA_DIR: "/data" - volumes: - - "sholes-data:/data" - restart: unless-stopped - healthcheck: - test: ["CMD", "curl", "-sf", "http://localhost:8080/health"] - interval: 30s - timeout: 5s - retries: 3 - start_period: 10s - - # ────────────────────────────────────────────────────────────────────── - # rokur — secrets-management gate (stapeln). Fronts the app and refuses - # to start the stack unless required secrets are present. on Wolfi. - # Remove this service if you do not use secret gating. - # ────────────────────────────────────────────────────────────────────── - rokur: - image: ghcr.io/hyperpolymath/rokur:latest - environment: - ROKUR_BACKEND: "http://sholes:8080" - ROKUR_LISTEN: "[::]:8081" - ROKUR_REQUIRED_SECRETS: "" # comma-separated env names that MUST be set - ROKUR_AUDIT_LOG: "/var/log/rokur/audit.jsonl" - ROKUR_LOG_FORMAT: "json" - ports: - - "8081:8081" - volumes: - - rokur-audit:/var/log/rokur - depends_on: - "sholes": - condition: service_healthy - restart: unless-stopped - healthcheck: - test: ["CMD", "curl", "-sf", "http://localhost:8081/health"] - interval: 30s - timeout: 5s - retries: 3 - - # ────────────────────────────────────────────────────────────────────── - # svalinn — edge gateway (stapeln). TLS termination, auth, rate limiting. - # Reads the gatekeeper policy from build/container/stapeln/.gatekeeper.yaml. - # Remove this service for a bare app with no gateway. - # ────────────────────────────────────────────────────────────────────── - svalinn: - image: ghcr.io/hyperpolymath/svalinn:latest - ports: - - "443:443" - - "80:80" - environment: - SVALINN_BACKEND: "http://rokur:8081" - SVALINN_POLICY_FILE: "/etc/svalinn/gatekeeper.yaml" - SVALINN_TLS_AUTO: "true" - volumes: - - ./stapeln/.gatekeeper.yaml:/etc/svalinn/gatekeeper.yaml:ro - depends_on: - - rokur - restart: unless-stopped - healthcheck: - test: ["CMD", "curl", "-sf", "http://localhost:80/health"] - interval: 30s - timeout: 5s - retries: 3 - -volumes: - "sholes-data": - rokur-audit: +{ + services: { + # ────────────────────────────────────────────────────────────────────── + # Primary application service + # ────────────────────────────────────────────────────────────────────── + sholes: { + build: { + context: "..", + dockerfile: "build/container/Containerfile", + }, + image: "ghcr.io/hyperpolymath/sholes:latest", + ports: [ + "8080:8080", + ], + environment: { + APP_HOST: "[::]", + APP_PORT: "8080", + APP_LOG_FORMAT: "json", + APP_DATA_DIR: "/data", + }, + volumes: [ + "sholes-data:/data", + ], + restart: "unless-stopped", + healthcheck: { + test: [ + "CMD", + "curl", + "-sf", + "http://localhost:8080/health", + ], + interval: "30s", + timeout: "5s", + retries: 3, + start_period: "10s", + }, + }, + # ────────────────────────────────────────────────────────────────────── + # rokur — secrets-management gate (stapeln). Fronts the app and refuses + # to start the stack unless required secrets are present. on Wolfi. + # Remove this service if you do not use secret gating. + # ────────────────────────────────────────────────────────────────────── + rokur: { + image: "ghcr.io/hyperpolymath/rokur:latest", + environment: { + ROKUR_BACKEND: "http://sholes:8080", + ROKUR_LISTEN: "[::]:8081", + ROKUR_REQUIRED_SECRETS: "", # comma-separated env names that MUST be set + ROKUR_AUDIT_LOG: "/var/log/rokur/audit.jsonl", + ROKUR_LOG_FORMAT: "json", + }, + ports: [ + "8081:8081", + ], + volumes: [ + "rokur-audit:/var/log/rokur", + ], + depends_on: { + sholes: { + condition: "service_healthy", + }, + }, + restart: "unless-stopped", + healthcheck: { + test: [ + "CMD", + "curl", + "-sf", + "http://localhost:8081/health", + ], + interval: "30s", + timeout: "5s", + retries: 3, + }, + }, + # ────────────────────────────────────────────────────────────────────── + # svalinn — edge gateway (stapeln). TLS termination, auth, rate limiting. + # Reads the gatekeeper policy from build/container/stapeln/.gatekeeper.yaml. + # Remove this service for a bare app with no gateway. + # ────────────────────────────────────────────────────────────────────── + svalinn: { + image: "ghcr.io/hyperpolymath/svalinn:latest", + ports: [ + "443:443", + "80:80", + ], + environment: { + SVALINN_BACKEND: "http://rokur:8081", + SVALINN_POLICY_FILE: "/etc/svalinn/gatekeeper.yaml", + SVALINN_TLS_AUTO: "true", + }, + volumes: [ + "./stapeln/.gatekeeper.yaml:/etc/svalinn/gatekeeper.yaml:ro", + ], + depends_on: [ + "rokur", + ], + restart: "unless-stopped", + healthcheck: { + test: [ + "CMD", + "curl", + "-sf", + "http://localhost:80/health", + ], + interval: "30s", + timeout: "5s", + retries: 3, + }, + }, + }, + volumes: { + sholes-data: null, + rokur-audit: null, + }, +} diff --git a/build/container/stapeln/.gatekeeper.yaml b/build/container/stapeln/.gatekeeper.yaml index 678bcfa..033e537 100644 --- a/build/container/stapeln/.gatekeeper.yaml +++ b/build/container/stapeln/.gatekeeper.yaml @@ -9,114 +9,149 @@ # # See: stapeln/container-stack/svalinn/ -version: "1.0" - -# ============================================================================ -# Authentication -# ============================================================================ -# -# Define which endpoints require authentication and at what level. - -auth: - # Public endpoints — no authentication required. - # Health and readiness probes must always be public so that - # orchestrators (selur, Podman, k8s) can check service status. - public: - - path: "/health" - methods: ["GET"] - - path: "/ready" - methods: ["GET"] - - path: "/metrics" - methods: ["GET"] - - # Endpoints requiring JWT or OAuth2 authentication. - # Svalinn validates the token before forwarding the request. - authenticated: - - path: "/api/v1/*" - methods: ["GET", "POST", "PUT", "DELETE"] - -# ============================================================================ -# Rate Limiting -# ============================================================================ -# -# Protects backend services from overload. Values here are moderate -# defaults — adjust based on your service capacity. - -rate_limits: - # Global limit: applied to all authenticated clients. - global: - requests_per_second: 500 - burst: 1000 - - # Write operations: stricter limit to protect data stores. - writes: - paths: ["/api/v1/*"] - methods: ["POST", "PUT", "DELETE"] - requests_per_second: 100 - burst: 200 - -# ============================================================================ -# Container Trust -# ============================================================================ -# -# Svalinn verifies that all .ctp bundles in the stack are signed by -# trusted keys and carry the required attestations. - -trust: - # Only accept .ctp bundles signed by these keys. - trusted_signers: - - key_id: "sholes-release" - algorithm: "Ed25519" - public_key_file: "/etc/svalinn/keys/sholes-release.pub" - - # Require these attestations on all .ctp bundles. - required_attestations: - - "source-signature" - - "sbom-complete" - - # Reject unsigned or untrusted images. - reject_unsigned: true - -# ============================================================================ -# Request Validation -# ============================================================================ -# -# Input validation at the gateway layer — catches malformed requests -# before they reach the application. - -validation: - # Maximum request body size. - max_body_size: "8MB" - - # Reject requests with NaN or Infinity in numeric fields. - reject_nan_inf: true - - # Maximum result limit per list/search query. - max_result_limit: 500 - -# ============================================================================ -# CORS -# ============================================================================ -# -# Cross-Origin Resource Sharing policy. The defaults below allow all -# origins — restrict to your frontend domain(s) in production. - -cors: - allow_origins: ["*"] - allow_methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"] - allow_headers: ["Content-Type", "Authorization"] - max_age: 3600 - -# ============================================================================ -# Logging -# ============================================================================ -# -# Structured logging for svalinn itself. Audit paths log all requests -# (including body hashes) for post-incident investigation. - -logging: - format: "json" - level: "info" - # Log all write operations for audit trail. - audit_paths: - - "/api/v1/*" +{ + version: "1.0", + # ============================================================================ + # Authentication + # ============================================================================ + # + # Define which endpoints require authentication and at what level. + auth: { + # Public endpoints — no authentication required. + # Health and readiness probes must always be public so that + # orchestrators (selur, Podman, k8s) can check service status. + public: [ + { + path: "/health", + methods: [ + "GET", + ], + }, + { + path: "/ready", + methods: [ + "GET", + ], + }, + { + path: "/metrics", + methods: [ + "GET", + ], + }, + ], + # Endpoints requiring JWT or OAuth2 authentication. + # Svalinn validates the token before forwarding the request. + authenticated: [ + { + path: "/api/v1/*", + methods: [ + "GET", + "POST", + "PUT", + "DELETE", + ], + }, + ], + }, + # ============================================================================ + # Rate Limiting + # ============================================================================ + # + # Protects backend services from overload. Values here are moderate + # defaults — adjust based on your service capacity. + rate_limits: { + # Global limit: applied to all authenticated clients. + global: { + requests_per_second: 500, + burst: 1000, + }, + # Write operations: stricter limit to protect data stores. + writes: { + paths: [ + "/api/v1/*", + ], + methods: [ + "POST", + "PUT", + "DELETE", + ], + requests_per_second: 100, + burst: 200, + }, + }, + # ============================================================================ + # Container Trust + # ============================================================================ + # + # Svalinn verifies that all .ctp bundles in the stack are signed by + # trusted keys and carry the required attestations. + trust: { + # Only accept .ctp bundles signed by these keys. + trusted_signers: [ + { + key_id: "sholes-release", + algorithm: "Ed25519", + public_key_file: "/etc/svalinn/keys/sholes-release.pub", + }, + ], + # Require these attestations on all .ctp bundles. + required_attestations: [ + "source-signature", + "sbom-complete", + ], + # Reject unsigned or untrusted images. + reject_unsigned: true, + }, + # ============================================================================ + # Request Validation + # ============================================================================ + # + # Input validation at the gateway layer — catches malformed requests + # before they reach the application. + validation: { + # Maximum request body size. + max_body_size: "8MB", + # Reject requests with NaN or Infinity in numeric fields. + reject_nan_inf: true, + # Maximum result limit per list/search query. + max_result_limit: 500, + }, + # ============================================================================ + # CORS + # ============================================================================ + # + # Cross-Origin Resource Sharing policy. The defaults below allow all + # origins — restrict to your frontend domain(s) in production. + cors: { + allow_origins: [ + "*", + ], + allow_methods: [ + "GET", + "POST", + "PUT", + "DELETE", + "OPTIONS", + ], + allow_headers: [ + "Content-Type", + "Authorization", + ], + max_age: 3600, + }, + # ============================================================================ + # Logging + # ============================================================================ + # + # Structured logging for svalinn itself. Audit paths log all requests + # (including body hashes) for post-incident investigation. + logging: { + format: "json", + level: "info", + # Log all write operations for audit trail. + audit_paths: [ + "/api/v1/*", + ], + }, +}