forked from mtusi2026/mtusi2026lab7
лабораторная работа 7
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
|
||||
Step Result Seconds Evidence
|
||||
---- ------ ------- --------
|
||||
check-contract PASS 0 evidence\run\check-contract.txt
|
||||
compose-config PASS 0 evidence\run\compose-config.txt
|
||||
up PASS 17 evidence\run\up.txt
|
||||
ps PASS 1 evidence\run\ps.txt
|
||||
test-smoke PASS 2 evidence\run\test-smoke.txt
|
||||
test-security PASS 0 evidence\run\test-security.txt
|
||||
tls-audit PASS 10 evidence\run\tls-audit.txt
|
||||
security-http PASS 2 evidence\run\security-http.txt
|
||||
bao-policy PASS 8 evidence\run\bao-policy.txt
|
||||
hardening PASS 4 evidence\run\hardening.txt
|
||||
rehash PASS 3 evidence\run\rehash.txt
|
||||
leak-check PASS 32 evidence\run\leak-check.txt
|
||||
expiry PASS 18 evidence\run\expiry.txt
|
||||
test-persistence PASS 54 evidence\run\test-persistence.txt
|
||||
test-failover-1 PASS 18 evidence\run\test-failover-1.txt
|
||||
restore-1 PASS 7 evidence\run\restore-1.txt
|
||||
test-failover-2 PASS 18 evidence\run\test-failover-2.txt
|
||||
restore-2 PASS 7 evidence\run\restore-2.txt
|
||||
rotate-db-password PASS 8 evidence\run\rotate-db-password.txt
|
||||
rotate-lb-cert PASS 22 evidence\run\rotate-lb-cert.txt
|
||||
rotate-secret-id PASS 5 evidence\run\rotate-secret-id.txt
|
||||
revoke-identity PASS 26 evidence\run\revoke-identity.txt
|
||||
bao-sealed PASS 26 evidence\run\bao-sealed.txt
|
||||
smoke-after-lifecycle PASS 3 evidence\run\smoke-after-lifecycle.txt
|
||||
student-tests PASS 31 evidence\run\student-tests.txt
|
||||
storage-tests PASS 10 evidence\run\storage-tests.txt
|
||||
login-budget PASS 45 evidence\run\login-budget.txt
|
||||
s3-check PASS 3 evidence\run\s3-check.txt
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
# OpenBao: allow/deny политик реальными токенами AppRole, CIDR, TTL
|
||||
# python scripts/ops.py bao-policy
|
||||
# 2026-11-17T23:57:40.0157734+03:00
|
||||
{
|
||||
"ok": true,
|
||||
"checks": [
|
||||
{
|
||||
"check": "approle login from outside secrets network is denied",
|
||||
"ok": true,
|
||||
"detail": "exit 2"
|
||||
},
|
||||
{
|
||||
"check": "api reads own kv/messenger/api",
|
||||
"ok": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"check": "api cannot read kv/messenger/worker",
|
||||
"ok": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"check": "api cannot write own kv path",
|
||||
"ok": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"check": "api cannot write policies",
|
||||
"ok": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"check": "api cannot mint SecretIDs",
|
||||
"ok": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"check": "api token is short-lived (ttl<=15m) and not root",
|
||||
"ok": true,
|
||||
"detail": "ttl=897s policies=['default', 'messenger-api']"
|
||||
},
|
||||
{
|
||||
"check": "worker reads own kv/messenger/worker",
|
||||
"ok": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"check": "worker cannot read kv/messenger/api",
|
||||
"ok": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"check": "worker cannot write own kv path",
|
||||
"ok": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"check": "worker cannot write policies",
|
||||
"ok": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"check": "worker cannot mint SecretIDs",
|
||||
"ok": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"check": "worker token is short-lived (ttl<=15m) and not root",
|
||||
"ok": true,
|
||||
"detail": "ttl=896s policies=['default', 'messenger-worker']"
|
||||
}
|
||||
]
|
||||
}
|
||||
2026-11-17T20:57:47.753Z saved evidence/bao_policy.json
|
||||
@@ -0,0 +1,8 @@
|
||||
# OpenBao sealed: API работает и перезапускается на отрисованных секретах, затем unseal
|
||||
# python scripts/ops.py bao-sealed
|
||||
# 2026-11-18T00:01:29.3386965+03:00
|
||||
OpenBao sealed: agents keep already rendered files; new auth/renew fail until `bao.py unseal`
|
||||
2026-11-17T21:01:42.296Z bao-sealed: smoke while OpenBao sealed -> PASS
|
||||
2026-11-17T21:01:53.384Z bao-sealed: api replicas restarted while sealed -> healthy (secrets from agent tmpfs volume)
|
||||
unsealed=True
|
||||
2026-11-17T21:01:55.371Z bao-sealed: unsealed after 25s; agents resume renew/render with backoff (<= 1 min)
|
||||
@@ -0,0 +1,4 @@
|
||||
# make check: структура skeleton, контракт, синтаксис тестов
|
||||
# python scripts/check_contract.py
|
||||
# 2026-11-17T23:57:07.0451038+03:00
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
@@ -0,0 +1,3 @@
|
||||
# docker compose config --quiet
|
||||
# docker compose config --quiet
|
||||
# 2026-11-17T23:57:07.2224890+03:00
|
||||
@@ -0,0 +1,50 @@
|
||||
# Истечение сессии (экземпляр с TTL 2 с, mTLS напрямую к реплике)
|
||||
# python scripts/ops.py in-network expiry
|
||||
# 2026-11-17T23:58:26.7184363+03:00
|
||||
Container messenger-lab7-s3-1 Running
|
||||
Container messenger-lab7-postgres-1 Running
|
||||
Container messenger-lab7-s3-gate-1 Running
|
||||
Container messenger-lab7-openbao-1 Running
|
||||
Container messenger-lab7-api-1 Running
|
||||
Container messenger-lab7-api-2 Running
|
||||
Container messenger-lab7-bao-agent-api-1 Running
|
||||
Container messenger-lab7-redis-1 Running
|
||||
Container messenger-lab7-api-short-ttl-1 Creating
|
||||
Container messenger-lab7-api-short-ttl-1 Created
|
||||
Container messenger-lab7-postgres-1 Waiting
|
||||
Container messenger-lab7-s3-1 Waiting
|
||||
Container messenger-lab7-postgres-1 Healthy
|
||||
Container messenger-lab7-s3-1 Healthy
|
||||
Container messenger-lab7-migrate-1 Starting
|
||||
Container messenger-lab7-s3-gate-1 Waiting
|
||||
Container messenger-lab7-migrate-1 Started
|
||||
Container messenger-lab7-s3-gate-1 Healthy
|
||||
Container messenger-lab7-s3-init-1 Starting
|
||||
Container messenger-lab7-s3-init-1 Started
|
||||
Container messenger-lab7-migrate-1 Waiting
|
||||
Container messenger-lab7-s3-init-1 Waiting
|
||||
Container messenger-lab7-bao-agent-api-1 Waiting
|
||||
Container messenger-lab7-postgres-1 Waiting
|
||||
Container messenger-lab7-redis-1 Waiting
|
||||
Container messenger-lab7-migrate-1 Exited
|
||||
Container messenger-lab7-bao-agent-api-1 Healthy
|
||||
Container messenger-lab7-redis-1 Healthy
|
||||
Container messenger-lab7-postgres-1 Healthy
|
||||
Container messenger-lab7-s3-init-1 Exited
|
||||
Container messenger-lab7-api-1 Waiting
|
||||
Container messenger-lab7-api-2 Waiting
|
||||
Container messenger-lab7-api-1 Healthy
|
||||
Container messenger-lab7-api-2 Healthy
|
||||
Container messenger-lab7-api-short-ttl-1 Starting
|
||||
Container messenger-lab7-api-short-ttl-1 Started
|
||||
Container messenger-lab7-api-run-a06a9f47848a Creating
|
||||
Container messenger-lab7-api-run-a06a9f47848a Created
|
||||
ready: https://api-short-ttl:8443/health/ready
|
||||
Container messenger-lab7-api-run-2ebe51c30cb2 Creating
|
||||
Container messenger-lab7-api-run-2ebe51c30cb2 Created
|
||||
test_session_expires_even_when_cached (test_expiry.ExpiryTests.test_session_expires_even_when_cached) ... ok
|
||||
System.Management.Automation.RemoteException
|
||||
----------------------------------------------------------------------
|
||||
Ran 1 test in 3.862s
|
||||
System.Management.Automation.RemoteException
|
||||
OK
|
||||
@@ -0,0 +1,38 @@
|
||||
# Hardening: non-root, read_only, cap_drop, no-new-privileges, лимиты, порты, сегментация, egress
|
||||
# python scripts/ops.py hardening
|
||||
# 2026-11-17T23:57:48.3174507+03:00
|
||||
service container Config.User uid ro drop add mem published result
|
||||
api messenger-lab7-api-1 10001:10001 10001 True ALL - 320M - ok
|
||||
api messenger-lab7-api-2 10001:10001 10001 True ALL - 320M - ok
|
||||
bao-agent-api messenger-lab7-bao-agent-api-1 10001:10001 10001 True ALL - 128M - ok
|
||||
bao-agent-worker messenger-lab7-bao-agent-worker-1 10001:10001 10001 True ALL - 128M - ok
|
||||
broker messenger-lab7-broker-1 redis 999 True ALL - 320M - ok
|
||||
broker-gate messenger-lab7-broker-gate-1 haproxy 99 True ALL - 64M - ok
|
||||
grafana messenger-lab7-grafana-1 472 472 False ALL - 256M [('127.0.0.1', '3000')] ok
|
||||
exception: read_only: совместимость Grafana с read-only rootfs не проверена на стенде; caps сброшены, no-new-privileges, uid 472
|
||||
lb messenger-lab7-lb-1 haproxy 99 True ALL - 128M [('127.0.0.1', '8443')] ok
|
||||
loki messenger-lab7-loki-1 10001 10001 True ALL - 512M - ok
|
||||
migrate messenger-lab7-migrate-1 10001:10001 - True ALL - 256M - ok
|
||||
openbao messenger-lab7-openbao-1 openbao _rpc True ALL - 256M - ok
|
||||
otel-collector messenger-lab7-otel-collector-1 10001 10001 True ALL - 384M - ok
|
||||
otel-gate messenger-lab7-otel-gate-1 haproxy 99 True ALL - 64M - ok
|
||||
postgres messenger-lab7-postgres-1 70:70 70 True ALL - 512M - ok
|
||||
prometheus messenger-lab7-prometheus-1 nobody nobody True ALL - 512M - ok
|
||||
redis messenger-lab7-redis-1 redis 999 True ALL - 96M - ok
|
||||
s3 messenger-lab7-s3-1 root(image default) root True ALL CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOW 512M - ok
|
||||
exception: root_user: образ SeaweedFS работает от uid 0; capabilities сброшены (CapDrop ALL), rootfs read-only, запись только в volume /data; cap_add: каталог /data в образе принадлежит не root: возвращены только DAC_OVERRIDE, CHOWN, FOWNER
|
||||
s3-gate messenger-lab7-s3-gate-1 haproxy 99 True ALL - 64M - ok
|
||||
s3-init messenger-lab7-s3-init-1 10001:10001 - True ALL - 192M - ok
|
||||
tempo messenger-lab7-tempo-1 10001:10001 10001 True ALL - 512M - ok
|
||||
tempo-init messenger-lab7-tempo-init-1 root - False ALL CAP_CHOWN 0M - ok
|
||||
exception: cap_add: one-shot chown volume (CAP_CHOWN), завершается до старта tempo; root_user: one-shot chown volume; limits: one-shot, завершается за доли секунды; read_only: one-shot chown volume, network_mode none
|
||||
worker messenger-lab7-worker-1 10001:10001 10001 True ALL - 1280M - ok
|
||||
|
||||
network segmentation / egress:
|
||||
api ok
|
||||
{"postgres": "reachable", "s3": "reachable", "broker": "reachable", "otel-collector": "reachable", "redis": "reachable", "loki": "no-dns", "tempo": "no-dns", "prometheus": "no-dns", "openbao": "no-dns", "grafana": "no-dns", "api": "reachable", "1.1.1.1": "unreachable"}
|
||||
worker ok
|
||||
{"postgres": "reachable", "s3": "reachable", "broker": "reachable", "otel-collector": "reachable", "redis": "reachable", "loki": "no-dns", "tempo": "no-dns", "prometheus": "no-dns", "openbao": "no-dns", "grafana": "no-dns", "api": "reachable", "1.1.1.1": "unreachable"}
|
||||
|
||||
PASS: 0 container(s) with problems
|
||||
2026-11-17T20:57:51.851Z saved evidence/hardening.txt
|
||||
@@ -0,0 +1,35 @@
|
||||
# В Loki/Tempo/Prometheus нет паролей, токенов, секретов ролей
|
||||
# python scripts/ops.py leak-check
|
||||
# 2026-11-17T23:57:55.1013288+03:00
|
||||
{
|
||||
"ok": true,
|
||||
"controls": {
|
||||
"loki has messenger-api logs": true,
|
||||
"tempo has POST /api/v1/auth/sessions spans": true,
|
||||
"prometheus has http metrics labels": true
|
||||
},
|
||||
"canary_user_created": true,
|
||||
"searched": {
|
||||
"loki_lines": 99,
|
||||
"tempo_traces": 88,
|
||||
"prometheus_labels": 26
|
||||
},
|
||||
"needles": [
|
||||
"argon2 hash",
|
||||
"basic header",
|
||||
"bearer header",
|
||||
"broker_api_password",
|
||||
"broker_worker_password",
|
||||
"cache_api_password",
|
||||
"db_api_password",
|
||||
"db_worker_password",
|
||||
"private key",
|
||||
"s3_secret_access_key",
|
||||
"s3_worker_secret_access_key",
|
||||
"session token",
|
||||
"user password",
|
||||
"wrong password"
|
||||
],
|
||||
"findings": []
|
||||
}
|
||||
2026-11-17T20:58:26.460Z saved evidence/leak_check.json
|
||||
@@ -0,0 +1,33 @@
|
||||
# Бюджет login DoS: Argon2id на стенде + поток входов
|
||||
# python scripts/ops.py login-budget
|
||||
# 2026-11-18T00:02:39.0541070+03:00
|
||||
Argon2id benchmark: N=15 per row, container CPU quota=0.50, KDF slots/replica=4
|
||||
m(KiB),t,p hash p50 verify p50 verify p95 RAM/hash MiB logins/s/replica
|
||||
19456,2,1 31.3ms 74.3ms 80.0ms 19.0 6.7 <- current
|
||||
19456,3,1 78.3ms 80.6ms 84.6ms 19.0 6.2
|
||||
47104,1,1 90.5ms 95.0ms 167.0ms 46.0 5.3
|
||||
65536,2,1 189.0ms 191.7ms 249.2ms 64.0 2.6
|
||||
65536,3,1 277.7ms 280.5ms 340.0ms 64.0 1.8
|
||||
|
||||
{
|
||||
"duration_s": 20.1,
|
||||
"concurrency": 16,
|
||||
"login_attempts": 1039,
|
||||
"login_attempts_per_s": 51.7,
|
||||
"login_status_counts": {
|
||||
"401": 299,
|
||||
"429": 740
|
||||
},
|
||||
"baseline_users_me_ms": {
|
||||
"p50": 29.7,
|
||||
"p95": 31.3
|
||||
},
|
||||
"during_flood_users_me_ms": {
|
||||
"p50": 100.7,
|
||||
"p95": 623.5,
|
||||
"non_200": 0,
|
||||
"samples": 69
|
||||
}
|
||||
}
|
||||
|
||||
2026-11-17T21:03:24.128Z saved evidence/login_budget.txt
|
||||
@@ -0,0 +1,6 @@
|
||||
# Реплики API: alias, health, статус в LB
|
||||
# python scripts/ops.py ps
|
||||
# 2026-11-17T23:57:24.3103206+03:00
|
||||
X-Instance-Id container state health lb lb_status
|
||||
api-1401d400 messenger-lab7-api-1 running healthy api1 UP
|
||||
api-21bd9440 messenger-lab7-api-2 running healthy api2 UP
|
||||
@@ -0,0 +1,5 @@
|
||||
# Argon2id: старый hash пересчитывается при успешном входе
|
||||
# python scripts/ops.py rehash-demo
|
||||
# 2026-11-17T23:57:52.1167844+03:00
|
||||
2026-11-17T20:57:55.086Z rehash-demo: user=rehash_77e2292d params before=m=8192,t=1,p=1 -> login HTTP 201 -> params after=m=19456,t=2,p=1
|
||||
2026-11-17T20:57:55.088Z saved evidence/rehash.txt
|
||||
@@ -0,0 +1,4 @@
|
||||
# Восстановление реплики
|
||||
# python scripts/ops.py restore
|
||||
# 2026-11-17T23:59:55.8260227+03:00
|
||||
2026-11-17T21:00:02.727Z restore: started ['messenger-lab7-api-1']; 2 replicas healthy and UP after 6.8s
|
||||
@@ -0,0 +1,4 @@
|
||||
# Восстановление реплики
|
||||
# python scripts/ops.py restore
|
||||
# 2026-11-18T00:00:20.7647574+03:00
|
||||
2026-11-17T21:00:27.711Z restore: started ['messenger-lab7-api-2']; 2 replicas healthy and UP after 6.9s
|
||||
@@ -0,0 +1,8 @@
|
||||
# Отзыв identity worker в OpenBao -> агент без доступа -> восстановление
|
||||
# python scripts/ops.py revoke-identity worker
|
||||
# 2026-11-18T00:01:03.4008626+03:00
|
||||
revoked identity worker: 1 SecretID, 2 token(s); agent can no longer authenticate
|
||||
2026-11-17T21:01:24.597Z rotate/revoke: identity worker revoked; agent re-auth denied=True; already rendered files remain -> worker keeps working until restart of the volume
|
||||
2026-11-17T21:01:24.613Z revoke-identity: LB ready while worker identity is revoked = True
|
||||
issued new SecretID for worker (ttl 168h, bound to 172.30.250.0/24); previous SecretID destroyed
|
||||
2026-11-17T21:01:29.326Z revoke-identity: recovered with a new SecretID; agent healthy
|
||||
@@ -0,0 +1,5 @@
|
||||
# Ротация рабочего секрета (пароль роли БД) без пересборки и рестарта API
|
||||
# python scripts/ops.py rotate-db-password api
|
||||
# 2026-11-18T00:00:27.7255998+03:00
|
||||
2026-11-17T21:00:31.985Z rotate-db-password: role=messenger_api; agent re-rendered after 3.4s; old password accepted=False (['psql: error: connection to server at "127.0.0.1", port 5432 failed: FATAL: password authentication failed for user "messenger_api"']); new password accepted=True; existing sessions terminated=3
|
||||
2026-11-17T21:00:36.079Z rotate-db-password: smoke after rotation (new pool connections): ['PASS: lab7 public API scenario; infrastructure and grading evidence remain separate.']
|
||||
@@ -0,0 +1,19 @@
|
||||
# Ротация leaf LB->API + отзыв старого сертификата (CRL), проверка старым и новым
|
||||
# python scripts/ops.py rotate-lb-cert
|
||||
# 2026-11-18T00:00:36.0907608+03:00
|
||||
Container messenger-lab7-tools-run-b0e6de7a5085 Creating
|
||||
Container messenger-lab7-tools-run-b0e6de7a5085 Created
|
||||
issue lb-client serial 44e0a374f70660066d7c277042b7d5a8d9ed8825 until 2026-12-17
|
||||
next: перезапустить потребителя нового ключа (без пересборки образа), затем revoke
|
||||
2026-11-17T21:00:44.120Z rotate-lb-cert: new lb-client in use (lb restarted, no image rebuild) after 7.9s
|
||||
Container messenger-lab7-tools-run-d38d3e848112 Creating
|
||||
Container messenger-lab7-tools-run-d38d3e848112 Created
|
||||
revoke lb-client serial 10b6b35f215923535d3ca55dc76d0c767bebdb0
|
||||
crl 3 revoked serial(s), next update 2026-12-17
|
||||
Container messenger-lab7-audit-run-fc86d31a5a74 Creating
|
||||
Container messenger-lab7-audit-run-fc86d31a5a74 Created
|
||||
System.Management.Automation.RemoteException
|
||||
{"label": "old-before-revoke", "target": "api:8443", "accepted": true, "observed": ["http", 200]}
|
||||
{"label": "old-after-revoke", "target": "api:8443", "accepted": false, "observed": ["closed", "connection closed without HTTP response"]}
|
||||
{"label": "new-after-revoke", "target": "api:8443", "accepted": true, "observed": ["http", 200]}
|
||||
2026-11-17T21:00:58.270Z rotate-lb-cert: old cert accepted before revoke=True, after revoke=False; new cert accepted=True; LB ready=True
|
||||
@@ -0,0 +1,5 @@
|
||||
# Новый SecretID агента API, старый уничтожен
|
||||
# python scripts/ops.py rotate-secret-id api
|
||||
# 2026-11-18T00:00:58.3186708+03:00
|
||||
issued new SecretID for api (ttl 168h, bound to 172.30.250.0/24); previous SecretID destroyed
|
||||
2026-11-17T21:01:03.388Z rotate-secret-id: ['api'] agent(s) re-authenticated with the new SecretID; old SecretID destroyed
|
||||
@@ -0,0 +1,67 @@
|
||||
# Приватность бакета и права ключа API вне API
|
||||
# python scripts/ops.py s3-check
|
||||
# 2026-11-18T00:03:24.3699830+03:00
|
||||
Container messenger-lab7-api-run-25e8a0a5666b Creating
|
||||
Container messenger-lab7-api-run-25e8a0a5666b Created
|
||||
{
|
||||
"endpoint_host": "s3",
|
||||
"bucket": "messenger-attachments",
|
||||
"checks": [
|
||||
{
|
||||
"check": "api credentials: put/get staging/",
|
||||
"ok": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"check": "api credentials cannot write final/ (worker prefix)",
|
||||
"ok": true,
|
||||
"detail": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"check": "api credentials cannot list the bucket",
|
||||
"ok": true,
|
||||
"detail": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"check": "anonymous GET object is denied",
|
||||
"ok": true,
|
||||
"detail": "HTTP 403"
|
||||
},
|
||||
{
|
||||
"check": "anonymous list bucket is denied",
|
||||
"ok": true,
|
||||
"detail": "HTTP 403"
|
||||
},
|
||||
{
|
||||
"check": "anonymous list buckets is denied",
|
||||
"ok": true,
|
||||
"detail": "HTTP 403"
|
||||
},
|
||||
{
|
||||
"check": "api credentials cannot create buckets",
|
||||
"ok": true,
|
||||
"detail": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"check": "api credentials cannot delete the bucket",
|
||||
"ok": true,
|
||||
"detail": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"check": "SeaweedFS admin/UI ports are not reachable on the shared network",
|
||||
"ok": true,
|
||||
"detail": "checked [9333, 8888, 8080, 19333, 18888, 8334, 18333, 18334]"
|
||||
},
|
||||
{
|
||||
"check": "anonymous GET of a real attachment object is denied",
|
||||
"ok": true,
|
||||
"detail": "HTTP 403"
|
||||
},
|
||||
{
|
||||
"check": "same object is readable with API credentials and matches sha256",
|
||||
"ok": true,
|
||||
"detail": "93 bytes"
|
||||
}
|
||||
],
|
||||
"ok": true
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
# ACL/вложения, X-User-Id, logout, 429 + Retry-After (общий), 413, ошибки без утечек, TLS снаружи
|
||||
# python scripts/ops.py security-http
|
||||
# 2026-11-17T23:57:38.0517038+03:00
|
||||
PASS setup: chat + attachment 202
|
||||
PASS outsider GET /api/v1/chats/{chat} -> 404 (no existence leak) 404
|
||||
PASS outsider GET /api/v1/chats/{chat}/messages -> 404 (no existence leak) 404
|
||||
PASS outsider POST /api/v1/chats/{chat}/messages -> 404 (no existence leak) 404
|
||||
PASS outsider GET /api/v1/attachments/{att} -> 404 (no existence leak) 404
|
||||
PASS outsider GET /api/v1/attachments/{att}/content -> 404 (no existence leak) 404
|
||||
PASS outsider attaches foreign attachment to own chat -> 404 404
|
||||
PASS X-User-Id cannot override Bearer identity eve_c7dfed486e
|
||||
PASS X-User-Id alone -> 401 + WWW-Authenticate Bearer Bearer realm="messenger"
|
||||
PASS Basic on business endpoint -> 401 401
|
||||
PASS unknown/forged token -> 401 401
|
||||
PASS logout 204 -> token rejected 401 -> repeat logout 401 (204, 401, 401)
|
||||
PASS wrong password -> 401, body has no username/password/hash {"error":{"code":"unauthorized","message":"Authentication required","request_id"
|
||||
PASS malformed JSON -> 400 without stack trace/SQL {"error":{"code":"invalid_request","message":"Invalid request","request_id":"AC1
|
||||
PASS login brute force -> 429 rate_limited + Retry-After [401, 401, 401, 401, 401, 401, 401, 401, 401, 429, 429, 429] Retry-After=21
|
||||
PASS rate limit is shared: responses from >= 2 replicas ['api-1401d400', 'api-21bd9440']
|
||||
PASS correct password while locked out -> 429 (no oracle) 429
|
||||
PASS JSON body 70 KB -> 413 payload_too_large from LB (before any replica) instance=None
|
||||
PASS chunked JSON 70 KB -> 413 payload_too_large (API) instance=api-1401d400
|
||||
PASS upload 10 MiB + 1 byte -> 413 413
|
||||
PASS wrong server name -> certificate verification error Hostname mismatch, certificate is not valid for 'evil.example'.
|
||||
PASS empty trust store -> verification error unable to get local issuer certificate
|
||||
PASS plaintext HTTP on HTTPS port is not served RemoteDisconnected
|
||||
PASS grafana over HTTPS requires authentication 401
|
||||
PASS: 24/24 checks
|
||||
2026-11-17T20:57:39.809Z saved evidence/security_http.txt
|
||||
@@ -0,0 +1,4 @@
|
||||
# Smoke после всех ротаций
|
||||
# python tests/smoke.py --base-url https://localhost:8443 --ca-file C:\Users\mrend\Desktop\VP_lab7\mtusi2026lab7-fork\secrets\pki\ca.crt
|
||||
# 2026-11-18T00:01:55.3847420+03:00
|
||||
PASS: lab7 public API scenario; infrastructure and grading evidence remain separate.
|
||||
@@ -0,0 +1,32 @@
|
||||
# White-box тесты хранилища внутри сети (identity администратора БД)
|
||||
# python scripts/ops.py in-network storage
|
||||
# 2026-11-18T00:02:29.4056637+03:00
|
||||
Container messenger-lab7-api-run-0f07d22b265d Creating
|
||||
Container messenger-lab7-api-run-0f07d22b265d Created
|
||||
test_cleanup_runs_on_one_replica_at_a_time (test_storage_idempotency.StorageIdempotencyTests.test_cleanup_runs_on_one_replica_at_a_time) ... ok
|
||||
test_conflict_on_different_body (test_storage_idempotency.StorageIdempotencyTests.test_conflict_on_different_body) ... ok
|
||||
test_expired_key_can_be_reused_and_is_cleaned (test_storage_idempotency.StorageIdempotencyTests.test_expired_key_can_be_reused_and_is_cleaned) ... ok
|
||||
test_failure_inside_transaction_stores_nothing (test_storage_idempotency.StorageIdempotencyTests.test_failure_inside_transaction_stores_nothing) ... ok
|
||||
test_threads_same_key_single_insert (test_storage_idempotency.StorageIdempotencyTests.test_threads_same_key_single_insert) ... ok
|
||||
test_failure_after_inserts_leaves_nothing (test_storage_rollback.StorageRollbackTests.test_failure_after_inserts_leaves_nothing) ... ok
|
||||
test_migrations_are_idempotent (test_storage_rollback.StorageRollbackTests.test_migrations_are_idempotent) ... ok
|
||||
test_no_orphan_chats_in_database (test_storage_rollback.StorageRollbackTests.test_no_orphan_chats_in_database) ... ok
|
||||
test_passwords_stored_as_argon2id (test_storage_rollback.StorageRollbackTests.test_passwords_stored_as_argon2id) ... ok
|
||||
System.Management.Automation.RemoteException
|
||||
----------------------------------------------------------------------
|
||||
Ran 9 tests in 3.350s
|
||||
System.Management.Automation.RemoteException
|
||||
OK
|
||||
Container messenger-lab7-api-run-c198a1fb2736 Creating
|
||||
Container messenger-lab7-api-run-c198a1fb2736 Created
|
||||
test_debt_survives_api_restart (test_session_cache.SessionRevocationCacheTests.test_debt_survives_api_restart)
|
||||
Процесс, выполнивший logout, умер до восстановления связи — новый процесс не доверяет кэшу. ... logout: cache invalidation deferred; positive cache disabled
|
||||
ok
|
||||
test_normal_logout_leaves_no_debt (test_session_cache.SessionRevocationCacheTests.test_normal_logout_leaves_no_debt) ... ok
|
||||
test_revoked_token_rejected_after_partition_heals (test_session_cache.SessionRevocationCacheTests.test_revoked_token_rejected_after_partition_heals) ... logout: cache invalidation deferred; positive cache disabled
|
||||
ok
|
||||
System.Management.Automation.RemoteException
|
||||
----------------------------------------------------------------------
|
||||
Ran 3 tests in 1.951s
|
||||
System.Management.Automation.RemoteException
|
||||
OK
|
||||
@@ -0,0 +1,111 @@
|
||||
# Собственные HTTP-тесты lab2-6 через HTTPS
|
||||
# python student-tests/run_all.py --base-url https://localhost:8443
|
||||
# 2026-11-18T00:01:58.0665970+03:00
|
||||
|
||||
== API, auth, concurrency, idempotency tests (DB/expiry tests skip without their env)
|
||||
test_chat_list_pagination (test_api.ApiBehaviorTests.test_chat_list_pagination) ... ok
|
||||
test_cursor_from_other_chat_returns_400 (test_api.ApiBehaviorTests.test_cursor_from_other_chat_returns_400) ... ok
|
||||
test_duplicate_username_returns_409 (test_api.ApiBehaviorTests.test_duplicate_username_returns_409) ... ok
|
||||
test_empty_message_returns_400 (test_api.ApiBehaviorTests.test_empty_message_returns_400) ... ok
|
||||
test_malformed_json_returns_400 (test_api.ApiBehaviorTests.test_malformed_json_returns_400) ... ok
|
||||
test_naive_timestamp_cursor_returns_400 (test_api.ApiBehaviorTests.test_naive_timestamp_cursor_returns_400) ... ok
|
||||
test_outsider_cannot_access_chat (test_api.ApiBehaviorTests.test_outsider_cannot_access_chat) ... ok
|
||||
test_pagination_returns_all_messages_without_duplicates (test_api.ApiBehaviorTests.test_pagination_returns_all_messages_without_duplicates) ... ok
|
||||
test_password_never_returned (test_api.ApiBehaviorTests.test_password_never_returned) ... ok
|
||||
test_registration_without_password_returns_400 (test_api.ApiBehaviorTests.test_registration_without_password_returns_400) ... ok
|
||||
test_sender_id_in_body_rejected (test_api.ApiBehaviorTests.test_sender_id_in_body_rejected) ... ok
|
||||
test_short_password_returns_400 (test_api.ApiBehaviorTests.test_short_password_returns_400) ... ok
|
||||
test_crash_between_put_and_commit_dry_run_then_apply_then_noop (test_attachment_consistency.AttachmentConsistencyTests.test_crash_between_put_and_commit_dry_run_then_apply_then_noop) ... skipped 'DATABASE_URL and S3 settings are not configured'
|
||||
test_fresh_pending_is_kept (test_attachment_consistency.AttachmentConsistencyTests.test_fresh_pending_is_kept) ... skipped 'DATABASE_URL and S3 settings are not configured'
|
||||
test_missing_object_is_reported_not_deleted (test_attachment_consistency.AttachmentConsistencyTests.test_missing_object_is_reported_not_deleted) ... skipped 'DATABASE_URL and S3 settings are not configured'
|
||||
test_orphan_object_deleted_only_after_grace (test_attachment_consistency.AttachmentConsistencyTests.test_orphan_object_deleted_only_after_grace) ... skipped 'DATABASE_URL and S3 settings are not configured'
|
||||
test_pending_cannot_be_attached (test_attachment_consistency.AttachmentConsistencyTests.test_pending_cannot_be_attached) ... skipped 'DATABASE_URL and S3 settings are not configured'
|
||||
test_ready_and_referenced_are_never_collected (test_attachment_consistency.AttachmentConsistencyTests.test_ready_and_referenced_are_never_collected) ... skipped 'DATABASE_URL and S3 settings are not configured'
|
||||
test_aborted_upload_leaves_no_row_and_no_object (test_attachment_consistency.UploadFailureTests.test_aborted_upload_leaves_no_row_and_no_object) ... skipped 'DATABASE_URL and S3 settings are not configured'
|
||||
test_db_failure_after_put_returns_503_and_deletes_object (test_attachment_consistency.UploadFailureTests.test_db_failure_after_put_returns_503_and_deletes_object) ... skipped 'DATABASE_URL and S3 settings are not configured'
|
||||
test_process_crash_after_put_is_collected_by_gc (test_attachment_consistency.UploadFailureTests.test_process_crash_after_put_is_collected_by_gc) ... skipped 'DATABASE_URL and S3 settings are not configured'
|
||||
test_s3_put_failure_returns_503_and_compensates (test_attachment_consistency.UploadFailureTests.test_s3_put_failure_returns_503_and_compensates) ... skipped 'DATABASE_URL and S3 settings are not configured'
|
||||
test_attachment_from_other_chat_is_404_and_nothing_saved (test_attachments.AttachmentTests.test_attachment_from_other_chat_is_404_and_nothing_saved) ... ok
|
||||
test_content_type_with_parameters_is_accepted (test_attachments.AttachmentTests.test_content_type_with_parameters_is_accepted) ... ok
|
||||
test_corrupted_images_are_415 (test_attachments.AttachmentTests.test_corrupted_images_are_415) ... ok
|
||||
test_dangerous_filenames_are_400 (test_attachments.AttachmentTests.test_dangerous_filenames_are_400) ... ok
|
||||
test_exactly_max_size_is_accepted (test_attachments.AttachmentTests.test_exactly_max_size_is_accepted) ... ok
|
||||
test_idempotency_includes_attachment_ids (test_attachments.AttachmentTests.test_idempotency_includes_attachment_ids) ... ok
|
||||
test_invalid_and_unknown_attachment_ids (test_attachments.AttachmentTests.test_invalid_and_unknown_attachment_ids) ... ok
|
||||
test_jpeg_baseline_and_progressive (test_attachments.AttachmentTests.test_jpeg_baseline_and_progressive) ... ok
|
||||
test_message_attachment_validation (test_attachments.AttachmentTests.test_message_attachment_validation) ... ok
|
||||
test_message_with_attachments_visible_to_members (test_attachments.AttachmentTests.test_message_with_attachments_visible_to_members) ... ok
|
||||
test_mime_spoofing_is_415 (test_attachments.AttachmentTests.test_mime_spoofing_is_415) ... ok
|
||||
test_original_variant_and_unknown_variants (test_attachments.AttachmentTests.test_original_variant_and_unknown_variants) ... ok
|
||||
test_outsider_and_unknown_chat_upload_404 (test_attachments.AttachmentTests.test_outsider_and_unknown_chat_upload_404) ... ok
|
||||
test_png_roundtrip_member_reads_outsider_404 (test_attachments.AttachmentTests.test_png_roundtrip_member_reads_outsider_404) ... ok
|
||||
test_too_large_chunked_without_content_length (test_attachments.AttachmentTests.test_too_large_chunked_without_content_length) ... ok
|
||||
test_too_large_with_content_length (test_attachments.AttachmentTests.test_too_large_with_content_length) ... ok
|
||||
test_too_many_pixels (test_attachments.AttachmentTests.test_too_many_pixels) ... ok
|
||||
test_basic_on_business_endpoint_rejected (test_auth.AuthTests.test_basic_on_business_endpoint_rejected) ... ok
|
||||
test_login_with_body_rejected (test_auth.AuthTests.test_login_with_body_rejected)
|
||||
Контракт: вход — только заголовок Basic, без тела. Лишний ввод -> 400, сессии нет. ... ok
|
||||
test_logout_revokes_only_current_session (test_auth.AuthTests.test_logout_revokes_only_current_session) ... ok
|
||||
test_malformed_basic_headers (test_auth.AuthTests.test_malformed_basic_headers) ... ok
|
||||
test_password_with_colon_and_unicode (test_auth.AuthTests.test_password_with_colon_and_unicode) ... ok
|
||||
test_session_shape_and_token_entropy (test_auth.AuthTests.test_session_shape_and_token_entropy) ... ok
|
||||
test_unknown_and_garbage_tokens (test_auth.AuthTests.test_unknown_and_garbage_tokens) ... ok
|
||||
test_wrong_password_and_unknown_user_look_the_same (test_auth.AuthTests.test_wrong_password_and_unknown_user_look_the_same) ... ok
|
||||
test_x_user_id_gives_no_access (test_auth.AuthTests.test_x_user_id_gives_no_access) ... ok
|
||||
test_duplicate_and_missing_caller_rejected (test_concurrency.ChatRollbackTests.test_duplicate_and_missing_caller_rejected) ... ok
|
||||
test_unknown_member_rolls_back_whole_chat (test_concurrency.ChatRollbackTests.test_unknown_member_rolls_back_whole_chat)
|
||||
Чат вставляется первым, затем участники по порядку (сначала сам владелец). ... ok
|
||||
test_same_username_parallel_registration (test_concurrency.RegistrationRaceTests.test_same_username_parallel_registration) ... ok
|
||||
test_session_expires_even_when_cached (test_expiry.ExpiryTests.test_session_expires_even_when_cached) ... skipped 'set EXPIRY_BASE_URL to the short-TTL API instance'
|
||||
test_auth_checked_before_key (test_idempotency.IdempotencyTests.test_auth_checked_before_key) ... ok
|
||||
test_concurrent_same_key_across_replicas_creates_one_message (test_idempotency.IdempotencyTests.test_concurrent_same_key_across_replicas_creates_one_message) ... ok
|
||||
test_concurrent_same_key_different_bodies_one_winner (test_idempotency.IdempotencyTests.test_concurrent_same_key_different_bodies_one_winner) ... ok
|
||||
test_failed_access_does_not_burn_key (test_idempotency.IdempotencyTests.test_failed_access_does_not_burn_key) ... ok
|
||||
test_json_formatting_and_key_order_do_not_matter (test_idempotency.IdempotencyTests.test_json_formatting_and_key_order_do_not_matter) ... ok
|
||||
test_key_survives_new_session_of_same_user (test_idempotency.IdempotencyTests.test_key_survives_new_session_of_same_user) ... ok
|
||||
test_missing_or_invalid_key_is_400 (test_idempotency.IdempotencyTests.test_missing_or_invalid_key_is_400) ... ok
|
||||
test_replay_rechecks_session (test_idempotency.IdempotencyTests.test_replay_rechecks_session) ... ok
|
||||
test_scope_is_user_and_chat (test_idempotency.IdempotencyTests.test_scope_is_user_and_chat) ... ok
|
||||
test_sequential_replay_and_conflict (test_idempotency.IdempotencyTests.test_sequential_replay_and_conflict) ... ok
|
||||
test_exif_orientation_applied_and_stripped (test_pipeline.PipelineTests.test_exif_orientation_applied_and_stripped) ... ok
|
||||
test_fixture_320x200 (test_pipeline.PipelineTests.test_fixture_320x200) ... ok
|
||||
test_progressive_jpeg (test_pipeline.PipelineTests.test_progressive_jpeg) ... ok
|
||||
test_result_is_stable_and_private (test_pipeline.PipelineTests.test_result_is_stable_and_private) ... ok
|
||||
test_small_source_not_upscaled_except_crop (test_pipeline.PipelineTests.test_small_source_not_upscaled_except_crop) ... ok
|
||||
test_transparency_on_white (test_pipeline.PipelineTests.test_transparency_on_white) ... ok
|
||||
test_unknown_variant_is_400 (test_pipeline.PipelineTests.test_unknown_variant_is_400) ... ok
|
||||
test_a_crash_between_commit_and_publish (test_pipeline_faults.PipelineFaultTests.test_a_crash_between_commit_and_publish) ... skipped 'needs API at https://localhost:8443 and DB/S3/broker env'
|
||||
test_b_crash_after_publish_duplicate_is_noop (test_pipeline_faults.PipelineFaultTests.test_b_crash_after_publish_duplicate_is_noop) ... skipped 'needs API at https://localhost:8443 and DB/S3/broker env'
|
||||
test_c_worker_crash_after_side_effects_before_commit (test_pipeline_faults.PipelineFaultTests.test_c_worker_crash_after_side_effects_before_commit) ... skipped 'needs API at https://localhost:8443 and DB/S3/broker env'
|
||||
test_d_worker_crash_after_commit_before_ack (test_pipeline_faults.PipelineFaultTests.test_d_worker_crash_after_commit_before_ack) ... skipped 'needs API at https://localhost:8443 and DB/S3/broker env'
|
||||
test_e_transient_errors_retry_with_backoff (test_pipeline_faults.PipelineFaultTests.test_e_transient_errors_retry_with_backoff) ... skipped 'needs API at https://localhost:8443 and DB/S3/broker env'
|
||||
test_f_permanent_error_fails_without_retry (test_pipeline_faults.PipelineFaultTests.test_f_permanent_error_fails_without_retry) ... skipped 'needs API at https://localhost:8443 and DB/S3/broker env'
|
||||
test_g_retry_exhausted_dlq_then_explicit_replay (test_pipeline_faults.PipelineFaultTests.test_g_retry_exhausted_dlq_then_explicit_replay) ... skipped 'needs API at https://localhost:8443 and DB/S3/broker env'
|
||||
test_h_hung_worker_lease_expires_and_is_fenced (test_pipeline_faults.PipelineFaultTests.test_h_hung_worker_lease_expires_and_is_fenced) ... skipped 'needs API at https://localhost:8443 and DB/S3/broker env'
|
||||
test_i_staging_removed_after_safe_commit (test_pipeline_faults.PipelineFaultTests.test_i_staging_removed_after_safe_commit) ... skipped 'needs API at https://localhost:8443 and DB/S3/broker env'
|
||||
test_j_garbage_broker_message_is_acked (test_pipeline_faults.PipelineFaultTests.test_j_garbage_broker_message_is_acked) ... skipped 'needs API at https://localhost:8443 and DB/S3/broker env'
|
||||
test_debt_survives_api_restart (test_session_cache.SessionRevocationCacheTests.test_debt_survives_api_restart)
|
||||
Процесс, выполнивший logout, умер до восстановления связи — новый процесс не доверяет кэшу. ... skipped 'DATABASE_URL is not configured'
|
||||
test_normal_logout_leaves_no_debt (test_session_cache.SessionRevocationCacheTests.test_normal_logout_leaves_no_debt) ... skipped 'DATABASE_URL is not configured'
|
||||
test_revoked_token_rejected_after_partition_heals (test_session_cache.SessionRevocationCacheTests.test_revoked_token_rejected_after_partition_heals) ... skipped 'DATABASE_URL is not configured'
|
||||
test_cleanup_runs_on_one_replica_at_a_time (test_storage_idempotency.StorageIdempotencyTests.test_cleanup_runs_on_one_replica_at_a_time) ... skipped 'DATABASE_URL is not configured'
|
||||
test_conflict_on_different_body (test_storage_idempotency.StorageIdempotencyTests.test_conflict_on_different_body) ... skipped 'DATABASE_URL is not configured'
|
||||
test_expired_key_can_be_reused_and_is_cleaned (test_storage_idempotency.StorageIdempotencyTests.test_expired_key_can_be_reused_and_is_cleaned) ... skipped 'DATABASE_URL is not configured'
|
||||
test_failure_inside_transaction_stores_nothing (test_storage_idempotency.StorageIdempotencyTests.test_failure_inside_transaction_stores_nothing) ... skipped 'DATABASE_URL is not configured'
|
||||
test_threads_same_key_single_insert (test_storage_idempotency.StorageIdempotencyTests.test_threads_same_key_single_insert) ... skipped 'DATABASE_URL is not configured'
|
||||
test_failure_after_inserts_leaves_nothing (test_storage_rollback.StorageRollbackTests.test_failure_after_inserts_leaves_nothing) ... skipped 'DATABASE_URL is not configured'
|
||||
test_migrations_are_idempotent (test_storage_rollback.StorageRollbackTests.test_migrations_are_idempotent) ... skipped 'DATABASE_URL is not configured'
|
||||
test_no_orphan_chats_in_database (test_storage_rollback.StorageRollbackTests.test_no_orphan_chats_in_database) ... skipped 'DATABASE_URL is not configured'
|
||||
test_passwords_stored_as_argon2id (test_storage_rollback.StorageRollbackTests.test_passwords_stored_as_argon2id) ... skipped 'DATABASE_URL is not configured'
|
||||
System.Management.Automation.RemoteException
|
||||
----------------------------------------------------------------------
|
||||
Ran 91 tests in 28.150s
|
||||
System.Management.Automation.RemoteException
|
||||
OK (skipped=33)
|
||||
|
||||
24 parallel POSTs, one key -> 1 message; replicas: ['api-01803f21', 'api-7e1626c5']
|
||||
|
||||
== Concurrent write test
|
||||
PASS: concurrent write test; 10 clients x 10 messages = 100 messages; no lost or duplicate messages
|
||||
|
||||
ALL STUDENT TESTS PASSED
|
||||
@@ -0,0 +1,6 @@
|
||||
# make test-failover: отказ одной API-реплики по HTTPS
|
||||
# python tests/resilience.py --mode failover --action-script C:\Users\mrend\Desktop\VP_lab7\mtusi2026lab7-fork\scripts\stop-one.cmd --base-url https://localhost:8443 --ca-file C:\Users\mrend\Desktop\VP_lab7\mtusi2026lab7-fork\secrets\pki\ca.crt
|
||||
# 2026-11-17T23:59:38.0003701+03:00
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 111, "failed_attempts": 0, "first_recovery_seconds": 4.984}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
@@ -0,0 +1,6 @@
|
||||
# Отказ другой реплики (последовательно)
|
||||
# python tests/resilience.py --mode failover --action-script C:\Users\mrend\Desktop\VP_lab7\mtusi2026lab7-fork\scripts\stop-one.cmd --base-url https://localhost:8443 --ca-file C:\Users\mrend\Desktop\VP_lab7\mtusi2026lab7-fork\secrets\pki\ca.crt
|
||||
# 2026-11-18T00:00:02.7399008+03:00
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 113, "failed_attempts": 0, "first_recovery_seconds": 5.063}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
@@ -0,0 +1,5 @@
|
||||
# make test-persistence: рестарт API и всех хранилищ (вкл. OpenBao + unseal), данные и токен живы
|
||||
# python tests/resilience.py --mode persistence --action-script C:\Users\mrend\Desktop\VP_lab7\mtusi2026lab7-fork\scripts\restart.cmd --base-url https://localhost:8443 --ca-file C:\Users\mrend\Desktop\VP_lab7\mtusi2026lab7-fork\secrets\pki\ca.crt
|
||||
# 2026-11-17T23:58:44.4582689+03:00
|
||||
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
@@ -0,0 +1,4 @@
|
||||
# make test-security: доверенный CA работает, недоверенный — ошибка проверки сертификата
|
||||
# python tests/security.py --base-url https://localhost:8443 --ca-file C:\Users\mrend\Desktop\VP_lab7\mtusi2026lab7-fork\secrets\pki\ca.crt
|
||||
# 2026-11-17T23:57:27.7419268+03:00
|
||||
PASS: trusted HTTPS works; untrusted CA rejected. This does NOT verify internal mTLS, OpenBao or hardening.
|
||||
@@ -0,0 +1,4 @@
|
||||
# make test BASE_URL=https://localhost:8443 CA_FILE=secrets\pki\ca.crt
|
||||
# python tests/smoke.py --base-url https://localhost:8443 --ca-file C:\Users\mrend\Desktop\VP_lab7\mtusi2026lab7-fork\secrets\pki\ca.crt
|
||||
# 2026-11-17T23:57:25.2579225+03:00
|
||||
PASS: lab7 public API scenario; infrastructure and grading evidence remain separate.
|
||||
@@ -0,0 +1,718 @@
|
||||
# Вся trust matrix: TLS/mTLS (нет cert / чужой CA / чужая identity / верная), имена, plaintext, ACL
|
||||
# python scripts/ops.py tls-audit
|
||||
# 2026-11-17T23:57:27.8839570+03:00
|
||||
{
|
||||
"ok": true,
|
||||
"total": 101,
|
||||
"failed": 0,
|
||||
"checks": [
|
||||
{
|
||||
"link": "client -> lb (public TLS)",
|
||||
"check": "trusted CA + hostname lb/localhost SAN",
|
||||
"expected": "HTTP 200",
|
||||
"ok": true,
|
||||
"observed": "('http', 200)"
|
||||
},
|
||||
{
|
||||
"link": "client -> lb (public TLS)",
|
||||
"check": "empty trust store",
|
||||
"expected": "verify_error",
|
||||
"ok": true,
|
||||
"observed": "('verify_error', 'unable to get local issuer certificate')"
|
||||
},
|
||||
{
|
||||
"link": "client -> lb (public TLS)",
|
||||
"check": "wrong hostname",
|
||||
"expected": "verify_error",
|
||||
"ok": true,
|
||||
"observed": "('verify_error', \"Hostname mismatch, certificate is not valid for 'evil.example'.\")"
|
||||
},
|
||||
{
|
||||
"link": "client -> lb (public TLS)",
|
||||
"check": "plaintext HTTP on :8443",
|
||||
"expected": "no successful plaintext response",
|
||||
"ok": true,
|
||||
"observed": "('closed', \"b''\")"
|
||||
},
|
||||
{
|
||||
"link": "client -> lb (public TLS)",
|
||||
"check": "HAProxy stats not exposed on network",
|
||||
"expected": "refused",
|
||||
"ok": true,
|
||||
"observed": "('refused', 'connection refused')"
|
||||
},
|
||||
{
|
||||
"link": "lb -> api (mTLS, allowlist lb + CRL)",
|
||||
"check": "identity lb (allowed)",
|
||||
"expected": "HTTP 200",
|
||||
"ok": true,
|
||||
"observed": "('http', 200)"
|
||||
},
|
||||
{
|
||||
"link": "lb -> api (mTLS, allowlist lb + CRL)",
|
||||
"check": "no client certificate",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('closed', 'connection closed without HTTP response')"
|
||||
},
|
||||
{
|
||||
"link": "lb -> api (mTLS, allowlist lb + CRL)",
|
||||
"check": "rogue CA with CN=lb",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('closed', 'connection closed without HTTP response')"
|
||||
},
|
||||
{
|
||||
"link": "lb -> api (mTLS, allowlist lb + CRL)",
|
||||
"check": "same CA, identity intruder",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('closed', 'connection closed without HTTP response')"
|
||||
},
|
||||
{
|
||||
"link": "lb -> api (mTLS, allowlist lb + CRL)",
|
||||
"check": "same CA, identity worker",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('closed', 'connection closed without HTTP response')"
|
||||
},
|
||||
{
|
||||
"link": "lb -> api (mTLS, allowlist lb + CRL)",
|
||||
"check": "same CA, identity api (replica as client)",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('closed', 'connection closed without HTTP response')"
|
||||
},
|
||||
{
|
||||
"link": "lb -> api (mTLS, allowlist lb + CRL)",
|
||||
"check": "plaintext HTTP on :8443",
|
||||
"expected": "no successful plaintext response",
|
||||
"ok": true,
|
||||
"observed": "('closed', \"b''\")"
|
||||
},
|
||||
{
|
||||
"link": "lb -> api (mTLS, allowlist lb + CRL)",
|
||||
"check": "health listener 8081 not reachable from network (loopback only)",
|
||||
"expected": "refused",
|
||||
"ok": true,
|
||||
"observed": "('refused', '[Errno 111] Connection refused')"
|
||||
},
|
||||
{
|
||||
"link": "lb -> api (mTLS, allowlist lb + CRL)",
|
||||
"check": "LB-side check: server name must be api",
|
||||
"expected": "verify_error",
|
||||
"ok": true,
|
||||
"observed": "('verify_error', \"Hostname mismatch, certificate is not valid for 'evil.example'.\")"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> postgres (TLS verify-full, roles)",
|
||||
"check": "messenger_api verify-full",
|
||||
"expected": "TLS session",
|
||||
"ok": true,
|
||||
"observed": "(True, 'TLSv1.3')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> postgres (TLS verify-full, roles)",
|
||||
"check": "plaintext (sslmode=disable)",
|
||||
"expected": "rejected",
|
||||
"ok": true,
|
||||
"observed": "connection failed: connection to server at \"172.19.0.3\", port 5432 failed: FATAL: pg_hba.conf rejects connection for host \"172.19.0.7\", user \"messenger_api\", database \"messenger\", no encryption"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> postgres (TLS verify-full, roles)",
|
||||
"check": "rogue CA as trust root",
|
||||
"expected": "rejected",
|
||||
"ok": true,
|
||||
"observed": "connection failed: connection to server at \"172.19.0.3\", port 5432 failed: SSL error: certificate verify failed"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> postgres (TLS verify-full, roles)",
|
||||
"check": "wrong hostname (IP instead of name)",
|
||||
"expected": "rejected",
|
||||
"ok": true,
|
||||
"observed": "connection failed: connection to server at \"172.19.0.3\", port 5432 failed: server certificate for \"postgres\" (and 1 other name) does not match host name \"172.19.0.3\""
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> postgres (TLS verify-full, roles)",
|
||||
"check": "messenger_worker: SELECT count(*) FROM attachments",
|
||||
"expected": "allowed",
|
||||
"ok": true,
|
||||
"observed": "executed"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> postgres (TLS verify-full, roles)",
|
||||
"check": "messenger_worker: SELECT password_hash FROM users LIMIT 1",
|
||||
"expected": "permission denied",
|
||||
"ok": true,
|
||||
"observed": "permission denied for table users"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> postgres (TLS verify-full, roles)",
|
||||
"check": "messenger_worker: SELECT token_hash FROM sessions LIMIT 1",
|
||||
"expected": "permission denied",
|
||||
"ok": true,
|
||||
"observed": "permission denied for table sessions"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> postgres (TLS verify-full, roles)",
|
||||
"check": "messenger_api: CREATE TABLE audit_ddl (i int)",
|
||||
"expected": "permission denied",
|
||||
"ok": true,
|
||||
"observed": "permission denied for schema public"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> postgres (TLS verify-full, roles)",
|
||||
"check": "messenger_api: TRUNCATE users",
|
||||
"expected": "permission denied",
|
||||
"ok": true,
|
||||
"observed": "permission denied for table users"
|
||||
},
|
||||
{
|
||||
"link": "api -> redis cache (mTLS + ACL)",
|
||||
"check": "messenger_api SET sess:*",
|
||||
"expected": "ok",
|
||||
"ok": true,
|
||||
"observed": "('ok', True)"
|
||||
},
|
||||
{
|
||||
"link": "api -> redis cache (mTLS + ACL)",
|
||||
"check": "messenger_api SET other:key 1",
|
||||
"expected": "NOPERM",
|
||||
"ok": true,
|
||||
"observed": "('noperm', 'No permissions to access a key')"
|
||||
},
|
||||
{
|
||||
"link": "api -> redis cache (mTLS + ACL)",
|
||||
"check": "messenger_api FLUSHALL",
|
||||
"expected": "NOPERM",
|
||||
"ok": true,
|
||||
"observed": "('noperm', \"User messenger_api has no permissions to run the 'flushall' command\")"
|
||||
},
|
||||
{
|
||||
"link": "api -> redis cache (mTLS + ACL)",
|
||||
"check": "messenger_api CONFIG GET *",
|
||||
"expected": "NOPERM",
|
||||
"ok": true,
|
||||
"observed": "('noperm', \"User messenger_api has no permissions to run the 'config|get' command\")"
|
||||
},
|
||||
{
|
||||
"link": "api -> redis cache (mTLS + ACL)",
|
||||
"check": "messenger_api KEYS *",
|
||||
"expected": "NOPERM",
|
||||
"ok": true,
|
||||
"observed": "('noperm', \"User messenger_api has no permissions to run the 'keys' command\")"
|
||||
},
|
||||
{
|
||||
"link": "api -> redis cache (mTLS + ACL)",
|
||||
"check": "cert without AUTH (default user off)",
|
||||
"expected": "NOAUTH",
|
||||
"ok": true,
|
||||
"observed": "('noauth', 'Authentication required.')"
|
||||
},
|
||||
{
|
||||
"link": "api -> redis cache (mTLS + ACL)",
|
||||
"check": "no client certificate",
|
||||
"expected": "connection rejected",
|
||||
"ok": true,
|
||||
"observed": "('conn_error', \"Error while reading from redis:6379 : (1, '[SSL: TLSV13_ALERT_CERTIFICATE_REQUIRED] tlsv13 alert certificate required (_\")"
|
||||
},
|
||||
{
|
||||
"link": "api -> redis cache (mTLS + ACL)",
|
||||
"check": "rogue CA client certificate",
|
||||
"expected": "connection rejected",
|
||||
"ok": true,
|
||||
"observed": "('conn_error', \"Error while reading from redis:6379 : (1, '[SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:2570)')\")"
|
||||
},
|
||||
{
|
||||
"link": "api -> redis cache (mTLS + ACL)",
|
||||
"check": "plaintext",
|
||||
"expected": "connection rejected",
|
||||
"ok": true,
|
||||
"observed": "('conn_error', \"Error while reading from redis:6379 : (104, 'Connection reset by peer')\")"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "no client certificate (with valid producer password)",
|
||||
"expected": "connection rejected",
|
||||
"ok": true,
|
||||
"observed": "('conn_error', \"Error while reading from broker:6380 : (1, '[SSL: TLSV13_ALERT_CERTIFICATE_REQUIRED] tlsv13 alert certificate required (\")"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "rogue CA with CN=api (with valid producer password)",
|
||||
"expected": "connection rejected",
|
||||
"ok": true,
|
||||
"observed": "('conn_error', \"Error while reading from broker:6380 : (1, '[SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:2570)')\")"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "same CA, identity intruder (with valid producer password)",
|
||||
"expected": "connection rejected",
|
||||
"ok": true,
|
||||
"observed": "('conn_error', 'Connection closed by server.')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "same CA, identity lb (with valid producer password)",
|
||||
"expected": "connection rejected",
|
||||
"ok": true,
|
||||
"observed": "('conn_error', 'Connection closed by server.')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "same CA, identity prometheus (with valid producer password)",
|
||||
"expected": "connection rejected",
|
||||
"ok": true,
|
||||
"observed": "('conn_error', 'Connection closed by server.')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "identity api without AUTH",
|
||||
"expected": "NOAUTH",
|
||||
"ok": true,
|
||||
"observed": "('noauth', 'Authentication required.')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "api_producer PING",
|
||||
"expected": "ok",
|
||||
"ok": true,
|
||||
"observed": "('ok', True)"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "api_producer XREADGROUP",
|
||||
"expected": "NOPERM",
|
||||
"ok": true,
|
||||
"observed": "('noperm', \"User api_producer has no permissions to run the 'xreadgroup' command\")"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "api_producer XACK",
|
||||
"expected": "NOPERM",
|
||||
"ok": true,
|
||||
"observed": "('noperm', \"User api_producer has no permissions to run the 'xack' command\")"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "api_producer XDEL",
|
||||
"expected": "NOPERM",
|
||||
"ok": true,
|
||||
"observed": "('noperm', \"User api_producer has no permissions to run the 'xdel' command\")"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "api_producer DEL",
|
||||
"expected": "NOPERM",
|
||||
"ok": true,
|
||||
"observed": "('noperm', \"User api_producer has no permissions to run the 'del' command\")"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "api_producer FLUSHALL",
|
||||
"expected": "NOPERM",
|
||||
"ok": true,
|
||||
"observed": "('noperm', \"User api_producer has no permissions to run the 'flushall' command\")"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "api_producer XADD other key",
|
||||
"expected": "NOPERM",
|
||||
"ok": true,
|
||||
"observed": "('noperm', 'No permissions to access a key')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "worker_consumer XLEN",
|
||||
"expected": "ok",
|
||||
"ok": true,
|
||||
"observed": "('ok', 1)"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "worker_consumer SET",
|
||||
"expected": "NOPERM",
|
||||
"ok": true,
|
||||
"observed": "('noperm', \"User worker_consumer has no permissions to run the 'set' command\")"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "worker_consumer FLUSHALL",
|
||||
"expected": "NOPERM",
|
||||
"ok": true,
|
||||
"observed": "('noperm', \"User worker_consumer has no permissions to run the 'flushall' command\")"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "worker_consumer CONFIG",
|
||||
"expected": "NOPERM",
|
||||
"ok": true,
|
||||
"observed": "('noperm', \"User worker_consumer has no permissions to run the 'config|get' command\")"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "worker_consumer DEL",
|
||||
"expected": "NOPERM",
|
||||
"ok": true,
|
||||
"observed": "('noperm', \"User worker_consumer has no permissions to run the 'del' command\")"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "Redis port 6379 not reachable from network (loopback only)",
|
||||
"expected": "connection refused",
|
||||
"ok": true,
|
||||
"observed": "('conn_error', 'Error 111 connecting to broker:6379. Connection refused.')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> broker-gate (mTLS allowlist api|worker) -> broker ACL",
|
||||
"check": "plaintext to gate",
|
||||
"expected": "connection rejected",
|
||||
"ok": true,
|
||||
"observed": "('conn_error', 'Connection closed by server.')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "TLS verify-full GET /healthz",
|
||||
"expected": "HTTP 200",
|
||||
"ok": true,
|
||||
"observed": "('http', 200)"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "wrong hostname",
|
||||
"expected": "verify_error",
|
||||
"ok": true,
|
||||
"observed": "('verify_error', \"Hostname mismatch, certificate is not valid for 'evil.example'.\")"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "plaintext on :8333",
|
||||
"expected": "no successful plaintext response",
|
||||
"ok": true,
|
||||
"observed": "('http', 400)"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "S3 API behind gate :8334 not reachable from network",
|
||||
"expected": "refused",
|
||||
"ok": true,
|
||||
"observed": "('refused', '[Errno 111] Connection refused')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "S3 gateway gRPC (unauthenticated) :18334 not reachable from network",
|
||||
"expected": "refused",
|
||||
"ok": true,
|
||||
"observed": "('refused', '[Errno 111] Connection refused')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "S3 gRPC default port :18333 not reachable from network",
|
||||
"expected": "refused",
|
||||
"ok": true,
|
||||
"observed": "('refused', '[Errno 111] Connection refused')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "master :9333 not reachable from network",
|
||||
"expected": "refused",
|
||||
"ok": true,
|
||||
"observed": "('refused', '[Errno 111] Connection refused')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "filer :8888 not reachable from network",
|
||||
"expected": "refused",
|
||||
"ok": true,
|
||||
"observed": "('refused', '[Errno 111] Connection refused')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "filer gRPC :18888 not reachable from network",
|
||||
"expected": "refused",
|
||||
"ok": true,
|
||||
"observed": "('refused', '[Errno 111] Connection refused')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "api PUT staging/",
|
||||
"expected": "allowed",
|
||||
"ok": true,
|
||||
"observed": "allowed"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "api DELETE staging/",
|
||||
"expected": "allowed",
|
||||
"ok": true,
|
||||
"observed": "allowed"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "api PUT final/ (worker prefix)",
|
||||
"expected": "AccessDenied",
|
||||
"ok": true,
|
||||
"observed": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "api LIST bucket",
|
||||
"expected": "AccessDenied",
|
||||
"ok": true,
|
||||
"observed": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "api CREATE bucket",
|
||||
"expected": "AccessDenied",
|
||||
"ok": true,
|
||||
"observed": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "worker LIST bucket",
|
||||
"expected": "allowed",
|
||||
"ok": true,
|
||||
"observed": "allowed"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "worker PUT outside its prefixes",
|
||||
"expected": "AccessDenied",
|
||||
"ok": true,
|
||||
"observed": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> s3 (TLS, scoped identities)",
|
||||
"check": "worker DELETE bucket",
|
||||
"expected": "AccessDenied",
|
||||
"ok": true,
|
||||
"observed": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> otel-gate (mTLS allowlist api|worker) -> collector",
|
||||
"check": "identity api POST /v1/logs",
|
||||
"expected": "HTTP 200",
|
||||
"ok": true,
|
||||
"observed": "('http', 200)"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> otel-gate (mTLS allowlist api|worker) -> collector",
|
||||
"check": "identity worker POST /v1/logs",
|
||||
"expected": "HTTP 200",
|
||||
"ok": true,
|
||||
"observed": "('http', 200)"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> otel-gate (mTLS allowlist api|worker) -> collector",
|
||||
"check": "no client certificate POST /v1/logs",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('tls_error', 'TLSV13_ALERT_CERTIFICATE_REQUIRED')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> otel-gate (mTLS allowlist api|worker) -> collector",
|
||||
"check": "rogue CA with CN=api POST /v1/logs",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('tls_error', 'TLSV1_ALERT_UNKNOWN_CA')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> otel-gate (mTLS allowlist api|worker) -> collector",
|
||||
"check": "same CA, identity intruder POST /v1/logs",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('closed', 'connection closed without HTTP response')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> otel-gate (mTLS allowlist api|worker) -> collector",
|
||||
"check": "same CA, identity prometheus POST /v1/logs",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('closed', 'connection closed without HTTP response')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> otel-gate (mTLS allowlist api|worker) -> collector",
|
||||
"check": "same CA, identity lb POST /v1/logs",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('closed', 'connection closed without HTTP response')"
|
||||
},
|
||||
{
|
||||
"link": "api/worker -> otel-gate (mTLS allowlist api|worker) -> collector",
|
||||
"check": "plaintext on :4318",
|
||||
"expected": "no successful plaintext response",
|
||||
"ok": true,
|
||||
"observed": "('closed', \"b''\")"
|
||||
},
|
||||
{
|
||||
"link": "prometheus -> otel-gate metrics (allowlist prometheus)",
|
||||
"check": "identity prometheus /metrics :8889",
|
||||
"expected": "HTTP 200",
|
||||
"ok": true,
|
||||
"observed": "('http', 200)"
|
||||
},
|
||||
{
|
||||
"link": "prometheus -> otel-gate metrics (allowlist prometheus)",
|
||||
"check": "identity prometheus /metrics :8888 (self)",
|
||||
"expected": "HTTP 200",
|
||||
"ok": true,
|
||||
"observed": "('http', 200)"
|
||||
},
|
||||
{
|
||||
"link": "prometheus -> otel-gate metrics (allowlist prometheus)",
|
||||
"check": "identity api /metrics :8889",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('closed', 'connection closed without HTTP response')"
|
||||
},
|
||||
{
|
||||
"link": "prometheus -> otel-gate metrics (allowlist prometheus)",
|
||||
"check": "collector loopback port 14318 not reachable",
|
||||
"expected": "refused",
|
||||
"ok": true,
|
||||
"observed": "('refused', '[Errno 111] Connection refused')"
|
||||
},
|
||||
{
|
||||
"link": "prometheus -> otel-gate metrics (allowlist prometheus)",
|
||||
"check": "collector loopback port 18889 not reachable",
|
||||
"expected": "refused",
|
||||
"ok": true,
|
||||
"observed": "('refused', '[Errno 111] Connection refused')"
|
||||
},
|
||||
{
|
||||
"link": "prometheus -> otel-gate metrics (allowlist prometheus)",
|
||||
"check": "collector loopback port 18888 not reachable",
|
||||
"expected": "refused",
|
||||
"ok": true,
|
||||
"observed": "('refused', '[Errno 111] Connection refused')"
|
||||
},
|
||||
{
|
||||
"link": "prometheus -> otel-gate metrics (allowlist prometheus)",
|
||||
"check": "collector loopback port 13133 not reachable",
|
||||
"expected": "refused",
|
||||
"ok": true,
|
||||
"observed": "('refused', '[Errno 111] Connection refused')"
|
||||
},
|
||||
{
|
||||
"link": "collector/grafana -> loki (mTLS)",
|
||||
"check": "client cert grafana (TLS ok, service ready)",
|
||||
"expected": "HTTP 200",
|
||||
"ok": true,
|
||||
"observed": "('http', 200)"
|
||||
},
|
||||
{
|
||||
"link": "collector/grafana -> loki (mTLS)",
|
||||
"check": "no client certificate",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('tls_error', 'TLSV13_ALERT_CERTIFICATE_REQUIRED')"
|
||||
},
|
||||
{
|
||||
"link": "collector/grafana -> loki (mTLS)",
|
||||
"check": "rogue CA client certificate",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('tls_error', 'TLSV1_ALERT_UNKNOWN_CA')"
|
||||
},
|
||||
{
|
||||
"link": "collector/grafana -> loki (mTLS)",
|
||||
"check": "plaintext",
|
||||
"expected": "no successful plaintext response",
|
||||
"ok": true,
|
||||
"observed": "('http', 400)"
|
||||
},
|
||||
{
|
||||
"link": "grafana -> tempo (mTLS)",
|
||||
"check": "client cert grafana (TLS ok, service ready)",
|
||||
"expected": "HTTP 200",
|
||||
"ok": true,
|
||||
"observed": "('http', 200)"
|
||||
},
|
||||
{
|
||||
"link": "grafana -> tempo (mTLS)",
|
||||
"check": "no client certificate",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('tls_error', 'TLSV13_ALERT_CERTIFICATE_REQUIRED')"
|
||||
},
|
||||
{
|
||||
"link": "grafana -> tempo (mTLS)",
|
||||
"check": "rogue CA client certificate",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('tls_error', 'TLSV1_ALERT_UNKNOWN_CA')"
|
||||
},
|
||||
{
|
||||
"link": "grafana -> tempo (mTLS)",
|
||||
"check": "plaintext",
|
||||
"expected": "no successful plaintext response",
|
||||
"ok": true,
|
||||
"observed": "('http', 400)"
|
||||
},
|
||||
{
|
||||
"link": "grafana -> prometheus (mTLS)",
|
||||
"check": "client cert grafana (TLS ok, service ready)",
|
||||
"expected": "HTTP 200",
|
||||
"ok": true,
|
||||
"observed": "('http', 200)"
|
||||
},
|
||||
{
|
||||
"link": "grafana -> prometheus (mTLS)",
|
||||
"check": "no client certificate",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('tls_error', 'TLSV13_ALERT_CERTIFICATE_REQUIRED')"
|
||||
},
|
||||
{
|
||||
"link": "grafana -> prometheus (mTLS)",
|
||||
"check": "rogue CA client certificate",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('tls_error', 'TLSV1_ALERT_UNKNOWN_CA')"
|
||||
},
|
||||
{
|
||||
"link": "grafana -> prometheus (mTLS)",
|
||||
"check": "plaintext",
|
||||
"expected": "no successful plaintext response",
|
||||
"ok": true,
|
||||
"observed": "('http', 400)"
|
||||
},
|
||||
{
|
||||
"link": "collector -> tempo OTLP gRPC (mTLS)",
|
||||
"check": "no client certificate",
|
||||
"expected": "rejected (TLS/handshake/close)",
|
||||
"ok": true,
|
||||
"observed": "('tls_error', 'TLSV13_ALERT_CERTIFICATE_REQUIRED')"
|
||||
},
|
||||
{
|
||||
"link": "agents -> openbao (TLS + AppRole)",
|
||||
"check": "TLS verify-full /v1/sys/health",
|
||||
"expected": "HTTP 200 (unsealed)",
|
||||
"ok": true,
|
||||
"observed": "('http', 200)"
|
||||
},
|
||||
{
|
||||
"link": "agents -> openbao (TLS + AppRole)",
|
||||
"check": "wrong hostname",
|
||||
"expected": "verify_error",
|
||||
"ok": true,
|
||||
"observed": "('verify_error', \"Hostname mismatch, certificate is not valid for 'evil.example'.\")"
|
||||
},
|
||||
{
|
||||
"link": "agents -> openbao (TLS + AppRole)",
|
||||
"check": "plaintext on :8200",
|
||||
"expected": "no successful plaintext response",
|
||||
"ok": true,
|
||||
"observed": "('http', 400)"
|
||||
},
|
||||
{
|
||||
"link": "agents -> openbao (TLS + AppRole)",
|
||||
"check": "read KV without token",
|
||||
"expected": "HTTP 403",
|
||||
"ok": true,
|
||||
"observed": "('http', 403)"
|
||||
}
|
||||
]
|
||||
}
|
||||
2026-11-17T20:57:35.308Z saved evidence/tls_audit.json
|
||||
@@ -0,0 +1,162 @@
|
||||
# Bootstrap: secrets -> образ -> PKI -> OpenBao init/unseal/configure -> стенд -> ожидание готовности
|
||||
# python scripts/ops.py up
|
||||
# 2026-11-17T23:57:07.5355535+03:00
|
||||
keep secrets/postgres_password
|
||||
keep secrets/database_admin_url
|
||||
keep secrets/db_api_password
|
||||
keep secrets/db_worker_password
|
||||
keep secrets/cache_api_password
|
||||
keep secrets/broker_api_password
|
||||
keep secrets/broker_worker_password
|
||||
keep secrets/grafana_admin_password
|
||||
keep secrets/s3_admin_access_key_id
|
||||
keep secrets/s3_admin_secret_access_key
|
||||
keep secrets/s3_access_key_id
|
||||
keep secrets/s3_secret_access_key
|
||||
keep secrets/s3_worker_access_key_id
|
||||
keep secrets/s3_worker_secret_access_key
|
||||
keep secrets/s3_config.json
|
||||
2026-11-17T20:57:07.709Z up: building image (api/worker/migrate/s3-init/tools)
|
||||
Image messenger-api:lab7 Building
|
||||
#1 [internal] load local bake definitions
|
||||
#1 reading from stdin 1.50kB 0.0s done
|
||||
#1 DONE 0.0s
|
||||
|
||||
#2 [internal] load build definition from Dockerfile
|
||||
#2 transferring dockerfile: 1.53kB done
|
||||
#2 DONE 0.0s
|
||||
|
||||
#3 [internal] load metadata for docker.io/library/python:3.12.7-slim-bookworm
|
||||
#3 DONE 1.4s
|
||||
|
||||
#4 [internal] load .dockerignore
|
||||
#4 transferring context: 264B done
|
||||
#4 DONE 0.0s
|
||||
|
||||
#5 [1/7] FROM docker.io/library/python:3.12.7-slim-bookworm@sha256:60d9996b6a8a3689d36db740b49f4327be3be09a21122bd02fb8895abb38b50d
|
||||
#5 resolve docker.io/library/python:3.12.7-slim-bookworm@sha256:60d9996b6a8a3689d36db740b49f4327be3be09a21122bd02fb8895abb38b50d 0.0s done
|
||||
#5 DONE 0.0s
|
||||
|
||||
#6 [internal] load build context
|
||||
#6 transferring context: 1.37kB done
|
||||
#6 DONE 0.0s
|
||||
|
||||
#7 [3/7] COPY requirements.txt .
|
||||
#7 CACHED
|
||||
|
||||
#8 [4/7] RUN pip install --no-cache-dir --disable-pip-version-check -r requirements.txt
|
||||
#8 CACHED
|
||||
|
||||
#9 [6/7] COPY migrations ./migrations
|
||||
#9 CACHED
|
||||
|
||||
#10 [2/7] WORKDIR /app
|
||||
#10 CACHED
|
||||
|
||||
#11 [5/7] COPY src ./src
|
||||
#11 CACHED
|
||||
|
||||
#12 [7/7] RUN groupadd --gid 10001 appuser && useradd --uid 10001 --gid 10001 --no-create-home --home-dir /nonexistent --shell /usr/sbin/nologin appuser
|
||||
#12 CACHED
|
||||
|
||||
#13 exporting to image
|
||||
#13 exporting layers
|
||||
#13 exporting layers done
|
||||
#13 exporting manifest sha256:3a3cbef5472c7fe7fb3770fd2a1361ab59ec02b28bda430f29b6c70043b43554 done
|
||||
#13 exporting config sha256:26f2e3e40f1cba8fe10cba8aa600e656f54656db05c77c043493c6c44acc98a7 done
|
||||
#13 exporting attestation manifest sha256:2387092eee85d6799f18a319530d1e434643d44ac3ffb5c82531ffd7d12d2d6c 0.0s done
|
||||
#13 exporting manifest list sha256:4427dfc802d546fd09249101e9efca16c96b46d6bad96682c9d4daae5ab1e21c 0.0s done
|
||||
#13 naming to docker.io/library/messenger-api:lab7
|
||||
#13 naming to docker.io/library/messenger-api:lab7 done
|
||||
#13 unpacking to docker.io/library/messenger-api:lab7 0.0s done
|
||||
#13 DONE 0.2s
|
||||
|
||||
#14 resolving provenance for metadata file
|
||||
#14 DONE 0.0s
|
||||
Image messenger-api:lab7 Built
|
||||
Container messenger-lab7-tools-run-d7893944bfb7 Creating
|
||||
Container messenger-lab7-tools-run-d7893944bfb7 Created
|
||||
keep ca.crt
|
||||
keep lb-public
|
||||
keep lb-client
|
||||
keep api
|
||||
keep worker
|
||||
keep postgres
|
||||
keep redis
|
||||
keep broker
|
||||
keep s3
|
||||
keep otel-collector
|
||||
keep loki
|
||||
keep tempo
|
||||
keep prometheus
|
||||
keep grafana
|
||||
keep openbao
|
||||
keep intruder
|
||||
OpenBao already initialized (keys: present)
|
||||
OpenBao is unsealed
|
||||
issued new SecretID for api (ttl 168h, bound to 172.30.250.0/24); previous SecretID destroyed
|
||||
issued new SecretID for worker (ttl 168h, bound to 172.30.250.0/24); previous SecretID destroyed
|
||||
configured: kv-v2, approle, policies messenger-api/messenger-worker, secrets written to KV
|
||||
2026-11-17T20:57:19.647Z up: starting the stand
|
||||
Container messenger-lab7-grafana-1 Running
|
||||
Container messenger-lab7-worker-1 Running
|
||||
Container messenger-lab7-tempo-1 Running
|
||||
Container messenger-lab7-broker-gate-1 Running
|
||||
Container messenger-lab7-otel-gate-1 Running
|
||||
Container messenger-lab7-redis-1 Running
|
||||
Container messenger-lab7-bao-agent-worker-1 Running
|
||||
Container messenger-lab7-api-1 Running
|
||||
Container messenger-lab7-api-2 Running
|
||||
Container messenger-lab7-openbao-1 Running
|
||||
Container messenger-lab7-otel-collector-1 Running
|
||||
Container messenger-lab7-broker-1 Running
|
||||
Container messenger-lab7-postgres-1 Running
|
||||
Container messenger-lab7-lb-1 Running
|
||||
Container messenger-lab7-loki-1 Running
|
||||
Container messenger-lab7-s3-gate-1 Running
|
||||
Container messenger-lab7-prometheus-1 Running
|
||||
Container messenger-lab7-bao-agent-api-1 Running
|
||||
Container messenger-lab7-s3-1 Running
|
||||
Container messenger-lab7-tempo-init-1 Starting
|
||||
Container messenger-lab7-broker-1 Waiting
|
||||
Container messenger-lab7-prometheus-1 Waiting
|
||||
Container messenger-lab7-postgres-1 Waiting
|
||||
Container messenger-lab7-s3-1 Waiting
|
||||
Container messenger-lab7-tempo-init-1 Started
|
||||
Container messenger-lab7-tempo-init-1 Waiting
|
||||
Container messenger-lab7-broker-1 Healthy
|
||||
Container messenger-lab7-s3-1 Healthy
|
||||
Container messenger-lab7-s3-gate-1 Waiting
|
||||
Container messenger-lab7-postgres-1 Healthy
|
||||
Container messenger-lab7-migrate-1 Starting
|
||||
Container messenger-lab7-prometheus-1 Healthy
|
||||
Container messenger-lab7-tempo-init-1 Exited
|
||||
Container messenger-lab7-migrate-1 Started
|
||||
Container messenger-lab7-s3-gate-1 Healthy
|
||||
Container messenger-lab7-s3-init-1 Starting
|
||||
Container messenger-lab7-s3-init-1 Started
|
||||
Container messenger-lab7-migrate-1 Waiting
|
||||
Container messenger-lab7-s3-init-1 Waiting
|
||||
Container messenger-lab7-bao-agent-worker-1 Waiting
|
||||
Container messenger-lab7-bao-agent-api-1 Waiting
|
||||
Container messenger-lab7-postgres-1 Waiting
|
||||
Container messenger-lab7-postgres-1 Waiting
|
||||
Container messenger-lab7-broker-gate-1 Waiting
|
||||
Container messenger-lab7-redis-1 Waiting
|
||||
Container messenger-lab7-migrate-1 Waiting
|
||||
Container messenger-lab7-s3-init-1 Waiting
|
||||
Container messenger-lab7-migrate-1 Exited
|
||||
Container messenger-lab7-bao-agent-worker-1 Healthy
|
||||
Container messenger-lab7-broker-gate-1 Healthy
|
||||
Container messenger-lab7-postgres-1 Healthy
|
||||
Container messenger-lab7-migrate-1 Exited
|
||||
Container messenger-lab7-bao-agent-api-1 Healthy
|
||||
Container messenger-lab7-postgres-1 Healthy
|
||||
Container messenger-lab7-redis-1 Healthy
|
||||
Container messenger-lab7-s3-init-1 Exited
|
||||
Container messenger-lab7-s3-init-1 Exited
|
||||
Container messenger-lab7-api-1 Waiting
|
||||
Container messenger-lab7-api-2 Waiting
|
||||
Container messenger-lab7-api-1 Healthy
|
||||
Container messenger-lab7-api-2 Healthy
|
||||
2026-11-17T20:57:24.297Z up: ready in 17s -> https://127.0.0.1:8443 (CA: secrets\pki\ca.crt); Grafana https://127.0.0.1:3000 (admin / secrets/grafana_admin_password)
|
||||
Reference in New Issue
Block a user