forked from mtusi2026/mtusi2026lab7
лр7: Docker-прогон, evidence, исправления
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
# Прогон в нативной песочнице (без Docker)
|
||||
|
||||
Решение собиралось в среде, где Docker Hub недоступен. Чтобы проверить код и конфигурации до Docker-прогона,
|
||||
тот же стенд запускался процессами на одной машине (Linux x86_64, 2 vCPU, 8 GiB на всё сразу): каждый сервис —
|
||||
на своём loopback-адресе с именем из compose (`/etc/hosts`: postgres, redis, s3, rabbitmq, openbao, otel-collector,
|
||||
prometheus), конфиги — файлы из `infra/` с подстановкой путей `/run/tls*` → `secrets/pki/...`; команды `docker` /
|
||||
`docker compose`, которые вызывают тесты и hooks, выполнялись подменой, управляющей процессами (stop/start/
|
||||
restart/kill/pause, exec в окружении сервиса, политика `restart: unless-stopped`).
|
||||
|
||||
Стенд поднят с нуля шагами оператора из REPORT.md: `pki.py init` → `init_secrets.py` → OpenBao → `bao.py init`,
|
||||
`unseal`, `configure` → остальные сервисы. Затем `python student-tests/collect_evidence.py <шаги>` с
|
||||
`EVIDENCE_DIR=evidence/native-sandbox` — результаты в этой папке, сводка — `summary.md`.
|
||||
|
||||
| Компонент | В песочнице | В compose.yaml |
|
||||
| --- | --- | --- |
|
||||
| Приложение (api ×2, worker, dispatcher, janitor, migrate, s3-init) | тот же код, Python 3.11, `requirements.txt` | образ из `Dockerfile` (python:3.11.13-slim) |
|
||||
| PostgreSQL | 16.15 (TLS, `pg_hba.conf` из infra) | 17.11-alpine |
|
||||
| Redis | 7.0.15 (`redis.conf` из infra, TLS + ACL) | 7.4.11-alpine |
|
||||
| SeaweedFS | 4.52 (те же флаги и `security.toml`) | 4.52 |
|
||||
| RabbitMQ | 4.4.0 (`rabbitmq.conf` из infra, EXTERNAL) | 4.1.4-alpine |
|
||||
| OpenBao | **HashiCorp Vault 2.1.2** — API-совместимая замена (sys/init, unseal, cert auth, KV v2, policies — те же пути и поля) | openbao/openbao:2.6.2 |
|
||||
| HAProxy (lb, otel-gate) | 2.8.30 (конфиги из infra; вместо DNS Docker — две статические реплики) | 3.2.25-alpine |
|
||||
| OTel Collector | заглушка OTLP/HTTP на 127.0.0.1:4319 за настоящим otel-gate (сохраняет пакеты для `leak_check.py`) | otelcol-contrib 0.164.0 |
|
||||
| Prometheus | 2.45 — только `web.yml` (TLS, `client_allowed_sans`) | v3.15.1 |
|
||||
| Loki, Tempo, Grafana | не запускались (нет бинарников) — их TLS проверяется только в Docker | 3.7.9, 3.1.1, 12.4.14 |
|
||||
|
||||
Не выполнялись в песочнице (нужен Docker или Loki/Tempo/Grafana): `stack`, `hardening --runtime` (статическая
|
||||
часть — да), `configs`, `telemetry*`, `dashboard`, `incident-*`, `upload-memory`, `s3-security`
|
||||
(`test_no_open_ports_or_console`), `rolling-update`, `failover-metrics`, `test_expiry.py`.
|
||||
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"rows": [
|
||||
{
|
||||
"m_kib": 19456,
|
||||
"t": 2,
|
||||
"p": 1,
|
||||
"hash_ms": 23.4,
|
||||
"verify_ms": 23.6,
|
||||
"max_logins_per_s_per_replica": 84.7
|
||||
},
|
||||
{
|
||||
"m_kib": 19456,
|
||||
"t": 3,
|
||||
"p": 1,
|
||||
"hash_ms": 42.2,
|
||||
"verify_ms": 42.1,
|
||||
"max_logins_per_s_per_replica": 47.5
|
||||
},
|
||||
{
|
||||
"m_kib": 32768,
|
||||
"t": 2,
|
||||
"p": 1,
|
||||
"hash_ms": 51.2,
|
||||
"verify_ms": 49.9,
|
||||
"max_logins_per_s_per_replica": 40.1
|
||||
},
|
||||
{
|
||||
"m_kib": 47104,
|
||||
"t": 2,
|
||||
"p": 1,
|
||||
"hash_ms": 63.9,
|
||||
"verify_ms": 62.1,
|
||||
"max_logins_per_s_per_replica": 32.2
|
||||
},
|
||||
{
|
||||
"m_kib": 65536,
|
||||
"t": 2,
|
||||
"p": 1,
|
||||
"hash_ms": 115.8,
|
||||
"verify_ms": 115.8,
|
||||
"max_logins_per_s_per_replica": 17.3
|
||||
},
|
||||
{
|
||||
"m_kib": 65536,
|
||||
"t": 3,
|
||||
"p": 1,
|
||||
"hash_ms": 195.8,
|
||||
"verify_ms": 187.2,
|
||||
"max_logins_per_s_per_replica": 10.7
|
||||
}
|
||||
],
|
||||
"maxrss_mib": 136.8,
|
||||
"current": [
|
||||
32768,
|
||||
2,
|
||||
1
|
||||
],
|
||||
"max_concurrency": 2,
|
||||
"queue_s": 2
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
# argon2-bench: lab7: Argon2id cost inside the api container for candidate parameters
|
||||
# date: 2026-11-07 15:08:10, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/argon2_bench.py
|
||||
# exit code: 0, 7.5 s
|
||||
|
||||
m (KiB) t p hash ms verify ms logins/s per replica at concurrency 2 RAM for hashing
|
||||
19456 2 1 23.4 23.6 84.7 38 MiB
|
||||
19456 3 1 42.2 42.1 47.5 38 MiB
|
||||
32768 2 1 51.2 49.9 40.1 64 MiB <- current
|
||||
47104 2 1 63.9 62.1 32.2 92 MiB
|
||||
65536 2 1 115.8 115.8 17.3 128 MiB
|
||||
65536 3 1 195.8 187.2 10.7 128 MiB
|
||||
process max RSS during the bench: 136.8 MiB
|
||||
saved evidence/argon2-bench.json
|
||||
@@ -0,0 +1,96 @@
|
||||
# attachments: lab4: files, limits, damaged images, MIME, filenames, access, attachment_ids
|
||||
# date: 2026-11-07 15:20:02, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_attachments.py
|
||||
# exit code: 0, 14.3 s
|
||||
|
||||
sample.png: 111817 bytes, sha256 99ea7533c441..., downloaded by the other member, same bytes
|
||||
sample.jpg: 1492 bytes, sha256 c310b9a1c208..., downloaded by the other member, same bytes
|
||||
progressive.jpg: 1081 bytes, sha256 913df01aec84..., downloaded by the other member, same bytes
|
||||
interlaced.png: 79 bytes, sha256 38149222f78f..., downloaded by the other member, same bytes
|
||||
1x1.png: 67 bytes, sha256 eaa4a94ea300..., downloaded by the other member, same bytes
|
||||
PASS: PNG, JPEG, progressive JPEG, interlaced PNG and 1x1 PNG are stored and returned byte for byte
|
||||
exactly 10485760 bytes (10 MiB) -> 202, then ready
|
||||
10485761 bytes (10 MiB + 1) with Content-Length -> 413 before reading the body
|
||||
PASS: the 10 MiB limit is exact
|
||||
12 MiB without Content-Length (chunked) -> 413 as soon as the 10 MiB limit is passed
|
||||
PASS: oversized streamed body is cut off, the API keeps working
|
||||
8000x5000 = 40 000 000 pixels (38957 bytes compressed) -> 202, ready 889591f7
|
||||
8001x5000 = 40 005 000 pixels (38962 bytes) -> 413
|
||||
header claims 100000x100000 in 65 bytes -> 413 from the header, nothing is decoded
|
||||
PASS: pixel limit is checked before decompression
|
||||
PNG cut in half (55908 bytes, image/png) -> 415
|
||||
PNG without IEND (111805 bytes, image/png) -> 415
|
||||
PNG with a flipped byte in IDAT (CRC mismatch) (111817 bytes, image/png) -> 415
|
||||
PNG with garbage after IEND (111824 bytes, image/png) -> 415
|
||||
PNG signature only (8 bytes, image/png) -> 415
|
||||
PNG with less pixel data than the header says (68 bytes, image/png) -> 415
|
||||
JPEG cut in half (746 bytes, image/jpeg) -> 415
|
||||
JPEG header only (20 bytes, image/jpeg) -> 415
|
||||
random bytes (1600 bytes, image/png) -> 415
|
||||
plain text (28 bytes, image/jpeg) -> 415
|
||||
empty body -> 400
|
||||
PASS: damaged and foreign files are rejected with 415, never 500
|
||||
PLTE 771 bytes = 257 entries (review case) (850 bytes, valid CRCs) -> 415
|
||||
PLTE length not a multiple of 3 (83 bytes, valid CRCs) -> 415
|
||||
empty PLTE (79 bytes, valid CRCs) -> 415
|
||||
palette larger than bit depth allows (depth 1, 3 entries) (88 bytes, valid CRCs) -> 415
|
||||
palette image without PLTE (67 bytes, valid CRCs) -> 415
|
||||
PLTE in a grayscale image (85 bytes, valid CRCs) -> 415
|
||||
PLTE after IDAT (85 bytes, valid CRCs) -> 415
|
||||
two PLTE chunks (103 bytes, valid CRCs) -> 415
|
||||
tRNS longer than the palette (100 bytes, valid CRCs) -> 415
|
||||
tRNS before PLTE (98 bytes, valid CRCs) -> 415
|
||||
tRNS of wrong size for RGB (4 bytes instead of 6) (85 bytes, valid CRCs) -> 415
|
||||
tRNS in an image with alpha channel (82 bytes, valid CRCs) -> 415
|
||||
IEND with data (70 bytes, valid CRCs) -> 415
|
||||
unknown critical chunk (81 bytes, valid CRCs) -> 415
|
||||
IDAT chunks not consecutive (95 bytes, valid CRCs) -> 415
|
||||
gAMA after IDAT (85 bytes, valid CRCs) -> 415
|
||||
gAMA of 2 bytes instead of 4 (83 bytes, valid CRCs) -> 415
|
||||
3 MiB metadata chunk before IDAT (3145809 bytes, valid CRCs) -> 415
|
||||
private chunk after IDAT (181 bytes, valid CRCs) -> 415
|
||||
animated PNG frame (fdAT) (91 bytes, valid CRCs) -> 415
|
||||
tIME of 2 bytes instead of 7 (83 bytes, valid CRCs) -> 415
|
||||
tEXt without keyword separator (86 bytes, valid CRCs) -> 415
|
||||
zTXt with broken zlib after IDAT (91 bytes, valid CRCs) -> 415
|
||||
zTXt text bomb: 50 MB of text in ~50 KB after IDAT (48694 bytes, valid CRCs) -> 415
|
||||
palette 256 entries + tRNS + tEXt and tIME after IDAT -> 201, downloaded byte for byte
|
||||
palette depth 2 with 4 entries -> 201, downloaded byte for byte
|
||||
RGB with 6-byte tRNS and gAMA -> 201, downloaded byte for byte
|
||||
compressed zTXt (100 KB of text) and iTXt after IDAT -> 201, downloaded byte for byte
|
||||
PASS: chunk contents are checked, not only CRCs; valid PNGs with metadata are still accepted
|
||||
PNG bytes sent as image/jpeg -> 415
|
||||
JPEG bytes sent as image/png -> 415
|
||||
GIF bytes sent as image/png -> 415
|
||||
PNG sent as image/gif -> 415
|
||||
PNG sent as text/html -> 415
|
||||
PNG sent as application/octet-stream -> 415
|
||||
PNG sent as multipart/form-data -> 415
|
||||
PNG sent as 'IMAGE/PNG; charset=binary' -> 201, stored as image/png
|
||||
PASS: the type is taken from the content; a declared type that does not match is refused
|
||||
13 dangerous or invalid names (path, slashes, NUL, control characters, empty, 256 chars) -> 400
|
||||
no filename -> 400
|
||||
Unicode, 255 chars, leading dots, %20 and ? are kept as display names only
|
||||
PASS: filename never becomes a path; dangerous names are refused
|
||||
outsider -> 404 for metadata and bytes (same as a non-existent id); no token -> 401; bad UUID -> 400
|
||||
upload into someone else's / unknown chat -> 404, without token -> 401
|
||||
variant=preview -> 400 (not in the contract); original/thumbnail/crop/optimized -> 200 (lab5)
|
||||
PASS: only chat members can see an attachment
|
||||
text='' with 2 attachments -> 201, order kept; any member may attach a file uploaded by another member
|
||||
history returns attachment_ids for every message, [] for a message without files; reuse is allowed
|
||||
attachment of another chat (author is a member of both) -> 404
|
||||
own + foreign attachment -> 404
|
||||
unknown attachment_id -> 404
|
||||
outsider referencing an attachment of the chat -> 404
|
||||
duplicate ids -> 400
|
||||
11 ids -> 400
|
||||
bad UUID -> 400
|
||||
empty text without attachments -> 400
|
||||
whitespace text without attachments -> 400
|
||||
PASS: only attachments of the same chat can be linked; rejected requests change nothing
|
||||
same key + same attachments -> same 201; other attachments -> 409; missing field == []
|
||||
PASS: Idempotency-Key covers attachment_ids
|
||||
sent 1.1 MB of a declared 5 MB body and closed the connection
|
||||
the API keeps serving uploads; nothing of the aborted request is visible (DB/S3 side is checked by test_consistency.py)
|
||||
PASS: an interrupted upload is dropped
|
||||
12 passed, 0 failed
|
||||
@@ -0,0 +1,18 @@
|
||||
# balancing: balancing, shared sessions/data/files, X-Instance-Id
|
||||
# date: 2026-11-07 15:21:37, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_balancing.py
|
||||
# exit code: 0, 2.8 s
|
||||
|
||||
20 x GET /users/me with one token -> replicas: {'4ec098d7198a': 10, '9b3c6b6625a9': 10}
|
||||
PASS: one session works on every replica, no second login (sessions are shared in Redis)
|
||||
message written by 9b3c6b6625a9; read back by ['4ec098d7198a', '9b3c6b6625a9']
|
||||
PASS: a message written via one replica is read right away via another (shared PostgreSQL)
|
||||
logout on 4ec098d7198a; old token then rejected by ['4ec098d7198a', '9b3c6b6625a9']
|
||||
PASS: logout on one replica revokes the session on all of them
|
||||
first POST on 4ec098d7198a -> 201 34d01e03-4930-4859-b912-60d58ae2bca9; same key on 9b3c6b6625a9 -> 201 34d01e03-4930-4859-b912-60d58ae2bca9
|
||||
PASS: Idempotency-Key is shared: a retry through another replica returns the same message
|
||||
file uploaded via 4ec098d7198a; downloaded byte for byte via ['4ec098d7198a', '9b3c6b6625a9']
|
||||
PASS: a file uploaded through one replica is downloaded through another (shared S3, nothing local)
|
||||
statuses [200, 200, 201, 400, 401, 404, 409]: every answer has X-Instance-Id of a running replica ['4ec098d7198a', '9b3c6b6625a9']; api containers -> aliases: {'api-1': '4ec098d7198a', 'api-2': '9b3c6b6625a9'}
|
||||
PASS: X-Instance-Id is in every response and points to a real container
|
||||
6 passed, 0 failed
|
||||
@@ -0,0 +1,6 @@
|
||||
# check: offline contract check (make check)
|
||||
# date: 2026-11-07 15:07:32, commit: 5bfc53a + uncommitted changes
|
||||
# command: python scripts/check_contract.py
|
||||
# exit code: 0, 0.1 s
|
||||
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
@@ -0,0 +1,47 @@
|
||||
# consistency: lab4: aborted upload, crash between S3 and DB, janitor, orphans, S3 outage
|
||||
# date: 2026-11-07 15:34:26, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_consistency.py
|
||||
# exit code: 0, 95.1 s
|
||||
|
||||
declared 9 000 000 bytes, sent 211817, closed the connection
|
||||
declared 9 000 000 bytes, sent 3111817, closed the connection
|
||||
rows in attachments: 69 -> 69; objects in bucket: 264 -> 264
|
||||
temporary upload files in api containers: {'api-1': 0, 'api-2': 0} (removed when the request ends)
|
||||
api containers have no volumes: the original is never stored locally
|
||||
PASS: an interrupted upload leaves no row, no object and no local file
|
||||
crash after S3 PUT: row bcd86485 state=uploading, object staging/dcc998514ccb4f5385947581f4c192cc exists in S3
|
||||
the half-written attachment is invisible: GET -> 404, attach to a message -> 404
|
||||
janitor with default grace (3600 s) right away: {"dry_run": false, "grace_seconds": 3600, "stale_uploads": 0, "stale_uploads_deleted": 0, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 269, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 1, "seconds": 0.192} -> fresh row and object are kept (the upload might still be running)
|
||||
row made 2 h old; janitor --dry-run: {"dry_run": true, "grace_seconds": 3600, "stale_uploads": 1, "stale_uploads_deleted": 0, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 269, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 1, "seconds": 0.207} -> nothing deleted
|
||||
janitor: {"dry_run": false, "grace_seconds": 3600, "stale_uploads": 1, "stale_uploads_deleted": 1, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 268, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 1, "seconds": 0.181} -> row and object deleted
|
||||
janitor again: {"dry_run": false, "grace_seconds": 3600, "stale_uploads": 0, "stale_uploads_deleted": 0, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 268, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 1, "seconds": 0.185} -> idempotent
|
||||
the ready attachment of the same chat is untouched
|
||||
PASS: S3 written but DB not committed -> invisible, reclaimed by janitor only after the grace period
|
||||
object staging/f07a7443c23b46d3ad398824008ba3b6 put into the bucket without a row in PostgreSQL
|
||||
janitor --grace-seconds 3 immediately: {"dry_run": false, "grace_seconds": 3, "stale_uploads": 1, "stale_uploads_deleted": 1, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 273, "orphan_objects": 5, "orphan_objects_deleted": 5, "missing_objects": 1, "seconds": 0.208} -> fresh object kept
|
||||
after 4 s, --dry-run: {"dry_run": true, "grace_seconds": 3, "stale_uploads": 0, "stale_uploads_deleted": 0, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 268, "orphan_objects": 1, "orphan_objects_deleted": 0, "missing_objects": 1, "seconds": 0.203} -> reported, kept
|
||||
janitor: {"dry_run": false, "grace_seconds": 3, "stale_uploads": 0, "stale_uploads_deleted": 0, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 268, "orphan_objects": 1, "orphan_objects_deleted": 1, "missing_objects": 1, "seconds": 0.198} -> orphan deleted
|
||||
ready attachments older than the grace period are untouched (they have rows)
|
||||
object of a ready attachment deleted behind the API's back: janitor reports missing_objects=2 and keeps the row; download -> 503 (not 500)
|
||||
PASS: orphans are found and deleted only after the grace period; missing objects are reported
|
||||
--- S3 stopped (connection refused / name not resolved): docker compose stop s3
|
||||
upload -> 503 unavailable in 386 ms, no storage details in the body
|
||||
download of an existing file -> 503
|
||||
metadata, messages (also with an already stored attachment) and /health/ready keep working: S3 is needed only for file bytes
|
||||
uploading rows of this chat: before 0, after the failed upload 1 (kept as a pointer for janitor if the rollback could not reach S3); not visible through the API
|
||||
docker compose start s3
|
||||
after S3 recovery the old file downloads byte for byte
|
||||
new upload -> 202 (16.2 s after the old file became readable)
|
||||
janitor after grace period: {"dry_run": false, "grace_seconds": 3600, "stale_uploads": 1, "stale_uploads_deleted": 1, "staging_ready_deleted": 1, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 278, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 2, "seconds": 0.197}
|
||||
PASS: S3 stopped (connection refused / name not resolved) -> 503 for file operations only, no visible half-uploads, everything cleaned up
|
||||
--- S3 frozen (no answer, timeouts): docker compose pause s3
|
||||
upload -> 503 unavailable in 4064 ms, no storage details in the body
|
||||
download of an existing file -> 503
|
||||
metadata, messages (also with an already stored attachment) and /health/ready keep working: S3 is needed only for file bytes
|
||||
uploading rows of this chat: before 0, after the failed upload 1 (kept as a pointer for janitor if the rollback could not reach S3); not visible through the API
|
||||
docker compose unpause s3
|
||||
after S3 recovery the old file downloads byte for byte
|
||||
new upload -> 202 (0.3 s after the old file became readable)
|
||||
janitor after grace period: {"dry_run": false, "grace_seconds": 3600, "stale_uploads": 1, "stale_uploads_deleted": 1, "staging_ready_deleted": 0, "staging_failed_expired": 0, "staging_kept_for_replay": 0, "outbox_rows_deleted": 0, "objects_scanned": 287, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 2, "seconds": 0.195}
|
||||
PASS: S3 frozen (no answer, timeouts) -> 503 for file operations only, no visible half-uploads, everything cleaned up
|
||||
5 passed, 0 failed
|
||||
@@ -0,0 +1,21 @@
|
||||
# db: PostgreSQL: rollback, FK, Argon2id, unique keys, migrations
|
||||
# date: 2026-11-07 15:21:56, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_db.py
|
||||
# exit code: 0, 7.0 s
|
||||
|
||||
chat with unknown member -> 400; rows with this title: 0; chats without members: 0; chats insert counter: 62 -> 63
|
||||
PASS: chat row was inserted and then rolled back together with members
|
||||
direct INSERT of a message from a non-member -> exit code 1: ERROR: insert or update on table "messages" violates foreign key constraint "messages_chat_id_sender_id_fkey"
|
||||
PASS: the database itself rejects a message from a non-member
|
||||
stored password: $argon2id$v=19$m=32768,t=2,p=1$... (length 97)
|
||||
PASS: password is stored as Argon2id hash
|
||||
unique constraint on users: UNIQUE (username)
|
||||
PASS: username is unique in the database
|
||||
applied migrations: 001_init.sql,002_text_as_bytes.sql,003_idempotency.sql,004_attachments.sql,005_jobs.sql,006_roles.sql; running the migrate service once more
|
||||
after the second run: 001_init.sql,002_text_as_bytes.sql,003_idempotency.sql,004_attachments.sql,005_jobs.sql,006_roles.sql; log: Migrations applied: none (schema is up to date)
|
||||
PASS: migrations are applied once, a repeated run does nothing
|
||||
api replicas that checked the schema at start: 5; api log lines 'Migrations applied': 0; migrate service: Exited (0)
|
||||
PASS: only the migrate service applies migrations, replicas wait for the schema
|
||||
unique constraint for Idempotency-Key: UNIQUE (chat_id, sender_id, idempotency_key)
|
||||
PASS: one message per (chat, sender, Idempotency-Key) is enforced by the database
|
||||
7 passed, 0 failed
|
||||
@@ -0,0 +1,99 @@
|
||||
=== Data volume
|
||||
messages_total | messages_in_big_chat
|
||||
----------------+----------------------
|
||||
23017 | 15000
|
||||
|
||||
|
||||
=== History index
|
||||
indexdef
|
||||
----------------------------------------------------------------------------------------
|
||||
CREATE INDEX messages_history ON public.messages USING btree (chat_id, created_at, id)
|
||||
|
||||
|
||||
=== 1. First page: limit=50, the app asks for 51 rows to know if there is a next page
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------
|
||||
Limit (actual time=0.013..0.125 rows=51 loops=1)
|
||||
Buffers: shared hit=55
|
||||
-> Index Scan using messages_history on messages (actual time=0.012..0.119 rows=51 loops=1)
|
||||
Index Cond: (chat_id = '88ae823e-42fe-42cd-b02e-4974b4bcbf0f'::uuid)
|
||||
Buffers: shared hit=55
|
||||
Planning:
|
||||
Buffers: shared hit=6
|
||||
Planning Time: 0.119 ms
|
||||
Execution Time: 0.141 ms
|
||||
|
||||
|
||||
=== 2. Page after the 10000th message by keyset cursor (this is what the app does)
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (actual time=0.011..0.030 rows=51 loops=1)
|
||||
Buffers: shared hit=6
|
||||
-> Index Scan using messages_history on messages (actual time=0.010..0.025 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = '88ae823e-42fe-42cd-b02e-4974b4bcbf0f'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 05:46:40+03'::timestamp with time zone, '1e03049f-75da-40e8-9821-2d439e107e51'::uuid)))
|
||||
Buffers: shared hit=6
|
||||
Planning Time: 0.124 ms
|
||||
Execution Time: 0.058 ms
|
||||
|
||||
|
||||
=== 2b. The same page exactly as the app sends it since lab4: with attachment_ids of every message
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (actual time=0.036..0.142 rows=51 loops=1)
|
||||
Buffers: shared hit=60
|
||||
-> Index Scan using messages_history on messages m (actual time=0.035..0.137 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = '88ae823e-42fe-42cd-b02e-4974b4bcbf0f'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 05:46:40+03'::timestamp with time zone, '1e03049f-75da-40e8-9821-2d439e107e51'::uuid)))
|
||||
Buffers: shared hit=60
|
||||
SubPlan 1
|
||||
-> Sort (actual time=0.002..0.002 rows=0 loops=51)
|
||||
Sort Key: a."position"
|
||||
Sort Method: quicksort Memory: 25kB
|
||||
Buffers: shared hit=54
|
||||
-> Bitmap Heap Scan on message_attachments a (actual time=0.001..0.001 rows=0 loops=51)
|
||||
Recheck Cond: (message_id = m.id)
|
||||
Buffers: shared hit=51
|
||||
-> Bitmap Index Scan on message_attachments_message_id_attachment_id_key (actual time=0.000..0.000 rows=0 loops=51)
|
||||
Index Cond: (message_id = m.id)
|
||||
Buffers: shared hit=51
|
||||
Planning:
|
||||
Buffers: shared hit=63
|
||||
Planning Time: 0.255 ms
|
||||
Execution Time: 0.202 ms
|
||||
|
||||
|
||||
=== 3. The same page with OFFSET 10000 (the app does NOT do this)
|
||||
QUERY PLAN
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Limit (actual time=2.823..2.840 rows=51 loops=1)
|
||||
Buffers: shared hit=311
|
||||
-> Index Scan using messages_history on messages (actual time=0.020..2.302 rows=10051 loops=1)
|
||||
Index Cond: (chat_id = '88ae823e-42fe-42cd-b02e-4974b4bcbf0f'::uuid)
|
||||
Buffers: shared hit=311
|
||||
Planning Time: 0.082 ms
|
||||
Execution Time: 2.859 ms
|
||||
|
||||
|
||||
=== 4. Query 2 without the index (index is dropped only inside this transaction)
|
||||
QUERY PLAN
|
||||
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (actual time=3.356..3.366 rows=51 loops=1)
|
||||
Buffers: shared hit=318
|
||||
-> Sort (actual time=3.354..3.359 rows=51 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: top-N heapsort Memory: 31kB
|
||||
Buffers: shared hit=318
|
||||
-> Seq Scan on messages (actual time=1.132..2.326 rows=5000 loops=1)
|
||||
Filter: ((chat_id = '88ae823e-42fe-42cd-b02e-4974b4bcbf0f'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 05:46:40+03'::timestamp with time zone, '1e03049f-75da-40e8-9821-2d439e107e51'::uuid)))
|
||||
Rows Removed by Filter: 18017
|
||||
Buffers: shared hit=318
|
||||
Planning:
|
||||
Buffers: shared hit=4
|
||||
Planning Time: 0.103 ms
|
||||
Execution Time: 3.385 ms
|
||||
|
||||
|
||||
=== ROLLBACK: test data removed, index is back
|
||||
explain_users_left
|
||||
--------------------
|
||||
0
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
# explain: EXPLAIN of the history page (full plans: explain-history.txt)
|
||||
# date: 2026-11-07 15:21:57, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/explain.py
|
||||
# exit code: 0, 0.9 s
|
||||
|
||||
=== Data volume
|
||||
=== History index
|
||||
=== 1. First page: limit=50, the app asks for 51 rows to know if there is a next page
|
||||
Buffers: shared hit=55
|
||||
-> Index Scan using messages_history on messages (actual time=0.012..0.119 rows=51 loops=1)
|
||||
Buffers: shared hit=55
|
||||
Buffers: shared hit=6
|
||||
Execution Time: 0.141 ms
|
||||
=== 2. Page after the 10000th message by keyset cursor (this is what the app does)
|
||||
Buffers: shared hit=6
|
||||
-> Index Scan using messages_history on messages (actual time=0.010..0.025 rows=51 loops=1)
|
||||
Buffers: shared hit=6
|
||||
Execution Time: 0.058 ms
|
||||
=== 2b. The same page exactly as the app sends it since lab4: with attachment_ids of every message
|
||||
Buffers: shared hit=60
|
||||
-> Index Scan using messages_history on messages m (actual time=0.035..0.137 rows=51 loops=1)
|
||||
Buffers: shared hit=60
|
||||
Buffers: shared hit=54
|
||||
-> Bitmap Heap Scan on message_attachments a (actual time=0.001..0.001 rows=0 loops=51)
|
||||
Buffers: shared hit=51
|
||||
-> Bitmap Index Scan on message_attachments_message_id_attachment_id_key (actual time=0.000..0.000 rows=0 loops=51)
|
||||
Buffers: shared hit=51
|
||||
Buffers: shared hit=63
|
||||
Execution Time: 0.202 ms
|
||||
=== 3. The same page with OFFSET 10000 (the app does NOT do this)
|
||||
Buffers: shared hit=311
|
||||
-> Index Scan using messages_history on messages (actual time=0.020..2.302 rows=10051 loops=1)
|
||||
Buffers: shared hit=311
|
||||
Execution Time: 2.859 ms
|
||||
=== 4. Query 2 without the index (index is dropped only inside this transaction)
|
||||
Buffers: shared hit=318
|
||||
Buffers: shared hit=318
|
||||
-> Seq Scan on messages (actual time=1.132..2.326 rows=5000 loops=1)
|
||||
Buffers: shared hit=318
|
||||
Buffers: shared hit=4
|
||||
Execution Time: 3.385 ms
|
||||
=== ROLLBACK: test data removed, index is back
|
||||
PASS: full plans saved to evidence/explain-history.txt
|
||||
@@ -0,0 +1,29 @@
|
||||
# failover: public failover test for every replica, file downloaded via the other one (make test-failover)
|
||||
# date: 2026-11-07 15:59:02, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/run_failover.py
|
||||
# exit code: 0, 40.8 s
|
||||
|
||||
hook: scripts/stop-one.sh; api replicas: ['api-1', 'api-2']
|
||||
=== run 1: api containers before
|
||||
api-1 api-1 Up (healthy)
|
||||
api-2 api-2 Up (healthy)
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 131, "failed_attempts": 0, "first_recovery_seconds": 3.82}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
api containers after
|
||||
api-1 api-1 Up (healthy)
|
||||
api-2 api-2 Exited (0)
|
||||
the hook stopped api-2 (the replica behind TARGET_INSTANCE_ID, mapped from its alias); other api containers kept running, postgres/redis/lb were not touched
|
||||
restored: docker start api-2 -> healthy and back in HAProxy
|
||||
=== run 2: api containers before
|
||||
api-1 api-1 Up (healthy)
|
||||
api-2 api-2 Up (healthy)
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 131, "failed_attempts": 0, "first_recovery_seconds": 3.721}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
api containers after
|
||||
api-1 api-1 Exited (0)
|
||||
api-2 api-2 Up (healthy)
|
||||
the hook stopped api-1 (the replica behind TARGET_INSTANCE_ID, mapped from its alias); other api containers kept running, postgres/redis/lb were not touched
|
||||
restored: docker start api-1 -> healthy and back in HAProxy
|
||||
PASS: public failover test passed 2 times; every api replica was stopped once and restored
|
||||
@@ -0,0 +1,29 @@
|
||||
# failures: Redis and PostgreSQL outages via the balancer
|
||||
# date: 2026-11-07 15:24:59, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_failures.py
|
||||
# exit code: 0, 33.8 s
|
||||
|
||||
stopping redis
|
||||
/health/live -> 200, /health/ready -> 503 (8 ms)
|
||||
valid token: GET /users/me -> 503 unavailable (7 ms), session cannot be checked
|
||||
unknown token -> 503, not 200: nobody is trusted without a check
|
||||
no token -> 401
|
||||
login -> 503: there is nowhere to store the session
|
||||
registration -> 201: it needs only PostgreSQL
|
||||
starting redis
|
||||
after start: the old token works, confirmed messages are in place
|
||||
PASS: Redis outage gives 503 and does not let anyone in without a session check
|
||||
killing redis with SIGKILL (docker compose kill redis): no graceful shutdown
|
||||
right after the crash: GET /users/me -> 503
|
||||
starting redis
|
||||
after start: the session issued before the crash still works (AOF, appendfsync always)
|
||||
PASS: sessions survive a Redis crash, not only a clean restart
|
||||
stopping postgres
|
||||
/health/live -> 200, /health/ready -> 503 (1007 ms)
|
||||
valid token: users/me, chats, history, new message -> 503 unavailable, no details
|
||||
no token -> 401, unknown token -> 401: anonymous users are not let in
|
||||
login -> 503, registration -> 503
|
||||
starting postgres
|
||||
after start: the old token works, confirmed messages are in place
|
||||
PASS: PostgreSQL outage gives limited 503 errors and keeps anonymous users out
|
||||
3 passed, 0 failed
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
||||
# idempotency: Idempotency-Key, parallel same key via replicas
|
||||
# date: 2026-11-07 15:21:41, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_idempotency.py
|
||||
# exit code: 0, 3.8 s
|
||||
|
||||
first -> 201; same JSON written differently -> 201; plain retry -> 201
|
||||
PASS: a retry with the same key returns the original 201 and message, no duplicate
|
||||
20 parallel POSTs with one key: statuses {201: 20}, replicas {'9b3c6b6625a9': 10, '4ec098d7198a': 10}, different bodies in answers: 1, messages in history: 1
|
||||
PASS: parallel requests with one key through different replicas create exactly one message
|
||||
20 parallel POSTs, one key, two different bodies: {('body A', 201): 10, ('body B', 409): 10}; saved: ['body A']
|
||||
PASS: the first body wins, the same body gets 201, the other body gets 409
|
||||
one key: alice in chat 1, bob in chat 1, alice in chat 2 -> 3 messages
|
||||
PASS: the key is scoped to the current user and chat; another body with a used key -> 409
|
||||
missing, empty, 129 chars, space, '/', non-ASCII, '"', '+' -> 400; 128 chars of A-Z a-z 0-9 . _ : - -> 201
|
||||
PASS: Idempotency-Key is required and checked: [A-Za-z0-9._:-]{1,128}
|
||||
key used by a 400 and by a 404 first, then valid request -> 201
|
||||
PASS: rejected requests (400, 404) do not store a result for the key
|
||||
same key and body by an outsider -> 404; by alice after logout -> 401
|
||||
PASS: a retry checks the session and chat access again, the saved answer is not leaked
|
||||
POST sent, connection closed without reading the answer; retry -> 201; messages: 1
|
||||
PASS: an unconfirmed POST can be safely retried with the same key
|
||||
8 passed, 0 failed
|
||||
@@ -0,0 +1,8 @@
|
||||
# jobs-concurrency: lab5: WORKER_CONCURRENCY consumers, prefetch 1, bounded processing
|
||||
# date: 2026-11-07 15:19:47, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_jobs.py concurrency
|
||||
# exit code: 0, 6.2 s
|
||||
|
||||
--- concurrency: Ограниченная конкуренция: WORKER_CONCURRENCY потребителей с prefetch=1; одновременно processing <= 2.
|
||||
2 consumers, prefetch_count 1, manual ack; 8 queued 3000x2000 JPEG drained in 3.0 s after worker start, peak processing 2 of 8 (17 samples)
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,15 @@
|
||||
# jobs-crash: lab5: worker crash after S3 PUT / after COMMIT before ack, staging cleanup, frozen worker lease
|
||||
# date: 2026-11-07 15:16:04, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_jobs.py crash-after-put crash-after-commit staging lease
|
||||
# exit code: 0, 133.0 s
|
||||
|
||||
--- crash-after-put: Worker падает после записи объектов в S3, до COMMIT/ack: повтор завершает тот же результат.
|
||||
worker killed after S3 PUT (before COMMIT and ack): redelivery saw a live lease (no-op), lease expired after 15 s, attempt 2 rewrote the same keys -> one set; events ['created', 'claimed', 'duplicate_ignored', 'lease_expired', 'claimed', 'ready']
|
||||
--- crash-after-commit: Worker падает после COMMIT результата, до ack: повторная доставка ready-задачи — no-op с ack.
|
||||
worker killed after COMMIT, before ack: broker redelivered, worker acked as no-op (1:duplicate_ignored:status=ready); queue empty (0 ready, 0 unacked)
|
||||
--- staging: Janitor доделывает очистку staging, если worker упал до неё (после crash-after-commit).
|
||||
staging source still present after the crash (worker died before cleanup); waiting 60 s window
|
||||
janitor removed the staging source of the ready attachment (this pass); source_key NULL, object gone
|
||||
--- lease: Зависший worker: аренда не продлевается -> dispatcher возвращает job -> другой поток завершает;
|
||||
frozen attempt 1 stopped renewing; lease expired, recovered by dispatcher, attempt 2 ready after 17 s; frozen attempt woke up -> stale_result_rejected; events ['created', 'claimed', 'lease_expired', 'claimed', 'ready', 'stale_result_rejected']
|
||||
4 passed, 0 failed
|
||||
@@ -0,0 +1,13 @@
|
||||
# jobs-janitor-replay: lab5: janitor does not delete objects re-written by replay (review fix)
|
||||
# date: 2026-11-07 15:19:41, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_janitor_replay.py
|
||||
# exit code: 0, 172.4 s
|
||||
|
||||
race-replayable: failed/retry_exhausted after a crash post-PUT; leftover objects ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
|
||||
race-terminal: failed/retry_exhausted after a crash post-PUT; leftover objects ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
|
||||
waiting 89 s until the leftovers are older than grace (120 s)
|
||||
janitor pass over the bucket: did not try to delete any object of the replayable failed attachment
|
||||
ops replay -> job bdf4dc61-b38c-4cf8-9a5a-0a5bbf7a7947 ready
|
||||
after the janitor pass: original/thumbnail/crop/optimized -> 200, 4 objects in S3; janitor report: orphans 1, deleted 1
|
||||
retention expired (STAGING_RETENTION_SECONDS=1 for this pass): staging source removed, leftovers of the failed attachment swept; replay refused: "source file is no longer in staging (retention expired)"
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,11 @@
|
||||
# jobs-limits: lab5: worker limits - bytes, pixels, memory (RLIMIT_AS), time (JOB_TIMEOUT_SECONDS)
|
||||
# date: 2026-11-07 15:13:13, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_jobs.py limits
|
||||
# exit code: 0, 66.6 s
|
||||
|
||||
--- limits: Лимиты: bytes и пиксели на API; память/пиксели/время процесса обработки на worker.
|
||||
10 MiB + 8 bytes -> 413 before any job is created
|
||||
imaging.py on 8000x5000 PNG: exit 0, peak RSS 223.8 MiB (RLIMIT_AS 512 MiB); same file with MAX_IMAGE_PIXELS=10M -> exit 4 (image_too_large)
|
||||
memory bomb in the imaging process -> failed/resource_limit after attempt 1; worker itself survived
|
||||
imaging hang -> killed after 60 s (processing_timeout, temporary), lease renewed meanwhile (no lease_expired), attempt 2 ready after 62 s
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,9 @@
|
||||
# jobs-outbox: lab5: dispatcher crash between COMMIT and publish / after confirm
|
||||
# date: 2026-11-07 15:13:51, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_jobs.py outbox-crash
|
||||
# exit code: 0, 6.5 s
|
||||
|
||||
--- outbox-crash: Разрыв COMMIT/publish: dispatcher падает после COMMIT задания до publish и после confirm до отметки.
|
||||
dispatcher killed between COMMIT and publish; restarted by policy, outbox re-published -> job a39e310d-6e0e-425c-baa6-33db9da3e290 ready, attempt 1, no manual action
|
||||
dispatcher killed after publisher confirm, before marking outbox -> message published twice; worker: ['created', 'claimed', 'ready', 'duplicate_ignored'] -> one result set
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,16 @@
|
||||
# jobs-recovery: lab5: worker down -> 202 -> restart api+broker -> ready; broker down -> outbox waits
|
||||
# date: 2026-11-07 15:13:44, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_jobs.py worker-down broker-down
|
||||
# exit code: 0, 30.6 s
|
||||
|
||||
--- worker-down: Защита п.2-3: worker остановлен -> 202 -> сообщение с вложением -> рестарт API+broker -> worker -> ready.
|
||||
worker stopped
|
||||
upload while worker is down -> 202 queued, attachment 6f25aa5c-c235-40f8-bf9f-520404807cab
|
||||
message with attachment 201, content 409, other messages 201; job 182a3066-efb5-453d-8d2a-c906da4ac027 published, queue messages/unacked = (1, 1)
|
||||
rabbitmq and api restarted with volumes; queue still holds 1 message(s); status queued
|
||||
worker started -> same job 182a3066-efb5-453d-8d2a-c906da4ac027 ready, thumbnail downloadable; staging object deleted
|
||||
--- broker-down: Брокер недоступен: API принимает (outbox), dispatcher копит и публикует после восстановления.
|
||||
rabbitmq stopped
|
||||
upload -> 202 and /health/ready 200 without broker; outbox row pending for job 4d076cc6-0e4e-4ec7-ba03-10b557817907
|
||||
rabbitmq started -> dispatcher published the pending row -> ready
|
||||
2 passed, 0 failed
|
||||
@@ -0,0 +1,15 @@
|
||||
# jobs-retry: lab5: backoff+jitter, retry_exhausted, replay, permanent errors, DLQ
|
||||
# date: 2026-11-07 15:16:49, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_jobs.py retry exhausted-replay permanent dlq
|
||||
# exit code: 0, 45.1 s
|
||||
|
||||
--- retry: Временные ошибки S3: backoff с jitter, затем ready; задержки видны в журнале.
|
||||
2 x storage_unavailable -> retries after 1.20 s and 2.30 s (equal jitter: 1..2 s, 2..4 s), attempt 3 ready
|
||||
--- exhausted-replay: Исчерпание попыток -> failed/retry_exhausted, реестр failed, явный replay; replay ready — отказ.
|
||||
5 temporary errors -> failed/retry_exhausted (public error_code), content 409, attach 409, listed by ops.py failed (replayable)
|
||||
ops replay -> same job_id 44cac72b-36f8-411d-9b08-cb90fd27bbb9 attempt 6 ready; second replay refused: "job is ready, replay is only for failed jobs"
|
||||
--- permanent: Постоянная ошибка (битое изображение в worker) -> failed сразу, без повторов.
|
||||
invalid image in the worker -> failed/invalid_image at attempt 1, no retry (permanent error)
|
||||
--- dlq: Невалидные сообщения и сообщения о неизвестной job -> DLQ; dlq-replay их не исполняет.
|
||||
schema-invalid message and unknown job_id -> reject -> DLQ (2 message(s)); dlq-replay kept them: ['invalid message is kept for analysis', 'unknown job']
|
||||
4 passed, 0 failed
|
||||
@@ -0,0 +1,14 @@
|
||||
# jobs-variants: lab5: thumbnail/crop/optimized, EXIF orientation, alpha, no upscale, metadata stripped
|
||||
# date: 2026-11-07 15:12:07, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_jobs.py variants
|
||||
# exit code: 0, 9.6 s
|
||||
|
||||
--- variants: thumbnail/crop/optimized по контракту, EXIF orientation, alpha -> белый, без увеличения, без метаданных.
|
||||
thumb320: thumbnail 256x160, crop 128x128, optimized 320x200; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
|
||||
exif6: thumbnail 192x256, crop 128x128, optimized 300x400; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
|
||||
alpha: thumbnail 256x170, crop 128x128, optimized 300x200; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
|
||||
tiny: thumbnail 40x30, crop 128x128, optimized 40x30; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
|
||||
large: thumbnail 256x170, crop 128x128, optimized 1280x853; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
|
||||
strip: thumbnail 256x1, crop 128x128, optimized 1280x1; original byte-identical; EXIF/XMP in variants: 0; S3 keys ['v1/crop.jpg', 'v1/optimized.webp', 'v1/original', 'v1/thumbnail.jpg']
|
||||
unknown variant name -> 400; variants carry their own size/sha256, original fields describe the upload
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,26 @@
|
||||
# lab7-security: lab7: HTTPS only, headers, outsider ACL, logout, shared login rate limit, size limits, Argon2id, rehash, no credential leaks
|
||||
# date: 2026-11-07 15:07:42, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_lab7_security.py
|
||||
# exit code: 0, 3.8 s
|
||||
|
||||
port 8080: something else answers locally, not the API
|
||||
empty trust store: rejected by certificate verification (unable to get local issuer certificate)
|
||||
foreign CA: rejected by certificate verification (unable to get local issuer certificate)
|
||||
wrong host name: rejected by certificate verification (Hostname mismatch, certificate is not valid for 'evil.example'.)
|
||||
PASS: only HTTPS on 8443; untrusted CA and wrong host name fail certificate verification
|
||||
HSTS, nosniff, no Server header; X-Instance-Id is an opaque alias (83d68b5bf960)
|
||||
PASS: security headers
|
||||
outsider: 6 attempts on a foreign chat/attachment -> 404 (existence not revealed); X-User-Id of the victim is ignored
|
||||
PASS: ACL — outsider reads/writes nothing, cannot attach a foreign file
|
||||
PASS: logout -> the same token is 401 on every replica (session deleted in shared Redis)
|
||||
codes [401, 401, 401, 401, 401, 401, 401, 401, 401, 429, 429, 429, 429, 429]; answered by replicas ['83d68b5bf960', 'd7b47c3fc484']; Retry-After 60 s
|
||||
PASS: login rate limit is shared by all replicas (Redis), 429 + Retry-After, before Argon2id
|
||||
JSON > 64 KiB -> 413 (with Content-Length and chunked); upload Content-Length 50 MB -> 413 at the LB
|
||||
PASS: request size limits
|
||||
stored: $argon2id$v=19$m=32768,t=2,p=1$<16-byte salt>$<hash>; two users with the same password have different hashes
|
||||
PASS: Argon2id with salt and parameters in the stored string
|
||||
legacy hash m=12288,t=3 -> after successful login m=32768,t=2,p=1; the new hash still verifies
|
||||
PASS: old password hash is upgraded on successful login
|
||||
errors do not echo credentials; Redis stores session:<SHA-256(token)> only; DB stores only the hash
|
||||
PASS: credentials and session tokens are not revealed
|
||||
9 passed, 0 failed
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"container_logs": {
|
||||
"password": 0,
|
||||
"token": 0,
|
||||
"basic_b64": 0
|
||||
},
|
||||
"container_logs_bearer_or_basic_header": 0,
|
||||
"loki": "unavailable: URLError",
|
||||
"tempo": {
|
||||
"traces_fetched": 0,
|
||||
"password": 0,
|
||||
"token": 0,
|
||||
"basic_b64": 0
|
||||
},
|
||||
"prometheus_labels": "unavailable: URLError",
|
||||
"otlp_payloads": {
|
||||
"password": 0,
|
||||
"token": 0,
|
||||
"basic_b64": 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
# leak-check: lab7: password/token/Authorization absent in container logs, Loki, Tempo traces, Prometheus labels
|
||||
# date: 2026-11-07 15:08:02, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/leak_check.py
|
||||
# exit code: 0, 20.6 s
|
||||
|
||||
{"container_logs": {"password": 0, "token": 0, "basic_b64": 0}, "container_logs_bearer_or_basic_header": 0, "loki": "unavailable: URLError", "tempo": {"traces_fetched": 0, "password": 0, "token": 0, "basic_b64": 0}, "prometheus_labels": "unavailable: URLError", "otlp_payloads": {"password": 0, "token": 0, "basic_b64": 0}}
|
||||
searched: container logs, Tempo, raw OTLP payloads (741 KiB); traces fetched: 0
|
||||
PASS: no password, session token or Authorization value in logs or telemetry
|
||||
@@ -0,0 +1,749 @@
|
||||
[
|
||||
{
|
||||
"service": "api",
|
||||
"area": "postgres",
|
||||
"action": "SELECT users",
|
||||
"expect": "allowed",
|
||||
"observed": "allowed",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "postgres",
|
||||
"action": "INSERT outbox (enqueue)",
|
||||
"expect": "allowed",
|
||||
"observed": "allowed",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "postgres",
|
||||
"action": "UPDATE users.username",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "permission denied for table users"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "postgres",
|
||||
"action": "SELECT outbox",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "permission denied for table outbox"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "postgres",
|
||||
"action": "DELETE messages",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "permission denied for table messages"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "postgres",
|
||||
"action": "DROP TABLE messages",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "must be owner of table messages"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "postgres",
|
||||
"action": "CREATE TABLE",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "permission denied for schema public"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "postgres",
|
||||
"action": "ALTER ROLE (escalate)",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "permission denied to alter role"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "s3",
|
||||
"action": "PUT staging/",
|
||||
"expect": "allowed",
|
||||
"observed": "allowed",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "s3",
|
||||
"action": "DELETE staging/ (rollback)",
|
||||
"expect": "allowed",
|
||||
"observed": "allowed",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "s3",
|
||||
"action": "PUT attachments/ (worker's prefix)",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "s3",
|
||||
"action": "GET staging/ (upload sources)",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "s3",
|
||||
"action": "LIST bucket",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "s3",
|
||||
"action": "DELETE attachments/",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "s3",
|
||||
"action": "CREATE bucket",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "openbao",
|
||||
"action": "own secret keys (no admin credentials)",
|
||||
"expect": "ok",
|
||||
"observed": "ok",
|
||||
"pass": true,
|
||||
"detail": "['db_password', 'redis_password', 's3_access_key_id', 's3_secret_access_key']"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/worker",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/worker -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/dispatcher",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/dispatcher -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/janitor",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/janitor -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/migrate",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/migrate -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/s3-init",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/s3-init -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "openbao",
|
||||
"action": "write own secret",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao POST /v1/messenger/data/api -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "openbao",
|
||||
"action": "write ACL policy",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao PUT /v1/sys/policies/acl/probe-evil -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "openbao",
|
||||
"action": "list auth methods",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/sys/auth -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "openbao",
|
||||
"action": "create token",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao POST /v1/auth/token/create -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "redis",
|
||||
"action": "GET session:*",
|
||||
"expect": "allowed",
|
||||
"observed": "allowed",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "redis",
|
||||
"action": "GET other key",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "this user has no permissions to access one of the keys used as arguments"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "redis",
|
||||
"action": "KEYS *",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "this user has no permissions to run the 'keys' command"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "redis",
|
||||
"action": "FLUSHALL",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "this user has no permissions to run the 'flushall' command"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "redis",
|
||||
"action": "CONFIG GET",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "this user has no permissions to run the 'config|get' command"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "redis",
|
||||
"action": "ACL LIST",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "this user has no permissions to run the 'acl|list' command"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "redis",
|
||||
"action": "SUBSCRIBE / PUBLISH",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "this user has no permissions to run the 'publish' command"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "postgres",
|
||||
"action": "SELECT attachments",
|
||||
"expect": "allowed",
|
||||
"observed": "allowed",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "postgres",
|
||||
"action": "SELECT users (passwords)",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "permission denied for table users"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "postgres",
|
||||
"action": "SELECT messages",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "permission denied for table messages"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "postgres",
|
||||
"action": "DELETE attachments",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "permission denied for table attachments"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "postgres",
|
||||
"action": "UPDATE outbox",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "permission denied for table outbox"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "s3",
|
||||
"action": "PUT attachments/",
|
||||
"expect": "allowed",
|
||||
"observed": "allowed",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "s3",
|
||||
"action": "LIST attachments/",
|
||||
"expect": "allowed",
|
||||
"observed": "allowed",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "s3",
|
||||
"action": "LIST bucket root",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "s3",
|
||||
"action": "PUT outside known prefixes",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "s3",
|
||||
"action": "CREATE bucket",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "openbao",
|
||||
"action": "own secret keys (no admin credentials)",
|
||||
"expect": "ok",
|
||||
"observed": "ok",
|
||||
"pass": true,
|
||||
"detail": "['db_password', 's3_access_key_id', 's3_secret_access_key']"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/api",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/api -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/dispatcher",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/dispatcher -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/janitor",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/janitor -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/migrate",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/migrate -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/s3-init",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/s3-init -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "openbao",
|
||||
"action": "write own secret",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao POST /v1/messenger/data/worker -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "openbao",
|
||||
"action": "write ACL policy",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao PUT /v1/sys/policies/acl/probe-evil -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "openbao",
|
||||
"action": "list auth methods",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/sys/auth -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "worker",
|
||||
"area": "openbao",
|
||||
"action": "create token",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao POST /v1/auth/token/create -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "dispatcher",
|
||||
"area": "postgres",
|
||||
"action": "SELECT outbox",
|
||||
"expect": "allowed",
|
||||
"observed": "allowed",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"service": "dispatcher",
|
||||
"area": "postgres",
|
||||
"action": "SELECT users",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "permission denied for table users"
|
||||
},
|
||||
{
|
||||
"service": "dispatcher",
|
||||
"area": "postgres",
|
||||
"action": "SELECT messages",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "permission denied for table messages"
|
||||
},
|
||||
{
|
||||
"service": "dispatcher",
|
||||
"area": "postgres",
|
||||
"action": "DELETE attachments",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "permission denied for table attachments"
|
||||
},
|
||||
{
|
||||
"service": "dispatcher",
|
||||
"area": "openbao",
|
||||
"action": "own secret keys (no admin credentials)",
|
||||
"expect": "ok",
|
||||
"observed": "ok",
|
||||
"pass": true,
|
||||
"detail": "['db_password']"
|
||||
},
|
||||
{
|
||||
"service": "dispatcher",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/api",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/api -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "dispatcher",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/worker",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/worker -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "dispatcher",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/janitor",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/janitor -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "dispatcher",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/migrate",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/migrate -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "dispatcher",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/s3-init",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/s3-init -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "dispatcher",
|
||||
"area": "openbao",
|
||||
"action": "write own secret",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao POST /v1/messenger/data/dispatcher -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "dispatcher",
|
||||
"area": "openbao",
|
||||
"action": "write ACL policy",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao PUT /v1/sys/policies/acl/probe-evil -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "dispatcher",
|
||||
"area": "openbao",
|
||||
"action": "list auth methods",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/sys/auth -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "dispatcher",
|
||||
"area": "openbao",
|
||||
"action": "create token",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao POST /v1/auth/token/create -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "postgres",
|
||||
"action": "SELECT attachments",
|
||||
"expect": "allowed",
|
||||
"observed": "allowed",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "postgres",
|
||||
"action": "SELECT users",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "permission denied for table users"
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "postgres",
|
||||
"action": "INSERT messages",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "permission denied for table messages"
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "postgres",
|
||||
"action": "DELETE chats",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "permission denied for table chats"
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "s3",
|
||||
"action": "LIST bucket",
|
||||
"expect": "allowed",
|
||||
"observed": "allowed",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "s3",
|
||||
"action": "GET object content",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "s3",
|
||||
"action": "CREATE bucket",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "AccessDenied"
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "openbao",
|
||||
"action": "own secret keys (no admin credentials)",
|
||||
"expect": "ok",
|
||||
"observed": "ok",
|
||||
"pass": true,
|
||||
"detail": "['db_password', 's3_access_key_id', 's3_secret_access_key']"
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/api",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/api -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/worker",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/worker -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/dispatcher",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/dispatcher -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/migrate",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/migrate -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "openbao",
|
||||
"action": "read messenger/s3-init",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/messenger/data/s3-init -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "openbao",
|
||||
"action": "write own secret",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao POST /v1/messenger/data/janitor -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "openbao",
|
||||
"action": "write ACL policy",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao PUT /v1/sys/policies/acl/probe-evil -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "openbao",
|
||||
"action": "list auth methods",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao GET /v1/sys/auth -> HTTP 403"
|
||||
},
|
||||
{
|
||||
"service": "janitor",
|
||||
"area": "openbao",
|
||||
"action": "create token",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "OpenBao POST /v1/auth/token/create -> HTTP 403"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,115 @@
|
||||
# least-privilege: lab7: each service identity vs PostgreSQL grants, S3 prefixes, OpenBao policies, Redis ACL
|
||||
# date: 2026-11-07 15:07:38, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_least_privilege.py
|
||||
# exit code: 0, 2.7 s
|
||||
|
||||
|
||||
api -> postgres
|
||||
PASS SELECT users expect allowed observed allowed
|
||||
PASS INSERT outbox (enqueue) expect allowed observed allowed
|
||||
PASS UPDATE users.username expect denied observed denied
|
||||
PASS SELECT outbox expect denied observed denied
|
||||
PASS DELETE messages expect denied observed denied
|
||||
PASS DROP TABLE messages expect denied observed denied
|
||||
PASS CREATE TABLE expect denied observed denied
|
||||
PASS ALTER ROLE (escalate) expect denied observed denied
|
||||
|
||||
api -> s3
|
||||
PASS PUT staging/ expect allowed observed allowed
|
||||
PASS DELETE staging/ (rollback) expect allowed observed allowed
|
||||
PASS PUT attachments/ (worker's prefix) expect denied observed denied
|
||||
PASS GET staging/ (upload sources) expect denied observed denied
|
||||
PASS LIST bucket expect denied observed denied
|
||||
PASS DELETE attachments/ expect denied observed denied
|
||||
PASS CREATE bucket expect denied observed denied
|
||||
|
||||
api -> openbao
|
||||
PASS own secret keys (no admin credentials) expect ok observed ok
|
||||
PASS read messenger/worker expect denied observed denied
|
||||
PASS read messenger/dispatcher expect denied observed denied
|
||||
PASS read messenger/janitor expect denied observed denied
|
||||
PASS read messenger/migrate expect denied observed denied
|
||||
PASS read messenger/s3-init expect denied observed denied
|
||||
PASS write own secret expect denied observed denied
|
||||
PASS write ACL policy expect denied observed denied
|
||||
PASS list auth methods expect denied observed denied
|
||||
PASS create token expect denied observed denied
|
||||
|
||||
api -> redis
|
||||
PASS GET session:* expect allowed observed allowed
|
||||
PASS GET other key expect denied observed denied
|
||||
PASS KEYS * expect denied observed denied
|
||||
PASS FLUSHALL expect denied observed denied
|
||||
PASS CONFIG GET expect denied observed denied
|
||||
PASS ACL LIST expect denied observed denied
|
||||
PASS SUBSCRIBE / PUBLISH expect denied observed denied
|
||||
|
||||
worker -> postgres
|
||||
PASS SELECT attachments expect allowed observed allowed
|
||||
PASS SELECT users (passwords) expect denied observed denied
|
||||
PASS SELECT messages expect denied observed denied
|
||||
PASS DELETE attachments expect denied observed denied
|
||||
PASS UPDATE outbox expect denied observed denied
|
||||
|
||||
worker -> s3
|
||||
PASS PUT attachments/ expect allowed observed allowed
|
||||
PASS LIST attachments/ expect allowed observed allowed
|
||||
PASS LIST bucket root expect denied observed denied
|
||||
PASS PUT outside known prefixes expect denied observed denied
|
||||
PASS CREATE bucket expect denied observed denied
|
||||
|
||||
worker -> openbao
|
||||
PASS own secret keys (no admin credentials) expect ok observed ok
|
||||
PASS read messenger/api expect denied observed denied
|
||||
PASS read messenger/dispatcher expect denied observed denied
|
||||
PASS read messenger/janitor expect denied observed denied
|
||||
PASS read messenger/migrate expect denied observed denied
|
||||
PASS read messenger/s3-init expect denied observed denied
|
||||
PASS write own secret expect denied observed denied
|
||||
PASS write ACL policy expect denied observed denied
|
||||
PASS list auth methods expect denied observed denied
|
||||
PASS create token expect denied observed denied
|
||||
|
||||
dispatcher -> postgres
|
||||
PASS SELECT outbox expect allowed observed allowed
|
||||
PASS SELECT users expect denied observed denied
|
||||
PASS SELECT messages expect denied observed denied
|
||||
PASS DELETE attachments expect denied observed denied
|
||||
|
||||
dispatcher -> openbao
|
||||
PASS own secret keys (no admin credentials) expect ok observed ok
|
||||
PASS read messenger/api expect denied observed denied
|
||||
PASS read messenger/worker expect denied observed denied
|
||||
PASS read messenger/janitor expect denied observed denied
|
||||
PASS read messenger/migrate expect denied observed denied
|
||||
PASS read messenger/s3-init expect denied observed denied
|
||||
PASS write own secret expect denied observed denied
|
||||
PASS write ACL policy expect denied observed denied
|
||||
PASS list auth methods expect denied observed denied
|
||||
PASS create token expect denied observed denied
|
||||
|
||||
janitor -> postgres
|
||||
PASS SELECT attachments expect allowed observed allowed
|
||||
PASS SELECT users expect denied observed denied
|
||||
PASS INSERT messages expect denied observed denied
|
||||
PASS DELETE chats expect denied observed denied
|
||||
|
||||
janitor -> s3
|
||||
PASS LIST bucket expect allowed observed allowed
|
||||
PASS GET object content expect denied observed denied
|
||||
PASS CREATE bucket expect denied observed denied
|
||||
|
||||
janitor -> openbao
|
||||
PASS own secret keys (no admin credentials) expect ok observed ok
|
||||
PASS read messenger/api expect denied observed denied
|
||||
PASS read messenger/worker expect denied observed denied
|
||||
PASS read messenger/dispatcher expect denied observed denied
|
||||
PASS read messenger/migrate expect denied observed denied
|
||||
PASS read messenger/s3-init expect denied observed denied
|
||||
PASS write own secret expect denied observed denied
|
||||
PASS write ACL policy expect denied observed denied
|
||||
PASS list auth methods expect denied observed denied
|
||||
PASS create token expect denied observed denied
|
||||
|
||||
83 checks, 0 failed; saved to evidence/least-privilege.json
|
||||
PASS: every service identity can do its job and nothing else that was probed
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"old_serial": "7867bb9789172458",
|
||||
"new_serial": "aed4162e0d6ff182",
|
||||
"probe": {
|
||||
"valid LB identity (CN=lb)": "http_200",
|
||||
"foreign CA, CN=lb": "connection_closed_after_handshake",
|
||||
"our CA, expired, CN=lb": "connection_closed_after_handshake",
|
||||
"previous (rotated, revoked) LB leaf": "connection_closed_after_handshake"
|
||||
},
|
||||
"api_events_after_revoke": {
|
||||
"tls.crl_loaded": 2,
|
||||
"tls.revoked_connections_closed": 2,
|
||||
"tls.client_rejected": 4
|
||||
},
|
||||
"load": {
|
||||
"seconds": 21.3,
|
||||
"codes": {
|
||||
"me:200": 265,
|
||||
"send:201": 265,
|
||||
"login:201": 10
|
||||
},
|
||||
"errors_5xx_or_conn": 0,
|
||||
"errors": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
# lifecycle-rotate-leaf: lab7: LB leaf rotated (HAProxy reload), old leaf revoked via CRL, rejected by API
|
||||
# date: 2026-11-07 15:08:49, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/lifecycle.py rotate-leaf
|
||||
# exit code: 0, 21.8 s
|
||||
|
||||
--- rotate-leaf: клиентский сертификат LB (CN=lb)
|
||||
{"old_serial": "7867bb9789172458", "new_serial": "aed4162e0d6ff182", "probe": {"valid LB identity (CN=lb)": "http_200", "foreign CA, CN=lb": "connection_closed_after_handshake", "our CA, expired, CN=lb": "connection_closed_after_handshake", "previous (rotated, revoked) LB leaf": "connection_closed_after_handshake"}, "api_events_after_revoke": {"tls.crl_loaded": 2, "tls.revoked_connections_closed": 2, "tls.client_rejected": 4}, "load": {"seconds": 21.3, "codes": {"me:200": 265, "send:201": 265, "login:201": 10}, "errors_5xx_or_conn": 0, "errors": []}}
|
||||
PASS: LB leaf rotated without rebuild/restart; old leaf revoked by CRL and rejected; no errors
|
||||
saved /home/claude/work/mtusi2026lab7/evidence/native-sandbox/lifecycle-rotate-leaf.json
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"kv_version": [
|
||||
1,
|
||||
2
|
||||
],
|
||||
"replicas": 2,
|
||||
"active_passwords_during_overlap": 2,
|
||||
"all_replicas_picked_up_after_s": 4.2,
|
||||
"active_password_hashes_after": 1,
|
||||
"new_password_hash_matches": true,
|
||||
"load": {
|
||||
"seconds": 17.2,
|
||||
"codes": {
|
||||
"me:200": 201,
|
||||
"send:201": 201,
|
||||
"login:201": 8
|
||||
},
|
||||
"errors_5xx_or_conn": 0,
|
||||
"errors": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
# lifecycle-rotate-secret: lab7: Redis password of api rotated via OpenBao under load, old one revoked
|
||||
# date: 2026-11-07 15:08:27, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/lifecycle.py rotate-secret
|
||||
# exit code: 0, 17.5 s
|
||||
|
||||
--- rotate-secret: пароль Redis ACL-пользователя api
|
||||
{"kv_version": [1, 2], "replicas": 2, "active_passwords_during_overlap": 2, "all_replicas_picked_up_after_s": 4.2, "active_password_hashes_after": 1, "new_password_hash_matches": true, "load": {"seconds": 17.2, "codes": {"me:200": 201, "send:201": 201, "login:201": 8}, "errors_5xx_or_conn": 0, "errors": []}}
|
||||
PASS: Redis password rotated via OpenBao without restarts; old password revoked; no errors
|
||||
saved /home/claude/work/mtusi2026lab7/evidence/native-sandbox/lifecycle-rotate-secret.json
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"sealed_seconds": 73.7,
|
||||
"restarted_replica_health_while_sealed": "unhealthy",
|
||||
"replicas_answering_while_sealed": 1,
|
||||
"restarted_replica_ready_after_unseal_s": 3.2,
|
||||
"api_events": {
|
||||
"secrets.refresh_failed": 25,
|
||||
"secrets.waiting": 8,
|
||||
"secrets.login": 2
|
||||
},
|
||||
"load": {
|
||||
"seconds": 85.2,
|
||||
"codes": {
|
||||
"me:200": 1108,
|
||||
"send:201": 1108,
|
||||
"login:201": 41
|
||||
},
|
||||
"errors_5xx_or_conn": 0,
|
||||
"errors": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
# lifecycle-sealed: lab7: sealed OpenBao: running replicas serve, restarted replica not ready until unseal
|
||||
# date: 2026-11-07 15:11:57, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/lifecycle.py sealed
|
||||
# exit code: 0, 85.6 s
|
||||
|
||||
--- sealed: OpenBao запечатан
|
||||
{"sealed_seconds": 73.7, "restarted_replica_health_while_sealed": "unhealthy", "replicas_answering_while_sealed": 1, "restarted_replica_ready_after_unseal_s": 3.2, "api_events": {"secrets.refresh_failed": 25, "secrets.waiting": 8, "secrets.login": 2}, "load": {"seconds": 85.2, "codes": {"me:200": 1108, "send:201": 1108, "login:201": 41}, "errors_5xx_or_conn": 0, "errors": []}}
|
||||
PASS: sealed OpenBao -> running replicas keep serving from memory, a restarted replica stays not ready (fail closed) until unseal
|
||||
saved /home/claude/work/mtusi2026lab7/evidence/native-sandbox/lifecycle-sealed.json
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"role_ttl": "20s / max 40s",
|
||||
"observed_seconds": 100,
|
||||
"api_events": {
|
||||
"secrets.refresh_failed": 2,
|
||||
"secrets.login": 6,
|
||||
"secrets.renewed": 16
|
||||
},
|
||||
"load": {
|
||||
"seconds": 102.1,
|
||||
"codes": {
|
||||
"me:200": 1302,
|
||||
"send:201": 1302,
|
||||
"login:201": 49
|
||||
},
|
||||
"errors_5xx_or_conn": 0,
|
||||
"errors": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
# lifecycle-token-expiry: lab7: OpenBao token TTL 20 s / max 40 s + revoke: services re-login with their cert
|
||||
# date: 2026-11-07 15:10:32, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/lifecycle.py token-expiry
|
||||
# exit code: 0, 102.6 s
|
||||
|
||||
--- token-expiry: короткий TTL токенов OpenBao роли api
|
||||
{"role_ttl": "20s / max 40s", "observed_seconds": 100, "api_events": {"secrets.refresh_failed": 2, "secrets.login": 6, "secrets.renewed": 16}, "load": {"seconds": 102.1, "codes": {"me:200": 1302, "send:201": 1302, "login:201": 49}, "errors_5xx_or_conn": 0, "errors": []}}
|
||||
PASS: expired/revoked tokens -> services re-login with their certificate; requests unaffected
|
||||
saved /home/claude/work/mtusi2026lab7/evidence/native-sandbox/lifecycle-token-expiry.json
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"lab": 7,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 30.0,
|
||||
"elapsed_seconds": 30.028,
|
||||
"concurrency": 4,
|
||||
"successful_requests": 4538,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 151.124,
|
||||
"successful_latency_ms": {
|
||||
"p50": 24.062,
|
||||
"p95": 42.691,
|
||||
"p99": 84.746
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
# load: public load generator, 30 s, concurrency 4
|
||||
# date: 2026-11-07 15:24:25, commit: 5bfc53a + uncommitted changes
|
||||
# command: python tests/load.py --base-url https://localhost:8443 --ca-file /home/claude/work/mtusi2026lab7/secrets/pki/public/ca.crt --duration 30 --concurrency 4 --output evidence/load.json
|
||||
# exit code: 0, 30.5 s
|
||||
|
||||
{
|
||||
"lab": 7,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 30.0,
|
||||
"elapsed_seconds": 30.028,
|
||||
"concurrency": 4,
|
||||
"successful_requests": 4538,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 151.124,
|
||||
"successful_latency_ms": {
|
||||
"p50": 24.062,
|
||||
"p95": 42.691,
|
||||
"p99": 84.746
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"baseline": {
|
||||
"legit": {
|
||||
"requests": 884,
|
||||
"codes": {
|
||||
"200": 442,
|
||||
"201": 442
|
||||
},
|
||||
"p50_ms": 12.1,
|
||||
"p95_ms": 16.4,
|
||||
"p99_ms": 20.9
|
||||
},
|
||||
"attack": null
|
||||
},
|
||||
"under_attack": {
|
||||
"legit": {
|
||||
"requests": 336,
|
||||
"codes": {
|
||||
"200": 168,
|
||||
"201": 168
|
||||
},
|
||||
"p50_ms": 38.0,
|
||||
"p95_ms": 123.9,
|
||||
"p99_ms": 197.3
|
||||
},
|
||||
"attack": {
|
||||
"requests": 1091,
|
||||
"codes": {
|
||||
"401": 360,
|
||||
"429": 731
|
||||
},
|
||||
"rps": 54.5,
|
||||
"p50_ms": 85.6,
|
||||
"p95_ms": 1062.3
|
||||
}
|
||||
},
|
||||
"seconds": 20,
|
||||
"attackers": 16,
|
||||
"burst_one_replica": {
|
||||
"requests": 200,
|
||||
"codes": {
|
||||
"hashed": 77,
|
||||
"rejected_503": 123
|
||||
},
|
||||
"max_parallel_hashes": 2,
|
||||
"limit": 2,
|
||||
"queue_s": 2,
|
||||
"seconds": 2.38,
|
||||
"slowest_rejection_s": 2.0,
|
||||
"maxrss_growth_mib": 36.8
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
# login-dos: lab7: wrong-password login flood: Argon2id budget per replica, 503/429, latency of legit requests
|
||||
# date: 2026-11-07 15:36:30, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/login_dos.py
|
||||
# exit code: 0, 49.2 s
|
||||
|
||||
baseline 20 s ...
|
||||
{"legit": {"requests": 884, "codes": {"200": 442, "201": 442}, "p50_ms": 12.1, "p95_ms": 16.4, "p99_ms": 20.9}, "attack": null}
|
||||
attack: 16 threads of wrong-password logins over 40 usernames ...
|
||||
{"legit": {"requests": 336, "codes": {"200": 168, "201": 168}, "p50_ms": 38.0, "p95_ms": 123.9, "p99_ms": 197.3}, "attack": {"requests": 1091, "codes": {"401": 360, "429": 731}, "rps": 54.5, "p50_ms": 85.6, "p95_ms": 1062.3}}
|
||||
burst of 200 simultaneous password checks in one api process: {"requests": 200, "codes": {"hashed": 77, "rejected_503": 123}, "max_parallel_hashes": 2, "limit": 2, "queue_s": 2, "seconds": 2.38, "slowest_rejection_s": 2.0, "maxrss_growth_mib": 36.8}
|
||||
attack: 54.5 login attempts/s; 401 (hash computed) 360, 503 busy (rejected before hashing) 0, 429 rate limited 731
|
||||
legit p95: 16.4 ms -> 123.9 ms; legit errors: {}
|
||||
saved evidence/login-dos.json
|
||||
@@ -0,0 +1,38 @@
|
||||
# persistence: public persistence test incl. S3, OpenBao (+ operator unseal) + proof of real restarts (make test-persistence)
|
||||
# date: 2026-11-07 15:35:41, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/run_persistence.py
|
||||
# exit code: 0, 74.7 s
|
||||
|
||||
before: container, ID, started at
|
||||
api-1 api-1 2026-11-07T12:32:21Z
|
||||
api-2 api-2 2026-11-07T12:32:21Z
|
||||
dispatcher dispatcher 2026-11-07T12:25:52Z
|
||||
janitor janitor 2026-11-07T12:25:52Z
|
||||
lb lb 2026-11-07T12:25:52Z
|
||||
openbao openbao 2026-11-07T12:25:30Z
|
||||
otel-collector otel-collect 2026-11-07T12:25:52Z
|
||||
otel-gate otel-gate 2026-11-07T12:25:52Z
|
||||
postgres postgres 2026-11-07T12:25:30Z
|
||||
prometheus prometheus 2026-11-07T12:25:30Z
|
||||
rabbitmq rabbitmq 2026-11-07T12:25:30Z
|
||||
redis redis 2026-11-07T12:25:30Z
|
||||
s3 s3 2026-11-07T12:33:40Z
|
||||
worker worker 2026-11-07T12:25:52Z
|
||||
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
after (hook + waiting for readiness took 73.0 s): container, ID, started at, restarted?
|
||||
api-1 api-1 2026-11-07T12:35:38Z same container: True, restarted: True
|
||||
api-2 api-2 2026-11-07T12:35:38Z same container: True, restarted: True
|
||||
dispatcher dispatcher 2026-11-07T12:35:38Z same container: True, restarted: True
|
||||
janitor janitor 2026-11-07T12:35:38Z same container: True, restarted: True
|
||||
lb lb 2026-11-07T12:35:38Z same container: True, restarted: True
|
||||
openbao openbao 2026-11-07T12:34:54Z same container: True, restarted: True
|
||||
otel-collector otel-collect 2026-11-07T12:35:38Z same container: True, restarted: True
|
||||
otel-gate otel-gate 2026-11-07T12:35:38Z same container: True, restarted: True
|
||||
postgres postgres 2026-11-07T12:34:54Z same container: True, restarted: True
|
||||
prometheus prometheus 2026-11-07T12:34:54Z same container: True, restarted: True
|
||||
rabbitmq rabbitmq 2026-11-07T12:34:54Z same container: True, restarted: True
|
||||
redis redis 2026-11-07T12:34:54Z same container: True, restarted: True
|
||||
s3 s3 2026-11-07T12:34:54Z same container: True, restarted: True
|
||||
worker worker 2026-11-07T12:35:38Z same container: True, restarted: True
|
||||
PASS: the hook restarted postgres, redis, s3, rabbitmq, openbao, api, janitor, dispatcher, worker, lb, otel-gate, otel-collector, prometheus (all api replicas; same containers, new start time); data, the attachment bytes and the old token survived
|
||||
@@ -0,0 +1,10 @@
|
||||
# race: lab2 races via the balancer
|
||||
# date: 2026-11-07 15:21:49, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_race.py
|
||||
# exit code: 0, 3.0 s
|
||||
|
||||
sent 100 messages from 10 clients in 0.63 s; read 100 in 4 pages, unique ids: 100
|
||||
PASS: 100 concurrent messages from 10 clients, no losses and no duplicates
|
||||
20 parallel registrations of one username: 201 x1, 409 x19
|
||||
PASS: concurrent registration created exactly one user
|
||||
2 passed, 0 failed
|
||||
@@ -0,0 +1,17 @@
|
||||
# redis: Redis as the session store
|
||||
# date: 2026-11-07 15:21:56, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/redis_info.py
|
||||
# exit code: 0, 0.9 s
|
||||
|
||||
session key: session:679ebfa63540e8f8...; value is the user id: True
|
||||
TTL of the key, seconds: 3600
|
||||
sessions in Redis: 263
|
||||
config appendonly = yes
|
||||
config appendfsync = always
|
||||
config maxmemory-policy = noeviction
|
||||
config port = 0
|
||||
config tls-port = 6379
|
||||
config tls-auth-clients = yes
|
||||
aof_enabled:1
|
||||
aof_last_write_status:ok
|
||||
without password: TLS without AUTH -> 'NOAUTH Authentication required.'; plaintext -> 'Error: Connection reset by peer'
|
||||
@@ -0,0 +1,6 @@
|
||||
# security: lab7 public: trusted HTTPS works, empty trust store fails verification (make test-security)
|
||||
# date: 2026-11-07 15:07:34, commit: 5bfc53a + uncommitted changes
|
||||
# command: python tests/security.py --base-url https://localhost:8443 --ca-file /home/claude/work/mtusi2026lab7/secrets/pki/public/ca.crt
|
||||
# exit code: 0, 0.1 s
|
||||
|
||||
PASS: trusted HTTPS works; untrusted CA rejected. This does NOT verify internal mTLS, OpenBao or hardening.
|
||||
@@ -0,0 +1,6 @@
|
||||
# smoke: public smoke over HTTPS (make test CA_FILE=...) with telemetry ON, with attachment
|
||||
# date: 2026-11-07 15:07:34, commit: 5bfc53a + uncommitted changes
|
||||
# command: python tests/smoke.py --base-url https://localhost:8443 --ca-file /home/claude/work/mtusi2026lab7/secrets/pki/public/ca.crt
|
||||
# exit code: 0, 2.0 s
|
||||
|
||||
PASS: lab7 public API scenario; infrastructure and grading evidence remain separate.
|
||||
@@ -0,0 +1,26 @@
|
||||
# student-tests: lab1/lab2 API tests via the balancer
|
||||
# date: 2026-11-07 15:21:46, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_api.py
|
||||
# exit code: 0, 4.8 s
|
||||
|
||||
PASS: duplicate username returns 409
|
||||
PASS: invalid JSON returns 400
|
||||
PASS: wrong and extra fields return 400
|
||||
PASS: foreign chat returns 404
|
||||
PASS: empty and too long messages return 400, 4000 chars is ok
|
||||
PASS: pagination works across multiple pages, foreign cursor returns 400
|
||||
PASS: empty cursor (?cursor= and ?cursor) returns 400, no cursor returns the first page
|
||||
PASS: chat list pagination
|
||||
PASS: unicode text is stored as is
|
||||
PASS: strings with U+0000 are stored and returned as is
|
||||
PASS: user response has no password or hash
|
||||
PASS: password length 12..128, blank password is rejected
|
||||
PASS: Basic login returns opaque Bearer token with expiry
|
||||
PASS: wrong password and unknown user both return the same 401
|
||||
PASS: malformed Basic header returns 401
|
||||
PASS: password with colon and unicode works
|
||||
PASS: business endpoints need Bearer; Basic and X-User-Id give 401
|
||||
PASS: X-User-Id does not change the current user
|
||||
PASS: 401 comes before 400 and 404
|
||||
PASS: logout revokes only the current session
|
||||
20 passed, 0 failed
|
||||
@@ -0,0 +1,109 @@
|
||||
# Сводка проверок
|
||||
|
||||
| Шаг | Что проверяет | Результат | Время, с | Файл |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| check | offline contract check (make check) | PASS | 0 | evidence/check.txt |
|
||||
| smoke | public smoke over HTTPS (make test CA_FILE=...) with telemetry ON, with attachment | PASS | 2 | evidence/smoke.txt |
|
||||
| security | lab7 public: trusted HTTPS works, empty trust store fails verification (make test-security) | PASS | 0 | evidence/security.txt |
|
||||
| tls-matrix | lab7: every trust-matrix link from inside — allowed identity passes, no cert / foreign CA / wrong identity / expired fail | PASS | 1 | evidence/tls-matrix.txt |
|
||||
| least-privilege | lab7: each service identity vs PostgreSQL grants, S3 prefixes, OpenBao policies, Redis ACL | PASS | 3 | evidence/least-privilege.txt |
|
||||
| lab7-security | lab7: HTTPS only, headers, outsider ACL, logout, shared login rate limit, size limits, Argon2id, rehash, no credential leaks | PASS | 4 | evidence/lab7-security.txt |
|
||||
| leak-check | lab7: password/token/Authorization absent in container logs, Loki, Tempo traces, Prometheus labels | PASS | 21 | evidence/leak-check.txt |
|
||||
| argon2-bench | lab7: Argon2id cost inside the api container for candidate parameters | PASS | 7 | evidence/argon2-bench.txt |
|
||||
| lifecycle-rotate-secret | lab7: Redis password of api rotated via OpenBao under load, old one revoked | PASS | 18 | evidence/lifecycle-rotate-secret.txt |
|
||||
| lifecycle-rotate-leaf | lab7: LB leaf rotated (HAProxy reload), old leaf revoked via CRL, rejected by API | PASS | 22 | evidence/lifecycle-rotate-leaf.txt |
|
||||
| lifecycle-token-expiry | lab7: OpenBao token TTL 20 s / max 40 s + revoke: services re-login with their cert | PASS | 103 | evidence/lifecycle-token-expiry.txt |
|
||||
| lifecycle-sealed | lab7: sealed OpenBao: running replicas serve, restarted replica not ready until unseal | PASS | 86 | evidence/lifecycle-sealed.txt |
|
||||
| jobs-variants | lab5: thumbnail/crop/optimized, EXIF orientation, alpha, no upscale, metadata stripped | PASS | 10 | evidence/jobs-variants.txt |
|
||||
| jobs-limits | lab5: worker limits - bytes, pixels, memory (RLIMIT_AS), time (JOB_TIMEOUT_SECONDS) | PASS | 67 | evidence/jobs-limits.txt |
|
||||
| jobs-recovery | lab5: worker down -> 202 -> restart api+broker -> ready; broker down -> outbox waits | PASS | 31 | evidence/jobs-recovery.txt |
|
||||
| jobs-outbox | lab5: dispatcher crash between COMMIT and publish / after confirm | PASS | 7 | evidence/jobs-outbox.txt |
|
||||
| jobs-crash | lab5: worker crash after S3 PUT / after COMMIT before ack, staging cleanup, frozen worker lease | PASS | 133 | evidence/jobs-crash.txt |
|
||||
| jobs-retry | lab5: backoff+jitter, retry_exhausted, replay, permanent errors, DLQ | PASS | 45 | evidence/jobs-retry.txt |
|
||||
| jobs-janitor-replay | lab5: janitor does not delete objects re-written by replay (review fix) | PASS | 172 | evidence/jobs-janitor-replay.txt |
|
||||
| jobs-concurrency | lab5: WORKER_CONCURRENCY consumers, prefetch 1, bounded processing | PASS | 6 | evidence/jobs-concurrency.txt |
|
||||
| attachments | lab4: files, limits, damaged images, MIME, filenames, access, attachment_ids | PASS | 14 | evidence/attachments.txt |
|
||||
| consistency | lab4: aborted upload, crash between S3 and DB, janitor, orphans, S3 outage | PASS | 95 | evidence/consistency.txt |
|
||||
| balancing | balancing, shared sessions/data/files, X-Instance-Id | PASS | 3 | evidence/balancing.txt |
|
||||
| idempotency | Idempotency-Key, parallel same key via replicas | PASS | 4 | evidence/idempotency.txt |
|
||||
| student-tests | lab1/lab2 API tests via the balancer | PASS | 5 | evidence/student-tests.txt |
|
||||
| race | lab2 races via the balancer | PASS | 3 | evidence/race.txt |
|
||||
| db | PostgreSQL: rollback, FK, Argon2id, unique keys, migrations | PASS | 7 | evidence/db.txt |
|
||||
| redis | Redis as the session store | PASS | 1 | evidence/redis.txt |
|
||||
| explain | EXPLAIN of the history page (full plans: explain-history.txt) | PASS | 1 | evidence/explain.txt |
|
||||
| failover | public failover test for every replica, file downloaded via the other one (make test-failover) | PASS | 41 | evidence/failover.txt |
|
||||
| load | public load generator, 30 s, concurrency 4 | PASS | 31 | evidence/load.txt |
|
||||
| failures | Redis and PostgreSQL outages via the balancer | PASS | 34 | evidence/failures.txt |
|
||||
| persistence | public persistence test incl. S3, OpenBao (+ operator unseal) + proof of real restarts (make test-persistence) | PASS | 75 | evidence/persistence.txt |
|
||||
| login-dos | lab7: wrong-password login flood: Argon2id budget per replica, 503/429, latency of legit requests | PASS | 49 | evidence/login-dos.txt |
|
||||
|
||||
# Замеры
|
||||
|
||||
Машина: Linux 6.18.44-fc-v310, x86_64; Docker VM: 2 CPU, 0.0 GiB RAM; клиент Python 3.11.18; дата прогона 2026-11-07, commit 5bfc53a + uncommitted changes. Лимиты контейнеров: api 1 CPU / 512 MiB каждая, postgres, s3 (SeaweedFS) и rabbitmq по 1 CPU / 512 MiB, redis и lb по 0,5 CPU / 128 MiB, janitor 0,25 CPU / 192 MiB, dispatcher 0,25 CPU / 128 MiB, worker 2 CPU / 1536 MiB; lab6: otel-collector 0,5 CPU / 384 MiB, prometheus, loki, tempo по 1 CPU / 512 MiB, grafana 0,5 CPU / 384 MiB; lab7: openbao 0,5 CPU / 256 MiB, otel-gate 0,25 CPU / 64 MiB; у всех — лимит PID.
|
||||
|
||||
TLS/mTLS-аудит trust matrix изнутри сети (`student-tests/test_tls_matrix.py`, контейнер probe):
|
||||
|
||||
| Связь | Проверок | Пройдено |
|
||||
| --- | --- | --- |
|
||||
| LB -> API (mTLS, allowlist CN=lb) | 9 | 9 |
|
||||
| API/worker -> RabbitMQ (mTLS + EXTERNAL, CN = broker user) | 11 | 11 |
|
||||
| API/worker -> OTel Collector (mTLS via otel-gate, allowlist app CNs) | 13 | 13 |
|
||||
| API/worker -> PostgreSQL (TLS verify-full, SCRAM, roles) | 3 | 3 |
|
||||
| API -> Redis (TLS + client cert of our CA + ACL user) | 6 | 6 |
|
||||
| API/worker -> S3 (HTTPS + per-service keys by prefix) | 6 | 6 |
|
||||
| Services -> OpenBao (TLS + cert auth by CN + policy) | 7 | 7 |
|
||||
| Collector/Grafana/operator -> Prometheus (mTLS + allowed SANs) | 7 | 7 |
|
||||
| Loki/Tempo/Grafana | 1 | 1 |
|
||||
|
||||
Минимальные права (`test_least_privilege.py`): 83 проверок, 83 пройдено (разрешённое работает, запрещённое — отказ).
|
||||
|
||||
Argon2id внутри контейнера api (`argon2_bench.py`, медиана из 7):
|
||||
|
||||
| m, KiB | t | p | hash, мс | verify, мс | входов/с на реплику при 2 параллельных | RAM на хеширование, MiB |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| 19456 | 2 | 1 | 23.4 | 23.6 | 84.7 | 38 |
|
||||
| 19456 | 3 | 1 | 42.2 | 42.1 | 47.5 | 38 |
|
||||
| 32768 (выбрано) | 2 | 1 | 51.2 | 49.9 | 40.1 | 64 |
|
||||
| 47104 | 2 | 1 | 63.9 | 62.1 | 32.2 | 92 |
|
||||
| 65536 | 2 | 1 | 115.8 | 115.8 | 17.3 | 128 |
|
||||
| 65536 | 3 | 1 | 195.8 | 187.2 | 10.7 | 128 |
|
||||
|
||||
Login DoS (`login_dos.py`, 16 потоков неверных входов, 20 с): атака 54.5 попыток/с, коды {'401': 360, '429': 731}; легитимный клиент p95 16.4 -> 123.9 мс, p99 20.9 -> 197.3 мс, коды {'200': 168, '201': 168}.
|
||||
|
||||
Ротация пароля Redis (api) через OpenBao: {"kv_version": [1, 2], "replicas": 2, "active_passwords_during_overlap": 2, "all_replicas_picked_up_after_s": 4.2, "active_password_hashes_after": 1, "new_password_hash_matches": true}; нагрузка 17.2 с, ответы {'me:200': 201, 'send:201': 201, 'login:201': 8}, ошибок 5xx/соединения 0.
|
||||
|
||||
Ротация leaf LB + отзыв старого через CRL: {"old_serial": "7867bb9789172458", "new_serial": "aed4162e0d6ff182", "probe": {"valid LB identity (CN=lb)": "http_200", "foreign CA, CN=lb": "connection_closed_after_handshake", "our CA, expired, CN=lb": "connection_closed_after_handshake", "previous (rotated, revoked) LB leaf": "connection_closed_after_handshake"}, "api_events_after_revoke": {"tls.crl_loaded": 2, "tls.revoked_connections_closed": 2, "tls.client_rejected": 4}}; нагрузка 21.3 с, ответы {'me:200': 265, 'send:201': 265, 'login:201': 10}, ошибок 5xx/соединения 0.
|
||||
|
||||
Истечение/отзыв токенов OpenBao: {"role_ttl": "20s / max 40s", "observed_seconds": 100, "api_events": {"secrets.refresh_failed": 2, "secrets.login": 6, "secrets.renewed": 16}}; нагрузка 102.1 с, ответы {'me:200': 1302, 'send:201': 1302, 'login:201': 49}, ошибок 5xx/соединения 0.
|
||||
|
||||
OpenBao sealed: {"sealed_seconds": 73.7, "restarted_replica_health_while_sealed": "unhealthy", "replicas_answering_while_sealed": 1, "restarted_replica_ready_after_unseal_s": 3.2, "api_events": {"secrets.refresh_failed": 25, "secrets.waiting": 8, "secrets.login": 2}}; нагрузка 85.2 с, ответы {'me:200': 1108, 'send:201': 1108, 'login:201': 41}, ошибок 5xx/соединения 0.
|
||||
|
||||
Публичный тест отказа (`make test-failover`, 15 с записи во время остановки реплики):
|
||||
|
||||
| Прогон | Остановлена реплика | Реплик до отказа | Успешных записей | Неудачных попыток (повторены с тем же ключом) | Первая запись после hook, с |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| 1 | api | 2 | 131 | 0 | 3.82 |
|
||||
| 2 | api | 2 | 131 | 0 | 3.721 |
|
||||
|
||||
| Воздействие | Что ожидаем | Что наблюдали | Время восстановления / потеря данных |
|
||||
| --- | --- | --- | --- |
|
||||
| публичный `make test-failover` для каждой реплики | запись продолжается не позже 10 с, подтверждённые сообщения на месте, дублей нет | PASS 2 раз(а), неудачных попыток: 0, 0 | первая запись после hook через 3.82, 3.721 с (hook ждёт остановки ~4 с); потерь нет |
|
||||
| перезапуск всего стенда (`restart` hook: postgres, redis, s3, api, janitor, lb) | данные, файл и прежний токен живы | PASS, те же контейнеры с новым временем старта | 73.0 с до готовности; потерь нет |
|
||||
| `docker compose stop s3` (SeaweedFS остановлен) | загрузка и скачивание -> 503, метаданные, сообщения и /health/ready работают | upload 503 за 386 мс, download 503, остальное 200/201 | после start файлы на месте; uploading-строку убрал janitor; потерь нет |
|
||||
| `docker compose pause s3` (SeaweedFS завис) | то же, но через таймауты S3-клиента | upload 503 за 4064 мс (2 попытки x 5 с + откат 2 с) | после unpause файлы на месте; потерь нет |
|
||||
| падение между PUT в S3 и COMMIT в БД (код API в контейнере, finish_upload падает) | вложение не видно, janitor не трогает его до конца grace period, потом удаляет объект и строку | GET/прикрепление -> 404; janitor: свежая строка сохранена, dry-run только отчёт, затем удалено | мусора не осталось; повторный проход ничего не делает |
|
||||
| обрыв загрузки клиентом (9 МБ заявлено, отправлено 0,2 и 3 МБ) | ничего не сохраняется | строк и объектов не прибавилось, временных файлов 0 | мгновенно |
|
||||
| worker остановлен, upload, рестарт rabbitmq и api с volumes, start worker | 202 queued, сообщение с вложением 201, content 409; после рестартов job в очереди; тот же job_id -> ready | worker started -> same job 182a3066-efb5-453d-8d2a-c906da4ac027 ready, thumbnail downloadable; staging object deleted | потерь нет; staging удалён после COMMIT |
|
||||
| rabbitmq остановлен во время upload | 202 и /health/ready 200 без брокера; строка outbox ждёт; после start публикуется | rabbitmq started -> dispatcher published the pending row -> ready | потерь нет |
|
||||
| crash dispatcher между COMMIT задания и publish | строка outbox не отмечена -> публикуется после рестарта процесса | dispatcher killed between COMMIT and publish; restarted by policy, outbox re-published -> job a39e310d-6e0e-425c-baa6-33db9da3e290 ready, attempt 1, no manual action | без ручного действия |
|
||||
| crash dispatcher после confirm, до отметки outbox | дубль сообщения, worker распознаёт по состоянию job | dispatcher killed after publisher confirm, before marking outbox -> message published twice; worker: ['created', 'claimed', 'ready', 'duplicate_ignored'] -> one result set | один набор вариантов |
|
||||
| crash worker после PUT в S3, до COMMIT и ack | повтор после истечения аренды перезаписывает те же ключи | worker killed after S3 PUT (before COMMIT and ack): redelivery saw a live lease (no-op), lease expired after 15 s, attempt 2 rewrote the same keys -> one set; events ['created', 'claimed', 'duplicate_ignored', 'lease_expired', 'claimed', 'ready'] | один набор, 4 объекта |
|
||||
| crash worker после COMMIT, до ack | redelivery ready-задачи -> no-op ack | worker killed after COMMIT, before ack: broker redelivered, worker acked as no-op (1:duplicate_ignored:status=ready); queue empty (0 ready, 0 unacked) | очередь пуста, дублей нет |
|
||||
| worker завис (не продлевает аренду) | dispatcher возвращает job, другой поток завершает; поздний результат отклонён fencing | frozen attempt 1 stopped renewing; lease expired, recovered by dispatcher, attempt 2 ready after 17 s; frozen attempt woke up -> stale_result_rejected; events ['created', 'claimed', 'lease_expired', 'claimed', 'ready', 'stale_result_rejected'] | ready не откатан |
|
||||
| зависание обработки изображения | процесс убит по JOB_TIMEOUT_SECONDS, временная ошибка, аренда продлевалась | imaging hang -> killed after 60 s (processing_timeout, temporary), lease renewed meanwhile (no lease_expired), attempt 2 ready after 62 s | повтор -> ready |
|
||||
| нехватка памяти в процессе обработки (RLIMIT_AS) | failed/resource_limit, worker жив | memory bomb in the imaging process -> failed/resource_limit after attempt 1; worker itself survived | постоянная ошибка, без повторов |
|
||||
| 2 временные ошибки S3 | backoff с jitter, затем ready | 2 x storage_unavailable -> retries after 1.20 s and 2.30 s (equal jitter: 1..2 s, 2..4 s), attempt 3 ready | - |
|
||||
| 5 временных ошибок подряд | failed/retry_exhausted, реестр failed, content 409 | 5 temporary errors -> failed/retry_exhausted (public error_code), content 409, attach 409, listed by ops.py failed (replayable) | replay оператора |
|
||||
| replay failed и повторный replay ready | тот же job_id -> ready; повтор отклонён | ops replay -> same job_id 44cac72b-36f8-411d-9b08-cb90fd27bbb9 attempt 6 ready; second replay refused: "job is ready, replay is only for failed jobs" | дубля нет |
|
||||
| невалидное сообщение и неизвестный job_id | reject -> DLQ, dlq-replay не исполняет | schema-invalid message and unknown job_id -> reject -> DLQ (2 message(s)); dlq-replay kept them: ['invalid message is kept for analysis', 'unknown job'] | сообщения сохранены |
|
||||
| 8 заданий в очереди, старт worker | WORKER_CONCURRENCY=2, prefetch 1 | 2 consumers, prefetch_count 1, manual ack; 8 queued 3000x2000 JPEG drained in 3.0 s after worker start, peak processing 2 of 8 (17 samples) | - |
|
||||
@@ -0,0 +1,602 @@
|
||||
{
|
||||
"summary": {
|
||||
"summary": true,
|
||||
"checks": 63,
|
||||
"failed": 0,
|
||||
"seconds": 0.8
|
||||
},
|
||||
"checks": [
|
||||
{
|
||||
"link": "LB -> API (mTLS, allowlist CN=lb)",
|
||||
"case": "valid LB identity (CN=lb)",
|
||||
"expect": "http_200",
|
||||
"observed": "http_200",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "LB -> API (mTLS, allowlist CN=lb)",
|
||||
"case": "no client certificate",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake"
|
||||
],
|
||||
"observed": "connection_closed_after_handshake",
|
||||
"pass": true,
|
||||
"detail": "BrokenPipeError: [Errno 32] Broken pipe"
|
||||
},
|
||||
{
|
||||
"link": "LB -> API (mTLS, allowlist CN=lb)",
|
||||
"case": "foreign CA, CN=lb",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake"
|
||||
],
|
||||
"observed": "connection_closed_after_handshake",
|
||||
"pass": true,
|
||||
"detail": "BrokenPipeError: [Errno 32] Broken pipe"
|
||||
},
|
||||
{
|
||||
"link": "LB -> API (mTLS, allowlist CN=lb)",
|
||||
"case": "our CA, expired, CN=lb",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake"
|
||||
],
|
||||
"observed": "connection_closed_after_handshake",
|
||||
"pass": true,
|
||||
"detail": "BrokenPipeError: [Errno 32] Broken pipe"
|
||||
},
|
||||
{
|
||||
"link": "LB -> API (mTLS, allowlist CN=lb)",
|
||||
"case": "our CA, CN=intruder",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake"
|
||||
],
|
||||
"observed": "connection_closed_after_handshake",
|
||||
"pass": true,
|
||||
"detail": "BrokenPipeError: [Errno 32] Broken pipe"
|
||||
},
|
||||
{
|
||||
"link": "LB -> API (mTLS, allowlist CN=lb)",
|
||||
"case": "our CA, CN=worker (other service)",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake"
|
||||
],
|
||||
"observed": "connection_closed_after_handshake",
|
||||
"pass": true,
|
||||
"detail": "BrokenPipeError: [Errno 32] Broken pipe"
|
||||
},
|
||||
{
|
||||
"link": "LB -> API (mTLS, allowlist CN=lb)",
|
||||
"case": "our CA, CN=api (server's own identity)",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake"
|
||||
],
|
||||
"observed": "connection_closed_after_handshake",
|
||||
"pass": true,
|
||||
"detail": "RemoteDisconnected: Remote end closed connection without response"
|
||||
},
|
||||
{
|
||||
"link": "LB -> API (mTLS, allowlist CN=lb)",
|
||||
"case": "server identity: client trusts only foreign CA",
|
||||
"expect": "client_rejected_server_cert",
|
||||
"observed": "client_rejected_server_cert",
|
||||
"pass": true,
|
||||
"detail": "SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1018)"
|
||||
},
|
||||
{
|
||||
"link": "LB -> API (mTLS, allowlist CN=lb)",
|
||||
"case": "plaintext client",
|
||||
"expect": [
|
||||
"no_plaintext_service"
|
||||
],
|
||||
"observed": "no_plaintext_service",
|
||||
"pass": true,
|
||||
"detail": "b''"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> RabbitMQ (mTLS + EXTERNAL, CN = broker user)",
|
||||
"case": "worker identity consumes its queue",
|
||||
"expect": "allowed",
|
||||
"observed": "allowed",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> RabbitMQ (mTLS + EXTERNAL, CN = broker user)",
|
||||
"case": "dispatcher identity publishes to exchange",
|
||||
"expect": "allowed",
|
||||
"observed": "allowed",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> RabbitMQ (mTLS + EXTERNAL, CN = broker user)",
|
||||
"case": "CN=api (no broker user, API uses outbox)",
|
||||
"expect": "login_refused",
|
||||
"observed": "login_refused",
|
||||
"pass": true,
|
||||
"detail": "ConnectionClosedByBroker: (403) 'ACCESS_REFUSED - Login was refused using authentication mechanism EXTERNAL. For details see the broker logfile.'"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> RabbitMQ (mTLS + EXTERNAL, CN = broker user)",
|
||||
"case": "our CA, CN=intruder",
|
||||
"expect": "login_refused",
|
||||
"observed": "login_refused",
|
||||
"pass": true,
|
||||
"detail": "ConnectionClosedByBroker: (403) 'ACCESS_REFUSED - Login was refused using authentication mechanism EXTERNAL. For details see the broker logfile.'"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> RabbitMQ (mTLS + EXTERNAL, CN = broker user)",
|
||||
"case": "our CA, CN=lb",
|
||||
"expect": "login_refused",
|
||||
"observed": "login_refused",
|
||||
"pass": true,
|
||||
"detail": "ConnectionClosedByBroker: (403) 'ACCESS_REFUSED - Login was refused using authentication mechanism EXTERNAL. For details see the broker logfile.'"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> RabbitMQ (mTLS + EXTERNAL, CN = broker user)",
|
||||
"case": "foreign CA, CN=worker",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake",
|
||||
"error"
|
||||
],
|
||||
"observed": "server_rejected_client_cert",
|
||||
"pass": true,
|
||||
"detail": "IncompatibleProtocolError: StreamLostError: (\"Stream connection lost: SSLError(1, '[SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:2592)')\",)"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> RabbitMQ (mTLS + EXTERNAL, CN = broker user)",
|
||||
"case": "no client certificate",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake",
|
||||
"error"
|
||||
],
|
||||
"observed": "server_rejected_client_cert",
|
||||
"pass": true,
|
||||
"detail": "IncompatibleProtocolError: StreamLostError: (\"Stream connection lost: SSLError(1, '[SSL: TLSV13_ALERT_CERTIFICATE_REQUIRED] tlsv13 alert certificate required (_ssl.c:2592)')\",)"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> RabbitMQ (mTLS + EXTERNAL, CN = broker user)",
|
||||
"case": "worker publishes (not allowed)",
|
||||
"expect": "access_refused_403",
|
||||
"observed": "access_refused_403",
|
||||
"pass": true,
|
||||
"detail": "(403, \"ACCESS_REFUSED - write access to exchange 'attachments' in vhost 'messenger' refused for user 'worker'\")"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> RabbitMQ (mTLS + EXTERNAL, CN = broker user)",
|
||||
"case": "dispatcher consumes main queue (not allowed)",
|
||||
"expect": "access_refused_403",
|
||||
"observed": "access_refused_403",
|
||||
"pass": true,
|
||||
"detail": "(403, \"ACCESS_REFUSED - read access to queue 'attachments.process.v1' in vhost 'messenger' refused for user 'dispatcher'\")"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> RabbitMQ (mTLS + EXTERNAL, CN = broker user)",
|
||||
"case": "worker declares a queue (no configure)",
|
||||
"expect": "access_refused_403",
|
||||
"observed": "access_refused_403",
|
||||
"pass": true,
|
||||
"detail": "(403, \"ACCESS_REFUSED - configure access to queue 'probe-evil-queue' in vhost 'messenger' refused for user 'worker'\")"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> RabbitMQ (mTLS + EXTERNAL, CN = broker user)",
|
||||
"case": "plaintext client",
|
||||
"expect": [
|
||||
"no_plaintext_service"
|
||||
],
|
||||
"observed": "no_plaintext_service",
|
||||
"pass": true,
|
||||
"detail": "tls alert"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> OTel Collector (mTLS via otel-gate, allowlist app CNs)",
|
||||
"case": "CN=api sends OTLP logs",
|
||||
"expect": [
|
||||
"http_200",
|
||||
"http_400"
|
||||
],
|
||||
"observed": "http_200",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> OTel Collector (mTLS via otel-gate, allowlist app CNs)",
|
||||
"case": "CN=worker sends OTLP logs",
|
||||
"expect": [
|
||||
"http_200",
|
||||
"http_400"
|
||||
],
|
||||
"observed": "http_200",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> OTel Collector (mTLS via otel-gate, allowlist app CNs)",
|
||||
"case": "CN=dispatcher sends OTLP logs",
|
||||
"expect": [
|
||||
"http_200",
|
||||
"http_400"
|
||||
],
|
||||
"observed": "http_200",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> OTel Collector (mTLS via otel-gate, allowlist app CNs)",
|
||||
"case": "CN=janitor sends OTLP logs",
|
||||
"expect": [
|
||||
"http_200",
|
||||
"http_400"
|
||||
],
|
||||
"observed": "http_200",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> OTel Collector (mTLS via otel-gate, allowlist app CNs)",
|
||||
"case": "our CA, CN=lb (not an app) sends OTLP",
|
||||
"expect": "http_403",
|
||||
"observed": "http_403",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> OTel Collector (mTLS via otel-gate, allowlist app CNs)",
|
||||
"case": "our CA, CN=grafana (not an app) sends OTLP",
|
||||
"expect": "http_403",
|
||||
"observed": "http_403",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> OTel Collector (mTLS via otel-gate, allowlist app CNs)",
|
||||
"case": "our CA, CN=intruder (not an app) sends OTLP",
|
||||
"expect": "http_403",
|
||||
"observed": "http_403",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> OTel Collector (mTLS via otel-gate, allowlist app CNs)",
|
||||
"case": "our CA, CN=operator (not an app) sends OTLP",
|
||||
"expect": "http_403",
|
||||
"observed": "http_403",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> OTel Collector (mTLS via otel-gate, allowlist app CNs)",
|
||||
"case": "foreign CA, CN=worker",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake"
|
||||
],
|
||||
"observed": "server_rejected_client_cert",
|
||||
"pass": true,
|
||||
"detail": "SSLError: [SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:2592)"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> OTel Collector (mTLS via otel-gate, allowlist app CNs)",
|
||||
"case": "no client certificate",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake"
|
||||
],
|
||||
"observed": "server_rejected_client_cert",
|
||||
"pass": true,
|
||||
"detail": "SSLError: [SSL: TLSV13_ALERT_CERTIFICATE_REQUIRED] tlsv13 alert certificate required (_ssl.c:2592)"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> OTel Collector (mTLS via otel-gate, allowlist app CNs)",
|
||||
"case": "Collector self-metrics, CN=operator",
|
||||
"expect": [
|
||||
"http_200",
|
||||
"http_404"
|
||||
],
|
||||
"observed": "http_404",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> OTel Collector (mTLS via otel-gate, allowlist app CNs)",
|
||||
"case": "Collector self-metrics, CN=api (not allowed)",
|
||||
"expect": "http_403",
|
||||
"observed": "http_403",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> OTel Collector (mTLS via otel-gate, allowlist app CNs)",
|
||||
"case": "plaintext client",
|
||||
"expect": [
|
||||
"no_plaintext_service"
|
||||
],
|
||||
"observed": "no_plaintext_service",
|
||||
"pass": true,
|
||||
"detail": "b''"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> PostgreSQL (TLS verify-full, SCRAM, roles)",
|
||||
"case": "TLS verify-full with our CA (wrong password on purpose)",
|
||||
"expect": "tls_ok_auth_failed",
|
||||
"observed": "tls_ok_auth_failed",
|
||||
"pass": true,
|
||||
"detail": "connection failed: connection to server at \"127.0.1.21\", port 5432 failed: FATAL: password authentication failed for user \"messenger_api\""
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> PostgreSQL (TLS verify-full, SCRAM, roles)",
|
||||
"case": "plaintext (sslmode=disable)",
|
||||
"expect": "rejected_no_tls",
|
||||
"observed": "rejected_no_tls",
|
||||
"pass": true,
|
||||
"detail": "connection failed: connection to server at \"127.0.1.21\", port 5432 failed: FATAL: pg_hba.conf rejects connection for host \"127.0.0.1\", user \"messenger_api\", database \"messenger\", no encryption"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> PostgreSQL (TLS verify-full, SCRAM, roles)",
|
||||
"case": "trust foreign CA only",
|
||||
"expect": "client_rejected_server_cert",
|
||||
"observed": "client_rejected_server_cert",
|
||||
"pass": true,
|
||||
"detail": "connection failed: connection to server at \"127.0.1.21\", port 5432 failed: SSL error: certificate verify failed"
|
||||
},
|
||||
{
|
||||
"link": "API -> Redis (TLS + client cert of our CA + ACL user)",
|
||||
"case": "our CA client cert, no AUTH",
|
||||
"expect": "noauth",
|
||||
"observed": "noauth",
|
||||
"pass": true,
|
||||
"detail": "-NOAUTH Authentication required.\r\n"
|
||||
},
|
||||
{
|
||||
"link": "API -> Redis (TLS + client cert of our CA + ACL user)",
|
||||
"case": "our CA, AUTH api with a wrong password",
|
||||
"expect": "wrongpass",
|
||||
"observed": "wrongpass",
|
||||
"pass": true,
|
||||
"detail": "-WRONGPASS invalid username-password pair or user is disabled.\r\n"
|
||||
},
|
||||
{
|
||||
"link": "API -> Redis (TLS + client cert of our CA + ACL user)",
|
||||
"case": "no client certificate",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake"
|
||||
],
|
||||
"observed": "server_rejected_client_cert",
|
||||
"pass": true,
|
||||
"detail": "SSLError: [SSL: TLSV13_ALERT_CERTIFICATE_REQUIRED] tlsv13 alert certificate required (_ssl.c:2592)"
|
||||
},
|
||||
{
|
||||
"link": "API -> Redis (TLS + client cert of our CA + ACL user)",
|
||||
"case": "foreign CA client certificate",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake"
|
||||
],
|
||||
"observed": "server_rejected_client_cert",
|
||||
"pass": true,
|
||||
"detail": "SSLError: [SSL: TLSV1_ALERT_UNKNOWN_CA] tlsv1 alert unknown ca (_ssl.c:2592)"
|
||||
},
|
||||
{
|
||||
"link": "API -> Redis (TLS + client cert of our CA + ACL user)",
|
||||
"case": "trust foreign CA only",
|
||||
"expect": "client_rejected_server_cert",
|
||||
"observed": "client_rejected_server_cert",
|
||||
"pass": true,
|
||||
"detail": "SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1018)"
|
||||
},
|
||||
{
|
||||
"link": "API -> Redis (TLS + client cert of our CA + ACL user)",
|
||||
"case": "plaintext client",
|
||||
"expect": [
|
||||
"no_plaintext_service"
|
||||
],
|
||||
"observed": "no_plaintext_service",
|
||||
"pass": true,
|
||||
"detail": "ConnectionResetError: [Errno 104] Connection reset by peer"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> S3 (HTTPS + per-service keys by prefix)",
|
||||
"case": "HTTPS anonymous list (no signature)",
|
||||
"expect": "http_403",
|
||||
"observed": "http_403",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> S3 (HTTPS + per-service keys by prefix)",
|
||||
"case": "trust foreign CA only",
|
||||
"expect": "client_rejected_server_cert",
|
||||
"observed": "client_rejected_server_cert",
|
||||
"pass": true,
|
||||
"detail": "SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1018)"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> S3 (HTTPS + per-service keys by prefix)",
|
||||
"case": "plaintext client",
|
||||
"expect": [
|
||||
"no_plaintext_service"
|
||||
],
|
||||
"observed": "no_plaintext_service",
|
||||
"pass": true,
|
||||
"detail": "b'HTTP/1.0 400 Bad Request\\r\\n\\r\\nClient sent an HTTP request to a'"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> S3 (HTTPS + per-service keys by prefix)",
|
||||
"case": "S3 gRPC :18333, CN=intruder (our CA)",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake"
|
||||
],
|
||||
"observed": "server_rejected_client_cert",
|
||||
"pass": true,
|
||||
"detail": "SSLError: [SSL: SSLV3_ALERT_BAD_CERTIFICATE] ssl/tls alert bad certificate (_ssl.c:2592)"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> S3 (HTTPS + per-service keys by prefix)",
|
||||
"case": "S3 gRPC :18333, CN=api (our CA)",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake"
|
||||
],
|
||||
"observed": "server_rejected_client_cert",
|
||||
"pass": true,
|
||||
"detail": "SSLError: [SSL: SSLV3_ALERT_BAD_CERTIFICATE] ssl/tls alert bad certificate (_ssl.c:2592)"
|
||||
},
|
||||
{
|
||||
"link": "API/worker -> S3 (HTTPS + per-service keys by prefix)",
|
||||
"case": "S3 gRPC :18333, no client certificate",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake"
|
||||
],
|
||||
"observed": "server_rejected_client_cert",
|
||||
"pass": true,
|
||||
"detail": "SSLError: [SSL: TLSV13_ALERT_CERTIFICATE_REQUIRED] tlsv13 alert certificate required (_ssl.c:2592)"
|
||||
},
|
||||
{
|
||||
"link": "Services -> OpenBao (TLS + cert auth by CN + policy)",
|
||||
"case": "CN=worker logs in as role worker",
|
||||
"expect": "http_200",
|
||||
"observed": "http_200",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "Services -> OpenBao (TLS + cert auth by CN + policy)",
|
||||
"case": "CN=worker logs in as role api",
|
||||
"expect": "http_400",
|
||||
"observed": "http_400",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "Services -> OpenBao (TLS + cert auth by CN + policy)",
|
||||
"case": "our CA, CN=intruder as role api",
|
||||
"expect": "http_400",
|
||||
"observed": "http_400",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "Services -> OpenBao (TLS + cert auth by CN + policy)",
|
||||
"case": "foreign CA, CN=worker as role worker",
|
||||
"expect": [
|
||||
"http_400",
|
||||
"server_rejected_client_cert"
|
||||
],
|
||||
"observed": "http_400",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "Services -> OpenBao (TLS + cert auth by CN + policy)",
|
||||
"case": "no client certificate as role api",
|
||||
"expect": "http_400",
|
||||
"observed": "http_400",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "Services -> OpenBao (TLS + cert auth by CN + policy)",
|
||||
"case": "trust foreign CA only",
|
||||
"expect": "client_rejected_server_cert",
|
||||
"observed": "client_rejected_server_cert",
|
||||
"pass": true,
|
||||
"detail": "SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1018)"
|
||||
},
|
||||
{
|
||||
"link": "Services -> OpenBao (TLS + cert auth by CN + policy)",
|
||||
"case": "plaintext client",
|
||||
"expect": [
|
||||
"no_plaintext_service"
|
||||
],
|
||||
"observed": "no_plaintext_service",
|
||||
"pass": true,
|
||||
"detail": "b'HTTP/1.0 400 Bad Request\\r\\n\\r\\nClient sent an HTTP request to a'"
|
||||
},
|
||||
{
|
||||
"link": "Collector/Grafana/operator -> Prometheus (mTLS + allowed SANs)",
|
||||
"case": "CN=operator",
|
||||
"expect": "http_200",
|
||||
"observed": "http_200",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "Collector/Grafana/operator -> Prometheus (mTLS + allowed SANs)",
|
||||
"case": "CN=grafana",
|
||||
"expect": "http_200",
|
||||
"observed": "http_200",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "Collector/Grafana/operator -> Prometheus (mTLS + allowed SANs)",
|
||||
"case": "CN=otel-collector",
|
||||
"expect": "http_200",
|
||||
"observed": "http_200",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
},
|
||||
{
|
||||
"link": "Collector/Grafana/operator -> Prometheus (mTLS + allowed SANs)",
|
||||
"case": "our CA, CN=api (SAN not allowed)",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake"
|
||||
],
|
||||
"observed": "server_rejected_client_cert",
|
||||
"pass": true,
|
||||
"detail": "SSLError: [SSL: SSLV3_ALERT_BAD_CERTIFICATE] ssl/tls alert bad certificate (_ssl.c:2592)"
|
||||
},
|
||||
{
|
||||
"link": "Collector/Grafana/operator -> Prometheus (mTLS + allowed SANs)",
|
||||
"case": "our CA, CN=intruder (SAN not allowed)",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake"
|
||||
],
|
||||
"observed": "server_rejected_client_cert",
|
||||
"pass": true,
|
||||
"detail": "SSLError: [SSL: SSLV3_ALERT_BAD_CERTIFICATE] ssl/tls alert bad certificate (_ssl.c:2592)"
|
||||
},
|
||||
{
|
||||
"link": "Collector/Grafana/operator -> Prometheus (mTLS + allowed SANs)",
|
||||
"case": "no client certificate",
|
||||
"expect": [
|
||||
"server_rejected_client_cert",
|
||||
"connection_closed_after_handshake"
|
||||
],
|
||||
"observed": "server_rejected_client_cert",
|
||||
"pass": true,
|
||||
"detail": "SSLError: [SSL: TLSV13_ALERT_CERTIFICATE_REQUIRED] tlsv13 alert certificate required (_ssl.c:2592)"
|
||||
},
|
||||
{
|
||||
"link": "Collector/Grafana/operator -> Prometheus (mTLS + allowed SANs)",
|
||||
"case": "plaintext client",
|
||||
"expect": [
|
||||
"no_plaintext_service"
|
||||
],
|
||||
"observed": "no_plaintext_service",
|
||||
"pass": true,
|
||||
"detail": "b'HTTP/1.0 400 Bad Request\\r\\n\\r\\nClient sent an HTTP request to a'"
|
||||
},
|
||||
{
|
||||
"link": "Loki/Tempo/Grafana",
|
||||
"case": "not available in the native sandbox",
|
||||
"expect": "skipped",
|
||||
"observed": "skipped",
|
||||
"pass": true,
|
||||
"detail": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
# tls-matrix: lab7: every trust-matrix link from inside — allowed identity passes, no cert / foreign CA / wrong identity / expired fail
|
||||
# date: 2026-11-07 15:07:35, commit: 5bfc53a + uncommitted changes
|
||||
# command: python student-tests/test_tls_matrix.py
|
||||
# exit code: 0, 1.1 s
|
||||
|
||||
|
||||
LB -> API (mTLS, allowlist CN=lb)
|
||||
PASS valid LB identity (CN=lb) -> http_200
|
||||
PASS no client certificate -> connection_closed_after_handshake
|
||||
PASS foreign CA, CN=lb -> connection_closed_after_handshake
|
||||
PASS our CA, expired, CN=lb -> connection_closed_after_handshake
|
||||
PASS our CA, CN=intruder -> connection_closed_after_handshake
|
||||
PASS our CA, CN=worker (other service) -> connection_closed_after_handshake
|
||||
PASS our CA, CN=api (server's own identity) -> connection_closed_after_handshake
|
||||
PASS server identity: client trusts only foreign CA -> client_rejected_server_cert
|
||||
PASS plaintext client -> no_plaintext_service
|
||||
|
||||
API/worker -> RabbitMQ (mTLS + EXTERNAL, CN = broker user)
|
||||
PASS worker identity consumes its queue -> allowed
|
||||
PASS dispatcher identity publishes to exchange -> allowed
|
||||
PASS CN=api (no broker user, API uses outbox) -> login_refused
|
||||
PASS our CA, CN=intruder -> login_refused
|
||||
PASS our CA, CN=lb -> login_refused
|
||||
PASS foreign CA, CN=worker -> server_rejected_client_cert
|
||||
PASS no client certificate -> server_rejected_client_cert
|
||||
PASS worker publishes (not allowed) -> access_refused_403
|
||||
PASS dispatcher consumes main queue (not allowed) -> access_refused_403
|
||||
PASS worker declares a queue (no configure) -> access_refused_403
|
||||
PASS plaintext client -> no_plaintext_service
|
||||
|
||||
API/worker -> OTel Collector (mTLS via otel-gate, allowlist app CNs)
|
||||
PASS CN=api sends OTLP logs -> http_200
|
||||
PASS CN=worker sends OTLP logs -> http_200
|
||||
PASS CN=dispatcher sends OTLP logs -> http_200
|
||||
PASS CN=janitor sends OTLP logs -> http_200
|
||||
PASS our CA, CN=lb (not an app) sends OTLP -> http_403
|
||||
PASS our CA, CN=grafana (not an app) sends OTLP -> http_403
|
||||
PASS our CA, CN=intruder (not an app) sends OTLP -> http_403
|
||||
PASS our CA, CN=operator (not an app) sends OTLP -> http_403
|
||||
PASS foreign CA, CN=worker -> server_rejected_client_cert
|
||||
PASS no client certificate -> server_rejected_client_cert
|
||||
PASS Collector self-metrics, CN=operator -> http_404
|
||||
PASS Collector self-metrics, CN=api (not allowed) -> http_403
|
||||
PASS plaintext client -> no_plaintext_service
|
||||
|
||||
API/worker -> PostgreSQL (TLS verify-full, SCRAM, roles)
|
||||
PASS TLS verify-full with our CA (wrong password on purpose) -> tls_ok_auth_failed
|
||||
PASS plaintext (sslmode=disable) -> rejected_no_tls
|
||||
PASS trust foreign CA only -> client_rejected_server_cert
|
||||
|
||||
API -> Redis (TLS + client cert of our CA + ACL user)
|
||||
PASS our CA client cert, no AUTH -> noauth
|
||||
PASS our CA, AUTH api with a wrong password -> wrongpass
|
||||
PASS no client certificate -> server_rejected_client_cert
|
||||
PASS foreign CA client certificate -> server_rejected_client_cert
|
||||
PASS trust foreign CA only -> client_rejected_server_cert
|
||||
PASS plaintext client -> no_plaintext_service
|
||||
|
||||
API/worker -> S3 (HTTPS + per-service keys by prefix)
|
||||
PASS HTTPS anonymous list (no signature) -> http_403
|
||||
PASS trust foreign CA only -> client_rejected_server_cert
|
||||
PASS plaintext client -> no_plaintext_service
|
||||
PASS S3 gRPC :18333, CN=intruder (our CA) -> server_rejected_client_cert
|
||||
PASS S3 gRPC :18333, CN=api (our CA) -> server_rejected_client_cert
|
||||
PASS S3 gRPC :18333, no client certificate -> server_rejected_client_cert
|
||||
|
||||
Services -> OpenBao (TLS + cert auth by CN + policy)
|
||||
PASS CN=worker logs in as role worker -> http_200
|
||||
PASS CN=worker logs in as role api -> http_400
|
||||
PASS our CA, CN=intruder as role api -> http_400
|
||||
PASS foreign CA, CN=worker as role worker -> http_400
|
||||
PASS no client certificate as role api -> http_400
|
||||
PASS trust foreign CA only -> client_rejected_server_cert
|
||||
PASS plaintext client -> no_plaintext_service
|
||||
|
||||
Collector/Grafana/operator -> Prometheus (mTLS + allowed SANs)
|
||||
PASS CN=operator -> http_200
|
||||
PASS CN=grafana -> http_200
|
||||
PASS CN=otel-collector -> http_200
|
||||
PASS our CA, CN=api (SAN not allowed) -> server_rejected_client_cert
|
||||
PASS our CA, CN=intruder (SAN not allowed) -> server_rejected_client_cert
|
||||
PASS no client certificate -> server_rejected_client_cert
|
||||
PASS plaintext client -> no_plaintext_service
|
||||
|
||||
Loki/Tempo/Grafana
|
||||
PASS not available in the native sandbox -> skipped
|
||||
|
||||
63 checks, 0 failed; saved to /home/claude/work/mtusi2026lab7/evidence/native-sandbox/tls-matrix.json
|
||||
PASS: every link of the trust matrix accepts the allowed identity and rejects the rest
|
||||
Reference in New Issue
Block a user