forked from mtusi2026/mtusi2026lab7
лр7: Docker-прогон, evidence, исправления
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"rows": [
|
||||
{
|
||||
"m_kib": 19456,
|
||||
"t": 2,
|
||||
"p": 1,
|
||||
"hash_ms": 12.2,
|
||||
"verify_ms": 12.2,
|
||||
"max_logins_per_s_per_replica": 163.9
|
||||
},
|
||||
{
|
||||
"m_kib": 19456,
|
||||
"t": 3,
|
||||
"p": 1,
|
||||
"hash_ms": 18.3,
|
||||
"verify_ms": 18.5,
|
||||
"max_logins_per_s_per_replica": 108.1
|
||||
},
|
||||
{
|
||||
"m_kib": 32768,
|
||||
"t": 2,
|
||||
"p": 1,
|
||||
"hash_ms": 22.6,
|
||||
"verify_ms": 22.2,
|
||||
"max_logins_per_s_per_replica": 90.1
|
||||
},
|
||||
{
|
||||
"m_kib": 47104,
|
||||
"t": 2,
|
||||
"p": 1,
|
||||
"hash_ms": 34.2,
|
||||
"verify_ms": 34.8,
|
||||
"max_logins_per_s_per_replica": 57.5
|
||||
},
|
||||
{
|
||||
"m_kib": 65536,
|
||||
"t": 2,
|
||||
"p": 1,
|
||||
"hash_ms": 49.8,
|
||||
"verify_ms": 50.4,
|
||||
"max_logins_per_s_per_replica": 39.7
|
||||
},
|
||||
{
|
||||
"m_kib": 65536,
|
||||
"t": 3,
|
||||
"p": 1,
|
||||
"hash_ms": 75.3,
|
||||
"verify_ms": 75.2,
|
||||
"max_logins_per_s_per_replica": 26.6
|
||||
}
|
||||
],
|
||||
"maxrss_mib": 96.1,
|
||||
"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 19:08:27, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/argon2_bench.py
|
||||
# exit code: 0, 3.9 s
|
||||
|
||||
m (KiB) t p hash ms verify ms logins/s per replica at concurrency 2 RAM for hashing
|
||||
19456 2 1 12.2 12.2 163.9 38 MiB
|
||||
19456 3 1 18.3 18.5 108.1 38 MiB
|
||||
32768 2 1 22.6 22.2 90.1 64 MiB <- current
|
||||
47104 2 1 34.2 34.8 57.5 92 MiB
|
||||
65536 2 1 49.8 50.4 39.7 128 MiB
|
||||
65536 3 1 75.3 75.2 26.6 128 MiB
|
||||
process max RSS during the bench: 96.1 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 19:40:25, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_attachments.py
|
||||
# exit code: 0, 12.8 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 54186d3d
|
||||
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 19:43:46, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_balancing.py
|
||||
# exit code: 0, 3.5 s
|
||||
|
||||
20 x GET /users/me with one token -> replicas: {'f9e5ac61cde6': 10, '708b4b92f569': 10}
|
||||
PASS: one session works on every replica, no second login (sessions are shared in Redis)
|
||||
message written by 708b4b92f569; read back by ['708b4b92f569', 'f9e5ac61cde6']
|
||||
PASS: a message written via one replica is read right away via another (shared PostgreSQL)
|
||||
logout on f9e5ac61cde6; old token then rejected by ['708b4b92f569', 'f9e5ac61cde6']
|
||||
PASS: logout on one replica revokes the session on all of them
|
||||
first POST on f9e5ac61cde6 -> 201 b67e1df0-7002-437c-ba25-1ca953b58180; same key on 708b4b92f569 -> 201 b67e1df0-7002-437c-ba25-1ca953b58180
|
||||
PASS: Idempotency-Key is shared: a retry through another replica returns the same message
|
||||
file uploaded via f9e5ac61cde6; downloaded byte for byte via ['708b4b92f569', 'f9e5ac61cde6']
|
||||
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 ['708b4b92f569', 'f9e5ac61cde6']; api containers -> aliases: {'0c7893e1043d': '708b4b92f569', 'b7f37f051ba1': 'f9e5ac61cde6'}
|
||||
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 19:07:13, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe scripts/check_contract.py
|
||||
# exit code: 0, 0.2 s
|
||||
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
@@ -0,0 +1,34 @@
|
||||
# configs: lab6: collector/prometheus/loki/tempo configs by their own tools, alert unit tests, Grafana provisioning
|
||||
# date: 2026-11-07 19:12:52, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/check_configs.py
|
||||
# exit code: 0, 5.7 s
|
||||
|
||||
--- otelcol-contrib validate (infra/otel/collector.yaml): exit 0
|
||||
|
||||
--- promtool check config (infra/prometheus/prometheus.yml): exit 0
|
||||
|
||||
Checking /etc/prometheus/rules/alerts.yml
|
||||
SUCCESS: 6 rules found
|
||||
|
||||
Checking /etc/prometheus/rules/recording.yml
|
||||
SUCCESS: 10 rules found
|
||||
--- promtool check rules (recording + alerts): exit 0
|
||||
Checking /etc/prometheus/rules/alerts.yml
|
||||
SUCCESS: 6 rules found
|
||||
|
||||
Checking /etc/prometheus/rules/recording.yml
|
||||
SUCCESS: 10 rules found
|
||||
--- promtool check web-config (lab7: TLS, client certs, allowed SANs): exit 0
|
||||
/etc/prometheus/web.yml SUCCESS
|
||||
--- promtool test rules (unit tests of alert thresholds/windows/for): exit 0
|
||||
SUCCESS
|
||||
--- loki -verify-config (infra/loki/loki.yaml): exit 0
|
||||
|
||||
--- tempo -config.verify (infra/tempo/tempo.yaml): exit 0
|
||||
|
||||
--- Grafana 12.4.14: database ok
|
||||
datasource prometheus (prometheus): OK Successfully queried the Prometheus API.
|
||||
datasource loki (loki): OK Data source successfully connected.
|
||||
datasource tempo (tempo): OK Data source is working
|
||||
dashboard 'Messenger — lab6 observability' in folder 'Messenger': 34 panels, provisioned=True, datasources ['loki', 'prometheus', 'tempo']
|
||||
PASS: collector, prometheus (config, rules, unit tests), loki and tempo configs are valid; Grafana provisioned 3 healthy datasources and the dashboard without manual steps
|
||||
@@ -0,0 +1,47 @@
|
||||
# consistency: lab4: aborted upload, crash between S3 and DB, janitor, orphans, S3 outage
|
||||
# date: 2026-11-07 19:42:46, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_consistency.py
|
||||
# exit code: 0, 131.5 s
|
||||
|
||||
declared 9 000 000 bytes, sent 211817, closed the connection
|
||||
declared 9 000 000 bytes, sent 3111817, closed the connection
|
||||
rows in attachments: 481 -> 481; objects in bucket: 1886 -> 1886
|
||||
temporary upload files in api containers: {'b7f37f051ba1': 0, '0c7893e1043d': 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 aa892679 state=uploading, object staging/a6d6cacccc714e1683e0cbf58f6c3bb8 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": 1891, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 2, "seconds": 0.698} -> 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": 1891, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 2, "seconds": 0.695} -> 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": 1890, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 2, "seconds": 0.691} -> 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": 1890, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 2, "seconds": 0.599} -> 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/71f7fcf571ca43e18de2aa82aac94d8e put into the bucket without a row in PostgreSQL
|
||||
janitor --grace-seconds 3 immediately: {"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": 1895, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 2, "seconds": 0.689} -> 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": 1895, "orphan_objects": 1, "orphan_objects_deleted": 0, "missing_objects": 2, "seconds": 0.793} -> 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": 1895, "orphan_objects": 1, "orphan_objects_deleted": 1, "missing_objects": 2, "seconds": 0.678} -> 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=3 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 781 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 (14.7 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": 1905, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 3, "seconds": 0.695}
|
||||
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 8703 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": 1914, "orphan_objects": 0, "orphan_objects_deleted": 0, "missing_objects": 3, "seconds": 0.685}
|
||||
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,36 @@
|
||||
# dashboard: lab6: every dashboard/rule query runs on live data, key signals present, no forbidden labels
|
||||
# date: 2026-11-07 19:14:22, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/check_dashboard.py
|
||||
# exit code: 0, 2.7 s
|
||||
|
||||
PromQL: 54 dashboard expressions + 16 rule expressions executed, 0 errors, 15 empty now (no traffic of that kind / Docker-only / no incident)
|
||||
empty now: CPU контейнеров / лимит
|
||||
empty now: Collector: потери и отказы
|
||||
empty now: SDK приложений: экспорт и потери
|
||||
empty now: alerts.yml: MessengerDbPoolSaturated
|
||||
empty now: alerts.yml: MessengerHighErrorRate
|
||||
empty now: alerts.yml: MessengerQueueLagGrowing
|
||||
empty now: alerts.yml: MessengerWorkerNoConsumers
|
||||
empty now: alerts.yml: TelemetryCollectorDown
|
||||
empty now: alerts.yml: TelemetryExportFailing
|
||||
empty now: Алерты Prometheus (pending/firing)
|
||||
empty now: Память: RSS процесса и контейнер
|
||||
LogQL ok: Предупреждения и ошибки (Loki): {service_name=~"messenger-.*"} | detected_level=~"warn|error"
|
||||
TraceQL ok: Трассы с ошибками (Tempo, TraceQL): { status = error } -> 5 trace(s)
|
||||
|
||||
data: http_server_request_duration_seconds_count{job="messenger-api"} 54 series <- HTTP requests/duration (3)
|
||||
data: messenger_job_duration_seconds_count 3 series <- jobs processed/failed + duration (3)
|
||||
data: messenger_attachment_time_to_ready_seconds_count 1 series <- end-to-end time to ready (4)
|
||||
data: messenger_queue_depth 2 series <- queue depth (4)
|
||||
data: messenger_queue_oldest_age_seconds 1 series <- oldest job age (4)
|
||||
data: db_client_connection_count 6 series <- DB pool used/idle (4)
|
||||
data: db_client_connection_pending_requests 3 series <- DB pool waiting (4)
|
||||
data: messenger_worker_busy 1 series <- worker busy (4)
|
||||
data: messenger_worker_capacity 1 series <- worker capacity (4)
|
||||
data: process_cpu_time_seconds_total 16 series <- process CPU (4)
|
||||
data: process_memory_usage_bytes 8 series <- process RAM (4)
|
||||
data: otelcol_exporter_queue_size 3 series <- collector queue (4)
|
||||
|
||||
labels used by application metrics: __name__, bao_role, cpu_mode, db_client_connection_pool_name, db_client_connection_state, deployment_environment_name, error_type, http_request_method, http_response_status_class, http_response_status_code, http_route, instance, job, job_type, le, messaging_destination_name, messenger_rate_limit, otel_component_name, otel_component_type, otel_span_parent_origin, otel_span_sampling_result, outcome, server_address, server_port, service_version, status, telemetry_sdk_language, telemetry_sdk_name, telemetry_sdk_version
|
||||
http_route values (templates, not URLs): ['/api/v1/attachments/{attachment_id}', '/api/v1/attachments/{attachment_id}/content', '/api/v1/auth/sessions', '/api/v1/auth/sessions/current', '/api/v1/chats', '/api/v1/chats/{chat_id}', '/api/v1/chats/{chat_id}/attachments', '/api/v1/chats/{chat_id}/messages', '/api/v1/users', '/api/v1/users/me', '/health/live', '/health/ready']
|
||||
PASS: every dashboard/rule query runs, key signals have data, no forbidden labels
|
||||
@@ -0,0 +1,21 @@
|
||||
# db: PostgreSQL: rollback, FK, Argon2id, unique keys, migrations
|
||||
# date: 2026-11-07 19:44:08, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_db.py
|
||||
# exit code: 0, 11.1 s
|
||||
|
||||
chat with unknown member -> 400; rows with this title: 0; chats without members: 0; chats insert counter: 389 -> 390
|
||||
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: 11; api log lines 'Migrations applied': 0; migrate service: Exited (0) 3 minutes ago
|
||||
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,112 @@
|
||||
=== Data volume
|
||||
messages_total | messages_in_big_chat
|
||||
----------------+----------------------
|
||||
141938 | 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.007..0.018 rows=51 loops=1)
|
||||
Buffers: shared hit=54
|
||||
-> Index Scan using messages_history on messages (actual time=0.007..0.015 rows=51 loops=1)
|
||||
Index Cond: (chat_id = '1efc622c-6386-4403-a0dc-6d7e17977038'::uuid)
|
||||
Buffers: shared hit=54
|
||||
Planning:
|
||||
Buffers: shared hit=7
|
||||
Planning Time: 0.066 ms
|
||||
Execution Time: 0.026 ms
|
||||
|
||||
|
||||
=== 2. Page after the 10000th message by keyset cursor (this is what the app does)
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (actual time=0.027..0.041 rows=51 loops=1)
|
||||
Buffers: shared hit=4
|
||||
-> Index Scan using messages_history on messages (actual time=0.026..0.036 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = '1efc622c-6386-4403-a0dc-6d7e17977038'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 02:46:40+00'::timestamp with time zone, 'cc573555-8177-419f-a1b0-2b402c9b73d3'::uuid)))
|
||||
Buffers: shared hit=4
|
||||
Planning Time: 0.084 ms
|
||||
Execution Time: 0.098 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.021..0.177 rows=51 loops=1)
|
||||
Buffers: shared hit=58
|
||||
-> Index Scan using messages_history on messages m (actual time=0.021..0.174 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = '1efc622c-6386-4403-a0dc-6d7e17977038'::uuid) AND (ROW(created_at, id) > ROW('2026-09-01 02:46:40+00'::timestamp with time zone, 'cc573555-8177-419f-a1b0-2b402c9b73d3'::uuid)))
|
||||
Buffers: shared hit=58
|
||||
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.000..0.000 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.164 ms
|
||||
Execution Time: 0.219 ms
|
||||
|
||||
|
||||
=== 3. The same page with OFFSET 10000 (the app does NOT do this)
|
||||
QUERY PLAN
|
||||
-------------------------------------------------------------------------------------------------------
|
||||
Limit (actual time=3.398..3.401 rows=51 loops=1)
|
||||
Buffers: shared hit=2553
|
||||
-> Sort (actual time=3.012..3.217 rows=10051 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: quicksort Memory: 2377kB
|
||||
Buffers: shared hit=2553
|
||||
-> Bitmap Heap Scan on messages (actual time=0.608..1.680 rows=15000 loops=1)
|
||||
Recheck Cond: (chat_id = '1efc622c-6386-4403-a0dc-6d7e17977038'::uuid)
|
||||
Heap Blocks: exact=2359
|
||||
Buffers: shared hit=2553
|
||||
-> Bitmap Index Scan on messages_history (actual time=0.458..0.458 rows=15000 loops=1)
|
||||
Index Cond: (chat_id = '1efc622c-6386-4403-a0dc-6d7e17977038'::uuid)
|
||||
Buffers: shared hit=194
|
||||
Planning Time: 0.036 ms
|
||||
Execution Time: 3.484 ms
|
||||
|
||||
|
||||
=== 4. Query 2 without the index (index is dropped only inside this transaction)
|
||||
QUERY PLAN
|
||||
-----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (actual time=1.636..1.639 rows=51 loops=1)
|
||||
Buffers: shared hit=2375
|
||||
-> Sort (actual time=1.635..1.637 rows=51 loops=1)
|
||||
Sort Key: created_at, id
|
||||
Sort Method: top-N heapsort Memory: 31kB
|
||||
Buffers: shared hit=2375
|
||||
-> Bitmap Heap Scan on messages (actual time=1.034..1.289 rows=5000 loops=1)
|
||||
Recheck Cond: (chat_id = '1efc622c-6386-4403-a0dc-6d7e17977038'::uuid)
|
||||
Filter: (ROW(created_at, id) > ROW('2026-09-01 02:46:40+00'::timestamp with time zone, 'cc573555-8177-419f-a1b0-2b402c9b73d3'::uuid))
|
||||
Rows Removed by Filter: 10000
|
||||
Heap Blocks: exact=2359
|
||||
Buffers: shared hit=2375
|
||||
-> Bitmap Index Scan on messages_idempotency_key (actual time=0.303..0.303 rows=15000 loops=1)
|
||||
Index Cond: (chat_id = '1efc622c-6386-4403-a0dc-6d7e17977038'::uuid)
|
||||
Buffers: shared hit=16
|
||||
Planning:
|
||||
Buffers: shared hit=4
|
||||
Planning Time: 0.099 ms
|
||||
Execution Time: 1.665 ms
|
||||
|
||||
|
||||
=== ROLLBACK: test data removed, index is back
|
||||
explain_users_left
|
||||
--------------------
|
||||
0
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# explain: EXPLAIN of the history page (full plans: explain-history.txt)
|
||||
# date: 2026-11-07 19:44:13, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/explain.py
|
||||
# exit code: 0, 0.8 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=54
|
||||
-> Index Scan using messages_history on messages (actual time=0.007..0.015 rows=51 loops=1)
|
||||
Buffers: shared hit=54
|
||||
Buffers: shared hit=7
|
||||
Execution Time: 0.026 ms
|
||||
=== 2. Page after the 10000th message by keyset cursor (this is what the app does)
|
||||
Buffers: shared hit=4
|
||||
-> Index Scan using messages_history on messages (actual time=0.026..0.036 rows=51 loops=1)
|
||||
Buffers: shared hit=4
|
||||
Execution Time: 0.098 ms
|
||||
=== 2b. The same page exactly as the app sends it since lab4: with attachment_ids of every message
|
||||
Buffers: shared hit=58
|
||||
-> Index Scan using messages_history on messages m (actual time=0.021..0.174 rows=51 loops=1)
|
||||
Buffers: shared hit=58
|
||||
Buffers: shared hit=54
|
||||
-> Bitmap Heap Scan on message_attachments a (actual time=0.000..0.000 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.219 ms
|
||||
=== 3. The same page with OFFSET 10000 (the app does NOT do this)
|
||||
Buffers: shared hit=2553
|
||||
Buffers: shared hit=2553
|
||||
-> Bitmap Heap Scan on messages (actual time=0.608..1.680 rows=15000 loops=1)
|
||||
Buffers: shared hit=2553
|
||||
-> Bitmap Index Scan on messages_history (actual time=0.458..0.458 rows=15000 loops=1)
|
||||
Buffers: shared hit=194
|
||||
Execution Time: 3.484 ms
|
||||
=== 4. Query 2 without the index (index is dropped only inside this transaction)
|
||||
Buffers: shared hit=2375
|
||||
Buffers: shared hit=2375
|
||||
-> Bitmap Heap Scan on messages (actual time=1.034..1.289 rows=5000 loops=1)
|
||||
Buffers: shared hit=2375
|
||||
-> Bitmap Index Scan on messages_idempotency_key (actual time=0.303..0.303 rows=15000 loops=1)
|
||||
Buffers: shared hit=16
|
||||
Buffers: shared hit=4
|
||||
Execution Time: 1.665 ms
|
||||
=== ROLLBACK: test data removed, index is back
|
||||
PASS: full plans saved to evidence\explain-history.txt
|
||||
@@ -0,0 +1,33 @@
|
||||
# failover: public failover test for every replica, file downloaded via the other one (make test-failover)
|
||||
# date: 2026-11-07 19:45:00, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/run_failover.py
|
||||
# exit code: 0, 46.3 s
|
||||
|
||||
hook: scripts\stop-one.cmd; api replicas: ['0c7893e1043d', 'b7f37f051ba1']
|
||||
=== run 1: api containers before
|
||||
SERVICE CONTAINER ID STATUS
|
||||
api b7f37f051ba1 Up 49 seconds (healthy)
|
||||
api 0c7893e1043d Up 49 seconds (healthy)
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 126, "failed_attempts": 0, "first_recovery_seconds": 5.453}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
api containers after
|
||||
SERVICE CONTAINER ID STATUS
|
||||
api b7f37f051ba1 Up About a minute (healthy)
|
||||
api 0c7893e1043d Exited (0) 11 seconds ago
|
||||
the hook stopped 0c7893e1043d (the replica behind TARGET_INSTANCE_ID, mapped from its alias); other api containers kept running, postgres/redis/lb were not touched
|
||||
restored: docker start 0c7893e1043d -> healthy and back in HAProxy
|
||||
=== run 2: api containers before
|
||||
SERVICE CONTAINER ID STATUS
|
||||
api b7f37f051ba1 Up About a minute (healthy)
|
||||
api 0c7893e1043d Up 5 seconds (healthy)
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 125, "failed_attempts": 0, "first_recovery_seconds": 5.313}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
api containers after
|
||||
SERVICE CONTAINER ID STATUS
|
||||
api b7f37f051ba1 Exited (0) 11 seconds ago
|
||||
api 0c7893e1043d Up 23 seconds (healthy)
|
||||
the hook stopped b7f37f051ba1 (the replica behind TARGET_INSTANCE_ID, mapped from its alias); other api containers kept running, postgres/redis/lb were not touched
|
||||
restored: docker start b7f37f051ba1 -> 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 19:46:03, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_failures.py
|
||||
# exit code: 0, 32.4 s
|
||||
|
||||
stopping redis
|
||||
/health/live -> 200, /health/ready -> 503 (0 ms)
|
||||
valid token: GET /users/me -> 503 unavailable (16 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 (1016 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,28 @@
|
||||
# hardening: lab7: no privileged/host net/docker.sock, caps dropped, no-new-privileges, read-only, non-root, limits, ports
|
||||
# date: 2026-11-07 19:07:19, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/check_hardening.py --runtime
|
||||
# exit code: 0, 0.8 s
|
||||
|
||||
EXCEPTION otel-collector network network_mode service:otel-gate — общий namespace с mTLS-шлюзом, Collector слушает только 127.0.0.1
|
||||
EXCEPTION rabbitmq read_only Erlang/RabbitMQ пишет cookie, схему и plugins-expand в /var/lib/rabbitmq и служебные файлы в /etc/rabbitmq при старте; данные — в volume, корень остав
|
||||
EXCEPTION telemetry-init cap_add одноразовый chown volumes Loki/Tempo для uid 10001: только CAP_CHOWN, без сети (network_mode none), сразу завершается
|
||||
EXCEPTION telemetry-init non_root chown требует uid 0 (+CAP_CHOWN)
|
||||
static: {'PASS': 183, 'EXCEPTION': 4, 'FAIL': 0}
|
||||
runtime api user=10001:10001 ro=True priv=False capdrop=['ALL'] capadd=None nnp=True mem=536870912 pids=256 ports=[]
|
||||
runtime api user=10001:10001 ro=True priv=False capdrop=['ALL'] capadd=None nnp=True mem=536870912 pids=256 ports=[]
|
||||
runtime dispatcher user=10001:10001 ro=True priv=False capdrop=['ALL'] capadd=None nnp=True mem=134217728 pids=256 ports=[]
|
||||
runtime grafana user=472 ro=True priv=False capdrop=['ALL'] capadd=None nnp=True mem=402653184 pids=256 ports=['3000/tcp']
|
||||
runtime janitor user=10001:10001 ro=True priv=False capdrop=['ALL'] capadd=None nnp=True mem=201326592 pids=256 ports=[]
|
||||
runtime lb user=haproxy ro=True priv=False capdrop=['ALL'] capadd=None nnp=True mem=134217728 pids=256 ports=['8404/tcp', '8443/tcp']
|
||||
runtime loki user=10001 ro=True priv=False capdrop=['ALL'] capadd=None nnp=True mem=536870912 pids=256 ports=['3100/tcp']
|
||||
runtime openbao user=100 ro=True priv=False capdrop=['ALL'] capadd=None nnp=True mem=268435456 pids=256 ports=['8200/tcp']
|
||||
runtime otel-collector user=10001:10001 ro=True priv=False capdrop=['ALL'] capadd=None nnp=True mem=402653184 pids=256 ports=[]
|
||||
runtime otel-gate user=haproxy ro=True priv=False capdrop=['ALL'] capadd=None nnp=True mem=67108864 pids=256 ports=[]
|
||||
runtime postgres user=70:70 ro=True priv=False capdrop=['ALL'] capadd=None nnp=True mem=536870912 pids=256 ports=[]
|
||||
runtime prometheus user=nobody ro=True priv=False capdrop=['ALL'] capadd=None nnp=True mem=536870912 pids=256 ports=['9090/tcp']
|
||||
runtime rabbitmq user=rabbitmq ro=False priv=False capdrop=['ALL'] capadd=None nnp=True mem=536870912 pids=512 ports=[]
|
||||
runtime redis user=999:1000 ro=True priv=False capdrop=['ALL'] capadd=None nnp=True mem=134217728 pids=256 ports=[]
|
||||
runtime s3 user=1000:1000 ro=True priv=False capdrop=['ALL'] capadd=None nnp=True mem=536870912 pids=256 ports=[]
|
||||
runtime tempo user=10001:10001 ro=True priv=False capdrop=['ALL'] capadd=None nnp=True mem=536870912 pids=256 ports=['3200/tcp']
|
||||
runtime worker user=10001:10001 ro=True priv=False capdrop=['ALL'] capadd=None nnp=True mem=1610612736 pids=128 ports=[]
|
||||
PASS: no privileged/host network/docker.sock; caps dropped; no-new-privileges; read-only roots; non-root; CPU/RAM/PID limits; only 127.0.0.1 ports — exceptions are explained
|
||||
@@ -0,0 +1,22 @@
|
||||
# idempotency: Idempotency-Key, parallel same key via replicas
|
||||
# date: 2026-11-07 19:43:50, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_idempotency.py
|
||||
# exit code: 0, 4.0 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 {'f9e5ac61cde6': 10, '708b4b92f569': 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,39 @@
|
||||
{
|
||||
"scenario": "collector-down",
|
||||
"date": "2026-11-07 19:27:10",
|
||||
"outage_s": 90,
|
||||
"baseline": {
|
||||
"requests": 796,
|
||||
"codes": {
|
||||
"201": 796
|
||||
},
|
||||
"success_ratio": 1.0,
|
||||
"success_rps": 53.1,
|
||||
"p95_ms_successful": 32.0
|
||||
},
|
||||
"during": {
|
||||
"requests": 5298,
|
||||
"codes": {
|
||||
"201": 5298
|
||||
},
|
||||
"success_ratio": 1.0,
|
||||
"success_rps": 53.3,
|
||||
"p95_ms_successful": 32.0
|
||||
},
|
||||
"api_mib_before": 831.6,
|
||||
"api_mib_max": 866.4,
|
||||
"sdk_lost_spans_api": {
|
||||
"processor_queue_full": 0,
|
||||
"exporter_failed": 19456
|
||||
},
|
||||
"sdk_exported_ok_after_restart": 5554,
|
||||
"after": {
|
||||
"requests": 1347,
|
||||
"codes": {
|
||||
"201": 1347
|
||||
},
|
||||
"success_ratio": 1.0,
|
||||
"success_rps": 53.7,
|
||||
"p95_ms_successful": 32.0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
# incident-collector: lab6: Collector down -> API unaffected, SDK queue bounded, drops counted
|
||||
# date: 2026-11-07 19:29:44, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/incidents.py collector-down
|
||||
# exit code: 0, 154.3 s
|
||||
|
||||
=== collector-down
|
||||
[ 24.6s] baseline: {'requests': 796, 'codes': {'201': 796}, 'success_ratio': 1.0, 'success_rps': 53.1, 'p95_ms_successful': 32.0}, api containers 831.6 MiB
|
||||
[ 25.1s] docker compose stop otel-collector
|
||||
[ 29.1s] {'t': 0.5, 'api_mib': 788.1}
|
||||
[ 43.1s] {'t': 14.5, 'api_mib': 850.0}
|
||||
[ 57.1s] {'t': 28.5, 'api_mib': 862.5}
|
||||
[ 71.1s] {'t': 42.5, 'api_mib': 866.4}
|
||||
[ 85.7s] {'t': 56.4, 'api_mib': 857.3}
|
||||
[ 99.7s] {'t': 71.1, 'api_mib': 846.4}
|
||||
[ 113.7s] {'t': 85.0, 'api_mib': 829.6}
|
||||
[ 124.1s] docker compose start otel-collector
|
||||
[ 154.2s] API during collector outage: {'requests': 5298, 'codes': {'201': 5298}, 'success_ratio': 1.0, 'success_rps': 53.3, 'p95_ms_successful': 32.0}; api memory 831.6 -> max 866.4 MiB; SDK lost spans (api): {'processor_queue_full': 0, 'exporter_failed': 19456}; exported OK in the last minute after restart: 5554
|
||||
[ 154.2s] saved C:\Users\Gigabyte\Desktop\lab7\mtusi2026lab7\evidence\incident-collector-down.json
|
||||
PASS: Collector down -> API unaffected, SDK memory bounded, lost spans counted, export resumes after start
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"scenario": "db-slow",
|
||||
"date": "2026-11-07 19:17:54",
|
||||
"lock_seconds": 210,
|
||||
"baseline": {
|
||||
"requests": 2042,
|
||||
"codes": {
|
||||
"201": 2042
|
||||
},
|
||||
"success_ratio": 1.0,
|
||||
"success_rps": 102.1,
|
||||
"p95_ms_successful": 32.0,
|
||||
"server_p95_s": 0.0236
|
||||
},
|
||||
"firing_after_lock_s": 122.5,
|
||||
"diagnosis": {
|
||||
"http_5xx_ratio_1m": 1.0,
|
||||
"http_p95_messages_s": 7.375,
|
||||
"pool_used": 8.0,
|
||||
"pool_wait_p95_s": 0.001,
|
||||
"status_codes_1m": {
|
||||
"201": 0.0,
|
||||
"200": 0.0,
|
||||
"400": 0.0,
|
||||
"409": 0.0,
|
||||
"404": 0.0,
|
||||
"503": 1.44
|
||||
},
|
||||
"reads_during_lock_ms": {
|
||||
"GET /users/me + GET /chats, avg per request": 15.6,
|
||||
"max": 31.5
|
||||
},
|
||||
"api_log_db_unavailable_by_error_type": {
|
||||
"QueryCanceled": 184
|
||||
},
|
||||
"error_trace": {
|
||||
"trace_id": "50418f127c336af7f2e4dc0190adf7ea",
|
||||
"server_ms": 5010.0,
|
||||
"slowest_db_span": "INSERT",
|
||||
"slowest_db_ms": 5001.6,
|
||||
"db_span_status": "ERROR",
|
||||
"db_share": 0.998,
|
||||
"tree": [
|
||||
"- [api] POST /api/v1/chats/{chat_id}/messages (SERVER, 5010.0 ms) ERROR http.response.status_code=503 error.type=503",
|
||||
" - [api] redis GET (CLIENT, 1.5 ms)",
|
||||
" - [api] SELECT (CLIENT, 0.6 ms)",
|
||||
" - [api] INSERT (CLIENT, 5001.6 ms) ERROR"
|
||||
]
|
||||
},
|
||||
"handler_cpu_contrast": {
|
||||
"trace_id": "2e774b9d5912ba768f3e9881f3c41e80",
|
||||
"server_ms": 47.0,
|
||||
"argon2id_ms": 32.2,
|
||||
"db_ms_total": 6.9,
|
||||
"tree": [
|
||||
"- [api] POST /api/v1/users (SERVER, 47.0 ms) http.response.status_code=201",
|
||||
" - [api] redis INCR (CLIENT, 6.2 ms)",
|
||||
" - [api] argon2id hash (INTERNAL, 32.2 ms)",
|
||||
" - [api] INSERT (CLIENT, 0.7 ms)"
|
||||
]
|
||||
}
|
||||
},
|
||||
"during_lock": {
|
||||
"requests": 328,
|
||||
"codes": {
|
||||
"503": 320,
|
||||
"201": 8
|
||||
},
|
||||
"success_ratio": 0.0244,
|
||||
"success_rps": 0.0,
|
||||
"p95_ms_successful": 2031.0
|
||||
},
|
||||
"resolved_after_unlock_s": 35.1,
|
||||
"after": {
|
||||
"requests": 3086,
|
||||
"codes": {
|
||||
"201": 3086
|
||||
},
|
||||
"success_ratio": 1.0,
|
||||
"success_rps": 102.4,
|
||||
"p95_ms_successful": 32.0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
# incident-db: lab6 incident 2: slow PostgreSQL (table lock) -> high error rate firing, cause from traces -> resolved
|
||||
# date: 2026-11-07 19:22:25, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/incidents.py db-slow
|
||||
# exit code: 0, 271.0 s
|
||||
|
||||
=== db-slow
|
||||
[ 0.1s] load: 8 threads POST /messages
|
||||
[ 25.2s] baseline: {'requests': 2042, 'codes': {'201': 2042}, 'success_ratio': 1.0, 'success_rps': 102.1, 'p95_ms_successful': 32.0, 'server_p95_s': 0.0236}
|
||||
[ 25.2s] LOCK TABLE messages IN ACCESS EXCLUSIVE MODE for 210 s (PostgreSQL alive, writes wait)
|
||||
[ 25.3s] 5xx ratio=0.0 p95=0.024 s pool used=0.0 waiting=0.0
|
||||
[ 30.4s] 5xx ratio=0.0 p95=0.024 s pool used=0.0 waiting=0.0
|
||||
[ 35.5s] 5xx ratio=0.0 p95=0.024 s pool used=8.0 waiting=0.0
|
||||
[ 40.6s] 5xx ratio=0.0 p95=0.024 s pool used=8.0 waiting=0.0
|
||||
[ 45.7s] 5xx ratio=0.0 p95=0.024 s pool used=8.0 waiting=0.0
|
||||
[ 50.7s] 5xx ratio=0.0 p95=0.024 s pool used=8.0 waiting=0.0
|
||||
[ 55.8s] 5xx ratio=0.0 p95=0.024 s pool used=8.0 waiting=0.0
|
||||
[ 60.9s] 5xx ratio=0.008 p95=0.024 s pool used=8.0 waiting=0.0
|
||||
[ 66.0s] 5xx ratio=0.008 p95=0.025 s pool used=8.0 waiting=0.0
|
||||
[ 71.1s] 5xx ratio=0.008 p95=0.025 s pool used=8.0 waiting=0.0
|
||||
[ 76.3s] 5xx ratio=0.016 p95=6.67 s pool used=8.0 waiting=0.0
|
||||
[ 81.4s] 5xx ratio=0.016 p95=6.737 s pool used=8.0 waiting=0.0
|
||||
[ 86.5s] 5xx ratio=0.016 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 91.6s] 5xx ratio=0.14 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 96.7s] 5xx ratio=0.14 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 101.8s] 5xx ratio=0.14 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 106.9s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 112.0s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 117.1s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 122.2s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 127.4s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 132.5s] 5xx ratio=1.0 p95=7.375 s pool used=8.0 waiting=0.0
|
||||
[ 137.6s] 5xx ratio=1.0 p95=7.375 s pool used=2.0 waiting=0.0
|
||||
[ 142.7s] 5xx ratio=1.0 p95=7.375 s pool used=2.0 waiting=0.0
|
||||
[ 147.7s] ALERT MessengerHighErrorRate firing (122.5 s after lock)
|
||||
[ 152.2s] diagnosis: {"http_5xx_ratio_1m": 1.0, "http_p95_messages_s": 7.375, "pool_used": 8.0, "pool_wait_p95_s": 0.001, "status_codes_1m": {"201": 0.0, "200": 0.0, "400": 0.0, "409": 0.0, "404": 0.0, "503": 1.44}, "reads_during_lock_ms": {"GET /users/me + GET /chats, avg per request": 15.6, "max": 31.5}, "api_log_db_unavailable_by_error_type": {"QueryCanceled": 184}}
|
||||
[ 152.2s] error trace (DB): {"trace_id": "50418f127c336af7f2e4dc0190adf7ea", "server_ms": 5010.0, "slowest_db_span": "INSERT", "slowest_db_ms": 5001.6, "db_span_status": "ERROR", "db_share": 0.998}
|
||||
- [api] POST /api/v1/chats/{chat_id}/messages (SERVER, 5010.0 ms) ERROR http.response.status_code=503 error.type=503
|
||||
- [api] redis GET (CLIENT, 1.5 ms)
|
||||
- [api] SELECT (CLIENT, 0.6 ms)
|
||||
- [api] INSERT (CLIENT, 5001.6 ms) ERROR
|
||||
[ 152.2s] contrast, slow handler (CPU): {"trace_id": "2e774b9d5912ba768f3e9881f3c41e80", "server_ms": 47.0, "argon2id_ms": 32.2, "db_ms_total": 6.9}
|
||||
- [api] POST /api/v1/users (SERVER, 47.0 ms) http.response.status_code=201
|
||||
- [api] redis INCR (CLIENT, 6.2 ms)
|
||||
- [api] argon2id hash (INTERNAL, 32.2 ms)
|
||||
- [api] INSERT (CLIENT, 0.7 ms)
|
||||
[ 235.7s] lock released (psql exit 0), 210.5 s after LOCK
|
||||
[ 235.7s] ... MessengerHighErrorRate: firing (0 s)
|
||||
[ 240.7s] ... MessengerHighErrorRate: firing (5 s)
|
||||
[ 245.8s] ... MessengerHighErrorRate: firing (10 s)
|
||||
[ 250.8s] ... MessengerHighErrorRate: firing (15 s)
|
||||
[ 255.8s] ... MessengerHighErrorRate: firing (20 s)
|
||||
[ 260.8s] ... MessengerHighErrorRate: firing (25 s)
|
||||
[ 265.8s] ... MessengerHighErrorRate: firing (30 s)
|
||||
[ 270.8s] ALERT MessengerHighErrorRate resolved 35.1 s after unlock
|
||||
[ 270.8s] load: during lock {'requests': 328, 'codes': {'503': 320, '201': 8}, 'success_ratio': 0.0244, 'success_rps': 0.0, 'p95_ms_successful': 2031.0}; after {'requests': 3086, 'codes': {'201': 3086}, 'success_ratio': 1.0, 'success_rps': 102.4, 'p95_ms_successful': 32.0}
|
||||
[ 270.9s] saved C:\Users\Gigabyte\Desktop\lab7\mtusi2026lab7\evidence\incident-db-slow.json
|
||||
PASS: slow DB -> 503 -> MessengerHighErrorRate firing; traces show the time in the INSERT span (not the handler); unlock -> resolved
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,273 @@
|
||||
{
|
||||
"scenario": "telemetry-down",
|
||||
"date": "2026-11-07 19:22:25",
|
||||
"stopped": [
|
||||
"tempo",
|
||||
"loki"
|
||||
],
|
||||
"outage_s": 150,
|
||||
"baseline": {
|
||||
"requests": 793,
|
||||
"codes": {
|
||||
"201": 793
|
||||
},
|
||||
"success_ratio": 1.0,
|
||||
"success_rps": 52.9,
|
||||
"p95_ms_successful": 32.0
|
||||
},
|
||||
"collector_heap_before_mib": 32.3,
|
||||
"collector_container_before_mib": 76.9,
|
||||
"during": {
|
||||
"requests": 8486,
|
||||
"codes": {
|
||||
"201": 8486
|
||||
},
|
||||
"success_ratio": 1.0,
|
||||
"success_rps": 52.9,
|
||||
"p95_ms_successful": 32.0
|
||||
},
|
||||
"samples": [
|
||||
{
|
||||
"t": 0.0,
|
||||
"collector_heap_mib": 51.5,
|
||||
"collector_rss_mib": 237.8,
|
||||
"collector_container_mib": 76.9,
|
||||
"queue": {
|
||||
"otlp_http/loki": 16.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 7.0
|
||||
},
|
||||
"alert": "inactive"
|
||||
},
|
||||
{
|
||||
"t": 12.1,
|
||||
"collector_heap_mib": 60.3,
|
||||
"collector_rss_mib": 237.8,
|
||||
"collector_container_mib": 76.9,
|
||||
"queue": {
|
||||
"otlp_http/loki": 16.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 7.0
|
||||
},
|
||||
"alert": "inactive"
|
||||
},
|
||||
{
|
||||
"t": 24.8,
|
||||
"collector_heap_mib": 44.3,
|
||||
"collector_rss_mib": 237.8,
|
||||
"collector_container_mib": 76.9,
|
||||
"queue": {
|
||||
"otlp_http/loki": 23.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 10.0
|
||||
},
|
||||
"alert": "pending"
|
||||
},
|
||||
{
|
||||
"t": 36.9,
|
||||
"collector_heap_mib": 53.4,
|
||||
"collector_rss_mib": 237.8,
|
||||
"collector_container_mib": 77.0,
|
||||
"queue": {
|
||||
"otlp_http/loki": 31.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 13.0
|
||||
},
|
||||
"alert": "pending"
|
||||
},
|
||||
{
|
||||
"t": 49.0,
|
||||
"collector_heap_mib": 62.1,
|
||||
"collector_rss_mib": 239.8,
|
||||
"collector_container_mib": 81.0,
|
||||
"queue": {
|
||||
"otlp_http/loki": 38.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 16.0
|
||||
},
|
||||
"alert": "pending"
|
||||
},
|
||||
{
|
||||
"t": 61.1,
|
||||
"collector_heap_mib": 62.1,
|
||||
"collector_rss_mib": 239.8,
|
||||
"collector_container_mib": 87.1,
|
||||
"queue": {
|
||||
"otlp_http/loki": 46.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 19.0
|
||||
},
|
||||
"alert": "pending"
|
||||
},
|
||||
{
|
||||
"t": 73.8,
|
||||
"collector_heap_mib": 45.9,
|
||||
"collector_rss_mib": 247.8,
|
||||
"collector_container_mib": 87.1,
|
||||
"queue": {
|
||||
"otlp_http/loki": 46.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 19.0
|
||||
},
|
||||
"alert": "pending"
|
||||
},
|
||||
{
|
||||
"t": 85.9,
|
||||
"collector_heap_mib": 54.5,
|
||||
"collector_rss_mib": 247.8,
|
||||
"collector_container_mib": 87.2,
|
||||
"queue": {
|
||||
"otlp_http/loki": 53.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 22.0
|
||||
},
|
||||
"alert": "firing"
|
||||
},
|
||||
{
|
||||
"t": 98.0,
|
||||
"collector_heap_mib": 66.1,
|
||||
"collector_rss_mib": 248.0,
|
||||
"collector_container_mib": 87.3,
|
||||
"queue": {
|
||||
"otlp_http/loki": 59.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 24.0
|
||||
},
|
||||
"alert": "firing"
|
||||
},
|
||||
{
|
||||
"t": 110.0,
|
||||
"collector_heap_mib": 75.7,
|
||||
"collector_rss_mib": 254.0,
|
||||
"collector_container_mib": 95.4,
|
||||
"queue": {
|
||||
"otlp_http/loki": 66.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 27.0
|
||||
},
|
||||
"alert": "firing"
|
||||
},
|
||||
{
|
||||
"t": 122.1,
|
||||
"collector_heap_mib": 84.7,
|
||||
"collector_rss_mib": 262.2,
|
||||
"collector_container_mib": 101.5,
|
||||
"queue": {
|
||||
"otlp_http/loki": 74.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 30.0
|
||||
},
|
||||
"alert": "firing"
|
||||
},
|
||||
{
|
||||
"t": 134.9,
|
||||
"collector_heap_mib": 84.7,
|
||||
"collector_rss_mib": 262.2,
|
||||
"collector_container_mib": 103.7,
|
||||
"queue": {
|
||||
"otlp_http/loki": 81.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 33.0
|
||||
},
|
||||
"alert": "firing"
|
||||
},
|
||||
{
|
||||
"t": 147.0,
|
||||
"collector_heap_mib": 64.8,
|
||||
"collector_rss_mib": 264.2,
|
||||
"collector_container_mib": 103.6,
|
||||
"queue": {
|
||||
"otlp_http/loki": 81.0,
|
||||
"otlp_http/prometheus": 0.0,
|
||||
"otlp_grpc/tempo": 33.0
|
||||
},
|
||||
"alert": "firing"
|
||||
}
|
||||
],
|
||||
"collector_heap_max_mib": 84.7,
|
||||
"collector_rss_max_mib": 264.2,
|
||||
"collector_container_max_mib": 103.7,
|
||||
"TelemetryExportFailing_firing_at_s": 85.9,
|
||||
"queue_drained_after_start_s": 55.3,
|
||||
"probe_traces": [
|
||||
{
|
||||
"sent_at_s": 0.0,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 12.1,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 24.8,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 36.9,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 49.0,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 61.1,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 73.8,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 85.9,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 98.0,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 110.0,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 122.1,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 134.9,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
},
|
||||
{
|
||||
"sent_at_s": 147.0,
|
||||
"http": 201,
|
||||
"trace_in_tempo": true
|
||||
}
|
||||
],
|
||||
"lost_in_collector": {
|
||||
"spans": 2048,
|
||||
"log_records": 213
|
||||
},
|
||||
"resolved_after_start_s": 70.6,
|
||||
"after": {
|
||||
"requests": 3489,
|
||||
"codes": {
|
||||
"201": 3489
|
||||
},
|
||||
"success_ratio": 1.0,
|
||||
"success_rps": 53.2,
|
||||
"p95_ms_successful": 32.0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
# incident-telemetry: lab6: Tempo+Loki down -> API unaffected, collector memory bounded, losses counted
|
||||
# date: 2026-11-07 19:27:09, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/incidents.py telemetry-down
|
||||
# exit code: 0, 284.7 s
|
||||
|
||||
=== telemetry-down
|
||||
[ 22.2s] baseline: {'requests': 793, 'codes': {'201': 793}, 'success_ratio': 1.0, 'success_rps': 52.9, 'p95_ms_successful': 32.0}, collector heap 32.3 MiB, container 76.9 MiB
|
||||
[ 53.5s] docker compose stop tempo loki: stopped
|
||||
[ 55.6s] {'t': 0.0, 'collector_heap_mib': 51.5, 'collector_rss_mib': 237.8, 'collector_container_mib': 76.9, 'queue': {'otlp_http/loki': 16.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 7.0}, 'alert': 'inactive'}
|
||||
[ 68.3s] {'t': 12.1, 'collector_heap_mib': 60.3, 'collector_rss_mib': 237.8, 'collector_container_mib': 76.9, 'queue': {'otlp_http/loki': 16.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 7.0}, 'alert': 'inactive'}
|
||||
[ 80.4s] {'t': 24.8, 'collector_heap_mib': 44.3, 'collector_rss_mib': 237.8, 'collector_container_mib': 76.9, 'queue': {'otlp_http/loki': 23.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 10.0}, 'alert': 'pending'}
|
||||
[ 92.4s] {'t': 36.9, 'collector_heap_mib': 53.4, 'collector_rss_mib': 237.8, 'collector_container_mib': 77.0, 'queue': {'otlp_http/loki': 31.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 13.0}, 'alert': 'pending'}
|
||||
[ 104.5s] {'t': 49.0, 'collector_heap_mib': 62.1, 'collector_rss_mib': 239.8, 'collector_container_mib': 81.0, 'queue': {'otlp_http/loki': 38.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 16.0}, 'alert': 'pending'}
|
||||
[ 117.3s] {'t': 61.1, 'collector_heap_mib': 62.1, 'collector_rss_mib': 239.8, 'collector_container_mib': 87.1, 'queue': {'otlp_http/loki': 46.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 19.0}, 'alert': 'pending'}
|
||||
[ 129.4s] {'t': 73.8, 'collector_heap_mib': 45.9, 'collector_rss_mib': 247.8, 'collector_container_mib': 87.1, 'queue': {'otlp_http/loki': 46.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 19.0}, 'alert': 'pending'}
|
||||
[ 141.4s] {'t': 85.9, 'collector_heap_mib': 54.5, 'collector_rss_mib': 247.8, 'collector_container_mib': 87.2, 'queue': {'otlp_http/loki': 53.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 22.0}, 'alert': 'firing'}
|
||||
[ 153.5s] {'t': 98.0, 'collector_heap_mib': 66.1, 'collector_rss_mib': 248.0, 'collector_container_mib': 87.3, 'queue': {'otlp_http/loki': 59.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 24.0}, 'alert': 'firing'}
|
||||
[ 165.6s] {'t': 110.0, 'collector_heap_mib': 75.7, 'collector_rss_mib': 254.0, 'collector_container_mib': 95.4, 'queue': {'otlp_http/loki': 66.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 27.0}, 'alert': 'firing'}
|
||||
[ 178.4s] {'t': 122.1, 'collector_heap_mib': 84.7, 'collector_rss_mib': 262.2, 'collector_container_mib': 101.5, 'queue': {'otlp_http/loki': 74.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 30.0}, 'alert': 'firing'}
|
||||
[ 190.4s] {'t': 134.9, 'collector_heap_mib': 84.7, 'collector_rss_mib': 262.2, 'collector_container_mib': 103.7, 'queue': {'otlp_http/loki': 81.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 33.0}, 'alert': 'firing'}
|
||||
[ 202.5s] {'t': 147.0, 'collector_heap_mib': 64.8, 'collector_rss_mib': 264.2, 'collector_container_mib': 103.6, 'queue': {'otlp_http/loki': 81.0, 'otlp_http/prometheus': 0.0, 'otlp_grpc/tempo': 33.0}, 'alert': 'firing'}
|
||||
[ 214.0s] docker compose start tempo loki
|
||||
[ 269.3s] exporter queues drained 55.3 s after start
|
||||
[ 284.6s] API during outage: {'requests': 8486, 'codes': {'201': 8486}, 'success_ratio': 1.0, 'success_rps': 52.9, 'p95_ms_successful': 32.0}
|
||||
[ 284.6s] probe traces: 13/13 reached Tempo (lost: sent at [] s)
|
||||
[ 284.6s] lost in Collector (send_failed+enqueue_failed): {'spans': 2048, 'log_records': 213}; collector heap 32.3 -> max 84.7 MiB (memory_limiter 200 MiB), container max 103.7 MiB
|
||||
[ 284.6s] saved C:\Users\Gigabyte\Desktop\lab7\mtusi2026lab7\evidence\incident-telemetry-down.json
|
||||
PASS: Tempo+Loki down -> API unaffected, collector memory bounded, losses counted; recovery -> resolved
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"scenario": "worker-stop",
|
||||
"date": "2026-11-07 19:15:03",
|
||||
"firing_after_stop_s": {
|
||||
"MessengerWorkerNoConsumers": 94.0,
|
||||
"MessengerQueueLagGrowing": 124.5
|
||||
},
|
||||
"diagnosis": {
|
||||
"queue_consumers": 0.0,
|
||||
"broker_queue_depth": 3.0,
|
||||
"jobs_backlog_queued": 3.0,
|
||||
"oldest_job_age_s": 115.4,
|
||||
"outbox_oldest_age_s": 0.0,
|
||||
"published_ok_last_5m": 12.39609660691289,
|
||||
"worker_metrics_last_seen_s": 123.0,
|
||||
"last_worker_log": {
|
||||
"event": "service.stopped",
|
||||
"message": "stopped"
|
||||
},
|
||||
"upload_trace_span_names": [
|
||||
"INSERT",
|
||||
"NOTIFY",
|
||||
"POST /api/v1/chats/{chat_id}/attachments",
|
||||
"S3 PutObject",
|
||||
"SELECT",
|
||||
"UPDATE",
|
||||
"create attachments",
|
||||
"inspect image",
|
||||
"publish attachments",
|
||||
"redis GET"
|
||||
],
|
||||
"upload_trace_has_consumer_span": false
|
||||
},
|
||||
"ready_after_start_s": [
|
||||
4.9,
|
||||
5.0,
|
||||
5.4
|
||||
],
|
||||
"resolved_after_start_s": {
|
||||
"MessengerWorkerNoConsumers": 45.6,
|
||||
"MessengerQueueLagGrowing": 45.6
|
||||
},
|
||||
"after_recovery": {
|
||||
"jobs_backlog_queued": 0.0,
|
||||
"oldest_job_age_s": 0.0,
|
||||
"queue_consumers": 2.0
|
||||
},
|
||||
"time_to_ready_p95_5m_s": 27.8
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
# incident-worker: lab6 incident 1: worker stopped -> queue lag + no consumers firing -> resolved
|
||||
# date: 2026-11-07 19:17:54, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/incidents.py worker-stop
|
||||
# exit code: 0, 170.7 s
|
||||
|
||||
=== worker-stop
|
||||
[ 0.2s] baseline: consumers=2.0, oldest job age=0.0 s
|
||||
[ 2.6s] docker compose stop worker
|
||||
[ 2.7s] uploaded 3 attachments: 202 queued (API accepts without worker)
|
||||
[ 2.8s] consumers=2.0 backlog queued=0.0 oldest age=0.0 s, alerts: {}
|
||||
[ 7.9s] consumers=2.0 backlog queued=0.0 oldest age=0.0 s, alerts: {}
|
||||
[ 13.0s] consumers=0.0 backlog queued=3.0 oldest age=5.1 s, alerts: {}
|
||||
[ 18.1s] consumers=0.0 backlog queued=3.0 oldest age=5.1 s, alerts: {}
|
||||
[ 23.1s] consumers=0.0 backlog queued=3.0 oldest age=15.1 s, alerts: {}
|
||||
[ 28.2s] consumers=0.0 backlog queued=3.0 oldest age=15.1 s, alerts: {}
|
||||
[ 33.3s] consumers=0.0 backlog queued=3.0 oldest age=25.2 s, alerts: {}
|
||||
[ 38.4s] consumers=0.0 backlog queued=3.0 oldest age=25.2 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 43.5s] consumers=0.0 backlog queued=3.0 oldest age=35.2 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 48.5s] consumers=0.0 backlog queued=3.0 oldest age=35.2 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 53.7s] consumers=0.0 backlog queued=3.0 oldest age=45.2 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 58.7s] consumers=0.0 backlog queued=3.0 oldest age=45.2 s, alerts: {'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 63.8s] consumers=0.0 backlog queued=3.0 oldest age=55.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 68.8s] consumers=0.0 backlog queued=3.0 oldest age=55.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 73.9s] consumers=0.0 backlog queued=3.0 oldest age=65.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 79.0s] consumers=0.0 backlog queued=3.0 oldest age=65.2 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 84.1s] consumers=0.0 backlog queued=3.0 oldest age=75.3 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 89.2s] consumers=0.0 backlog queued=3.0 oldest age=75.3 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'pending'}
|
||||
[ 94.2s] ALERT MessengerWorkerNoConsumers firing (94.0 s after stop)
|
||||
[ 94.2s] consumers=0.0 backlog queued=3.0 oldest age=85.3 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
|
||||
[ 99.3s] consumers=0.0 backlog queued=3.0 oldest age=85.3 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
|
||||
[ 104.4s] consumers=0.0 backlog queued=3.0 oldest age=95.3 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
|
||||
[ 109.5s] consumers=0.0 backlog queued=3.0 oldest age=95.3 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
|
||||
[ 114.6s] consumers=0.0 backlog queued=3.0 oldest age=105.4 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
|
||||
[ 119.7s] consumers=0.0 backlog queued=3.0 oldest age=105.4 s, alerts: {'MessengerQueueLagGrowing': 'pending', 'MessengerWorkerNoConsumers': 'firing'}
|
||||
[ 124.7s] ALERT MessengerQueueLagGrowing firing (124.5 s after stop)
|
||||
[ 124.8s] diagnosis: {"queue_consumers": 0.0, "broker_queue_depth": 3.0, "jobs_backlog_queued": 3.0, "oldest_job_age_s": 115.4, "outbox_oldest_age_s": 0.0, "published_ok_last_5m": 12.39609660691289, "worker_metrics_last_seen_s": 123.0, "last_worker_log": {"event": "service.stopped", "message": "stopped"}, "upload_trace_span_names": ["INSERT", "NOTIFY", "POST /api/v1/chats/{chat_id}/attachments", "S3 PutObject", "SELECT", "UPDATE", "create attachments", "inspect image", "publish attachments", "redis GET"], "upload_trace_has_consumer_span": false}
|
||||
[ 128.9s] docker compose start worker
|
||||
[ 130.3s] all attachments ready 5.4 s after worker start; backlog now 3.0
|
||||
[ 130.3s] ... MessengerWorkerNoConsumers: firing (0 s)
|
||||
[ 135.3s] ... MessengerWorkerNoConsumers: firing (5 s)
|
||||
[ 140.3s] ... MessengerWorkerNoConsumers: firing (10 s)
|
||||
[ 145.4s] ... MessengerWorkerNoConsumers: firing (15 s)
|
||||
[ 150.4s] ... MessengerWorkerNoConsumers: firing (20 s)
|
||||
[ 155.4s] ... MessengerWorkerNoConsumers: firing (25 s)
|
||||
[ 160.4s] ... MessengerWorkerNoConsumers: firing (30 s)
|
||||
[ 165.5s] ... MessengerWorkerNoConsumers: firing (35 s)
|
||||
[ 170.5s] alerts resolved: {'MessengerWorkerNoConsumers': 45.6, 'MessengerQueueLagGrowing': 45.6}; now {'jobs_backlog_queued': 0.0, 'oldest_job_age_s': 0.0, 'queue_consumers': 2.0}
|
||||
[ 170.6s] saved C:\Users\Gigabyte\Desktop\lab7\mtusi2026lab7\evidence\incident-worker-stop.json
|
||||
PASS: worker stop -> no consumers + growing queue lag -> firing; cause from metrics/logs/trace; start -> backlog drained -> resolved
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,8 @@
|
||||
# jobs-concurrency: lab5: WORKER_CONCURRENCY consumers, prefetch 1, bounded processing
|
||||
# date: 2026-11-07 19:40:12, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_jobs.py concurrency
|
||||
# exit code: 0, 19.2 s
|
||||
|
||||
--- concurrency: Ограниченная конкуренция: WORKER_CONCURRENCY потребителей с prefetch=1; одновременно processing <= 2.
|
||||
2 consumers, prefetch_count 1, manual ack; 8 queued 3000x2000 JPEG drained in 2.6 s after worker start, peak processing 2 of 8 (6 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 19:35:22, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_jobs.py crash-after-put crash-after-commit staging lease
|
||||
# exit code: 0, 161.4 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 18 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 19:39:53, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_janitor_replay.py
|
||||
# exit code: 0, 192.2 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 84 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 c532cc9d-8fd5-4baa-9dcf-cc7331f50086 ready
|
||||
after the janitor pass: original/thumbnail/crop/optimized -> 200, 4 objects in S3; janitor report: orphans 2, deleted 2
|
||||
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 19:31:20, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_jobs.py limits
|
||||
# exit code: 0, 74.8 s
|
||||
|
||||
--- limits: Лимиты: bytes и пиксели на API; память/пиксели/время процесса обработки на worker.
|
||||
10 MiB + 8 bytes -> 413 before any job is created
|
||||
imaging.py on 8000x5000 PNG: exit 0, peak RSS 225.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 63 s
|
||||
1 passed, 0 failed
|
||||
@@ -0,0 +1,9 @@
|
||||
# jobs-outbox: lab5: dispatcher crash between COMMIT and publish / after confirm
|
||||
# date: 2026-11-07 19:32:40, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_jobs.py outbox-crash
|
||||
# exit code: 0, 20.3 s
|
||||
|
||||
--- outbox-crash: Разрыв COMMIT/publish: dispatcher падает после COMMIT задания до publish и после confirm до отметки.
|
||||
dispatcher killed between COMMIT and publish; restarted by policy, outbox re-published -> job 60ca1ef4-a5fb-48ad-94bd-5f14f683304d 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 19:32:20, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_jobs.py worker-down broker-down
|
||||
# exit code: 0, 60.4 s
|
||||
|
||||
--- worker-down: Защита п.2-3: worker остановлен -> 202 -> сообщение с вложением -> рестарт API+broker -> worker -> ready.
|
||||
worker stopped
|
||||
upload while worker is down -> 202 queued, attachment 5d7b65bc-2cb9-4b4a-801e-6c30173dd513
|
||||
message with attachment 201, content 409, other messages 201; job 6133fe0a-b568-4024-8bb7-4d7d32ed0433 published, queue messages/unacked = (1, 0)
|
||||
rabbitmq and api restarted with volumes; queue still holds 1 message(s); status queued
|
||||
worker started -> same job 6133fe0a-b568-4024-8bb7-4d7d32ed0433 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 3e57742c-4cc4-48b0-9645-0e742fa323d0
|
||||
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 19:36:41, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_jobs.py retry exhausted-replay permanent dlq
|
||||
# exit code: 0, 78.5 s
|
||||
|
||||
--- retry: Временные ошибки S3: backoff с jitter, затем ready; задержки видны в журнале.
|
||||
2 x storage_unavailable -> retries after 1.70 s and 2.50 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 3d109dba-1036-482a-a6fb-8116c7894b6d 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 (4 message(s)); dlq-replay kept them: ['unknown job', '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 19:30:05, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_jobs.py variants
|
||||
# exit code: 0, 21.0 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 19:08:02, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_lab7_security.py
|
||||
# exit code: 0, 17.3 s
|
||||
|
||||
port 8080: closed
|
||||
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 (c4ba1764f1a3)
|
||||
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 ['76a44da5ae93', 'c4ba1764f1a3']; 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,24 @@
|
||||
{
|
||||
"container_logs": {
|
||||
"password": 0,
|
||||
"token": 0,
|
||||
"basic_b64": 0
|
||||
},
|
||||
"container_logs_bearer_or_basic_header": 0,
|
||||
"loki": {
|
||||
"password": 0,
|
||||
"token": 0,
|
||||
"basic_b64": 0
|
||||
},
|
||||
"tempo": {
|
||||
"traces_fetched": 4,
|
||||
"password": 0,
|
||||
"token": 0,
|
||||
"basic_b64": 0,
|
||||
"authorization_attribute": 0
|
||||
},
|
||||
"prometheus_labels": {
|
||||
"token": 0,
|
||||
"user_id": 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
# leak-check: lab7: password/token/Authorization absent in container logs, Loki, Tempo traces, Prometheus labels
|
||||
# date: 2026-11-07 19:08:23, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/leak_check.py
|
||||
# exit code: 0, 21.5 s
|
||||
|
||||
{"container_logs": {"password": 0, "token": 0, "basic_b64": 0}, "container_logs_bearer_or_basic_header": 0, "loki": {"password": 0, "token": 0, "basic_b64": 0}, "tempo": {"traces_fetched": 4, "password": 0, "token": 0, "basic_b64": 0, "authorization_attribute": 0}, "prometheus_labels": {"token": 0, "user_id": 0}}
|
||||
searched: container logs, Loki, Tempo, Prometheus labels; traces fetched: 4
|
||||
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": "No permissions to access a key"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "redis",
|
||||
"action": "KEYS *",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "User api has no permissions to run the 'keys' command"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "redis",
|
||||
"action": "FLUSHALL",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "User api has no permissions to run the 'flushall' command"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "redis",
|
||||
"action": "CONFIG GET",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "User api has no permissions to run the 'config|get' command"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "redis",
|
||||
"action": "ACL LIST",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "User api has no permissions to run the 'acl|list' command"
|
||||
},
|
||||
{
|
||||
"service": "api",
|
||||
"area": "redis",
|
||||
"action": "SUBSCRIBE / PUBLISH",
|
||||
"expect": "denied",
|
||||
"observed": "denied",
|
||||
"pass": true,
|
||||
"detail": "User api 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 19:07:44, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_least_privilege.py
|
||||
# exit code: 0, 5.5 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": "70ea18ded7f86e5a",
|
||||
"new_serial": "22a71730433d9d42",
|
||||
"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": 23.1,
|
||||
"codes": {
|
||||
"me:200": 243,
|
||||
"send:201": 243,
|
||||
"login:201": 11
|
||||
},
|
||||
"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 19:09:33, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/lifecycle.py rotate-leaf
|
||||
# exit code: 0, 27.6 s
|
||||
|
||||
--- rotate-leaf: клиентский сертификат LB (CN=lb)
|
||||
{"old_serial": "70ea18ded7f86e5a", "new_serial": "22a71730433d9d42", "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": 23.1, "codes": {"me:200": 243, "send:201": 243, "login:201": 11}, "errors_5xx_or_conn": 0, "errors": []}}
|
||||
PASS: LB leaf rotated without rebuild/restart; old leaf revoked by CRL and rejected; no errors
|
||||
saved C:\Users\Gigabyte\Desktop\lab7\mtusi2026lab7\evidence\lifecycle-rotate-leaf.json
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"kv_version": [
|
||||
5,
|
||||
6
|
||||
],
|
||||
"replicas": 2,
|
||||
"active_passwords_during_overlap": 2,
|
||||
"all_replicas_picked_up_after_s": 23.9,
|
||||
"active_password_hashes_after": 1,
|
||||
"new_password_hash_matches": true,
|
||||
"load": {
|
||||
"seconds": 37.6,
|
||||
"codes": {
|
||||
"me:200": 431,
|
||||
"send:201": 431,
|
||||
"login:201": 18
|
||||
},
|
||||
"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 19:09:06, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/lifecycle.py rotate-secret
|
||||
# exit code: 0, 38.2 s
|
||||
|
||||
--- rotate-secret: пароль Redis ACL-пользователя api
|
||||
{"kv_version": [5, 6], "replicas": 2, "active_passwords_during_overlap": 2, "all_replicas_picked_up_after_s": 23.9, "active_password_hashes_after": 1, "new_password_hash_matches": true, "load": {"seconds": 37.6, "codes": {"me:200": 431, "send:201": 431, "login:201": 18}, "errors_5xx_or_conn": 0, "errors": []}}
|
||||
PASS: Redis password rotated via OpenBao without restarts; old password revoked; no errors
|
||||
saved C:\Users\Gigabyte\Desktop\lab7\mtusi2026lab7\evidence\lifecycle-rotate-secret.json
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"sealed_seconds": 75.6,
|
||||
"restarted_replica_health_while_sealed": "starting",
|
||||
"replicas_answering_while_sealed": 1,
|
||||
"restarted_replica_ready_after_unseal_s": 5.4,
|
||||
"api_events": {
|
||||
"secrets.refresh_failed": 5,
|
||||
"secrets.waiting": 8,
|
||||
"secrets.login": 1
|
||||
},
|
||||
"load": {
|
||||
"seconds": 89.2,
|
||||
"codes": {
|
||||
"me:200": 1012,
|
||||
"send:201": 1012,
|
||||
"login:201": 43
|
||||
},
|
||||
"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 19:12:47, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/lifecycle.py sealed
|
||||
# exit code: 0, 90.8 s
|
||||
|
||||
--- sealed: OpenBao запечатан
|
||||
{"sealed_seconds": 75.6, "restarted_replica_health_while_sealed": "starting", "replicas_answering_while_sealed": 1, "restarted_replica_ready_after_unseal_s": 5.4, "api_events": {"secrets.refresh_failed": 5, "secrets.waiting": 8, "secrets.login": 1}, "load": {"seconds": 89.2, "codes": {"me:200": 1012, "send:201": 1012, "login:201": 43}, "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 C:\Users\Gigabyte\Desktop\lab7\mtusi2026lab7\evidence\lifecycle-sealed.json
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"role_ttl": "20s / max 40s",
|
||||
"observed_seconds": 100,
|
||||
"api_events": {
|
||||
"secrets.refresh_failed": 2,
|
||||
"secrets.login": 4
|
||||
},
|
||||
"load": {
|
||||
"seconds": 101.6,
|
||||
"codes": {
|
||||
"me:200": 1172,
|
||||
"send:201": 1172,
|
||||
"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 19:11:16, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/lifecycle.py token-expiry
|
||||
# exit code: 0, 102.4 s
|
||||
|
||||
--- token-expiry: короткий TTL токенов OpenBao роли api
|
||||
{"role_ttl": "20s / max 40s", "observed_seconds": 100, "api_events": {"secrets.refresh_failed": 2, "secrets.login": 4}, "load": {"seconds": 101.6, "codes": {"me:200": 1172, "send:201": 1172, "login:201": 49}, "errors_5xx_or_conn": 0, "errors": []}}
|
||||
PASS: expired/revoked tokens -> services re-login with their certificate; requests unaffected
|
||||
saved C:\Users\Gigabyte\Desktop\lab7\mtusi2026lab7\evidence\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.016,
|
||||
"concurrency": 4,
|
||||
"successful_requests": 6202,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 206.623,
|
||||
"successful_latency_ms": {
|
||||
"p50": 16.0,
|
||||
"p95": 32.0,
|
||||
"p99": 47.0
|
||||
},
|
||||
"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 19:45:30, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe tests/load.py --base-url https://127.0.0.1:8443 --ca-file C:\Users\Gigabyte\Desktop\lab7\mtusi2026lab7\secrets\pki\public\ca.crt --duration 30 --concurrency 4 --output C:\Users\Gigabyte\Desktop\lab7\mtusi2026lab7\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.016,
|
||||
"concurrency": 4,
|
||||
"successful_requests": 6202,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 206.623,
|
||||
"successful_latency_ms": {
|
||||
"p50": 16.0,
|
||||
"p95": 32.0,
|
||||
"p99": 47.0
|
||||
},
|
||||
"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": 694,
|
||||
"codes": {
|
||||
"200": 347,
|
||||
"201": 347
|
||||
},
|
||||
"p50_ms": 12.3,
|
||||
"p95_ms": 34.6,
|
||||
"p99_ms": 35.5
|
||||
},
|
||||
"attack": null
|
||||
},
|
||||
"under_attack": {
|
||||
"legit": {
|
||||
"requests": 186,
|
||||
"codes": {
|
||||
"200": 93,
|
||||
"201": 93
|
||||
},
|
||||
"p50_ms": 91.1,
|
||||
"p95_ms": 194.1,
|
||||
"p99_ms": 243.6
|
||||
},
|
||||
"attack": {
|
||||
"requests": 1924,
|
||||
"codes": {
|
||||
"401": 360,
|
||||
"429": 1564
|
||||
},
|
||||
"rps": 96.2,
|
||||
"p50_ms": 116.8,
|
||||
"p95_ms": 480.5
|
||||
}
|
||||
},
|
||||
"seconds": 20,
|
||||
"attackers": 16,
|
||||
"burst_one_replica": {
|
||||
"requests": 200,
|
||||
"codes": {
|
||||
"hashed": 75,
|
||||
"rejected_503": 125
|
||||
},
|
||||
"max_parallel_hashes": 2,
|
||||
"limit": 2,
|
||||
"queue_s": 2,
|
||||
"seconds": 2.11,
|
||||
"slowest_rejection_s": 2.05,
|
||||
"maxrss_growth_mib": 74.7
|
||||
}
|
||||
}
|
||||
@@ -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 19:48:14, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/login_dos.py
|
||||
# exit code: 0, 47.5 s
|
||||
|
||||
baseline 20 s ...
|
||||
{"legit": {"requests": 694, "codes": {"200": 347, "201": 347}, "p50_ms": 12.3, "p95_ms": 34.6, "p99_ms": 35.5}, "attack": null}
|
||||
attack: 16 threads of wrong-password logins over 40 usernames ...
|
||||
{"legit": {"requests": 186, "codes": {"200": 93, "201": 93}, "p50_ms": 91.1, "p95_ms": 194.1, "p99_ms": 243.6}, "attack": {"requests": 1924, "codes": {"401": 360, "429": 1564}, "rps": 96.2, "p50_ms": 116.8, "p95_ms": 480.5}}
|
||||
burst of 200 simultaneous password checks in one api process: {"requests": 200, "codes": {"hashed": 75, "rejected_503": 125}, "max_parallel_hashes": 2, "limit": 2, "queue_s": 2, "seconds": 2.11, "slowest_rejection_s": 2.05, "maxrss_growth_mib": 74.7}
|
||||
attack: 96.2 login attempts/s; 401 (hash computed) 360, 503 busy (rejected before hashing) 0, 429 rate limited 1564
|
||||
legit p95: 34.6 ms -> 194.1 ms; legit errors: {}
|
||||
saved evidence/login-dos.json
|
||||
@@ -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
|
||||
@@ -0,0 +1,44 @@
|
||||
# persistence: public persistence test incl. S3, OpenBao (+ operator unseal) + proof of real restarts (make test-persistence)
|
||||
# date: 2026-11-07 19:47:26, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/run_persistence.py
|
||||
# exit code: 0, 83.2 s
|
||||
|
||||
before: container, ID, started at
|
||||
messenger-lab7-api-1 b7f37f051ba1 2026-11-07T16:44:58.316386952Z
|
||||
messenger-lab7-api-2 0c7893e1043d 2026-11-07T16:44:34.378971323Z
|
||||
messenger-lab7-dispatcher-1 f2787c26ffc3 2026-11-07T16:32:32.586338075Z
|
||||
messenger-lab7-grafana-1 be25618091d7 2026-11-07T16:00:42.333331319Z
|
||||
messenger-lab7-janitor-1 e167fb33db21 2026-11-07T16:06:23.215919678Z
|
||||
messenger-lab7-lb-1 733e8216253c 2026-11-07T16:00:55.728412944Z
|
||||
messenger-lab7-loki-1 ca8cc04e19ec 2026-11-07T16:25:58.834134167Z
|
||||
messenger-lab7-openbao-1 f01a5f31cea2 2026-11-07T15:59:42.297678095Z
|
||||
messenger-lab7-otel-collector-1 2662c37d8db1 2026-11-07T16:29:14.108345949Z
|
||||
messenger-lab7-otel-gate-1 a25633d7ddb9 2026-11-07T16:00:40.861906637Z
|
||||
messenger-lab7-postgres-1 b5eac95ae4b8 2026-11-07T16:45:54.788002009Z
|
||||
messenger-lab7-prometheus-1 baa76cf6614e 2026-11-07T16:14:30.188234358Z
|
||||
messenger-lab7-rabbitmq-1 10b4296f40a0 2026-11-07T16:32:03.709212622Z
|
||||
messenger-lab7-redis-1 d700f22e246b 2026-11-07T16:45:33.860574669Z
|
||||
messenger-lab7-s3-1 61161c90cf64 2026-11-07T16:41:50.944260871Z
|
||||
messenger-lab7-tempo-1 1168d83367e8 2026-11-07T16:25:58.849506935Z
|
||||
messenger-lab7-worker-1 e597bd78dfcd 2026-11-07T16:40:05.579645887Z
|
||||
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 82.1 s): container, ID, started at, restarted?
|
||||
messenger-lab7-api-1 b7f37f051ba1 2026-11-07T16:47:20.011970429Z same container: True, restarted: True
|
||||
messenger-lab7-api-2 0c7893e1043d 2026-11-07T16:47:20.22263146Z same container: True, restarted: True
|
||||
messenger-lab7-dispatcher-1 f2787c26ffc3 2026-11-07T16:47:17.139389574Z same container: True, restarted: True
|
||||
messenger-lab7-grafana-1 be25618091d7 2026-11-07T16:47:15.199778456Z same container: True, restarted: True
|
||||
messenger-lab7-janitor-1 e167fb33db21 2026-11-07T16:47:17.000342934Z same container: True, restarted: True
|
||||
messenger-lab7-lb-1 733e8216253c 2026-11-07T16:47:24.364710349Z same container: True, restarted: True
|
||||
messenger-lab7-loki-1 ca8cc04e19ec 2026-11-07T16:46:13.114210916Z same container: True, restarted: True
|
||||
messenger-lab7-openbao-1 f01a5f31cea2 2026-11-07T16:46:10.313665536Z same container: True, restarted: True
|
||||
messenger-lab7-otel-collector-1 2662c37d8db1 2026-11-07T16:47:14.191901505Z same container: True, restarted: True
|
||||
messenger-lab7-otel-gate-1 a25633d7ddb9 2026-11-07T16:47:13.522591952Z same container: True, restarted: True
|
||||
messenger-lab7-postgres-1 b5eac95ae4b8 2026-11-07T16:46:12.679396292Z same container: True, restarted: True
|
||||
messenger-lab7-prometheus-1 baa76cf6614e 2026-11-07T16:46:12.91171788Z same container: True, restarted: True
|
||||
messenger-lab7-rabbitmq-1 10b4296f40a0 2026-11-07T16:46:15.724420893Z same container: True, restarted: True
|
||||
messenger-lab7-redis-1 d700f22e246b 2026-11-07T16:46:12.081226037Z same container: True, restarted: True
|
||||
messenger-lab7-s3-1 61161c90cf64 2026-11-07T16:46:37.15586754Z same container: True, restarted: True
|
||||
messenger-lab7-tempo-1 1168d83367e8 2026-11-07T16:46:32.818326702Z same container: True, restarted: True
|
||||
messenger-lab7-worker-1 e597bd78dfcd 2026-11-07T16:47:17.325438641Z same container: True, restarted: True
|
||||
PASS: the hook restarted postgres, redis, s3, rabbitmq, openbao, api, janitor, dispatcher, worker, lb, otel-gate, otel-collector, prometheus, loki, tempo, grafana (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 19:43:57, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/test_race.py
|
||||
# exit code: 0, 2.4 s
|
||||
|
||||
sent 100 messages from 10 clients in 0.52 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 19:44:13, commit: 20afc2c + uncommitted changes
|
||||
# command: python.exe student-tests/redis_info.py
|
||||
# exit code: 0, 4.6 s
|
||||
|
||||
session key: session:351c4550608e19a3...; value is the user id: True
|
||||
TTL of the key, seconds: 3599
|
||||
sessions in Redis: 479
|
||||
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'
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user