diff --git a/00_SUBMISSION_PACKAGE/evidence/scoring-run-report.md b/00_SUBMISSION_PACKAGE/evidence/scoring-run-report.md index 323505e..4979037 100644 --- a/00_SUBMISSION_PACKAGE/evidence/scoring-run-report.md +++ b/00_SUBMISSION_PACKAGE/evidence/scoring-run-report.md @@ -18,6 +18,7 @@ phase3-evidence-pack **7** · phase-h5-approval **12** · phase-h5-infra **7** · phase-h6-agentops **20** · phase-c7-incident **15** · phase-h4-multilingual **7** · phase-c6-sandbox **6** · phase-h4-split-inject **8** · phase10-traceability **3**. - Direct model-router suite: **10 PASS / 0 FAIL** (includes model-digest pin OK, mismatch BLOCK, mismatch WARN rollout mode). +- Local production-like Docker infra lab: **2 PASS / 0 FAIL**, with `infra-lab verify` internal **7 PASS / 0 FAIL** (Vault Transit, OIDC/JWKS, MinIO Object Lock, alert webhook, billing API mock, dashboard nginx auth). - Frontend Vitest: **16 PASS / 0 FAIL**. Backend `npm test` is blocked by pre-existing app-test infra mismatch (`schema.prisma` provider MySQL but `setup-sqlite.mjs` applies the MySQL migration to SQLite). - `security-gate` aggregate: **verdict PASS=11 FAIL=0 SKIP=0** (run 2026-07-04). - H4 recall: model 0.85 > regex 0.00 (GATE PASS). Benign-FP: **fp_rate 0.00% · block_rate 100.00%** (95 mẫu benign EN/VI/JA + 12 vector). @@ -55,7 +56,7 @@ - (5/5 gate)×100 chỉ đo **độ phủ control**, không đo **độ trưởng thành/vận-hành-thật** — report này tách bạch: mục 2 = coverage/pass thật, mục 3 = trưởng thành công tâm. ## 5. Ranh giới trung thực -- CASAN **Level 4 chứng minh bằng tấn công (218 core harness tests)**. Level 5 các control hiện thực + test cục bộ; production Level 5 cần **IdP thật/JWKS**, **WORM store (S3 Object Lock)**, KMS mặc định + HSM, **billing-API thật** (usage endpoint OpenAI/Anthropic), **dashboard deploy thật** (nginx/container + auth), **kênh alert managed + on-call**, sandbox isolation rootless/nsjail/base image CI. +- CASAN **Level 4 chứng minh bằng tấn công (218 core harness tests + local-prod Docker infra lab)**. Level 5 các control hiện thực + test cục bộ; production Level 5 vẫn cần **enterprise IdP/JWKS**, **WORM store thật (S3 Object Lock/QLDB)**, KMS mặc định + HSM, **billing-API thật** (usage endpoint OpenAI/Anthropic), **dashboard deploy managed + TLS/OIDC**, **kênh alert managed + on-call**, sandbox isolation rootless/nsjail/base image CI. - KMS đã chạy **live qua Vault dev** ở lần chấm 2026-07-04 (đường Transit thật, khoá non-exportable); lần chạy 2026-07-05 Vault down → suite KMS **SKIP đúng thiết kế** (không tính là fail). Production thay bằng Vault/AWS-KMS/CloudHSM. - H6 "live" nghĩa là: webhook, provider-usage API, dashboard `/healthz` đều là **endpoint HTTP thật chạy local** (cùng chuẩn Vault-dev) — chưa phải dịch vụ hosted/managed bên ngoài. - Model = Ollama ornith:9b **local**; đường cloud (OpenAI/Anthropic) đã hiện thực trong `model-call.py` nhưng **chưa test bằng key thật**. @@ -81,6 +82,7 @@ bash .specify/tests/phase-c6-sandbox-tests.sh # 6/0 bash .specify/tests/phase-h4-split-inject-tests.sh # 8/0 bash .specify/tests/phase10-traceability-tests.sh # 3/0 bash .specify/tests/phase3-model-router-tests.sh # 10/0 (direct model-router/digest suite) +bash .specify/tests/phase-prod-infra-lab-tests.sh # 2/0, starts Docker infra lab bash .specify/scripts/bash/security-gate.sh # verdict PASS=11 FAIL=0 ``` > Mục 3 là **đánh giá trưởng thành theo rubric** (người chấm, neo vào bằng chứng + gap thật), không phải output tự động của scorecard.sh (vốn chỉ đo coverage). Suite model cần Ollama live; suite KMS cần Vault live để chạy (không có thì SKIP, không tính là fail). Suite H6 **tự dựng** webhook sink / mock provider-API / dashboard server trên cổng ephemeral local — deterministic, không cần model. diff --git a/AINative_OKR_CASAN5/.specify/scripts/bash/approval-verify.sh b/AINative_OKR_CASAN5/.specify/scripts/bash/approval-verify.sh index 9e4eee0..0684c56 100755 --- a/AINative_OKR_CASAN5/.specify/scripts/bash/approval-verify.sh +++ b/AINative_OKR_CASAN5/.specify/scripts/bash/approval-verify.sh @@ -21,6 +21,7 @@ set -uo pipefail # CASAN_REVIEWERS_DIR (default governance/reviewers) — base dir for pubkey-file # CASAN_APPROVAL_JWT (optional RS256 IdP token) # CASAN_IDP_PUBLIC_KEY (default central-governance/idp-public.pem) +# CASAN_IDP_JWKS_URL (optional OIDC JWKS endpoint; overrides public key) # Exit: 0 ok (prints "APPROVAL_OK role="), 3 deny (reason on stderr), 64 usage. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" @@ -54,7 +55,11 @@ ROLES="$(awk -v a="$ACTION" '$1=="action" && $2==a {print $3; exit}' "$REVIEWERS if [[ -n "${CASAN_APPROVAL_JWT:-}" ]]; then IDP_PUB="${CASAN_IDP_PUBLIC_KEY:-$GOV_DIR/idp-public.pem}" - [[ -f "$IDP_PUB" ]] || deny "idp_pubkey_missing($IDP_PUB)" + if [[ -n "${CASAN_IDP_JWKS_URL:-}" ]]; then + IDP_PUB="jwks:${CASAN_IDP_JWKS_URL}" + else + [[ -f "$IDP_PUB" ]] || deny "idp_pubkey_missing($IDP_PUB)" + fi JWT_OUT="$( python3 - "$CASAN_APPROVAL_JWT" "$IDP_PUB" "$APPROVER" "$ROLES" "$ACTION" "$ACTOR" "$INPUT_SHA" <<'PY' import base64 @@ -64,6 +69,7 @@ import subprocess import sys import tempfile import time +import urllib.request jwt, pub, approver, roles_csv, action, actor, input_sha = sys.argv[1:8] @@ -101,13 +107,54 @@ if claims.get("input_sha256") != input_sha: sig = b64u_decode(parts[2]) signing_input = ".".join(parts[:2]).encode() + +def der_len(n): + if n < 128: + return bytes([n]) + raw = n.to_bytes((n.bit_length() + 7) // 8, "big") + return bytes([0x80 | len(raw)]) + raw + +def der_tlv(tag, body): + return bytes([tag]) + der_len(len(body)) + body + +def der_int(n): + raw = n.to_bytes((n.bit_length() + 7) // 8, "big") or b"\x00" + if raw[0] & 0x80: + raw = b"\x00" + raw + return der_tlv(0x02, raw) + +def jwk_to_pem(jwk): + n = int.from_bytes(b64u_decode(jwk["n"]), "big") + e = int.from_bytes(b64u_decode(jwk["e"]), "big") + rsa_pub = der_tlv(0x30, der_int(n) + der_int(e)) + alg_id = der_tlv( + 0x30, + der_tlv(0x06, b"\x2a\x86\x48\x86\xf7\x0d\x01\x01\x01") + der_tlv(0x05, b""), + ) + spki = der_tlv(0x30, alg_id + der_tlv(0x03, b"\x00" + rsa_pub)) + b64 = base64.encodebytes(spki).decode().replace("\n", "") + lines = [b64[i:i+64] for i in range(0, len(b64), 64)] + return "-----BEGIN PUBLIC KEY-----\n" + "\n".join(lines) + "\n-----END PUBLIC KEY-----\n" + +pub_file = pub with tempfile.TemporaryDirectory() as td: sig_path = os.path.join(td, "sig.bin") msg_path = os.path.join(td, "msg.txt") open(sig_path, "wb").write(sig) open(msg_path, "wb").write(signing_input) + if pub.startswith("jwks:"): + try: + jwks = json.loads(urllib.request.urlopen(pub[len("jwks:"):], timeout=5).read().decode()) + except Exception: + die("jwks_fetch_failed") + kid = header.get("kid") + keys = [k for k in jwks.get("keys", []) if k.get("kty") == "RSA" and (not kid or k.get("kid") == kid)] + if not keys: + die("jwks_key_not_found") + pub_file = os.path.join(td, "idp-public.pem") + open(pub_file, "w", encoding="utf-8").write(jwk_to_pem(keys[0])) rc = subprocess.run( - ["openssl", "dgst", "-sha256", "-verify", pub, "-signature", sig_path, msg_path], + ["openssl", "dgst", "-sha256", "-verify", pub_file, "-signature", sig_path, msg_path], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ).returncode diff --git a/AINative_OKR_CASAN5/.specify/scripts/bash/dashboard-server.py b/AINative_OKR_CASAN5/.specify/scripts/bash/dashboard-server.py index 8b55773..48e60e0 100644 --- a/AINative_OKR_CASAN5/.specify/scripts/bash/dashboard-server.py +++ b/AINative_OKR_CASAN5/.specify/scripts/bash/dashboard-server.py @@ -73,6 +73,8 @@ class Handler(BaseHTTPRequestHandler): def log_message(self, *args): # silence per-request stderr noise pass +BIND = os.environ.get("CASAN_DASHBOARD_BIND", "127.0.0.1") + if __name__ == "__main__": - HTTPServer(("127.0.0.1", PORT), Handler).serve_forever() + HTTPServer((BIND, PORT), Handler).serve_forever() diff --git a/AINative_OKR_CASAN5/.specify/scripts/bash/infra-lab.sh b/AINative_OKR_CASAN5/.specify/scripts/bash/infra-lab.sh new file mode 100755 index 0000000..dcf8882 --- /dev/null +++ b/AINative_OKR_CASAN5/.specify/scripts/bash/infra-lab.sh @@ -0,0 +1,143 @@ +#!/usr/bin/env bash +set -uo pipefail + +# CASAN local production-like infra lab. +# +# Usage: +# infra-lab.sh start|stop|status|verify|env + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)" +COMPOSE="$PROJECT_ROOT/infra/local-prod/docker-compose.yml" +CMD="${1:-status}" + +compose() { + docker compose -f "$COMPOSE" "$@" +} + +need_docker() { + command -v docker >/dev/null 2>&1 || { echo "INFRA_LAB_DOCKER_MISSING" >&2; exit 1; } + docker compose version >/dev/null 2>&1 || { echo "INFRA_LAB_COMPOSE_MISSING" >&2; exit 1; } +} + +hash_file() { + if command -v sha256sum >/dev/null 2>&1; then sha256sum "$1" | awk '{print $1}' + else shasum -a 256 "$1" | awk '{print $1}'; fi +} + +wait_url() { + local url="$1" + for _ in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24; do + curl -fsS -m 3 "$url" >/dev/null 2>&1 && return 0 + sleep 2 + done + echo "INFRA_LAB_WAIT_TIMEOUT url=$url" >&2 + return 1 +} + +case "$CMD" in + start) + need_docker + compose up -d --build + wait_url "http://127.0.0.1:18200/v1/sys/health" || exit 1 + wait_url "http://127.0.0.1:18081/healthz" || exit 1 + wait_url "http://127.0.0.1:19090/minio/health/live" || exit 1 + wait_url "http://127.0.0.1:19092/healthz" || exit 1 + wait_url "http://127.0.0.1:19093/healthz" || exit 1 + wait_url "http://127.0.0.1:18080/healthz" || exit 1 + echo "INFRA_LAB_STARTED compose=$COMPOSE" + ;; + + stop) + need_docker + compose down + echo "INFRA_LAB_STOPPED" + ;; + + status) + need_docker + compose ps + ;; + + env) + cat <<'EOF' +export VAULT_ADDR=http://127.0.0.1:18200 +export VAULT_TOKEN=root +export CASAN_IDP_JWKS_URL=http://127.0.0.1:18081/.well-known/jwks.json +export CASAN_ALERT_WEBHOOK=http://127.0.0.1:19092/alert +export CASAN_PROVIDER_USAGE_API=http://127.0.0.1:19093/usage +export CASAN_DASHBOARD_URL=http://127.0.0.1:18080 +export CASAN_DASHBOARD_AUTH=casan:casan +export CASAN_MINIO_ENDPOINT=http://127.0.0.1:19090 +export CASAN_MINIO_BUCKET=casan-worm +EOF + ;; + + verify) + need_docker + PASS=0; FAIL=0 + pass() { echo "PASS: $1"; PASS=$((PASS + 1)); } + fail() { echo "FAIL: $1"; FAIL=$((FAIL + 1)); } + + wait_url "http://127.0.0.1:18200/v1/sys/health" && pass "Vault dev reachable" || fail "Vault dev unreachable" + VAULT_ADDR=http://127.0.0.1:18200 VAULT_TOKEN=root bash "$SCRIPT_DIR/vault-kms.sh" enable-transit >/dev/null 2>&1 + WORK="$(mktemp -d)" + trap 'rm -rf "$WORK"' EXIT + printf 'infra-lab-head\n' > "$WORK/head.txt" + if VAULT_ADDR=http://127.0.0.1:18200 VAULT_TOKEN=root bash "$SCRIPT_DIR/vault-kms.sh" sign "$WORK/head.txt" "$WORK/head.sig" casan-infra-lab >/dev/null 2>&1 \ + && VAULT_ADDR=http://127.0.0.1:18200 VAULT_TOKEN=root bash "$SCRIPT_DIR/vault-kms.sh" verify "$WORK/head.txt" "$WORK/head.sig" casan-infra-lab >/dev/null 2>&1; then + pass "Vault Transit signs and verifies" + else + fail "Vault Transit sign/verify failed" + fi + + printf 'deploy to production and run database migration\n' > "$WORK/approval.txt" + INPUT_SHA="$(hash_file "$WORK/approval.txt")" + TOKEN="$(curl -fsS -m 5 -H 'Content-Type: application/json' \ + -d "{\"sub\":\"oidc-ops\",\"role\":\"ops\",\"action\":\"deploy\",\"actor\":\"alice\",\"input_sha256\":\"$INPUT_SHA\",\"ttl_s\":300}" \ + http://127.0.0.1:18081/token | python3 -c 'import json,sys; print(json.load(sys.stdin)["access_token"])')" || TOKEN="" + if [[ -n "$TOKEN" ]] && CASAN_APPROVAL_JWT="$TOKEN" CASAN_IDP_JWKS_URL="http://127.0.0.1:18081/.well-known/jwks.json" \ + bash "$SCRIPT_DIR/approval-verify.sh" deploy alice "$WORK/approval.txt" oidc-ops - >/dev/null 2>&1; then + pass "Mock OIDC IdP issues JWKS-verifiable approval JWT" + else + fail "Mock OIDC approval verification failed" + fi + + if compose run --rm minio-mc -c 'set -eu; obj="verify-$(date +%s)-$$.txt"; mc alias set local http://minio:9000 casanadmin casanadmin123 >/dev/null; printf verify >/tmp/verify.txt; mc cp /tmp/verify.txt "local/casan-worm/$obj" >/dev/null; out="$(mc retention info "local/casan-worm/$obj")"; case "$out" in *COMPLIANCE*|*Mode*) exit 0;; *) echo "$out" >&2; exit 1;; esac' >/dev/null 2>&1; then + pass "MinIO WORM/Object Lock bucket accepts retained object" + else + fail "MinIO WORM verification failed" + fi + + ALERT_FILE="$WORK/alert.json" + printf '{"body":{"alert.type":"execution-failed","step.name":"infra-lab"},"resource":{"service.name":"casan"}}\n' > "$ALERT_FILE" + if CASAN_AGENTOPS_DIR="$WORK/agentops" CASAN_ALERT_WEBHOOK=http://127.0.0.1:19092/alert bash "$SCRIPT_DIR/alert-dispatch.sh" "$ALERT_FILE" >/dev/null 2>&1 \ + && curl -fsS http://127.0.0.1:19092/events | grep -q "infra-lab"; then + pass "Alert webhook receives live dispatch" + else + fail "Alert webhook verification failed" + fi + + if bash "$SCRIPT_DIR/provider-usage-fetch.sh" http://127.0.0.1:19093/usage "$WORK/provider.jsonl" >/dev/null 2>&1 \ + && grep -q "provider_api" "$WORK/provider.jsonl"; then + pass "Billing API mock imports provider telemetry" + else + fail "Billing API mock verification failed" + fi + + if curl -fsS http://127.0.0.1:18080/healthz | grep -q '"status"' \ + && curl -fsS -u casan:casan http://127.0.0.1:18080/ | grep -q "AgentOps Dashboard"; then + pass "Dashboard served behind nginx basic auth" + else + fail "Dashboard/nginx verification failed" + fi + + echo "INFRA_LAB_VERIFY_SUMMARY PASS=$PASS FAIL=$FAIL" + [[ "$FAIL" -eq 0 ]] || exit 1 + ;; + + *) + echo "Usage: infra-lab.sh start|stop|status|verify|env" >&2 + exit 64 + ;; +esac diff --git a/AINative_OKR_CASAN5/.specify/tests/phase-prod-infra-lab-tests.sh b/AINative_OKR_CASAN5/.specify/tests/phase-prod-infra-lab-tests.sh new file mode 100755 index 0000000..2474743 --- /dev/null +++ b/AINative_OKR_CASAN5/.specify/tests/phase-prod-infra-lab-tests.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +set -uo pipefail + +# CASAN Tier-2 local production-like infra lab tests. +# Starts Docker Compose if needed, verifies Vault/IdP/MinIO/dashboard/alert/billing. + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" +S="$PROJECT_ROOT/.specify/scripts/bash" + +PASS=0; FAIL=0; SKIP=0 +pass() { echo "PASS: $1"; PASS=$((PASS + 1)); } +fail() { echo "FAIL: $1"; FAIL=$((FAIL + 1)); } +skip() { echo "SKIP: $1"; SKIP=$((SKIP + 1)); } + +if ! command -v docker >/dev/null 2>&1 || ! docker compose version >/dev/null 2>&1; then + skip "Docker Compose unavailable" + echo "===== PROD INFRA LAB SUMMARY: PASS=$PASS FAIL=$FAIL SKIP=$SKIP =====" + exit 0 +fi + +if bash "$S/infra-lab.sh" start >/dev/null 2>&1; then + pass "local-prod Docker Compose stack starts" +else + fail "local-prod Docker Compose stack failed to start" +fi + +if bash "$S/infra-lab.sh" verify > /tmp/casan-infra-lab-verify.out 2>&1; then + pass "local-prod infra lab verification passes" +else + cat /tmp/casan-infra-lab-verify.out + fail "local-prod infra lab verification failed" +fi + +echo "" +echo "===== PROD INFRA LAB SUMMARY: PASS=$PASS FAIL=$FAIL SKIP=$SKIP =====" +[[ "$FAIL" -eq 0 ]] || exit 1 diff --git a/AINative_OKR_CASAN5/infra/local-prod/README.md b/AINative_OKR_CASAN5/infra/local-prod/README.md new file mode 100644 index 0000000..464b131 --- /dev/null +++ b/AINative_OKR_CASAN5/infra/local-prod/README.md @@ -0,0 +1,29 @@ +# CASAN Local Production-Like Infra Lab + +This Docker Compose stack emulates the external infrastructure needed to move +CASAN Tier 2 from "needs infra" to locally testable production-like controls. + +## Services + +| Service | Local URL | Purpose | +|---|---|---| +| Vault dev | `http://127.0.0.1:18200` | KMS Transit signing/rotation/non-exportable keys | +| Mock IdP/OIDC | `http://127.0.0.1:18081` | RS256 JWT + JWKS for approval identity | +| MinIO | `http://127.0.0.1:19090` | S3-compatible WORM/Object Lock emulation | +| MinIO Console | `http://127.0.0.1:19091` | Object store admin UI | +| Alert webhook | `http://127.0.0.1:19092` | Slack/PagerDuty-style webhook emulator | +| Billing API mock | `http://127.0.0.1:19093/usage` | Provider usage API emulator | +| Dashboard via nginx | `http://127.0.0.1:18080` | Dashboard behind basic auth (`casan` / `casan`) | + +## Commands + +```bash +bash .specify/scripts/bash/infra-lab.sh start +bash .specify/scripts/bash/infra-lab.sh verify +bash .specify/scripts/bash/infra-lab.sh env +bash .specify/scripts/bash/infra-lab.sh stop +``` + +This is a lab, not a compliance claim. AWS S3 Object Lock, real enterprise IdP, +CloudHSM, PagerDuty/Slack, and OpenAI/Anthropic billing APIs still need real +managed services and credentials before claiming production Strong readiness. diff --git a/AINative_OKR_CASAN5/infra/local-prod/docker-compose.yml b/AINative_OKR_CASAN5/infra/local-prod/docker-compose.yml new file mode 100644 index 0000000..b4fed97 --- /dev/null +++ b/AINative_OKR_CASAN5/infra/local-prod/docker-compose.yml @@ -0,0 +1,140 @@ +name: casan-local-prod + +services: + vault: + image: hashicorp/vault:1.15 + cap_add: + - IPC_LOCK + environment: + VAULT_DEV_ROOT_TOKEN_ID: root + VAULT_DEV_LISTEN_ADDRESS: 0.0.0.0:8200 + ports: + - "18200:8200" + healthcheck: + test: ["CMD", "wget", "-q", "-O", "-", "http://127.0.0.1:8200/v1/sys/health"] + interval: 5s + timeout: 3s + retries: 20 + + idp: + build: + context: ./idp + environment: + CASAN_IDP_PORT: "8080" + CASAN_IDP_ISSUER: http://127.0.0.1:18081 + ports: + - "18081:8080" + healthcheck: + test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/healthz', timeout=2)"] + interval: 5s + timeout: 3s + retries: 20 + + minio: + image: minio/minio:RELEASE.2025-09-07T16-13-09Z + command: server /data --console-address ":9001" + environment: + MINIO_ROOT_USER: casanadmin + MINIO_ROOT_PASSWORD: casanadmin123 + MINIO_BROWSER_REDIRECT_URL: http://127.0.0.1:19091 + ports: + - "19090:9000" + - "19091:9001" + volumes: + - minio-data:/data + healthcheck: + test: ["CMD", "curl", "-fsS", "http://127.0.0.1:9000/minio/health/live"] + interval: 5s + timeout: 3s + retries: 20 + + minio-init: + image: minio/mc:RELEASE.2025-08-13T08-35-41Z + depends_on: + minio: + condition: service_healthy + entrypoint: /bin/sh + command: + - -c + - | + set -eu + mc alias set local http://minio:9000 casanadmin casanadmin123 + mc mb --ignore-existing --with-lock local/casan-worm + mc retention set --default COMPLIANCE 1d local/casan-worm + mc anonymous set none local/casan-worm + echo MINIO_WORM_READY bucket=casan-worm mode=COMPLIANCE retention=1d + + minio-mc: + image: minio/mc:RELEASE.2025-08-13T08-35-41Z + profiles: ["tools"] + depends_on: + minio: + condition: service_healthy + entrypoint: /bin/sh + + alert-webhook: + build: + context: ./mock-http + command: ["python", "/app/mock_http.py", "alert"] + environment: + CASAN_MOCK_PORT: "8080" + ports: + - "19092:8080" + healthcheck: + test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/healthz', timeout=2)"] + interval: 5s + timeout: 3s + retries: 20 + + billing-api: + build: + context: ./mock-http + command: ["python", "/app/mock_http.py", "billing"] + environment: + CASAN_MOCK_PORT: "8080" + ports: + - "19093:8080" + healthcheck: + test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/healthz', timeout=2)"] + interval: 5s + timeout: 3s + retries: 20 + + dashboard: + image: python:3.12-slim + working_dir: /workspace + command: ["python", ".specify/scripts/bash/dashboard-server.py", "8787"] + environment: + CASAN_DASHBOARD_BIND: 0.0.0.0 + CASAN_DASHBOARD_STALE_S: "315360000" + CASAN_DASHBOARD_METRICS: /workspace/.specify/logs/cost/metrics.jsonl + CASAN_DASHBOARD_HTML: /workspace/docs/output/casan/central-agentops-dashboard.html + CASAN_DASHBOARD_ALERTS: /workspace/.specify/agentops/alerts.log + volumes: + - ../..:/workspace:ro + expose: + - "8787" + healthcheck: + test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8787/healthz', timeout=2)"] + interval: 5s + timeout: 3s + retries: 20 + + dashboard-nginx: + image: nginx:1.27-alpine + depends_on: + dashboard: + condition: service_healthy + ports: + - "18080:80" + volumes: + - ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro + - ./nginx/htpasswd:/etc/nginx/.htpasswd:ro + healthcheck: + test: ["CMD", "wget", "-q", "-O", "-", "http://127.0.0.1/healthz"] + interval: 5s + timeout: 3s + retries: 20 + +volumes: + minio-data: diff --git a/AINative_OKR_CASAN5/infra/local-prod/idp/Dockerfile b/AINative_OKR_CASAN5/infra/local-prod/idp/Dockerfile new file mode 100644 index 0000000..eac2eec --- /dev/null +++ b/AINative_OKR_CASAN5/infra/local-prod/idp/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.12-slim + +RUN pip install --no-cache-dir "pyjwt[crypto]==2.10.1" +WORKDIR /app +COPY mock_idp.py /app/mock_idp.py +EXPOSE 8080 +CMD ["python", "/app/mock_idp.py"] diff --git a/AINative_OKR_CASAN5/infra/local-prod/idp/mock_idp.py b/AINative_OKR_CASAN5/infra/local-prod/idp/mock_idp.py new file mode 100644 index 0000000..fb64927 --- /dev/null +++ b/AINative_OKR_CASAN5/infra/local-prod/idp/mock_idp.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python3 +import json +import os +import time +from http.server import BaseHTTPRequestHandler, HTTPServer +from urllib.parse import urlparse + +import jwt +from cryptography.hazmat.primitives.asymmetric import rsa + + +PORT = int(os.environ.get("CASAN_IDP_PORT", "8080")) +ISSUER = os.environ.get("CASAN_IDP_ISSUER", f"http://127.0.0.1:{PORT}") +KID = "casan-local-prod-idp" +KEY = rsa.generate_private_key(public_exponent=65537, key_size=2048) + + +def b64u_int(value: int) -> str: + raw = value.to_bytes((value.bit_length() + 7) // 8, "big") + import base64 + + return base64.urlsafe_b64encode(raw).decode().rstrip("=") + + +def jwk(): + numbers = KEY.public_key().public_numbers() + return { + "kty": "RSA", + "use": "sig", + "alg": "RS256", + "kid": KID, + "n": b64u_int(numbers.n), + "e": b64u_int(numbers.e), + } + + +class Handler(BaseHTTPRequestHandler): + def send_json(self, code, payload): + body = json.dumps(payload).encode() + self.send_response(code) + self.send_header("Content-Type", "application/json") + self.send_header("Content-Length", str(len(body))) + self.end_headers() + self.wfile.write(body) + + def do_GET(self): # noqa: N802 + path = urlparse(self.path).path + if path == "/healthz": + self.send_json(200, {"status": "ok", "issuer": ISSUER}) + elif path == "/.well-known/openid-configuration": + self.send_json( + 200, + { + "issuer": ISSUER, + "jwks_uri": f"{ISSUER}/.well-known/jwks.json", + "token_endpoint": f"{ISSUER}/token", + "id_token_signing_alg_values_supported": ["RS256"], + }, + ) + elif path == "/.well-known/jwks.json": + self.send_json(200, {"keys": [jwk()]}) + else: + self.send_json(404, {"error": "not_found"}) + + def do_POST(self): # noqa: N802 + if urlparse(self.path).path != "/token": + self.send_json(404, {"error": "not_found"}) + return + size = int(self.headers.get("Content-Length", "0")) + try: + payload = json.loads(self.rfile.read(size) or b"{}") + except json.JSONDecodeError: + self.send_json(400, {"error": "invalid_json"}) + return + now = int(time.time()) + claims = { + "iss": ISSUER, + "sub": payload.get("sub", "oidc-ops"), + "role": payload.get("role", "ops"), + "action": payload.get("action", "deploy"), + "actor": payload.get("actor", "alice"), + "input_sha256": payload.get("input_sha256", ""), + "iat": now, + "exp": now + int(payload.get("ttl_s", 300)), + } + token = jwt.encode(claims, KEY, algorithm="RS256", headers={"kid": KID}) + self.send_json(200, {"access_token": token, "token_type": "Bearer", "expires_in": claims["exp"] - now}) + + def log_message(self, *args): + pass + + +if __name__ == "__main__": + HTTPServer(("0.0.0.0", PORT), Handler).serve_forever() diff --git a/AINative_OKR_CASAN5/infra/local-prod/mock-http/Dockerfile b/AINative_OKR_CASAN5/infra/local-prod/mock-http/Dockerfile new file mode 100644 index 0000000..ad1a432 --- /dev/null +++ b/AINative_OKR_CASAN5/infra/local-prod/mock-http/Dockerfile @@ -0,0 +1,5 @@ +FROM python:3.12-slim + +WORKDIR /app +COPY mock_http.py /app/mock_http.py +EXPOSE 8080 diff --git a/AINative_OKR_CASAN5/infra/local-prod/mock-http/mock_http.py b/AINative_OKR_CASAN5/infra/local-prod/mock-http/mock_http.py new file mode 100644 index 0000000..c07333c --- /dev/null +++ b/AINative_OKR_CASAN5/infra/local-prod/mock-http/mock_http.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +import json +import os +import sys +from http.server import BaseHTTPRequestHandler, HTTPServer +from urllib.parse import urlparse + + +MODE = sys.argv[1] if len(sys.argv) > 1 else "alert" +PORT = int(os.environ.get("CASAN_MOCK_PORT", "8080")) +EVENTS = [] + + +USAGE = [ + { + "provider": "local-prod-mock", + "model": "billing-api-emulator", + "run_id": "infra-lab-run", + "step": "speckit.implement", + "input_tokens": 1842, + "output_tokens": 936, + "total_tokens": 2778, + "cost_usd": 0.08334, + "latency_ms": 4210, + "status": "success", + } +] + + +class Handler(BaseHTTPRequestHandler): + def send_json(self, code, payload): + body = json.dumps(payload).encode() + self.send_response(code) + self.send_header("Content-Type", "application/json") + self.send_header("Content-Length", str(len(body))) + self.end_headers() + self.wfile.write(body) + + def do_GET(self): # noqa: N802 + path = urlparse(self.path).path + if path == "/healthz": + self.send_json(200, {"status": "ok", "mode": MODE, "events": len(EVENTS)}) + elif MODE == "alert" and path == "/events": + self.send_json(200, EVENTS) + elif MODE == "billing" and path in ("/usage", "/v1/usage"): + self.send_json(200, USAGE) + else: + self.send_json(404, {"error": "not_found"}) + + def do_POST(self): # noqa: N802 + if MODE != "alert": + self.send_json(404, {"error": "not_found"}) + return + size = int(self.headers.get("Content-Length", "0")) + raw = self.rfile.read(size) + try: + payload = json.loads(raw or b"{}") + except json.JSONDecodeError: + payload = {"raw": raw.decode(errors="replace")} + EVENTS.append(payload) + self.send_json(200, {"ok": True, "events": len(EVENTS)}) + + def log_message(self, *args): + pass + + +if __name__ == "__main__": + HTTPServer(("0.0.0.0", PORT), Handler).serve_forever() diff --git a/AINative_OKR_CASAN5/infra/local-prod/nginx/default.conf b/AINative_OKR_CASAN5/infra/local-prod/nginx/default.conf new file mode 100644 index 0000000..5f7f1b1 --- /dev/null +++ b/AINative_OKR_CASAN5/infra/local-prod/nginx/default.conf @@ -0,0 +1,17 @@ +server { + listen 80; + server_name _; + + location = /healthz { + proxy_pass http://dashboard:8787/healthz; + } + + location / { + auth_basic "CASAN local-prod dashboard"; + auth_basic_user_file /etc/nginx/.htpasswd; + proxy_pass http://dashboard:8787; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} diff --git a/AINative_OKR_CASAN5/infra/local-prod/nginx/htpasswd b/AINative_OKR_CASAN5/infra/local-prod/nginx/htpasswd new file mode 100644 index 0000000..1c864ee --- /dev/null +++ b/AINative_OKR_CASAN5/infra/local-prod/nginx/htpasswd @@ -0,0 +1 @@ +casan:$apr1$bCe9E6jA$7NdeZUhyLMXXWGe9RCCY1/ diff --git a/casan-next-plans/CASAN_BACKLOG_STATUS.md b/casan-next-plans/CASAN_BACKLOG_STATUS.md index 0cec4bd..b97e171 100644 --- a/casan-next-plans/CASAN_BACKLOG_STATUS.md +++ b/casan-next-plans/CASAN_BACKLOG_STATUS.md @@ -5,7 +5,7 @@ > cũng làm tiếp được ngay**. Cập nhật mỗi khi hoàn thành một mục. > > Cập nhật lần cuối: 2026-07-06 · Nhánh làm tiếp từ handoff Claude. -> Test hiện tại: **218 PASS / 0 FAIL** trên 13 core harness suite; `phase3-model-router` riêng **10 PASS / 0 FAIL**; frontend Vitest **16 PASS / 0 FAIL**. Backend `npm test` còn bị chặn bởi test-infra cũ (`schema.prisma` MySQL nhưng `setup-sqlite.mjs` chạy SQLite). +> Test hiện tại: **218 PASS / 0 FAIL** trên 13 core harness suite; local-prod Docker infra lab **2 PASS / 0 FAIL** (`infra-lab verify`: 7/0 internal checks); `phase3-model-router` riêng **10 PASS / 0 FAIL**; frontend Vitest **16 PASS / 0 FAIL**. Backend `npm test` còn bị chặn bởi test-infra cũ (`schema.prisma` MySQL nhưng `setup-sqlite.mjs` chạy SQLite). > Điểm công tâm vẫn quanh **~81/100**, harness thấp nhất 80; TIER 2 infra thật vẫn là trần Strong. > Nguồn liên quan: `CASAN_HARDENING_STATUS.md` (chi tiết control) · `evidence/scoring-run-report.md` (điểm). @@ -24,15 +24,15 @@ | T1.2 | **IdP/OIDC cho approval** (thay registry pubkey tĩnh) | 07 C4 / V20 | ✅ MVP done+test | `approval-verify.sh` chấp nhận `CASAN_APPROVAL_JWT` RS256 ký bởi mock IdP, verify chữ ký bằng pubkey, check `sub`/`role`/`exp` + bind `action`/`actor`/`input_sha256`. Test: JWT hợp lệ→APPROVED, hết hạn/sai role/chữ ký giả→DENY. Prod còn cần IdP/JWKS thật. | | T1.3 | **Traceability REQ→code→test** (khác biệt nhất) | 10 | ✅ MVP done+test | `traceability-matrix.py` parse FR-xx từ requirement, dùng `.specify/traceability-map.json`, gate mọi FR có ≥1 code + ≥1 test; Evidence Pack thêm `traceability-matrix.json`. Test: FR đủ→PASS, FR thiếu test→FAIL. | -## TIER 2 — Plan-07 gaps cần hạ tầng (MVP đã có, cần bản prod) 🔌 +## TIER 2 — Plan-07 gaps cần hạ tầng (Docker local-prod lab đã có; prod managed thật vẫn cần) 🔌 | # | Hạng mục | Trạng thái | Bước tiếp theo (bản production) | |---|---|:--:|---| -| T2.1 | KMS mặc định + HSM | 🟡 (Vault Transit live, chưa default) | Đặt `sign-audit-head.sh`/`telemetry-integrity.sh` route qua KMS khi có `VAULT_ADDR` (đã vậy); thêm cấu hình prod: Vault/AWS-KMS/CloudHSM + token ngắn hạn qua IdP; bỏ fallback khoá local ở môi trường prod (giữ cho dev). | -| T2.2 | WORM store thật (S3 Object Lock) | 🟡 (ledger local hash-link) | `audit-ship.sh` thêm backend S3: `aws s3api put-object --object-lock-mode COMPLIANCE --retain-until-date …`; hoặc QLDB. Giữ ledger local làm cache. Cần: AWS creds + bucket Object-Lock. | -| T2.3 | Dashboard deploy + auth | 🟡 (HTTP local + /healthz) | Đóng gói `dashboard-server.py` vào container + nginx reverse-proxy + auth (OIDC/basic); expose `/healthz` cho uptime monitor. Cần: host + TLS cert. | -| T2.4 | Kênh alert managed + on-call | 🟡 (webhook + dead-letter) | `alert-dispatch.sh` trỏ `CASAN_ALERT_WEBHOOK` tới Slack/PagerDuty incoming-webhook; map severity→on-call rota (tie C7 incident). Cần: webhook URL + rota. | -| T2.5 | Billing-API telemetry thật | 🟡 (fetch vs endpoint local) | `provider-usage-fetch.sh` trỏ tới usage API thật của OpenAI/Anthropic (đã có schema-gate + reconcile). Cần: API key thật (chưa test). | +| T2.1 | KMS mặc định + HSM | 🟡 Docker lab ✅ (Vault Transit) | `infra/local-prod` dựng Vault dev @ `:18200`; `infra-lab verify` chứng minh sign+verify. Prod: Vault/AWS-KMS/CloudHSM + token ngắn hạn qua IdP; bỏ fallback khoá local ở môi trường prod. | +| T2.2 | WORM store thật (S3 Object Lock) | 🟡 Docker lab ✅ (MinIO Object Lock) | MinIO bucket `casan-worm` bật Object Lock COMPLIANCE 1d. Prod: S3 Object Lock/QLDB + trusted timestamp; cần AWS creds + bucket Object-Lock. | +| T2.3 | Dashboard deploy + auth | 🟡 Docker lab ✅ (nginx basic auth + /healthz) | Dashboard container + nginx reverse-proxy @ `:18080`, user/pass lab `casan/casan`; `/healthz` exposed. Prod: host/TLS/OIDC or enterprise auth. | +| T2.4 | Kênh alert managed + on-call | 🟡 Docker lab ✅ (webhook emulator) | `alert-webhook` @ `:19092` nhận live POST. Prod: trỏ `CASAN_ALERT_WEBHOOK` tới Slack/PagerDuty + rota/on-call thật. | +| T2.5 | Billing-API telemetry thật | 🟡 Docker lab ✅ (billing API mock) | `billing-api` @ `:19093/usage`; `provider-usage-fetch.sh` import được provider telemetry. Prod: OpenAI/Anthropic usage API thật + key. | | T2.6 | Sandbox: rootless/nsjail + base image CI | 🟡 (container isolation live via Docker) | Thêm profile nsjail/bubblewrap cho Linux CI (không cần Docker daemon); hardened base image tối thiểu. `sandbox-container.sh` đã có bản Docker. | ## TIER 3 — Platform plans (INDEX 01–12, việc lớn nhiều phiên) 📋 @@ -53,10 +53,10 @@ --- ## Trần điểm & điều kiện lên "Strong (81+)" -Harness thấp nhất = 80 (H5, H6). Để CẢ pipeline vào Strong cần đóng **các mục 🔌 TIER 2** -(IdP live, WORM-S3, KMS default, dashboard deploy, managed alert, billing-API) — đều là -**hạ tầng/khoá thật**, không code thuần được nữa. Các mục 🟦 TIER 1 nâng H4/H2 nhưng không -đổi trần (H5/H6 vẫn 80) cho tới khi TIER 2 xong. +Harness thấp nhất = 80 (H5, H6). Docker local-prod lab đã chứng minh luồng infra +production-like chạy được trên Mac, nhưng để CẢ pipeline vào Strong vẫn cần bản **managed thật** +(enterprise IdP/JWKS, WORM-S3/QLDB, KMS default/HSM, dashboard deploy TLS/OIDC, managed alert/on-call, billing-API thật). +Các mục này cần key/dịch vụ ngoài nên chưa nên claim production Strong. ## Cách kiểm chứng nhanh (bất kỳ AI kế nào) ```bash @@ -67,4 +67,5 @@ for s in run-casan4-harness adversarial-harness phase1-track-a phase2-track-c \ phase10-traceability; do bash .specify/tests/$s-tests.sh >/dev/null 2>&1 && echo "$s OK" || echo "$s FAIL"; done # KMS live cần Vault dev; C6 live cần Docker (không có thì SKIP, không fail). +bash .specify/tests/phase-prod-infra-lab-tests.sh # starts/verifies local-prod Docker lab ``` diff --git a/casan-next-plans/CASAN_HARDENING_STATUS.md b/casan-next-plans/CASAN_HARDENING_STATUS.md index dee2556..8ca36e0 100644 --- a/casan-next-plans/CASAN_HARDENING_STATUS.md +++ b/casan-next-plans/CASAN_HARDENING_STATUS.md @@ -64,6 +64,12 @@ | B4 | **Model-digest pinning (V16)**: approved Ollama model digest pinned; router verifies live digest before generation/classify/judge; mismatch blocks by default with warn mode for rollout | [implemented+tested] | `model-digest-check.sh`, `model-call.py`, `.specify/security/model-digest.pin` | phase3-model-router (digest cases) | | Plan-10 | **Traceability REQ→code→test MVP**: parse `FR-*`, require code+test mapping per FR, generate matrix, and include it in Evidence Pack | [implemented+tested] | `traceability-matrix.py`, `.specify/traceability-map.json`, `docs/output/casan/traceability-matrix.json` | phase10-traceability (3) | +### Phase 7 — Local production-like infra lab (Tier-2 emulation) — [implemented+tested] + +| Control | Status | Where | Test | +|---|---|---|---| +| Docker Compose lab for Vault KMS, OIDC/JWKS IdP, MinIO Object Lock WORM, dashboard behind nginx basic auth, alert webhook, and provider billing API mock | [implemented+tested] (local-prod emulation; managed prod services still required for Strong claim) | `infra/local-prod/docker-compose.yml`, `infra-lab.sh` | phase-prod-infra-lab (2); `infra-lab verify` internal 7/0 | + ## 2. Test inventory (all suites) | Suite | Checks | Purpose | @@ -81,7 +87,8 @@ | `phase-c6-sandbox-tests.sh` | 6 | **New** — TRUE container isolation (C6, live via Docker / skip-aware) | | `phase-h4-split-inject-tests.sh` | 8 | **New** — split-injection assembly scan + classifier-inject (B2) | | `phase10-traceability-tests.sh` | 3 | **New** — Plan-10 FR→code→test matrix + fail-able missing-test gate | -| **Total** | **218** | Baseline 79 preserved; +139 new hardening/traceability checks. Last full harness run 2026-07-06, 0 fail. Direct `phase3-model-router-tests.sh` adds 10/0 for model-router/digest/cloud/fallback checks. | +| `phase-prod-infra-lab-tests.sh` | 2 | **New optional/local-prod** — Docker Compose infra lab starts + verifies Vault/IdP/MinIO/dashboard/alert/billing | +| **Total** | **218 core + 2 local-prod infra lab** | Baseline 79 preserved; +139 new hardening/traceability checks. Last full harness run 2026-07-06, 0 fail. Direct `phase3-model-router-tests.sh` adds 10/0; `infra-lab verify` adds 7 internal infra checks. | Run order note: `run-casan4-harness-tests.sh` does `rm -rf .specify/logs`, so run it **first** and never concurrently with the other suites. @@ -96,7 +103,7 @@ Run order note: `run-casan4-harness-tests.sh` does `rm -rf .specify/logs`, so ru | Provider billing-API telemetry | [partial] — API fetch + schema gate + local-vs-provider reconciliation done against a live local endpoint; real OpenAI/Anthropic usage-API calls (needs keys) planned | Phase 5 D2 | | True runtime isolation | [partial] — real container isolation done + validated live via Docker (C6 phase-6); nsjail/rootless + a hardened base image for CI still planned | Plan-07 C6 (V22) | | KMS key management (rotation, non-exportable) | [partial] — Vault Transit path implemented + validated live; not yet the default (local-key fallback), no HSM/short-lived IdP tokens | Plan-07 B3 | -| Reviewer approval workflow | [partial] — cryptographic **approval-identity** done (signed reviewer + role) + mock **IdP/OIDC JWT** done; live IdP/JWKS + policy versioning/diff still planned | Plan-07 C4 (V20) | +| Reviewer approval workflow | [partial] — cryptographic **approval-identity** done + Docker mock **IdP/OIDC JWKS** done; enterprise IdP/JWKS + policy versioning/diff still planned | Plan-07 C4 (V20) | | External append-only (WORM) audit | [partial] — hash-linked local ledger + rollback/tamper detection done; true WORM store (S3 Object Lock/QLDB) + trusted timestamp planned | Plan-07 C5 (V21) | | Live CVE/OSV scanning wired in | [partial] — availability detected; local denylist authoritative offline | Plan-07 C2 follow-up | @@ -113,7 +120,7 @@ isolation validated live/skip-aware via Vault dev + Docker). Fair maturity score dimension closed; **H5 and H6 remain at 80** (their remaining gaps are infra), so the **lowest harness stays 80** — CASAN **Level 4**, proven by attack. This is **not** full production readiness: crossing the whole pipeline into "Strong (81+)" still needs the -H5/H6 infra items — live IdP/JWKS, a true WORM store (S3 Object Lock), -KMS-by-default + HSM, a deployed dashboard host + managed alert channel/on-call, and +H5/H6 infra items — enterprise IdP/JWKS, a true WORM store (S3 Object Lock/QLDB), +KMS-by-default + HSM, a deployed dashboard host with TLS/OIDC + managed alert channel/on-call, and real billing-API telemetry — the [partial]/[planned] rows above and in `CASAN_PLAN_07_PRODUCTION_HARDENING.md`. diff --git a/casan-next-plans/CASAN_PLAN_07_PRODUCTION_HARDENING.md b/casan-next-plans/CASAN_PLAN_07_PRODUCTION_HARDENING.md index 775b34e..a4592fc 100644 --- a/casan-next-plans/CASAN_PLAN_07_PRODUCTION_HARDENING.md +++ b/casan-next-plans/CASAN_PLAN_07_PRODUCTION_HARDENING.md @@ -19,7 +19,7 @@ ## 2. Thang điểm sẵn sàng production (0–5, cao = tốt) -> ✅ **CẬP NHẬT 2026-07-06 — Track A + C-MVP + Evidence Pack + H5/H6/deep-gap hardening + Plan-10 traceability ĐÃ LÀM + TEST (218 core checks, 0 fail; model-router riêng 10/0).** +> ✅ **CẬP NHẬT 2026-07-06 — Track A + C-MVP + Evidence Pack + H5/H6/deep-gap hardening + Plan-10 traceability ĐÃ LÀM + TEST (218 core checks, 0 fail; model-router riêng 10/0). Local production-like Docker infra lab cũng đã có (2/0, verify nội bộ 7/0).** > Bảng dưới có cột **Baseline → Nay**. Điểm chấm CÔNG TÂM (0–100, theo `casan_harness_assessment.md`): > **H4 = 80 · H5 = 76→80 ⬆ · H6 = 79→80 ⬆ · trung bình 7 harness ~80.9/100 · không còn harness nào dưới 80 → CASAN Level 4 (vững ngưỡng)**. > Nguồn: `00_SUBMISSION_PACKAGE/evidence/scoring-run-report.md`. Chi tiết implemented-vs-planned: `CASAN_HARDENING_STATUS.md`. @@ -30,7 +30,7 @@ | Fail-safe | 4 | **4.5** | `CASAN_SECURITY_STRICT` fail-closed — hết "semantic SKIP âm thầm" | — | | Toàn vẹn/chống giả mạo (H5) | 3 | **4** | telemetry vào manifest **ký RSA** (sửa 1 token → MISMATCH) | — | | Kiểm soát chi phí (H6) | 3 | **4** | trần tuyệt đối/call + ngân sách tích luỹ + cold-start (ngoài median×mult) | hard-cap per-provider live | -| Quan sát (observability) | 3 | **4** | telemetry toàn vẹn (ký) · **alerting LIVE** (webhook + dedup + dead-letter, end-to-end từ step fail) · **dashboard hosted** (`/healthz` stale-aware) · **provider-API reconcile** (bắt under-reporting) · window breaker (V15) | dashboard deploy thật + auth · kênh alert managed (Slack/PagerDuty + on-call) · billing-API thật | +| Quan sát (observability) | 3 | **4** | telemetry toàn vẹn (ký) · **alerting LIVE** (webhook + dedup + dead-letter, end-to-end từ step fail) · **dashboard hosted** (`/healthz` stale-aware) · **Docker lab** có nginx auth + alert/billing mock · provider-API reconcile · window breaker (V15) | dashboard deploy managed + TLS/OIDC · Slack/PagerDuty/on-call thật · billing-API thật | | Đa domain/i18n | 2 | **2.5** | benign corpus VI/JA/EN đo được (FP 0%) | detection vẫn chủ yếu EN (Track B) | | Quản lý khóa | 2 | **4** | **KMS live** (Vault Transit) — ký qua KMS, **rotate**, khoá **non-exportable** (đã chạy thật) | KMS chưa mặc định (fallback local) · HSM · IdP token ngắn hạn | | Phủ kiểm thử | 4 | **4.5** | **218 core tests** (35+44+25+29+7+12+7+20+15+7+6+8+3) đối kháng, 0 fail | line/symbol-level traceability + CI release gate | @@ -45,12 +45,12 @@ | Supply-chain (dependency sinh ra) | 1 | **3.5** | `supply-chain-gate.sh` (V18) — typosquat/postinstall/denylist + dep-diff | CVE/OSV scanner live chưa nối | | Data-governance / anti-exfil | 2 | **4** | `data-exfil-guard.sh` (V19) — secret→cloud BLOCK, PII→audit mask | — | | Evidence Pack (Plan-09) | — | **4** | `casan pack/verify-pack` — manifest ký, tamper-evident, certified-gate | KMS sign · hosted store | -| Policy governance / approval | 2 | **4** | **approval-identity + mock IdP/OIDC** (C4) — reviewer KÝ request hoặc JWT RS256 + role authz, hết env-var; SoD giữ (đã test 12/12) | live IdP/JWKS · policy versioning/diff [planned] | +| Policy governance / approval | 2 | **4** | **approval-identity + Docker mock IdP/OIDC JWKS** (C4) — reviewer KÝ request hoặc JWT RS256 + role authz, hết env-var; SoD giữ (đã test 12/12 + infra lab) | enterprise IdP/JWKS · policy versioning/diff [planned] | | Runtime sandbox | 1 | **2.5** | `sandbox-run.sh` scaffold (V22) — chặn ssh/egress/forkbomb/write-outside + ulimit | **cô lập kernel thật** (container/nsjail) [planned] | | External append-only audit | 1 | **3.5** | **WORM ledger** (C5) — ship head hash-link ngoài, bắt rollback (`AUDIT_GAP_DETECTED`) + tamper | WORM store thật (S3 Object Lock) · trusted timestamp [planned] | | Incident response | 1 | **1** | — | severity/owner/kill-switch (C7) [planned] | -**→ C-MVP (C1+C2+C3 + Evidence Pack) ~3.8/5 + H5-hardening (C4 approval-identity + mock OIDC, KMS live, C5 WORM) + H6-hardening (D1 alerting live, D2 provider-API reconcile, D3 dashboard hosted, D4 window breaker V15) + deep-gap closers + Plan-10 traceability [đã làm + test thật]. Còn: live IdP/JWKS, WORM-store thật, KMS default/HSM, dashboard deploy + kênh alert managed, billing-API thật [planned].** Trio H4/H5/H6 nay **~4.0/5 (H4=80·H5=80·H6=80)**; harness thấp nhất nhích **76 (H5) → 79 (H6) → 80 (đồng đều)**. Production toàn diện vẫn cần các mục [planned] ở trên. +**→ C-MVP (C1+C2+C3 + Evidence Pack) ~3.8/5 + H5-hardening (C4 approval-identity + Docker mock OIDC/JWKS, KMS live, C5 WORM/MinIO Object Lock lab) + H6-hardening (D1 alerting live, D2 provider-API reconcile, D3 dashboard hosted/nginx auth lab, D4 window breaker V15) + deep-gap closers + Plan-10 traceability [đã làm + test thật]. Còn: enterprise IdP/JWKS, S3 Object Lock/QLDB thật, KMS default/HSM, dashboard deploy managed + kênh alert managed, billing-API thật [planned].** Trio H4/H5/H6 nay **~4.0/5 (H4=80·H5=80·H6=80)**; harness thấp nhất nhích **76 (H5) → 79 (H6) → 80 (đồng đều)**. Production toàn diện vẫn cần các mục [planned] ở trên. ## 3. Bảng đường lọt (tóm tắt từ threat-model)