From b2990d8be586ff451b548bce859476d88444ee6a Mon Sep 17 00:00:00 2001 From: Alexey Bodanyuk <144894236+wfa22@users.noreply.github.com> Date: Sat, 28 Nov 2026 17:53:53 +0300 Subject: [PATCH] =?UTF-8?q?lab7:=20=D0=B4=D0=BE=D0=BA=D0=B0=D0=B7=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D1=8C=D1=81=D1=82=D0=B2=D0=B0=20=D0=B8=D0=B7?= =?UTF-8?q?=20=D1=87=D0=B8=D1=81=D1=82=D0=BE=D0=B3=D0=BE=20clone=20(eviden?= =?UTF-8?q?ce/,=20425=20passed,=2012/12=20=D1=88=D0=B0=D0=B3=D0=BE=D0=B2),?= =?UTF-8?q?=20REPORT=20=D0=BF=D0=BE=20=D1=80=D0=B5=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D0=BE=D0=BC=D1=83=20=D0=BF=D1=80=D0=BE=D0=B3=D0=BE=D0=BD=D1=83?= =?UTF-8?q?,=20=D1=83=D1=82=D0=BE=D1=87=D0=BD=D0=B5=D0=BD=D1=8B=20=D1=86?= =?UTF-8?q?=D0=B8=D1=84=D1=80=D1=8B=20Argon2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- REPORT.md | 101 +++++--- docs/DEFENSE.md | 2 +- evidence/SUMMARY.md | 18 ++ evidence/argon2/bench.json | 290 ++++++++++++++++++++++ evidence/bao-check.txt | 98 ++++++++ evidence/check.txt | 7 + evidence/dashboard-check.txt | 42 ++++ evidence/failover.txt | 67 +++++ evidence/mtls-check.txt | 39 +++ evidence/persistence.txt | 52 ++++ evidence/smoke.txt | 7 + evidence/stand.md | 64 +++++ evidence/student-tests.txt | 459 +++++++++++++++++++++++++++++++++++ evidence/test-security.txt | 7 + evidence/trace-demo.txt | 46 ++++ security/THREAT_MODEL.md | 2 +- 16 files changed, 1271 insertions(+), 30 deletions(-) create mode 100644 evidence/SUMMARY.md create mode 100644 evidence/argon2/bench.json create mode 100644 evidence/bao-check.txt create mode 100644 evidence/check.txt create mode 100644 evidence/dashboard-check.txt create mode 100644 evidence/failover.txt create mode 100644 evidence/mtls-check.txt create mode 100644 evidence/persistence.txt create mode 100644 evidence/smoke.txt create mode 100644 evidence/stand.md create mode 100644 evidence/student-tests.txt create mode 100644 evidence/test-security.txt create mode 100644 evidence/trace-demo.txt diff --git a/REPORT.md b/REPORT.md index 2432ac7..675ba36 100644 --- a/REPORT.md +++ b/REPORT.md @@ -45,7 +45,7 @@ make check test test-security CA_FILE="$PWD/secrets/pki/public-ca.crt" PYTHON=.v make mtls-check bao-check PYTHON=.venv/bin/python make test-persistence ACTION_SCRIPT=scripts/restart.sh CA_FILE="$PWD/secrets/pki/public-ca.crt" PYTHON=.venv/bin/python make test-failover ACTION_SCRIPT=scripts/stop-one.sh CA_FILE="$PWD/secrets/pki/public-ca.crt" PYTHON=.venv/bin/python && make restore -.venv/bin/python -m pytest student-tests -v # свои тесты, ~1,5-2 ч на этом ПК +.venv/bin/python -m pytest student-tests -v # свои тесты, ~30-60 мин на этом ПК ``` То же самое для чистого стенда: `make secrets up`, затем `python scripts/collect_evidence.py` (вывод — в `evidence/`). @@ -107,7 +107,7 @@ operator --docker compose exec--> openbao (root token и доли unseal чер | `APP_HOST`, `APP_PORT` | `0.0.0.0`, **8443** (mTLS); health — `APP_HEALTH_PORT=8081` на loopback | | `SESSION_TTL_SECONDS`, `IDEMPOTENCY_TTL_SECONDS`, `API_REPLICAS` | как есть (3600, 86400, 2) | | `DATABASE_URL_FILE`, `CACHE_URL_FILE` | **нет у api/relay/worker**: `database_url`, `cache_url` читаются из OpenBao (`messenger/data/`); `DATABASE_URL_FILE` есть только у `migrate`, `jobctl`, `auditor` | -| `SESSION_STORE` | `valkey` | +| `SESSION_STORE` | `valkey`; плюс `CACHE_TIMEOUT_SECONDS=1.0` (TLS-рукопожатие) и `CACHE_POOL_SIZE=8` (пул, прогретый до readiness) | | `S3_ENDPOINT` | `https://s3:8333` | | `S3_REGION`, `S3_BUCKET`, `MAX_UPLOAD_BYTES`, `MAX_IMAGE_PIXELS`, `WORKER_CONCURRENCY`, `JOB_MAX_ATTEMPTS`, `JOB_TIMEOUT_SECONDS`, `STAGING_RETENTION_SECONDS` | как в lab6 (+ `S3_STAGING_BUCKET`) | | `S3_*_FILE` | у api/worker — из OpenBao; файлы только у `s3`, `s3-init`, `auditor` | @@ -127,7 +127,31 @@ operator --docker compose exec--> openbao (root token и доли unseal чер Все файлы — в [evidence/](evidence/), сводка — [evidence/SUMMARY.md](evidence/SUMMARY.md). Прогон из **чистого clone** в отдельной папке: новые secrets и сертификаты, пустые volumes, `COMPOSE_PROJECT_NAME=mtusi-lab7-clean`. Commit и окружение — в [evidence/stand.md](evidence/stand.md). -RESULTS_TABLE +Прогон: commit `f2bd580`, 2026-11-28. Все 12 шагов сборщика — код 0. + +| Критерий README | Команда/сценарий | Наблюдаемый результат | Файл доказательства | +| --- | --- | --- | --- | +| Публичный smoke по HTTPS с проверяемым CA и hostname | `make test BASE_URL=https://localhost:8443 CA_FILE=/secrets/pki/public-ca.crt` | `PASS: lab7 public API scenario` (полный сценарий ЛР 1–6: пользователи, чаты, идемпотентность, файл → thumbnail, logout) | [smoke.txt](evidence/smoke.txt) | +| Недоверенный CA отклоняется | `make test-security` | `PASS: trusted HTTPS works; untrusted CA rejected` | [test-security.txt](evidence/test-security.txt) | +| Чужой hostname, внутренний CA снаружи, нет открытого входа | `pytest student-tests/test_security.py -k "ingress or plaintext"` | Hostname mismatch → ошибка проверки; порты 8080/8404/5432/6379/5671/8200/8333/… закрыты | [student-tests.txt](evidence/student-tests.txt) | +| Сертификаты создаются локально документированным bootstrap | `scripts/init_secrets.py` → `init_pki.py` в чистом clone | 2 CA + leaf на сервис созданы на хосте; в Git и образе ключей нет (`test_no_secret_in_git_or_in_the_image`) | [stand.md](evidence/stand.md), [student-tests.txt](evidence/student-tests.txt) | +| LB → **каждая** API-реплика: обязательное mTLS, отказ без cert / чужой CA / неверная identity | `make mtls-check` (`scripts/mtls_check.sh`) | по 2 репликам × TLS 1.3/1.2: без cert, `foreign-ca SAN=lb`, `internal-ca SAN=worker` → refused; `SAN=lb` → 200; открытый HTTP на 8443 и порт 8081 снаружи → нет; в логе API `mtls_identity_rejected "client_san": ["worker"]` | [mtls-check.txt](evidence/mtls-check.txt) | +| Прямого обхода публичным портом API нет | `test_api_has_no_published_port_and_answers_only_mtls`, `test_compose_policy_limits_ports_secrets_images` | у API нет PortBindings; опубликованы только lb 8443 и grafana 3000 на 127.0.0.1/::1 | [student-tests.txt](evidence/student-tests.txt), [stand.md](evidence/stand.md) | +| TLS с проверкой сервера к DB, Valkey, S3, broker, Collector, backends; раздельные права | `pytest student-tests/test_security.py -k "postgres or valkey or broker or s3 or telemetry"` | PG: `ssl=on`, `sslmode=disable` → отказ, superuser по сети → отказ, 15 запрещённых запросов → `permission denied`; Valkey: NOPERM на FLUSHALL/CONFIG/KEYS/ACL/EVAL; RabbitMQ: relay не читает очередь, 5672 закрыт; S3: `api: write final: refused`; Collector без cert → отказ; worker с cert того же CA в Prometheus → отказ | [student-tests.txt](evidence/student-tests.txt), матрица — [contracts/trust-matrix.md](contracts/trust-matrix.md) | +| Телеметрия работает через mTLS | `scripts/trace_demo.py`, `scripts/check_dashboard.py` | trace API → relay → worker → S3/DB и логи с trace_id: 7/7 PASS; все запросы dashboard: `queries failed: 0` | [trace-demo.txt](evidence/trace-demo.txt), [dashboard-check.txt](evidence/dashboard-check.txt) | +| OpenBao в стенде, не dev, persistent storage | `bao_operator.py status`, `test_openbao_not_dev_and_persistent` | `initialized=True sealed=False storage=raft version=2.7.3`; команда без `-dev`; после рестарта данные на месте (persistence PASS) | [bao-check.txt](evidence/bao-check.txt) | +| api/relay/worker: сервисная аутентификация + scoped policy; нет root token / unseal / всемогущего токена | `make bao-check` | 3 × 16 проверок allow/deny: свой путь — 200, чужие пути, запись, `sys/*`, `auth/token/create` → 403, отозванный токен → 403; root token и 3 доли не найдены в `/run/secrets`, `/app`, `/tmp`, окружении PID 1 (положительный контроль находит свой role_id); env без `*TOKEN*`. Итого 66 PASS, 0 FAIL | [bao-check.txt](evidence/bao-check.txt) | +| Sealed OpenBao: работающие реплики живут, новые ждут unseal | `test_sealed_openbao_keeps_running_replicas_and_blocks_new_ones` | PASS | [student-tests.txt](evidence/student-tests.txt) | +| Argon2id: соль и параметры в хеше, ≥ 19 MiB / t=2 / p=1, обосновано замером | `test_argon2id_hash_carries_salt_and_parameters`; `make argon2-bench` | `$argon2id$v=19$m=19456,t=2,p=1$<соль>$<хеш>`, разные соли у одинаковых паролей; замер — раздел «Эксперименты» | [argon2/bench.json](evidence/argon2/bench.json), [bench-run1-dev.json](evidence/argon2/bench-run1-dev.json) | +| Ограничение частоты входа 429 + Retry-After | `test_failed_logins_are_rate_limited_with_retry_after` | 5 × 401 → 429 `rate_limited`, `Retry-After` 1–60; верный пароль во время блокировки тоже 429; другой аккаунт — 201 | [student-tests.txt](evidence/student-tests.txt) | +| Ограничение размера запросов | `test_api.py::test_oversized_body_and_wrong_content_type`, `test_attachments.py::test_size_limit_through_the_load_balancer` | 413 до чтения тела; 10 MiB проходит через LB | [student-tests.txt](evidence/student-tests.txt) | +| Посторонний, logout/expiry, X-User-Id | `test_api.py`, `test_sessions.py`, `test_idempotency.py::test_outsider_and_revoked_session_never_see_the_stored_result` | чужое → 404; после logout и истечения TTL → 401; X-User-Id игнорируется | [student-tests.txt](evidence/student-tests.txt) | +| Контейнеры без privileged/host network/docker.sock; app и worker non-root, без capabilities, с лимитами | `test_running_containers_are_hardened`, `test_compose_policy…`, `stand.md` | у всех `CapDrop=[ALL]`, `no-new-privileges`, лимиты CPU/RAM; api/relay/worker uid 10001, `CapEff=0` | [stand.md](evidence/stand.md), [student-tests.txt](evidence/student-tests.txt) | +| Секреты не в Git, образе, телеметрии | `test_no_secret_in_git_or_in_the_image`, `test_observability.py::test_no_secrets_or_message_text_in_logs_and_traces` | значения секретов не найдены `git grep` и в файловой системе образа; в Loki/Tempo нет пароля, токена и текста | [student-tests.txt](evidence/student-tests.txt) | +| `X-Instance-Id` без hostname/IP | `test_x_instance_id_is_a_random_alias_without_hostname_or_ip` | `i-<12 hex>`, не совпадает с hostname/IP контейнеров | [student-tests.txt](evidence/student-tests.txt) | +| Рестарт с сохранением данных (шаг 4 защиты) | `make test-persistence ACTION_SCRIPT=scripts/restart.sh` | PASS за 65 с: рестарт LB, API ×2, relay, worker, PostgreSQL, Valkey, S3, RabbitMQ, OpenBao + unseal; `docker compose ps` до и после | [persistence.txt](evidence/persistence.txt) | +| Последовательный отказ API-реплик (шаг 4 защиты) | `make test-failover ACTION_SCRIPT=scripts/stop-one.sh` × 2 + `make restore` | остановлены обе реплики по очереди (`17c5883f5d19`, `87d05ecea97d`): 117 и 120 записей, 0 неудачных, восстановление 1,75 и 1,79 с | [failover.txt](evidence/failover.txt) | +| Всё из ЛР 2–6 сохранено | `pytest student-tests` (unit + стенд) | **425 passed, 4 skipped** (djpeg не установлен на Windows-хосте), 32 мин; в том числе 17 тестов `test_security.py` | [student-tests.txt](evidence/student-tests.txt) | ## Эксперименты и отказы @@ -139,34 +163,36 @@ RESULTS_TABLE | m, KiB (MiB) | t | замер 1 (dev): медиана / p95 | замер 2 (чистый clone): медиана / p95 | CPU на хеш, мс (1 / 2) | | --- | --- | --- | --- | --- | -| 19456 (19) | 2 **выбрано** | 30.6 / 47.4 | 154.0 / 270.1 | 30.4 / 87.9 | -| 19456 (19) | 3 | 47.4 / 54.7 | 210.4 / 391.7 | 45.1 / 143.6 | -| 19456 (19) | 4 | 102.3 / 175.4 | 265.5 / 486.4 | 62.3 / 195.0 | -| 32768 (32) | 2 | 72.9 / 82.4 | 245.6 / 601.1 | 69.8 / 205.4 | -| 32768 (32) | 3 | 144.5 / 284.0 | 461.3 / 732.6 | 116.3 / 292.8 | -| 32768 (32) | 4 | 144.6 / 378.7 | 431.4 / 942.8 | 135.4 / 356.6 | -| 47104 (46) | 2 | 119.1 / 291.2 | 496.6 / 778.5 | 114.6 / 335.1 | -| 47104 (46) | 3 | 144.3 / 384.1 | 598.8 / 937.3 | 141.7 / 433.5 | -| 47104 (46) | 4 | 246.7 / 485.3 | 915.5 / 2236.4 | 215.5 / 635.7 | -| 65536 (64) | 2 | 162.8 / 368.5 | 699.4 / 1298.1 | 157.4 / 474.5 | -| 65536 (64) | 3 | 233.3 / 669.8 | 703.0 / 1489.6 | 222.1 / 580.9 | -| 65536 (64) | 4 | 319.5 / 711.3 | 1199.7 / 1682.2 | 261.4 / 731.5 | +| 19456 (19) | 2 **выбрано** | 30.6 / 47.4 | 50.6 / 64.9 | 30.4 / 47.8 | +| 19456 (19) | 3 | 47.4 / 54.7 | 106.1 / 172.3 | 45.1 / 57.4 | +| 19456 (19) | 4 | 102.3 / 175.4 | 87.9 / 152.6 | 62.3 / 78.5 | +| 32768 (32) | 2 | 72.9 / 82.4 | 109.9 / 277.4 | 69.8 / 82.5 | +| 32768 (32) | 3 | 144.5 / 284.0 | 144.1 / 371.5 | 116.3 / 126.9 | +| 32768 (32) | 4 | 144.6 / 378.7 | 165.8 / 294.4 | 135.4 / 143.4 | +| 47104 (46) | 2 | 119.1 / 291.2 | 167.8 / 249.6 | 114.6 / 140.0 | +| 47104 (46) | 3 | 144.3 / 384.1 | 166.3 / 516.5 | 141.7 / 157.7 | +| 47104 (46) | 4 | 246.7 / 485.3 | 210.6 / 586.1 | 215.5 / 209.4 | +| 65536 (64) | 2 | 162.8 / 368.5 | 162.0 / 379.4 | 157.4 / 157.2 | +| 65536 (64) | 3 | 233.3 / 669.8 | 264.1 / 601.4 | 222.1 / 233.3 | +| 65536 (64) | 4 | 319.5 / 711.3 | 301.6 / 1100.1 | 261.4 / 279.5 | -Параллельно (K потоков хешируют одновременно; 6 хешей на поток) — пропускная способность одной реплики = сколько входов в секунду она может проверить: +Параллельно (K потоков хешируют одновременно, по 6 хешей на поток). Пропускная способность одной реплики = сколько входов в секунду она может проверить: | m, KiB | t | K | хешей/с (1 / 2) | медиана, мс (1 / 2) | p95, мс (1 / 2) | RAM на хеши, MiB | | --- | --- | --- | --- | --- | --- | --- | -| 19456 | 2 | 1 | 26.8 / 12.1 | 33.6 / 75.2 | 61.0 / 105.4 | 19.0 | -| 19456 | 2 | 2 | 30.6 / 7.8 | 74.3 / 212.3 | 89.3 / 373.0 | 38.0 | -| 19456 | 2 | 4 | 17.4 / 7.5 | 204.1 / 480.6 | 289.0 / 972.2 | 76.0 | -| 47104 | 2 | 1 | 4.3 / 1.8 | 206.5 / 501.0 | 369.1 / 807.2 | 46.0 | -| 47104 | 2 | 2 | 7.4 / 2.4 | 286.2 / 805.2 | 295.9 / 1043.5 | 92.0 | -| 47104 | 2 | 4 | 5.4 / 2.5 | 703.6 / 1496.4 | 988.7 / 1900.7 | 184.0 | -| 19456 | 3 | 1 | 8.8 / 3.6 | 101.2 / 278.5 | 165.8 / 374.2 | 19.0 | -| 19456 | 3 | 2 | 14.3 / 5.6 | 114.2 / 345.8 | 201.5 / 516.2 | 38.0 | -| 19456 | 3 | 4 | 12.2 / 5.8 | 304.6 / 650.2 | 409.3 / 881.8 | 76.0 | +| 19456 | 2 | 1 | 26.8 / 32.0 | 33.6 / 29.7 | 61.0 / 40.7 | 19.0 | +| 19456 | 2 | 2 | 30.6 / 28.8 | 74.3 / 83.0 | 89.3 / 89.6 | 38.0 | +| 19456 | 2 | 4 | 17.4 / 17.4 | 204.1 / 205.0 | 289.0 / 291.6 | 76.0 | +| 47104 | 2 | 1 | 4.3 / 5.5 | 206.5 / 176.9 | 369.1 / 309.5 | 46.0 | +| 47104 | 2 | 2 | 7.4 / 8.2 | 286.2 / 224.2 | 295.9 / 305.3 | 92.0 | +| 47104 | 2 | 4 | 5.4 / 5.0 | 703.6 / 799.9 | 988.7 / 980.1 | 184.0 | +| 19456 | 3 | 1 | 8.8 / 22.1 | 101.2 / 43.9 | 165.8 / 53.1 | 19.0 | +| 19456 | 3 | 2 | 14.3 / 19.0 | 114.2 / 106.5 | 201.5 / 156.0 | 38.0 | +| 19456 | 3 | 4 | 12.2 / 11.5 | 304.6 / 385.3 | 409.3 / 407.5 | 76.0 | -Замер 1: 2026-11-27T13:50:01Z, dev-стенд; замер 2: 2026-11-28T12:21:11Z, чистый стенд. Оба — в контейнере API, cgroup `cpu.max` 100000 100000, `memory.max` 536870912; argon2-cffi 25.1.0, Python 3.13.16. Абсолютные числа различаются в 2–5 раз (Docker Desktop, разная фоновая нагрузка хоста), **соотношения между точками сохраняются**. +Замер 1: 2026-11-27T13:50:01Z, dev-стенд; замер 2: 2026-11-28T14:18:18Z, чистый стенд. Оба — в контейнере API: cgroup `cpu.max` 100000 100000, `memory.max` 536870912; argon2-cffi 25.1.0, Python 3.13.16. + +Ещё один промежуточный замер на чистом стенде шёл, пока хост был загружен посторонним процессом на 85–100 % CPU. Там медиана m=19 MiB / t=2 была 154 мс; его сырой файл перезаписан финальным замером. Абсолютные числа меняются в 2–5 раз от фоновой нагрузки хоста, **соотношения между точками сохраняются**. **Вывод.** Реплика имеет 1 CPU и разрешает 2 хеша одновременно (`PASSWORD_HASH_CONCURRENCY=2`, это 2 × m RAM). Цель — вход не дольше ~100 мс при двух параллельных хешах. Её выполняет только базовая конфигурация OWASP m=19 MiB, t=2, p=1. @@ -179,8 +205,8 @@ RESULTS_TABLE | Воздействие | Что ожидаем | Что наблюдали | Время восстановления / потеря данных | | --- | --- | --- | --- | -| `restart.sh`: рестарт LB, API ×2, relay, worker, PostgreSQL, Valkey, S3, RabbitMQ, **OpenBao** (+ unseal оператором) | данные и сессия сохранены | PERSIST_RESULT | 0 потерь | -| `stop-one.sh` по очереди для обеих реплик | запросы идут через оставшуюся, повтор без дублей | FAILOVER_RESULT | 0 потерь подтверждённых | +| `restart.sh`: рестарт LB, API ×2, relay, worker, PostgreSQL, Valkey, S3, RabbitMQ, **OpenBao** (+ unseal оператором) | данные и сессия сохранены | PASS за 65 с, тот же токен, сообщения и файл на месте (`evidence/persistence.txt`) | 0 потерь | +| `stop-one.sh` по очереди для обеих реплик | запросы идут через оставшуюся, повтор без дублей | обе реплики по очереди: 117 и 120 записей, 0 неудачных попыток, первая успешная запись после отказа через 1,75 и 1,79 с (`evidence/failover.txt`) | 0 потерь подтверждённых | | OpenBao запечатан (`docker compose restart openbao`) | работающие реплики обслуживают; новая не стартует до unseal | `test_sealed_openbao_keeps_running_replicas_and_blocks_new_ones` PASS: запросы 200, новая реплика пишет `openbao_unavailable` и не становится healthy, после unseal поднимается | до unseal оператором | | 5 неудачных входов одного пользователя | 429 + `Retry-After`, CPU не тратится | `test_failed_logins_are_rate_limited_with_retry_after` PASS | окно 60 с | @@ -193,6 +219,25 @@ RESULTS_TABLE 5. **`X-Instance-Id` перезаписывался вспомогательным процессом.** Отладочный `docker compose exec api python …` генерировал новый alias и переписывал `/tmp/instance_id`, и `stop-one` не находил реплику. Исправлено: файл пишет только главный процесс сервиса. 6. **CRLF в stdin на Windows.** Тесты, передающие пароль через stdin, на Windows посылали `\r\n`. Исправлено: stdin передаётся байтами. +Ещё шесть дефектов нашёл первый прогон из чистого clone (13 падений из 425). Часть совпала с перегрузкой хоста посторонним процессом на 85–100 % CPU, поэтому прогон был повторён полностью. В итоговом прогоне — 0 падений. + +7. **Всплеск TLS-соединений к Valkey.** + * Что было: 24 параллельных запроса на свежей реплике открывали 24 новых TLS-соединения, часть рукопожатий не укладывалась в таймаут → 503 (`test_concurrent_same_key…`, требование ЛР 3 «все 201»). + * Исправлено: ограниченный пул (`CACHE_POOL_SIZE=8`), прогретый до readiness (`sessions.warm`). +8. **`restart.sh` дольше 90 с.** Три отдельных `docker compose start` ждали healthcheck по ~23 с каждый. Исправлено: один `start api relay worker lb` (80 → 65 с). +9. **`stop-one.sh` дольше 10 с.** + * Что было: `docker exec` на Windows стоит ~1,8 с на реплику, плюс синхронный `docker stop` с drain. + * Исправлено: alias реплик читаются параллельно, `docker stop` запускается в фоне. Docker сразу помечает контейнер остановленным пользователем, поэтому restart policy его не поднимет. +10. **Healthcheck и `start_period` API.** + * Что было: под нагрузкой старт Python-пробы занимал > 2 с, и здоровая реплика оставалась `unhealthy`; после холодного старта Docker `up --wait` сдавался раньше, чем API успевал войти в OpenBao. + * Исправлено: `timeout: 5s`, `start_period: 30s`. Обнаружение упавшей реплики после старта осталось 3 × 2 с. +11. **`check_dashboard.py` без нашего CA.** Скрипт обращался к Grafana без публичного CA. Исправлено: `context=obs.TLS`. +12. **Хрупкие тесты.** + * Время «реплика не замерла» включало `docker exec` → теперь меряется внутри контейнера. + * Ручной upload по TLS читал только первую TLS-запись → теперь дочитывает ответ. + * Grace уборщика 3 с был короче самих проверок через `docker exec` → 15 с. + * Сборщик доказательств ронял одну и ту же реплику из-за положения round-robin → теперь сдвигает его между прогонами. + ## Ограничения и следующие шаги * **Уровень 4 не заявлен:** diff --git a/docs/DEFENSE.md b/docs/DEFENSE.md index cecc20c..d5df8d5 100644 --- a/docs/DEFENSE.md +++ b/docs/DEFENSE.md @@ -75,6 +75,6 @@ * **mTLS:** «Подпись CA — это пропуск, allowlist SAN — список допущенных ролей, сессия — права пользователя.» * **PostgreSQL:** «Шесть ролей, никто из сервисов не суперпользователь, `pg_hba` принимает только `hostssl`; GRANT выписаны по коду, а worker не видит даже таблицу users.» * **OpenBao:** «Не dev, raft на volume, TLS. AppRole на каждый сервис, токен живёт секунды, root token и доли — у оператора вне репозитория.» -* **Argon2id:** «Параметры m=19 MiB, t=2, p=1 выбраны замером в контейнере API с лимитом 1 CPU. Это ~31 мс на вход; более тяжёлые давали 70–250 мс и 4–14 входов в секунду на реплику, то есть дешёвый DoS.» +* **Argon2id:** «Параметры m=19 MiB, t=2, p=1 выбраны замером в контейнере API с лимитом 1 CPU. Это 30–50 мс на вход при 1 CPU; более тяжёлые давали 70–250 мс и 2–14 входов в секунду на реплику, то есть дешёвый DoS.» * **Лимит входа:** «Счётчик неудач в Valkey, общий для реплик, проверяется до Argon2; при блокировке даже верный пароль получает 429, иначе блокировка подсказывала бы, что пароль угадан.» * **Hardening:** «Везде `cap_drop: ALL` и `no-new-privileges`, app/worker с uid 10001 и нулевыми capabilities; наружу только 8443 и 3000, оба HTTPS на loopback.» diff --git a/evidence/SUMMARY.md b/evidence/SUMMARY.md new file mode 100644 index 0000000..68ee3a9 --- /dev/null +++ b/evidence/SUMMARY.md @@ -0,0 +1,18 @@ +# Сводка доказательств lab7 + +Собрано: 2026-11-28T14:51:20+00:00 + +| Шаг | Команда | Код | Файл | Время, с | +| --- | --- | --- | --- | --- | +| стенд: версии/hardening/секреты по сервисам | `docker compose config/ps/inspect/exec` | 0 | [stand.md](stand.md) | 0 | +| make check | `.venv\Scripts\python.exe scripts/check_contract.py` | 0 | [check.txt](check.txt) | 4 | +| make test (HTTPS, public CA) | `.venv\Scripts\python.exe tests/smoke.py --base-url https://localhost:8443 --ca-file C:\Users\wfa2` | 0 | [smoke.txt](smoke.txt) | 5 | +| make test-security (недоверенный CA) | `.venv\Scripts\python.exe tests/security.py --base-url https://localhost:8443 --ca-file C:\Users\w` | 0 | [test-security.txt](test-security.txt) | 1 | +| mTLS LB->API: без cert / чужой CA / неверная identity / lb | `C:\Program Files\Git\bin\bash.exe scripts\mtls_check.sh` | 0 | [mtls-check.txt](mtls-check.txt) | 4 | +| OpenBao allow/deny, root credential отсутствует в app | `C:\Program Files\Git\bin\bash.exe scripts\bao_check.sh && C:\Users\wfa22\Desktop\Высоконагруженны` | 0 | [bao-check.txt](bao-check.txt) | 20 | +| make test-persistence (рестарт всех процессов, unseal) | `docker compose ps -a && .venv\Scripts\python.exe tests/resilience.py --mode persistence --action-` | 0 | [persistence.txt](persistence.txt) | 65 | +| make test-failover x N, обе реплики по очереди | `tests/resilience.py --mode failover + restore` | 0 | [failover.txt](failover.txt) | 0 | +| Argon2id: замер в контейнере API (1 CPU) | `docker compose exec -T api python - < bench/argon2_bench.py` | 0 | [argon2/bench.json](argon2/bench.json) | 52 | +| Телеметрия по mTLS: trace + logs | `.venv\Scripts\python.exe scripts/trace_demo.py` | 0 | [trace-demo.txt](trace-demo.txt) | 7 | +| Dashboard: все запросы через Grafana (HTTPS) | `.venv\Scripts\python.exe scripts/check_dashboard.py` | 0 | [dashboard-check.txt](dashboard-check.txt) | 2 | +| Свои тесты (unit + стенд, в т.ч. test_security.py) | `.venv\Scripts\python.exe -m pytest student-tests -v -p no:cacheprovider --durations=15` | 0 | [student-tests.txt](student-tests.txt) | 1923 | diff --git a/evidence/argon2/bench.json b/evidence/argon2/bench.json new file mode 100644 index 0000000..918420f --- /dev/null +++ b/evidence/argon2/bench.json @@ -0,0 +1,290 @@ +{ + "when": "2026-11-28T14:18:18Z", + "python": "3.13.16", + "argon2_cffi": "25.1.0", + "cpus_visible": 8, + "cgroup": { + "cpu_max": "100000 100000", + "memory_max": "536870912" + }, + "sequential": [ + { + "m_kib": 19456, + "t": 2, + "p": 1, + "n": 15, + "median_ms": 50.6, + "p95_ms": 64.9, + "cpu_ms_per_hash": 47.8, + "hash_example_prefix": [ + "argon2id", + "v=19", + "m=19456,t=2,p=1" + ] + }, + { + "m_kib": 19456, + "t": 3, + "p": 1, + "n": 15, + "median_ms": 106.1, + "p95_ms": 172.3, + "cpu_ms_per_hash": 57.4, + "hash_example_prefix": [ + "argon2id", + "v=19", + "m=19456,t=3,p=1" + ] + }, + { + "m_kib": 19456, + "t": 4, + "p": 1, + "n": 15, + "median_ms": 87.9, + "p95_ms": 152.6, + "cpu_ms_per_hash": 78.5, + "hash_example_prefix": [ + "argon2id", + "v=19", + "m=19456,t=4,p=1" + ] + }, + { + "m_kib": 32768, + "t": 2, + "p": 1, + "n": 15, + "median_ms": 109.9, + "p95_ms": 277.4, + "cpu_ms_per_hash": 82.5, + "hash_example_prefix": [ + "argon2id", + "v=19", + "m=32768,t=2,p=1" + ] + }, + { + "m_kib": 32768, + "t": 3, + "p": 1, + "n": 15, + "median_ms": 144.1, + "p95_ms": 371.5, + "cpu_ms_per_hash": 126.9, + "hash_example_prefix": [ + "argon2id", + "v=19", + "m=32768,t=3,p=1" + ] + }, + { + "m_kib": 32768, + "t": 4, + "p": 1, + "n": 15, + "median_ms": 165.8, + "p95_ms": 294.4, + "cpu_ms_per_hash": 143.4, + "hash_example_prefix": [ + "argon2id", + "v=19", + "m=32768,t=4,p=1" + ] + }, + { + "m_kib": 47104, + "t": 2, + "p": 1, + "n": 15, + "median_ms": 167.8, + "p95_ms": 249.6, + "cpu_ms_per_hash": 140.0, + "hash_example_prefix": [ + "argon2id", + "v=19", + "m=47104,t=2,p=1" + ] + }, + { + "m_kib": 47104, + "t": 3, + "p": 1, + "n": 15, + "median_ms": 166.3, + "p95_ms": 516.5, + "cpu_ms_per_hash": 157.7, + "hash_example_prefix": [ + "argon2id", + "v=19", + "m=47104,t=3,p=1" + ] + }, + { + "m_kib": 47104, + "t": 4, + "p": 1, + "n": 15, + "median_ms": 210.6, + "p95_ms": 586.1, + "cpu_ms_per_hash": 209.4, + "hash_example_prefix": [ + "argon2id", + "v=19", + "m=47104,t=4,p=1" + ] + }, + { + "m_kib": 65536, + "t": 2, + "p": 1, + "n": 15, + "median_ms": 162.0, + "p95_ms": 379.4, + "cpu_ms_per_hash": 157.2, + "hash_example_prefix": [ + "argon2id", + "v=19", + "m=65536,t=2,p=1" + ] + }, + { + "m_kib": 65536, + "t": 3, + "p": 1, + "n": 15, + "median_ms": 264.1, + "p95_ms": 601.4, + "cpu_ms_per_hash": 233.3, + "hash_example_prefix": [ + "argon2id", + "v=19", + "m=65536,t=3,p=1" + ] + }, + { + "m_kib": 65536, + "t": 4, + "p": 1, + "n": 15, + "median_ms": 301.6, + "p95_ms": 1100.1, + "cpu_ms_per_hash": 279.5, + "hash_example_prefix": [ + "argon2id", + "v=19", + "m=65536,t=4,p=1" + ] + } + ], + "concurrent": [ + { + "m_kib": 19456, + "t": 2, + "threads": 1, + "hashes": 6, + "wall_s": 0.19, + "hashes_per_s": 32.0, + "median_ms": 29.7, + "p95_ms": 40.7, + "cpu_utilisation": 0.99, + "ram_mib_hashing": 19.0 + }, + { + "m_kib": 19456, + "t": 2, + "threads": 2, + "hashes": 12, + "wall_s": 0.42, + "hashes_per_s": 28.8, + "median_ms": 83.0, + "p95_ms": 89.6, + "cpu_utilisation": 1.04, + "ram_mib_hashing": 38.0 + }, + { + "m_kib": 19456, + "t": 2, + "threads": 4, + "hashes": 24, + "wall_s": 1.38, + "hashes_per_s": 17.4, + "median_ms": 205.0, + "p95_ms": 291.6, + "cpu_utilisation": 0.88, + "ram_mib_hashing": 76.0 + }, + { + "m_kib": 47104, + "t": 2, + "threads": 1, + "hashes": 6, + "wall_s": 1.09, + "hashes_per_s": 5.5, + "median_ms": 176.9, + "p95_ms": 309.5, + "cpu_utilisation": 0.6, + "ram_mib_hashing": 46.0 + }, + { + "m_kib": 47104, + "t": 2, + "threads": 2, + "hashes": 12, + "wall_s": 1.46, + "hashes_per_s": 8.2, + "median_ms": 224.2, + "p95_ms": 305.3, + "cpu_utilisation": 0.99, + "ram_mib_hashing": 92.0 + }, + { + "m_kib": 47104, + "t": 2, + "threads": 4, + "hashes": 24, + "wall_s": 4.76, + "hashes_per_s": 5.0, + "median_ms": 799.9, + "p95_ms": 980.1, + "cpu_utilisation": 0.82, + "ram_mib_hashing": 184.0 + }, + { + "m_kib": 19456, + "t": 3, + "threads": 1, + "hashes": 6, + "wall_s": 0.27, + "hashes_per_s": 22.1, + "median_ms": 43.9, + "p95_ms": 53.1, + "cpu_utilisation": 0.94, + "ram_mib_hashing": 19.0 + }, + { + "m_kib": 19456, + "t": 3, + "threads": 2, + "hashes": 12, + "wall_s": 0.63, + "hashes_per_s": 19.0, + "median_ms": 106.5, + "p95_ms": 156.0, + "cpu_utilisation": 1.0, + "ram_mib_hashing": 38.0 + }, + { + "m_kib": 19456, + "t": 3, + "threads": 4, + "hashes": 24, + "wall_s": 2.09, + "hashes_per_s": 11.5, + "median_ms": 385.3, + "p95_ms": 407.5, + "cpu_utilisation": 0.83, + "ram_mib_hashing": 76.0 + } + ] +} diff --git a/evidence/bao-check.txt b/evidence/bao-check.txt new file mode 100644 index 0000000..4f7aefd --- /dev/null +++ b/evidence/bao-check.txt @@ -0,0 +1,98 @@ +# OpenBao allow/deny, root credential отсутствует в app +# 2026-11-28T14:15:50+00:00 + +$ C:\Program Files\Git\bin\bash.exe scripts\bao_check.sh +== api +service api: OpenBao https://openbao:8200 (TLS verified against /run/secrets/internal-ca.crt) + PASS allow AppRole login with the service's role_id/secret_id -> HTTP 200 + token policies=['api'] ttl=3600s renewable=True + PASS allow read own path messenger/data/api -> HTTP 200 + keys: ['cache_url', 'database_url', 's3_access_key_id', 's3_secret_access_key'] + PASS allow token lookup-self -> HTTP 200 + PASS deny read other service's path messenger/data/relay -> HTTP 403 + PASS deny read other service's path messenger/data/worker -> HTTP 403 + PASS deny write own path messenger/data/api -> HTTP 403 + PASS deny list messenger/metadata -> HTTP 403 + PASS deny write policy sys/policies/acl/api -> HTTP 403 + PASS deny read policy list sys/policies/acl -> HTTP 403 + PASS deny create a child token auth/token/create -> HTTP 403 + PASS deny enable an auth method sys/auth/userpass -> HTTP 403 + PASS deny read sys/mounts -> HTTP 403 + PASS allow revoke-self -> HTTP 204 + PASS deny use the token after revoke-self (lookup-self) -> HTTP 403 + PASS deny read own path with the revoked token -> HTTP 403 + PASS deny AppRole login with a wrong secret_id -> HTTP 400 +PASS: OpenBao policy of api, 0 failure(s) +== relay +service relay: OpenBao https://openbao:8200 (TLS verified against /run/secrets/internal-ca.crt) + PASS allow AppRole login with the service's role_id/secret_id -> HTTP 200 + token policies=['relay'] ttl=3600s renewable=True + PASS allow read own path messenger/data/relay -> HTTP 200 + keys: ['broker_url', 'database_url'] + PASS allow token lookup-self -> HTTP 200 + PASS deny read other service's path messenger/data/api -> HTTP 403 + PASS deny read other service's path messenger/data/worker -> HTTP 403 + PASS deny write own path messenger/data/relay -> HTTP 403 + PASS deny list messenger/metadata -> HTTP 403 + PASS deny write policy sys/policies/acl/relay -> HTTP 403 + PASS deny read policy list sys/policies/acl -> HTTP 403 + PASS deny create a child token auth/token/create -> HTTP 403 + PASS deny enable an auth method sys/auth/userpass -> HTTP 403 + PASS deny read sys/mounts -> HTTP 403 + PASS allow revoke-self -> HTTP 204 + PASS deny use the token after revoke-self (lookup-self) -> HTTP 403 + PASS deny read own path with the revoked token -> HTTP 403 + PASS deny AppRole login with a wrong secret_id -> HTTP 400 +PASS: OpenBao policy of relay, 0 failure(s) +== worker +service worker: OpenBao https://openbao:8200 (TLS verified against /run/secrets/internal-ca.crt) + PASS allow AppRole login with the service's role_id/secret_id -> HTTP 200 + token policies=['worker'] ttl=3600s renewable=True + PASS allow read own path messenger/data/worker -> HTTP 200 + keys: ['broker_url', 'database_url', 's3_access_key_id', 's3_secret_access_key'] + PASS allow token lookup-self -> HTTP 200 + PASS deny read other service's path messenger/data/api -> HTTP 403 + PASS deny read other service's path messenger/data/relay -> HTTP 403 + PASS deny write own path messenger/data/worker -> HTTP 403 + PASS deny list messenger/metadata -> HTTP 403 + PASS deny write policy sys/policies/acl/worker -> HTTP 403 + PASS deny read policy list sys/policies/acl -> HTTP 403 + PASS deny create a child token auth/token/create -> HTTP 403 + PASS deny enable an auth method sys/auth/userpass -> HTTP 403 + PASS deny read sys/mounts -> HTTP 403 + PASS allow revoke-self -> HTTP 204 + PASS deny use the token after revoke-self (lookup-self) -> HTTP 403 + PASS deny read own path with the revoked token -> HTTP 403 + PASS deny AppRole login with a wrong secret_id -> HTTP 400 +PASS: OpenBao policy of worker, 0 failure(s) + +== root credential / unseal material in the application containers (values compared, never printed) + PASS api: no *TOKEN*/*UNSEAL*/*ROOT* environment variable + PASS control: own role_id found by the same search (/run/secrets/bao_role_id) + PASS api: root-token absent (/run/secrets, /app, /tmp, PID 1 environment) + PASS api: unseal-share-1 absent (/run/secrets, /app, /tmp, PID 1 environment) + PASS api: unseal-share-2 absent (/run/secrets, /app, /tmp, PID 1 environment) + PASS api: unseal-share-3 absent (/run/secrets, /app, /tmp, PID 1 environment) + api /run/secrets: bao_role_id bao_secret_id internal-ca.crt service.crt service.key + PASS relay: no *TOKEN*/*UNSEAL*/*ROOT* environment variable + PASS control: own role_id found by the same search (/run/secrets/bao_role_id) + PASS relay: root-token absent (/run/secrets, /app, /tmp, PID 1 environment) + PASS relay: unseal-share-1 absent (/run/secrets, /app, /tmp, PID 1 environment) + PASS relay: unseal-share-2 absent (/run/secrets, /app, /tmp, PID 1 environment) + PASS relay: unseal-share-3 absent (/run/secrets, /app, /tmp, PID 1 environment) + relay /run/secrets: bao_role_id bao_secret_id internal-ca.crt service.crt service.key + PASS worker: no *TOKEN*/*UNSEAL*/*ROOT* environment variable + PASS control: own role_id found by the same search (/run/secrets/bao_role_id) + PASS worker: root-token absent (/run/secrets, /app, /tmp, PID 1 environment) + PASS worker: unseal-share-1 absent (/run/secrets, /app, /tmp, PID 1 environment) + PASS worker: unseal-share-2 absent (/run/secrets, /app, /tmp, PID 1 environment) + PASS worker: unseal-share-3 absent (/run/secrets, /app, /tmp, PID 1 environment) + worker /run/secrets: bao_role_id bao_secret_id internal-ca.crt service.crt service.key +PASS: OpenBao allow/deny and no root credential in the application + +[exit 0] + +$ .venv\Scripts\python.exe scripts/bao_operator.py status +bao-operator: initialized=True sealed=False storage=raft version=2.7.3 operator_dir=C:\Users\wfa22\.mtusi-lab7-operator\mtusi-lab7-clean + +[exit 0] diff --git a/evidence/check.txt b/evidence/check.txt new file mode 100644 index 0000000..c913eb5 --- /dev/null +++ b/evidence/check.txt @@ -0,0 +1,7 @@ +# make check +# 2026-11-28T14:15:37+00:00 + +$ .venv\Scripts\python.exe scripts/check_contract.py +PASS: offline skeleton structure, local refs and Python syntax; application NOT tested. + +[exit 0] diff --git a/evidence/dashboard-check.txt b/evidence/dashboard-check.txt new file mode 100644 index 0000000..bda2f1a --- /dev/null +++ b/evidence/dashboard-check.txt @@ -0,0 +1,42 @@ +# Dashboard: все запросы через Grafana (HTTPS) +# 2026-11-28T14:19:16+00:00 + +$ .venv\Scripts\python.exe scripts/check_dashboard.py +dashboard messenger-lab6 "Messenger lab 6: API, worker, queue, SLO" (provisioned), window 30 min +== API: requests, errors, latency (all replicas) + [timeseries] Requests per second by route: A: 10 series/446 points + [timeseries] Error ratio (5xx and 4xx / all business requests): A: 1 series/67 points; B: 1 series/67 points + [timeseries] Latency p50 / p95 / p99 (all routes, all replicas): A: 1 series/67 points; B: 1 series/67 points; C: 1 series/67 points + [timeseries] p95 by route: A: 10 series/446 points + [timeseries] Requests in flight by replica: A: 42 series/851 points +== Worker and queue + [timeseries] Jobs handled per second by outcome: A: 1 series/47 points + [timeseries] Job duration p50 / p95 / p99 (succeeded): A: 1 series/47 points; B: 1 series/47 points; C: 1 series/47 points + [timeseries] Time to ready p50 / p95 / p99 (uploads): A: 1 series/47 points; B: 1 series/47 points; C: 1 series/47 points + [timeseries] Queue depth (PostgreSQL) and outbox: A: 2 series/136 points; B: 2 series/136 points + [timeseries] Oldest job age / oldest due outbox row: A: 1 series/68 points; B: 1 series/68 points + [timeseries] Worker saturation (busy / capacity): A: 1 series/66 points +== Database pool and resources + [timeseries] DB pool: used / max, waiting requests: A: 3 series/204 points; B: 3 series/204 points; C: 3 series/204 points + [timeseries] DB unit of work p95 by service: A: 3 series/202 points + [timeseries] DB pool wait p95 by service: A: 3 series/202 points + [timeseries] Container CPU (cores): A: 48 series/375 points; B: 1 series/69 points + [timeseries] Container memory: A: 48 series/1042 points; B: 1 series/70 points +== SLO (docs/SLO.md) and alerts + [stat] Availability, last 1 h (target 99 %): A: 1 series/70 points + [stat] Requests under 250 ms, last 5 min (target 95 %): A: 1 series/67 points + [stat] Uploads ready within 30 s, last 1 h (target 99 %): A: 1 series/70 points + [stat] Alerts firing: A: 1 series/121 points + [table] Alerts (pending / firing): A: no data +== Telemetry pipeline (Collector, SDK) + [timeseries] Collector: spans accepted / sent / failed per second: A: 1 series/66 points; B: 1 series/66 points; C: 1 series/66 points; D: no data + [timeseries] Collector: logs and metric points per second: A: 1 series/67 points; B: no data; C: 1 series/67 points; D: no data + [timeseries] Collector: exporter queues: A: 3 series/210 points; B: 3 series/210 points + [timeseries] SDK: spans recorded vs exported (all processes): A: 3 series/161 points; B: 3 series/161 points + [timeseries] Telemetry components up: A: 3 series/209 points +== Logs and traces + [logs] Application logs (Loki): warnings and errors: A: 1 series/100 points + [table] Recent upload traces (Tempo): A: 1 series/12 points +queries failed: 0 + +[exit 0] diff --git a/evidence/failover.txt b/evidence/failover.txt new file mode 100644 index 0000000..34ddb8c --- /dev/null +++ b/evidence/failover.txt @@ -0,0 +1,67 @@ +# make test-failover: последовательный отказ реплик API + +$ .venv\Scripts\python.exe tests/resilience.py --mode failover --action-script scripts\stop-one.cmd --ca-file secrets\pki\public-ca.crt +Executing explicit failover hook; hook output suppressed to avoid leaking secrets. +{"observed_instances_before": 2, "successful_writes": 117, "failed_attempts": 0, "first_recovery_seconds": 1.748} +PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence. + +[exit 0] + +$ docker compose ps -a api +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +mtusi-lab7-clean-api-1 mtusi-messenger:lab7 "python -m messenger" api 3 minutes ago Exited (0) 9 seconds ago +mtusi-lab7-clean-api-2 mtusi-messenger:lab7 "python -m messenger" api 3 minutes ago Up 26 seconds (healthy) 8080/tcp, 8443/tcp + +[exit 0] + +$ C:\Program Files\Git\bin\bash.exe scripts\restore-api.sh +mtusi-lab7-clean-api-1 Up 6 seconds (healthy) +mtusi-lab7-clean-api-2 Up 35 seconds (healthy) + Container mtusi-lab7-clean-api-2 Running + Container mtusi-lab7-clean-api-1 Starting + Container mtusi-lab7-clean-api-1 Started + Container mtusi-lab7-clean-api-1 Waiting + Container mtusi-lab7-clean-api-2 Waiting + Container mtusi-lab7-clean-api-1 Healthy + Container mtusi-lab7-clean-api-2 Healthy + +[exit 0] + +$ .venv\Scripts\python.exe scripts/lbctl.py wait-up 2 +2 API replica(s) UP in HAProxy after 1.1 s: ['i-5f67386b096f', 'i-7bcf23aa0693'] + +[exit 0] + +$ .venv\Scripts\python.exe tests/resilience.py --mode failover --action-script scripts\stop-one.cmd --ca-file secrets\pki\public-ca.crt +Executing explicit failover hook; hook output suppressed to avoid leaking secrets. +{"observed_instances_before": 2, "successful_writes": 120, "failed_attempts": 0, "first_recovery_seconds": 1.787} +PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence. + +[exit 0] + +$ docker compose ps -a api +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +mtusi-lab7-clean-api-1 mtusi-messenger:lab7 "python -m messenger" api 3 minutes ago Up 28 seconds (healthy) 8080/tcp, 8443/tcp +mtusi-lab7-clean-api-2 mtusi-messenger:lab7 "python -m messenger" api 3 minutes ago Exited (0) 10 seconds ago + +[exit 0] + +$ C:\Program Files\Git\bin\bash.exe scripts\restore-api.sh +mtusi-lab7-clean-api-1 Up 37 seconds (healthy) +mtusi-lab7-clean-api-2 Up 7 seconds (healthy) + Container mtusi-lab7-clean-api-1 Running + Container mtusi-lab7-clean-api-2 Starting + Container mtusi-lab7-clean-api-2 Started + Container mtusi-lab7-clean-api-1 Waiting + Container mtusi-lab7-clean-api-2 Waiting + Container mtusi-lab7-clean-api-1 Healthy + Container mtusi-lab7-clean-api-2 Healthy + +[exit 0] + +$ .venv\Scripts\python.exe scripts/lbctl.py wait-up 2 +2 API replica(s) UP in HAProxy after 1.1 s: ['i-5f67386b096f', 'i-83def22f481a'] + +[exit 0] + +stopped containers over the runs: ['17c5883f5d19', '87d05ecea97d'] diff --git a/evidence/mtls-check.txt b/evidence/mtls-check.txt new file mode 100644 index 0000000..20165be --- /dev/null +++ b/evidence/mtls-check.txt @@ -0,0 +1,39 @@ +# mTLS LB->API: без cert / чужой CA / неверная identity / lb +# 2026-11-28T14:15:47+00:00 + +$ C:\Program Files\Git\bin\bash.exe scripts\mtls_check.sh +API replicas behind DNS name `api`: 2 + +replica 172.26.0.3:8443 + PASS TLS 1.3 client cert none -> refused closed by the server after the handshake (no HTTP response) + PASS TLS 1.3 client cert foreign-ca SAN=lb -> refused closed by the server after the handshake (no HTTP response) + PASS TLS 1.3 client cert internal-ca SAN=worker -> refused closed by the server after the handshake (no HTTP response) + PASS TLS 1.3 client cert internal-ca SAN=lb -> 200 HTTP 200; server cert SAN api verified + PASS TLS 1.2 client cert none -> refused server closed the connection during the handshake (no HTTP response) + PASS TLS 1.2 client cert foreign-ca SAN=lb -> refused server closed the connection during the handshake (no HTTP response) + PASS TLS 1.2 client cert internal-ca SAN=worker -> refused server closed the connection during the handshake (no HTTP response) + PASS TLS 1.2 client cert internal-ca SAN=lb -> 200 HTTP 200; server cert SAN api verified + PASS plaintext HTTP to the mTLS port -> no HTTP answer (TLS-only listener) + PASS loopback health port from outside -> ConnectionRefusedError + +replica 172.26.0.4:8443 + PASS TLS 1.3 client cert none -> refused closed by the server after the handshake (no HTTP response) + PASS TLS 1.3 client cert foreign-ca SAN=lb -> refused closed by the server after the handshake (no HTTP response) + PASS TLS 1.3 client cert internal-ca SAN=worker -> refused closed by the server after the handshake (no HTTP response) + PASS TLS 1.3 client cert internal-ca SAN=lb -> 200 HTTP 200; server cert SAN api verified + PASS TLS 1.2 client cert none -> refused server closed the connection during the handshake (no HTTP response) + PASS TLS 1.2 client cert foreign-ca SAN=lb -> refused server closed the connection during the handshake (no HTTP response) + PASS TLS 1.2 client cert internal-ca SAN=worker -> refused server closed the connection during the handshake (no HTTP response) + PASS TLS 1.2 client cert internal-ca SAN=lb -> 200 HTTP 200; server cert SAN api verified + PASS plaintext HTTP to the mTLS port -> no HTTP answer (TLS-only listener) + PASS loopback health port from outside -> ConnectionRefusedError + +PASS: mTLS LB->API, 2 replica(s), 0 failure(s) + +API log since 2026-11-28T14:15:47Z, identity allowlist refusals (cases 1-2 are dropped by TLS and never logged): +{"ts": "2026-11-28T14:15:49.594Z", "level": "warning", "logger": "messenger.tls", "event": "mtls_identity_rejected", "client_san": ["worker"], "peer": "172.26.0.5", "allowed": ["lb"]} +{"ts": "2026-11-28T14:15:49.691Z", "level": "warning", "logger": "messenger.tls", "event": "mtls_identity_rejected", "client_san": ["worker"], "peer": "172.26.0.5", "allowed": ["lb"]} +{"ts": "2026-11-28T14:15:49.309Z", "level": "warning", "logger": "messenger.tls", "event": "mtls_identity_rejected", "client_san": ["worker"], "peer": "172.26.0.5", "allowed": ["lb"]} +{"ts": "2026-11-28T14:15:49.438Z", "level": "warning", "logger": "messenger.tls", "event": "mtls_identity_rejected", "client_san": ["worker"], "peer": "172.26.0.5", "allowed": ["lb"]} + +[exit 0] diff --git a/evidence/persistence.txt b/evidence/persistence.txt new file mode 100644 index 0000000..381d618 --- /dev/null +++ b/evidence/persistence.txt @@ -0,0 +1,52 @@ +# make test-persistence (рестарт всех процессов, unseal) +# 2026-11-28T14:16:10+00:00 + +$ docker compose ps -a +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +mtusi-lab7-clean-api-1 mtusi-messenger:lab7 "python -m messenger" api About a minute ago Up About a minute (healthy) 8080/tcp, 8443/tcp +mtusi-lab7-clean-api-2 mtusi-messenger:lab7 "python -m messenger" api About a minute ago Up About a minute (healthy) 8080/tcp, 8443/tcp +mtusi-lab7-clean-broker-1 rabbitmq:4.3.7-alpine@sha256:b1f997f74103d08fc1f20a13890dc44fe6cfa51d528cf521b480ada988d3ffa5 "docker-entrypoint.s…" broker 16 hours ago Up 14 minutes (healthy) 4369/tcp, 5671-5672/tcp, 15691-15692/tcp, 25672/tcp +mtusi-lab7-clean-grafana-1 grafana/grafana:13.2.6@sha256:b21409d7951ddcfd63a4b49083e4ef2cc35bc1437d071813bf82bfb238b00bca "/run.sh" grafana 16 hours ago Up 14 minutes (healthy) 127.0.0.1:3000->3000/tcp, [::1]:3000->3000/tcp +mtusi-lab7-clean-lb-1 haproxy:3.2.26-alpine@sha256:254e6370f01cd654e0744edf607c67f33777c1b6a9dc0d4b28bcba7171460122 "docker-entrypoint.s…" lb 16 hours ago Up 14 minutes (healthy) 127.0.0.1:8443->8443/tcp, [::1]:8443->8443/tcp +mtusi-lab7-clean-loki-1 grafana/loki:3.7.10@sha256:b43c257ccfc925d4a50b8717cac61a3b51df8c48d01847936057e5c4075a24a7 "/usr/bin/loki -conf…" loki 16 hours ago Up 14 minutes 3100/tcp +mtusi-lab7-clean-migrate-1 mtusi-messenger:lab7 "python -m messenger…" migrate 5 minutes ago Exited (0) 5 minutes ago +mtusi-lab7-clean-openbao-1 openbao/openbao:2.7.3@sha256:b9418c63e2185157d8ee8689a8a93265d5aadad677d6320156172bd42ad3b10b "docker-entrypoint.s…" openbao 16 hours ago Up 14 minutes (healthy) 8200/tcp +mtusi-lab7-clean-otel-collector-1 otel/opentelemetry-collector-contrib:0.165.0@sha256:e40d61f10c9a617cca1ffd1be4d7e2b3a4b0f0001798ff07e58cabe82e618cea "/otelcol-contrib --…" otel-collector 16 hours ago Up 14 minutes 4317-4318/tcp, 55679/tcp +mtusi-lab7-clean-postgres-1 postgres:18.6-bookworm@sha256:afc7e2d441324c0388fa80c3d24f733b4194a4eb7f47dd8ee2b08eb1a24a647c "docker-entrypoint.s…" postgres 16 hours ago Up About a minute (healthy) 5432/tcp +mtusi-lab7-clean-prometheus-1 prom/prometheus:v3.16.0@sha256:e04987641b57704f408e31f6373ba4138ecf27cb4a165d24aabb6c38fddd0f06 "/bin/prometheus --c…" prometheus 16 hours ago Up 14 minutes (healthy) 9090/tcp +mtusi-lab7-clean-relay-1 mtusi-messenger:lab7 "python -m messenger…" relay 5 minutes ago Up 5 minutes (healthy) 8080/tcp +mtusi-lab7-clean-s3-1 chrislusf/seaweedfs:4.46@sha256:08d516132314207d10c8e37cbffc1f32b147d870169688734cc61c6231625b62 "/bin/sh /etc/seawee…" s3 16 hours ago Up 14 minutes (healthy) 7333/tcp, 8080/tcp, 8333/tcp, 8888/tcp, 9333/tcp, 18080/tcp, 18888/tcp, 19333/tcp +mtusi-lab7-clean-s3-init-1 mtusi-messenger:lab7 "python -m messenger…" s3-init 5 minutes ago Exited (0) 5 minutes ago +mtusi-lab7-clean-tempo-1 grafana/tempo:2.10.10@sha256:12b0820f13ffa10ce956b6e9acc3b03f3cffded99109be6cc09d106fe56e5d38 "/tempo -config.file…" tempo 16 hours ago Up 14 minutes +mtusi-lab7-clean-valkey-1 valkey/valkey:8.1.3-bookworm@sha256:fea8b3e67b15729d4bb70589eb03367bab9ad1ee89c876f54327fc7c6e618571 "/bin/sh /etc/valkey…" valkey 16 hours ago Up 3 minutes (healthy) 6379/tcp +mtusi-lab7-clean-worker-1 mtusi-messenger:lab7 "python -m messenger…" worker 5 minutes ago Up 5 minutes (healthy) 8080/tcp + +[exit 0] + +$ .venv\Scripts\python.exe tests/resilience.py --mode persistence --action-script scripts\restart.cmd --ca-file secrets\pki\public-ca.crt +Executing explicit persistence hook; hook output suppressed to avoid leaking secrets. +PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence. + +[exit 0] + +$ docker compose ps -a +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +mtusi-lab7-clean-api-1 mtusi-messenger:lab7 "python -m messenger" api 2 minutes ago Up 8 seconds (healthy) 8080/tcp, 8443/tcp +mtusi-lab7-clean-api-2 mtusi-messenger:lab7 "python -m messenger" api 2 minutes ago Up 7 seconds (healthy) 8080/tcp, 8443/tcp +mtusi-lab7-clean-broker-1 rabbitmq:4.3.7-alpine@sha256:b1f997f74103d08fc1f20a13890dc44fe6cfa51d528cf521b480ada988d3ffa5 "docker-entrypoint.s…" broker 16 hours ago Up 53 seconds (healthy) 4369/tcp, 5671-5672/tcp, 15691-15692/tcp, 25672/tcp +mtusi-lab7-clean-grafana-1 grafana/grafana:13.2.6@sha256:b21409d7951ddcfd63a4b49083e4ef2cc35bc1437d071813bf82bfb238b00bca "/run.sh" grafana 16 hours ago Up 15 minutes (healthy) 127.0.0.1:3000->3000/tcp, [::1]:3000->3000/tcp +mtusi-lab7-clean-lb-1 haproxy:3.2.26-alpine@sha256:254e6370f01cd654e0744edf607c67f33777c1b6a9dc0d4b28bcba7171460122 "docker-entrypoint.s…" lb 16 hours ago Up 1 second (health: starting) 127.0.0.1:8443->8443/tcp, [::1]:8443->8443/tcp +mtusi-lab7-clean-loki-1 grafana/loki:3.7.10@sha256:b43c257ccfc925d4a50b8717cac61a3b51df8c48d01847936057e5c4075a24a7 "/usr/bin/loki -conf…" loki 16 hours ago Up 15 minutes 3100/tcp +mtusi-lab7-clean-migrate-1 mtusi-messenger:lab7 "python -m messenger…" migrate 7 minutes ago Exited (0) 28 seconds ago +mtusi-lab7-clean-openbao-1 openbao/openbao:2.7.3@sha256:b9418c63e2185157d8ee8689a8a93265d5aadad677d6320156172bd42ad3b10b "docker-entrypoint.s…" openbao 16 hours ago Up 53 seconds (healthy) 8200/tcp +mtusi-lab7-clean-otel-collector-1 otel/opentelemetry-collector-contrib:0.165.0@sha256:e40d61f10c9a617cca1ffd1be4d7e2b3a4b0f0001798ff07e58cabe82e618cea "/otelcol-contrib --…" otel-collector 16 hours ago Up 15 minutes 4317-4318/tcp, 55679/tcp +mtusi-lab7-clean-postgres-1 postgres:18.6-bookworm@sha256:afc7e2d441324c0388fa80c3d24f733b4194a4eb7f47dd8ee2b08eb1a24a647c "docker-entrypoint.s…" postgres 16 hours ago Up 54 seconds (healthy) 5432/tcp +mtusi-lab7-clean-prometheus-1 prom/prometheus:v3.16.0@sha256:e04987641b57704f408e31f6373ba4138ecf27cb4a165d24aabb6c38fddd0f06 "/bin/prometheus --c…" prometheus 16 hours ago Up 15 minutes (healthy) 9090/tcp +mtusi-lab7-clean-relay-1 mtusi-messenger:lab7 "python -m messenger…" relay 7 minutes ago Up 28 seconds (healthy) 8080/tcp +mtusi-lab7-clean-s3-1 chrislusf/seaweedfs:4.46@sha256:08d516132314207d10c8e37cbffc1f32b147d870169688734cc61c6231625b62 "/bin/sh /etc/seawee…" s3 16 hours ago Up 34 seconds (healthy) 7333/tcp, 8080/tcp, 8333/tcp, 8888/tcp, 9333/tcp, 18080/tcp, 18888/tcp, 19333/tcp +mtusi-lab7-clean-s3-init-1 mtusi-messenger:lab7 "python -m messenger…" s3-init 7 minutes ago Exited (0) 8 seconds ago +mtusi-lab7-clean-tempo-1 grafana/tempo:2.10.10@sha256:12b0820f13ffa10ce956b6e9acc3b03f3cffded99109be6cc09d106fe56e5d38 "/tempo -config.file…" tempo 16 hours ago Up 15 minutes +mtusi-lab7-clean-valkey-1 valkey/valkey:8.1.3-bookworm@sha256:fea8b3e67b15729d4bb70589eb03367bab9ad1ee89c876f54327fc7c6e618571 "/bin/sh /etc/valkey…" valkey 16 hours ago Up 54 seconds (healthy) 6379/tcp +mtusi-lab7-clean-worker-1 mtusi-messenger:lab7 "python -m messenger…" worker 7 minutes ago Up 6 seconds (healthy) 8080/tcp + +[exit 0] diff --git a/evidence/smoke.txt b/evidence/smoke.txt new file mode 100644 index 0000000..506f24f --- /dev/null +++ b/evidence/smoke.txt @@ -0,0 +1,7 @@ +# make test (HTTPS, public CA) +# 2026-11-28T14:15:41+00:00 + +$ .venv\Scripts\python.exe tests/smoke.py --base-url https://localhost:8443 --ca-file secrets\pki\public-ca.crt +PASS: lab7 public API scenario; infrastructure and grading evidence remain separate. + +[exit 0] diff --git a/evidence/stand.md b/evidence/stand.md new file mode 100644 index 0000000..2fd1139 --- /dev/null +++ b/evidence/stand.md @@ -0,0 +1,64 @@ +# Стенд: версии, образы, hardening, секреты по сервисам (только имена) + +commit: f2bd580c2f1ee6473034e6f8bd03f44dbc67c73c +docker: 29.8.0 (linux/amd64) +docker VM: 8 CPU, 15686336512 bytes RAM +compose project: mtusi-lab7-clean + +| service | image | cap_drop | cap_add | no-new-priv | cpus | memory | published | secrets (names) | +| --- | --- | --- | --- | --- | --- | --- | --- | --- | +| api | mtusi-messenger:lab7 | ['ALL'] | | True | 1 | 512 MiB | [] | bao_api_role_id, bao_api_secret_id, pki_api_crt, pki_api_key, pki_internal_ca | +| broker | rabbitmq:4.3.7-alpine@sha256:b1f997f74103d08fc1f20a13890dc44fe6cfa51d528cf521b480ada988d3ffa5 | ['ALL'] | ['CHOWN', 'DAC_OVERRIDE', 'FOWNER', 'SETGID', 'SETUID'] | True | 1 | 512 MiB | [] | pki_broker_crt, pki_broker_key, pki_internal_ca, rabbitmq_users | +| grafana | grafana/grafana:13.2.6@sha256:b21409d7951ddcfd63a4b49083e4ef2cc35bc1437d071813bf82bfb238b00bca | ['ALL'] | | True | 1 | 1024 MiB | ['127.0.0.1:3000', '::1:3000'] | grafana_admin_password, pki_grafana_crt, pki_grafana_key, pki_grafana_ui_crt, pki_grafana_ui_key, pki_internal_ca, pki_public_ca | +| lb | haproxy:3.2.26-alpine@sha256:254e6370f01cd654e0744edf607c67f33777c1b6a9dc0d4b28bcba7171460122 | ['ALL'] | | True | 1 | 128 MiB | ['127.0.0.1:8443', '::1:8443'] | pki_ingress_pem, pki_internal_ca, pki_lb_pem | +| loki | grafana/loki:3.7.10@sha256:b43c257ccfc925d4a50b8717cac61a3b51df8c48d01847936057e5c4075a24a7 | ['ALL'] | | True | 1 | 512 MiB | [] | pki_internal_ca, pki_loki_crt, pki_loki_key | +| migrate | mtusi-messenger:lab7 | ['ALL'] | | True | 0.5 | 256 MiB | [] | database_url_migrate, pki_internal_ca | +| openbao | openbao/openbao:2.7.3@sha256:b9418c63e2185157d8ee8689a8a93265d5aadad677d6320156172bd42ad3b10b | ['ALL'] | | True | 0.5 | 256 MiB | [] | pki_internal_ca, pki_openbao_crt, pki_openbao_key | +| otel-collector | otel/opentelemetry-collector-contrib:0.165.0@sha256:e40d61f10c9a617cca1ffd1be4d7e2b3a4b0f0001798ff07e58cabe82e618cea | ['ALL'] | | True | 1 | 512 MiB | [] | pki_internal_ca, pki_otel_collector_crt, pki_otel_collector_key | +| postgres | postgres:18.6-bookworm@sha256:afc7e2d441324c0388fa80c3d24f733b4194a4eb7f47dd8ee2b08eb1a24a647c | ['ALL'] | ['CHOWN', 'DAC_OVERRIDE', 'FOWNER', 'SETGID', 'SETUID'] | True | 2 | 1024 MiB | [] | pg_api_password, pg_auditor_password, pg_jobctl_password, pg_migrate_password, pg_relay_password, pg_worker_password, pki_internal_ca, pki_postgres_crt, pki_postgres_key, postgres_password | +| prometheus | prom/prometheus:v3.16.0@sha256:e04987641b57704f408e31f6373ba4138ecf27cb4a165d24aabb6c38fddd0f06 | ['ALL'] | | True | 1 | 512 MiB | [] | pki_internal_ca, pki_prometheus_crt, pki_prometheus_key | +| relay | mtusi-messenger:lab7 | ['ALL'] | | True | 0.5 | 256 MiB | [] | bao_relay_role_id, bao_relay_secret_id, pki_internal_ca, pki_relay_crt, pki_relay_key | +| s3 | chrislusf/seaweedfs:4.46@sha256:08d516132314207d10c8e37cbffc1f32b147d870169688734cc61c6231625b62 | ['ALL'] | ['CHOWN', 'DAC_OVERRIDE', 'FOWNER', 'SETGID', 'SETUID'] | True | 1 | 1024 MiB | [] | pki_internal_ca, pki_s3_crt, pki_s3_key, s3_admin_access_key_id, s3_admin_secret_access_key, s3_api_access_key_id, s3_api_secret_access_key, s3_auditor_access_key_id, s3_auditor_secret_access_key, s3_worker_access_key_id, s3_worker_secret_access_key | +| s3-init | mtusi-messenger:lab7 | ['ALL'] | | True | 0.5 | 256 MiB | [] | pki_internal_ca, s3_admin_access_key_id, s3_admin_secret_access_key, s3_api_access_key_id, s3_api_secret_access_key, s3_auditor_access_key_id, s3_auditor_secret_access_key, s3_worker_access_key_id, s3_worker_secret_access_key | +| tempo | grafana/tempo:2.10.10@sha256:12b0820f13ffa10ce956b6e9acc3b03f3cffded99109be6cc09d106fe56e5d38 | ['ALL'] | | True | 1 | 512 MiB | [] | pki_internal_ca, pki_tempo_crt, pki_tempo_key | +| valkey | valkey/valkey:8.1.3-bookworm@sha256:fea8b3e67b15729d4bb70589eb03367bab9ad1ee89c876f54327fc7c6e618571 | ['ALL'] | ['CHOWN', 'DAC_OVERRIDE', 'FOWNER', 'SETGID', 'SETUID'] | True | 0.5 | 256 MiB | [] | pki_internal_ca, pki_valkey_crt, pki_valkey_key, valkey_api_password | +| worker | mtusi-messenger:lab7 | ['ALL'] | | True | 2 | 1536 MiB | [] | bao_worker_role_id, bao_worker_secret_id, pki_internal_ca, pki_worker_crt, pki_worker_key | + +## docker compose ps -a + +``` +api Up 49 seconds (healthy) 8080/tcp, 8443/tcp +api Up 48 seconds (healthy) 8080/tcp, 8443/tcp +broker Up 13 minutes (healthy) 4369/tcp, 5671-5672/tcp, 15691-15692/tcp, 25672/tcp +grafana Up 13 minutes (healthy) 127.0.0.1:3000->3000/tcp, [::1]:3000->3000/tcp +lb Up 13 minutes (healthy) 127.0.0.1:8443->8443/tcp, [::1]:8443->8443/tcp +loki Up 13 minutes 3100/tcp +migrate Exited (0) 5 minutes ago +openbao Up 13 minutes (healthy) 8200/tcp +otel-collector Up 13 minutes 4317-4318/tcp, 55679/tcp +postgres Up About a minute (healthy) 5432/tcp +prometheus Up 13 minutes (healthy) 9090/tcp +relay Up 5 minutes (healthy) 8080/tcp +s3 Up 13 minutes (healthy) 7333/tcp, 8080/tcp, 8333/tcp, 8888/tcp, 9333/tcp, 18080/tcp, 18888/tcp, 19333/tcp +s3-init Exited (0) 4 minutes ago +tempo Up 13 minutes +valkey Up 2 minutes (healthy) 6379/tcp +worker Up 4 minutes (healthy) 8080/tcp +``` + +## Пользователь и capabilities PID 1 (запущенные контейнеры) + +| service | container | user | capabilities | X-Instance-Id alias | +| --- | --- | --- | --- | --- | +| api | 17c5883f5d19 | uid 10001 | CapEff 0000000000000000 | i-1c2252476ea2 | +| api | 87d05ecea97d | uid 10001 | CapEff 0000000000000000 | i-7a9bc4eb5903 | +| relay | 638e500712f8 | uid 10001 | CapEff 0000000000000000 | i-f6d48092a828 | +| worker | 7b83b29d9feb | uid 10001 | CapEff 0000000000000000 | i-5751896bbdd1 | +| lb | ae03174dae61 | uid 99 | CapEff 0000000000000000 | - | +| openbao | 51aa7f9765f9 | uid 100 | CapEff 0000000000000000 | - | +| otel-collector | 1acf642bfd4f | uid OCI runtime exec failed: exec failed: unable to start container process: exec: "id": executable file not found in $PATH | CapEff $PATH | OCI runtime exec failed: exec failed: unable to start container process: exec: "cat": executable file not found in $PATH | +| prometheus | 8583fee78ae1 | uid 65534 | CapEff 0000000000000000 | - | +| grafana | 294735cabfeb | uid 472 | CapEff 0000000000000000 | - | +| loki | 163ba071b6b3 | uid OCI runtime exec failed: exec failed: unable to start container process: exec: "id": executable file not found in $PATH | CapEff $PATH | OCI runtime exec failed: exec failed: unable to start container process: exec: "cat": executable file not found in $PATH | +| tempo | fa42af48bede | uid OCI runtime exec failed: exec failed: unable to start container process: exec: "id": executable file not found in $PATH | CapEff $PATH | OCI runtime exec failed: exec failed: unable to start container process: exec: "cat": executable file not found in $PATH | + diff --git a/evidence/student-tests.txt b/evidence/student-tests.txt new file mode 100644 index 0000000..f5989cc --- /dev/null +++ b/evidence/student-tests.txt @@ -0,0 +1,459 @@ +# Свои тесты (unit + стенд, в т.ч. test_security.py) +# 2026-11-28T14:19:18+00:00 + +$ .venv\Scripts\python.exe -m pytest student-tests -v -p no:cacheprovider --durations=15 +============================= test session starts ============================= +platform win32 -- Python 3.14.6, pytest-9.1.1, pluggy-1.7.0 -- .venv\Scripts\python.exe +rootdir: . +plugins: anyio-4.15.1 +collecting ... collected 429 items + +student-tests/test_api.py::test_register_never_returns_password_and_login_returns_bearer PASSED [ 0%] +student-tests/test_api.py::test_duplicate_username_is_409 PASSED [ 0%] +student-tests/test_api.py::test_bad_password_on_registration_is_400[short-11ch] PASSED [ 0%] +student-tests/test_api.py::test_bad_password_on_registration_is_400[ ] PASSED [ 0%] +student-tests/test_api.py::test_bad_password_on_registration_is_400[ \t \n \t \n \t \n ] PASSED [ 1%] +student-tests/test_api.py::test_bad_password_on_registration_is_400[\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f] PASSED [ 1%] +student-tests/test_api.py::test_edge_passwords_register_and_login[\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f] PASSED [ 1%] +student-tests/test_api.py::test_edge_passwords_register_and_login[with:colons:inside] PASSED [ 1%] +student-tests/test_api.py::test_edge_passwords_register_and_login[Twelve chars] PASSED [ 2%] +student-tests/test_api.py::test_wrong_password_and_unknown_user_give_the_same_401 PASSED [ 2%] +student-tests/test_api.py::test_malformed_basic_is_401_not_500[Basic \xe9] PASSED [ 2%] +student-tests/test_api.py::test_malformed_basic_is_401_not_500[Basic !!!] PASSED [ 2%] +student-tests/test_api.py::test_malformed_basic_is_401_not_500[Basic bm9fY29sb24=] PASSED [ 3%] +student-tests/test_api.py::test_malformed_basic_is_401_not_500[Basic //46eA==] PASSED [ 3%] +student-tests/test_api.py::test_malformed_basic_is_401_not_500[Bearer aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] PASSED [ 3%] +student-tests/test_api.py::test_malformed_basic_is_401_not_500[] PASSED [ 3%] +student-tests/test_api.py::test_logout_revokes_only_this_token PASSED [ 3%] +student-tests/test_api.py::test_x_user_id_basic_and_garbage_do_not_authenticate PASSED [ 4%] +student-tests/test_api.py::test_malformed_json_is_400[{] PASSED [ 4%] +student-tests/test_api.py::test_malformed_json_is_400[] PASSED [ 4%] +student-tests/test_api.py::test_malformed_json_is_400[[]] PASSED [ 4%] +student-tests/test_api.py::test_malformed_json_is_400[null] PASSED [ 5%] +student-tests/test_api.py::test_malformed_json_is_400[{"username": "abc_def", "display_name": NaN, "password": "Twelve-chars"}] PASSED [ 5%] +student-tests/test_api.py::test_malformed_json_is_400[{"username": "abc_def", "display_name": "x", "password": "Twelve-chars"}{"a": 1}] PASSED [ 5%] +student-tests/test_api.py::test_malformed_json_is_400[{"username": "abc_def", "display_name": "\ud800", "password": "Twelve-chars"}] PASSED [ 5%] +student-tests/test_api.py::test_invalid_registration_fields_are_400[body0] PASSED [ 6%] +student-tests/test_api.py::test_invalid_registration_fields_are_400[body1] PASSED [ 6%] +student-tests/test_api.py::test_invalid_registration_fields_are_400[body2] PASSED [ 6%] +student-tests/test_api.py::test_invalid_registration_fields_are_400[body3] PASSED [ 6%] +student-tests/test_api.py::test_invalid_registration_fields_are_400[body4] PASSED [ 6%] +student-tests/test_api.py::test_invalid_registration_fields_are_400[body5] PASSED [ 7%] +student-tests/test_api.py::test_unicode_limits_are_code_points_and_nul_is_stored PASSED [ 7%] +student-tests/test_api.py::test_oversized_body_and_wrong_content_type PASSED [ 7%] +student-tests/test_api.py::test_chat_validation PASSED [ 7%] +student-tests/test_api.py::test_foreign_chat_is_indistinguishable_from_missing PASSED [ 8%] +student-tests/test_api.py::test_chat_list_order_pagination_and_isolation PASSED [ 8%] +student-tests/test_api.py::test_history_pages_without_loss_or_duplicates PASSED [ 8%] +student-tests/test_api.py::test_bad_limit_or_cursor_is_400[limit=0] PASSED [ 8%] +student-tests/test_api.py::test_bad_limit_or_cursor_is_400[limit=101] PASSED [ 9%] +student-tests/test_api.py::test_bad_limit_or_cursor_is_400[limit=abc] PASSED [ 9%] +student-tests/test_api.py::test_bad_limit_or_cursor_is_400[limit=1&limit=2] PASSED [ 9%] +student-tests/test_api.py::test_bad_limit_or_cursor_is_400[cursor=] PASSED [ 9%] +student-tests/test_api.py::test_bad_limit_or_cursor_is_400[cursor=garbage] PASSED [ 10%] +student-tests/test_api.py::test_bad_limit_or_cursor_is_400[cursor=djF8bXx4fDF8Mg] PASSED [ 10%] +student-tests/test_api.py::test_bad_limit_or_cursor_is_400[cursor=djF8bXx4fDk5OTk5OTk5OTk5OTk5OTk5OTk5fHk=] PASSED [ 10%] +student-tests/test_api.py::test_cursor_bound_to_chat PASSED [ 10%] +student-tests/test_api.py::test_read_after_write PASSED [ 10%] +student-tests/test_api.py::test_malformed_cursor_values_are_400_on_both_lists PASSED [ 11%] +student-tests/test_api.py::test_bad_message_body_is_400_and_nothing_is_stored[\xff] PASSED [ 11%] +student-tests/test_api.py::test_bad_message_body_is_400_and_nothing_is_stored[{"text":"first","TEXT":"second"}] PASSED [ 11%] +student-tests/test_api.py::test_bad_message_body_is_400_and_nothing_is_stored[{"text":"a","text":"b"}] PASSED [ 11%] +student-tests/test_api.py::test_bad_message_body_is_400_and_nothing_is_stored[{"text":123}] PASSED [ 12%] +student-tests/test_api.py::test_bad_message_body_is_400_and_nothing_is_stored[{"text":"valid"}}] PASSED [ 12%] +student-tests/test_api.py::test_bad_message_body_is_400_and_nothing_is_stored[{"text":"valid"}]] PASSED [ 12%] +student-tests/test_api.py::test_bad_message_body_is_400_and_nothing_is_stored[{"text":"x"} {}] PASSED [ 12%] +student-tests/test_api.py::test_bad_message_body_is_400_and_nothing_is_stored[{"text":"x","sender_id":"11111111-1111-4111-8111-111111111111"}] PASSED [ 13%] +student-tests/test_api.py::test_bad_message_body_is_400_and_nothing_is_stored[{"text":"x","attachment_ids":null}] PASSED [ 13%] +student-tests/test_api.py::test_bad_message_body_is_400_and_nothing_is_stored[{"text":"x","attachment_ids":["nope"]}] PASSED [ 13%] +student-tests/test_api.py::test_bad_message_body_is_400_and_nothing_is_stored[{"text":" \n\t "}] PASSED [ 13%] +student-tests/test_api.py::test_ff_byte_body_on_registration_is_contract_error PASSED [ 13%] +student-tests/test_api.py::test_text_is_stored_verbatim_and_length_counts_raw_text PASSED [ 14%] +student-tests/test_api.py::test_unknown_attachment_ids_are_404 PASSED [ 14%] +student-tests/test_api.py::test_member_ids_are_compared_as_uuids_not_strings PASSED [ 14%] +student-tests/test_api.py::test_non_ascii_or_garbage_bearer_is_401_not_500[Bearer \xe9] PASSED [ 14%] +student-tests/test_api.py::test_non_ascii_or_garbage_bearer_is_401_not_500[Bearer .] PASSED [ 15%] +student-tests/test_api.py::test_non_ascii_or_garbage_bearer_is_401_not_500[Bearer a b] PASSED [ 15%] +student-tests/test_api.py::test_non_ascii_or_garbage_bearer_is_401_not_500[Bearer \xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9] PASSED [ 15%] +student-tests/test_api.py::test_non_ascii_or_garbage_bearer_is_401_not_500[bearer\taaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] PASSED [ 15%] +student-tests/test_api.py::test_login_with_a_body_is_rejected PASSED [ 16%] +student-tests/test_api.py::test_password_range_is_12_to_128_code_points PASSED [ 16%] +student-tests/test_api.py::test_every_api_response_carries_instance_and_request_id PASSED [ 16%] +student-tests/test_api.py::test_unicode_whitespace_only_strings_are_400[\xa0] PASSED [ 16%] +student-tests/test_api.py::test_unicode_whitespace_only_strings_are_400[\u2003\u2003] PASSED [ 17%] +student-tests/test_api.py::test_unicode_whitespace_only_strings_are_400[ \xa0\t\u3000] PASSED [ 17%] +student-tests/test_api.py::test_odd_registration_bodies_are_400_and_the_api_survives[{"username":"num_probe","display_name":"x","password":1e1000}] PASSED [ 17%] +student-tests/test_api.py::test_odd_registration_bodies_are_400_and_the_api_survives[{"username":"ff_probe","display_name":"x","password":"12345678901\xff"}] PASSED [ 17%] +student-tests/test_api.py::test_odd_registration_bodies_are_400_and_the_api_survives[{"username":"num_probe","display_name":1,"password":"Twelve-chars-ok"}] PASSED [ 17%] +student-tests/test_api.py::test_more_than_100_members_is_400 PASSED [ 18%] +student-tests/test_api.py::test_cursor_of_one_list_is_rejected_by_the_other PASSED [ 18%] +student-tests/test_attachments.py::test_png_and_jpeg_roundtrip_byte_for_byte PASSED [ 18%] +student-tests/test_attachments.py::test_metadata_reveals_no_storage_details PASSED [ 18%] +student-tests/test_attachments.py::test_original_is_not_stored_on_api_containers PASSED [ 19%] +student-tests/test_attachments.py::test_outsider_and_unknown_get_404 PASSED [ 19%] +student-tests/test_attachments.py::test_attachment_ids_are_checked_per_chat PASSED [ 19%] +student-tests/test_attachments.py::test_message_with_attachments_and_history PASSED [ 19%] +student-tests/test_attachments.py::test_idempotent_replay_with_attachments PASSED [ 20%] +student-tests/test_attachments.py::test_message_body_validation[{"attachment_ids":["%(a)s"]}] PASSED [ 20%] +student-tests/test_attachments.py::test_message_body_validation[{"text":null,"attachment_ids":["%(a)s"]}] PASSED [ 20%] +student-tests/test_attachments.py::test_message_body_validation[{"text":1,"attachment_ids":["%(a)s"]}] PASSED [ 20%] +student-tests/test_attachments.py::test_message_body_validation[{"text":"x","attachment_ids":null}] PASSED [ 20%] +student-tests/test_attachments.py::test_message_body_validation[{"text":"x","attachment_ids":"%(a)s"}] PASSED [ 21%] +student-tests/test_attachments.py::test_message_body_validation[{"text":"x","attachment_ids":{}}] PASSED [ 21%] +student-tests/test_attachments.py::test_message_body_validation[{"text":"x","attachment_ids":["%(a)s","%] PASSED [ 21%] +student-tests/test_attachments.py::test_message_body_validation[{"text":"x","attachment_ids":["%(a)s",1]] PASSED [ 21%] +student-tests/test_attachments.py::test_message_body_validation[{"text":"x","attachment_ids":["not-a-uui] PASSED [ 22%] +student-tests/test_attachments.py::test_message_body_validation[{"text":"","attachment_ids":[]}] PASSED [ 22%] +student-tests/test_attachments.py::test_message_body_validation[{"text":" "}] PASSED [ 22%] +student-tests/test_attachments.py::test_message_body_validation[{"text":"x","attachment_ids":[],"sender_] PASSED [ 22%] +student-tests/test_attachments.py::test_at_most_ten_attachments PASSED [ 23%] +student-tests/test_attachments.py::test_size_limit_through_the_load_balancer PASSED [ 23%] +student-tests/test_attachments.py::test_pixel_limit_before_decoding PASSED [ 23%] +student-tests/test_attachments.py::test_exactly_40_megapixels_is_accepted PASSED [ 23%] +student-tests/test_attachments.py::test_bad_content_is_415[png: first 33 bytes of the fixture] PASSED [ 24%] +student-tests/test_attachments.py::test_bad_content_is_415[png: truncated] PASSED [ 24%] +student-tests/test_attachments.py::test_bad_content_is_415[png: corrupt IDAT, valid CRC] PASSED [ 24%] +student-tests/test_attachments.py::test_bad_content_is_415[png: fewer rows than IHDR] PASSED [ 24%] +student-tests/test_attachments.py::test_bad_content_is_415[png: flipped byte] PASSED [ 24%] +student-tests/test_attachments.py::test_bad_content_is_415[png: bytes after IEND] PASSED [ 25%] +student-tests/test_attachments.py::test_bad_content_is_415[jpeg: no scan data after SOS] PASSED [ 25%] +student-tests/test_attachments.py::test_bad_content_is_415[jpeg: truncated] PASSED [ 25%] +student-tests/test_attachments.py::test_bad_content_is_415[review: png row filter 5] PASSED [ 25%] +student-tests/test_attachments.py::test_bad_content_is_415[review: png row filter 0xff] PASSED [ 26%] +student-tests/test_attachments.py::test_bad_content_is_415[review: png IDAT not-a-zlib-stream] PASSED [ 26%] +student-tests/test_attachments.py::test_bad_content_is_415[review: jpeg 27 bytes, no tables/scan] PASSED [ 26%] +student-tests/test_attachments.py::test_bad_content_is_415[review: jpeg SOS component not in SOF] PASSED [ 26%] +student-tests/test_attachments.py::test_bad_content_is_415[mime: png bytes declared jpeg] PASSED [ 27%] +student-tests/test_attachments.py::test_bad_content_is_415[mime: jpeg bytes declared png] PASSED [ 27%] +student-tests/test_attachments.py::test_bad_content_is_415[mime: gif declared png] PASSED [ 27%] +student-tests/test_attachments.py::test_bad_content_is_415[mime: html declared png] PASSED [ 27%] +student-tests/test_attachments.py::test_bad_content_is_415[type: text/plain] PASSED [ 27%] +student-tests/test_attachments.py::test_bad_content_is_415[type: octet-stream] PASSED [ 28%] +student-tests/test_attachments.py::test_bad_content_is_415[type: multipart] PASSED [ 28%] +student-tests/test_attachments.py::test_bad_content_is_415[type: missing] PASSED [ 28%] +student-tests/test_attachments.py::test_empty_body_is_400 PASSED [ 28%] +student-tests/test_attachments.py::test_bad_filename_is_400[missing] PASSED [ 29%] +student-tests/test_attachments.py::test_bad_filename_is_400[filename=] PASSED [ 29%] +student-tests/test_attachments.py::test_bad_filename_is_400[filename=%20%20%20] PASSED [ 29%] +student-tests/test_attachments.py::test_bad_filename_is_400[filename=.] PASSED [ 29%] +student-tests/test_attachments.py::test_bad_filename_is_400[filename=..] PASSED [ 30%] +student-tests/test_attachments.py::test_bad_filename_is_400[filename=a%2Fb.png] PASSED [ 30%] +student-tests/test_attachments.py::test_bad_filename_is_400[filename=a%5Cb.png] PASSED [ 30%] +student-tests/test_attachments.py::test_bad_filename_is_400[filename=a%00b.png] PASSED [ 30%] +student-tests/test_attachments.py::test_bad_filename_is_400[filename=c1%C2%85.png] PASSED [ 31%] +student-tests/test_attachments.py::test_bad_filename_is_400[filename=tab%09.png] PASSED [ 31%] +student-tests/test_attachments.py::test_bad_filename_is_400[filename=photo%E2%80%AEgnp.exe] PASSED [ 31%] +student-tests/test_attachments.py::test_bad_filename_is_400[filename=%FF%FE.png] PASSED [ 31%] +student-tests/test_attachments.py::test_bad_filename_is_400[filename=a.png&filename=b.png] PASSED [ 31%] +student-tests/test_attachments.py::test_bad_filename_is_400[filename=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] PASSED [ 32%] +student-tests/test_attachments.py::test_unicode_filename_is_kept_and_safely_exposed PASSED [ 32%] +student-tests/test_attachments.py::test_variant_parameter PASSED [ 32%] +student-tests/test_balancing.py::test_one_session_is_served_by_every_real_replica PASSED [ 32%] +student-tests/test_balancing.py::test_write_on_one_replica_is_read_on_the_other PASSED [ 33%] +student-tests/test_balancing.py::test_lb_stops_routing_to_a_replica_that_is_alive_but_not_ready[0-pg_hba] PASSED [ 33%] +student-tests/test_balancing.py::test_lb_stops_routing_to_a_replica_that_is_alive_but_not_ready[0-network] PASSED [ 33%] +student-tests/test_balancing.py::test_lb_stops_routing_to_a_replica_that_is_alive_but_not_ready[1-pg_hba] PASSED [ 33%] +student-tests/test_balancing.py::test_lb_stops_routing_to_a_replica_that_is_alive_but_not_ready[1-network] PASSED [ 34%] +student-tests/test_balancing.py::test_graceful_stop_of_each_replica_loses_no_request[0] PASSED [ 34%] +student-tests/test_balancing.py::test_graceful_stop_of_each_replica_loses_no_request[1] PASSED [ 34%] +student-tests/test_balancing.py::test_killed_replica_bounded_errors_recovery_and_no_duplicates[0] PASSED [ 34%] +student-tests/test_balancing.py::test_killed_replica_bounded_errors_recovery_and_no_duplicates[1] PASSED [ 34%] +student-tests/test_balancing.py::test_graceful_shutdown_order_in_logs PASSED [ 35%] +student-tests/test_balancing.py::test_full_restart_lb_rediscovers_all_replicas PASSED [ 35%] +student-tests/test_balancing.py::test_scale_up_and_down_is_picked_up_without_errors PASSED [ 35%] +student-tests/test_balancing.py::test_compose_policy_limits_ports_secrets_images PASSED [ 35%] +student-tests/test_balancing.py::test_running_containers_have_limits_and_no_bypass_ports PASSED [ 36%] +student-tests/test_balancing.py::test_migrations_ran_once_by_the_migrate_service PASSED [ 36%] +student-tests/test_consistency.py::test_interrupted_and_stalled_uploads_leave_nothing PASSED [ 36%] +student-tests/test_consistency.py::test_crash_after_staging_before_job_is_cleaned_by_janitor PASSED [ 36%] +student-tests/test_consistency.py::test_lost_answer_after_job_commit_still_becomes_ready PASSED [ 37%] +student-tests/test_consistency.py::test_fresh_pending_upload_is_not_touched_by_janitor PASSED [ 37%] +student-tests/test_db.py::test_registration_race_exactly_one_201_and_seven_409 PASSED [ 37%] +student-tests/test_db.py::test_create_chat_rolls_back_after_the_chat_row_was_inserted PASSED [ 37%] +student-tests/test_db.py::test_migrations_rerun_is_a_noop PASSED [ 37%] +student-tests/test_db.py::test_100_messages_from_10_clients_keep_order_and_cursor_walk PASSED [ 38%] +student-tests/test_db.py::test_secrets_are_not_stored_in_plain_text PASSED [ 38%] +student-tests/test_explain.py::test_late_page_uses_index_range_not_filter PASSED [ 38%] +student-tests/test_failures.py::test_valkey_failure[stop] PASSED [ 38%] +student-tests/test_failures.py::test_valkey_failure[pause] PASSED [ 39%] +student-tests/test_failures.py::test_postgres_failure[stop] PASSED [ 39%] +student-tests/test_failures.py::test_postgres_failure[pause] PASSED [ 39%] +student-tests/test_failures.py::test_locked_table_gives_bounded_503 PASSED [ 39%] +student-tests/test_failures.py::test_logout_during_valkey_outage_is_never_lost PASSED [ 40%] +student-tests/test_idempotency.py::test_replay_returns_the_same_201_and_message_from_every_replica PASSED [ 40%] +student-tests/test_idempotency.py::test_other_body_with_the_same_key_is_409_and_keeps_the_original PASSED [ 40%] +student-tests/test_idempotency.py::test_key_order_and_missing_attachment_ids_are_the_same_body PASSED [ 40%] +student-tests/test_idempotency.py::test_missing_or_invalid_key_is_400[] PASSED [ 41%] +student-tests/test_idempotency.py::test_missing_or_invalid_key_is_400[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] PASSED [ 41%] +student-tests/test_idempotency.py::test_missing_or_invalid_key_is_400[\u043a\u043b\u044e\u0447] PASSED [ 41%] +student-tests/test_idempotency.py::test_missing_or_invalid_key_is_400[a b] PASSED [ 41%] +student-tests/test_idempotency.py::test_missing_or_invalid_key_is_400[a/b] PASSED [ 41%] +student-tests/test_idempotency.py::test_missing_or_invalid_key_is_400[a,b] PASSED [ 42%] +student-tests/test_idempotency.py::test_missing_or_invalid_key_is_400[a\tb] PASSED [ 42%] +student-tests/test_idempotency.py::test_missing_or_invalid_key_is_400[*] PASSED [ 42%] +student-tests/test_idempotency.py::test_repeated_key_header_is_400 PASSED [ 42%] +student-tests/test_idempotency.py::test_longest_key_and_every_allowed_character PASSED [ 43%] +student-tests/test_idempotency.py::test_scope_is_user_plus_chat_plus_key PASSED [ 43%] +student-tests/test_idempotency.py::test_outsider_and_revoked_session_never_see_the_stored_result PASSED [ 43%] +student-tests/test_idempotency.py::test_concurrent_same_key_through_different_replicas_creates_exactly_one PASSED [ 43%] +student-tests/test_idempotency.py::test_concurrent_same_key_different_bodies_one_wins PASSED [ 44%] +student-tests/test_idempotency.py::test_failure_after_the_key_insert_rolls_everything_back PASSED [ 44%] +student-tests/test_idempotency.py::test_client_timeout_then_retry_with_the_same_key_gives_the_committed_message PASSED [ 44%] +student-tests/test_idempotency.py::test_lock_timeout_is_a_transient_503_that_is_not_recorded PASSED [ 44%] +student-tests/test_idempotency.py::test_replay_after_the_serving_replica_is_stopped PASSED [ 44%] +student-tests/test_observability.py::test_upload_is_one_trace_api_relay_worker_s3_db PASSED [ 45%] +student-tests/test_observability.py::test_retry_is_visible_in_the_same_trace PASSED [ 45%] +student-tests/test_observability.py::test_logs_of_api_and_worker_are_joined_by_trace_id PASSED [ 45%] +student-tests/test_observability.py::test_no_ids_or_raw_paths_in_metric_labels PASSED [ 45%] +student-tests/test_observability.py::test_no_secrets_or_message_text_in_logs_and_traces PASSED [ 46%] +student-tests/test_observability.py::test_history_survives_restart_of_the_stores PASSED [ 46%] +student-tests/test_pipeline_flow.py::test_upload_is_202_queued_then_ready_with_contract_variants PASSED [ 46%] +student-tests/test_pipeline_flow.py::test_queued_attachment_is_attachable_failed_is_not PASSED [ 46%] +student-tests/test_pipeline_flow.py::test_worker_stopped_upload_202_content_409_restart_api_and_broker_then_ready PASSED [ 47%] +student-tests/test_pipeline_flow.py::test_broker_down_commit_to_publish_gap_is_closed_by_the_outbox PASSED [ 47%] +student-tests/test_pipeline_flow.py::test_relay_down_job_waits_in_outbox_not_lost PASSED [ 47%] +student-tests/test_pipeline_flow.py::test_crash_after_publish_before_confirm_is_recorded_gives_a_harmless_duplicate PASSED [ 47%] +student-tests/test_pipeline_flow.py::test_duplicate_and_reordered_deliveries_are_noops PASSED [ 48%] +student-tests/test_pipeline_flow.py::test_worker_crash_before_side_effect_lease_expires_and_job_completes PASSED [ 48%] +student-tests/test_pipeline_flow.py::test_worker_crash_after_s3_write_before_commit_republishes_without_duplicates PASSED [ 48%] +student-tests/test_pipeline_flow.py::test_worker_crash_after_commit_before_ack_redelivery_is_noop PASSED [ 48%] +student-tests/test_pipeline_flow.py::test_transient_errors_are_retried_with_jittered_backoff PASSED [ 48%] +student-tests/test_pipeline_flow.py::test_retry_exhausted_failed_registry_then_replay PASSED [ 49%] +student-tests/test_pipeline_flow.py::test_permanent_error_fails_at_once_without_retries PASSED [ 49%] +student-tests/test_pipeline_flow.py::test_memory_and_time_limits_of_the_worker PASSED [ 49%] +student-tests/test_pipeline_flow.py::test_bad_message_is_dead_lettered_not_processed PASSED [ 49%] +student-tests/test_pipeline_flow.py::test_hung_worker_loses_its_lease_and_cannot_publish PASSED [ 50%] +student-tests/test_pipeline_flow.py::test_graceful_worker_stop_finishes_the_running_attempt PASSED [ 50%] +student-tests/test_pipeline_flow.py::test_concurrency_is_bounded_by_prefetch PASSED [ 50%] +student-tests/test_pipeline_flow.py::test_queued_staging_is_never_deleted_even_after_retention PASSED [ 50%] +student-tests/test_pipeline_flow.py::test_retention_deletes_failed_staging_then_replay_is_refused PASSED [ 51%] +student-tests/test_pipeline_flow.py::test_cleanup_racing_a_replay_never_deletes_the_replayed_source PASSED [ 51%] +student-tests/test_pipeline_flow.py::test_reprocess_of_a_not_ready_upload_is_refused PASSED [ 51%] +student-tests/test_pipeline_flow.py::test_zz_invariants_hold_after_all_scenarios PASSED [ 51%] +student-tests/test_security.py::test_ingress_verifies_ca_and_hostname PASSED [ 51%] +student-tests/test_security.py::test_no_plaintext_entry_point PASSED [ 52%] +student-tests/test_security.py::test_lb_to_api_mtls_refuses_foreign_and_wrong_identity PASSED [ 52%] +student-tests/test_security.py::test_api_has_no_published_port_and_answers_only_mtls PASSED [ 52%] +student-tests/test_security.py::test_postgres_tls_only_and_roles_least_privilege PASSED [ 52%] +student-tests/test_security.py::test_valkey_tls_and_acl PASSED [ 53%] +student-tests/test_security.py::test_broker_tls_only_and_users_scoped PASSED [ 53%] +student-tests/test_security.py::test_s3_https_and_scoped_keys PASSED [ 53%] +student-tests/test_security.py::test_telemetry_endpoints_require_client_certificates PASSED [ 53%] +student-tests/test_security.py::test_openbao_policies_and_no_root_credential_in_apps PASSED [ 54%] +student-tests/test_security.py::test_openbao_not_dev_and_persistent PASSED [ 54%] +student-tests/test_security.py::test_sealed_openbao_keeps_running_replicas_and_blocks_new_ones PASSED [ 54%] +student-tests/test_security.py::test_argon2id_hash_carries_salt_and_parameters PASSED [ 54%] +student-tests/test_security.py::test_failed_logins_are_rate_limited_with_retry_after PASSED [ 55%] +student-tests/test_security.py::test_x_instance_id_is_a_random_alias_without_hostname_or_ip PASSED [ 55%] +student-tests/test_security.py::test_running_containers_are_hardened PASSED [ 55%] +student-tests/test_security.py::test_no_secret_in_git_or_in_the_image PASSED [ 55%] +student-tests/test_sessions.py::test_short_ttl_expires[valkey] PASSED [ 55%] +student-tests/test_sessions.py::test_short_ttl_expires[postgres] PASSED [ 56%] +student-tests/test_sessions.py::test_restart_does_not_extend_ttl PASSED [ 56%] +student-tests/test_sessions.py::test_postgres_session_store PASSED [ 56%] +student-tests/test_storage_failures.py::test_s3_outage_is_503_and_text_keeps_working[stop] PASSED [ 56%] +student-tests/test_storage_failures.py::test_s3_outage_is_503_and_text_keeps_working[pause] PASSED [ 57%] +student-tests/test_storage_failures.py::test_upload_survives_failover_of_the_serving_replica PASSED [ 57%] +student-tests/test_storage_failures.py::test_bucket_is_private_outside_the_api PASSED [ 57%] +student-tests/test_storage_failures.py::test_s3_restart_keeps_objects PASSED [ 57%] +student-tests/unit/test_images.py::test_public_fixture_is_accepted PASSED [ 58%] +student-tests/unit/test_images.py::test_valid_png_kinds[rgba] PASSED [ 58%] +student-tests/unit/test_images.py::test_valid_png_kinds[palette] PASSED [ 58%] +student-tests/unit/test_images.py::test_valid_png_kinds[1bit] PASSED [ 58%] +student-tests/unit/test_images.py::test_valid_png_kinds[gray] PASSED [ 58%] +student-tests/unit/test_images.py::test_valid_png_kinds[noise] PASSED [ 59%] +student-tests/unit/test_images.py::test_valid_png_kinds[1x1] PASSED [ 59%] +student-tests/unit/test_images.py::test_interlaced_png_is_accepted PASSED [ 59%] +student-tests/unit/test_images.py::test_broken_png_is_415[first 33 bytes of the fixture] PASSED [ 59%] +student-tests/unit/test_images.py::test_broken_png_is_415[truncated (no IEND)] PASSED [ 60%] +student-tests/unit/test_images.py::test_broken_png_is_415[truncated in IDAT] PASSED [ 60%] +student-tests/unit/test_images.py::test_broken_png_is_415[flipped byte -> CRC error] PASSED [ 60%] +student-tests/unit/test_images.py::test_broken_png_is_415[garbage IDAT with valid CRC] PASSED [ 60%] +student-tests/unit/test_images.py::test_broken_png_is_415[fewer rows than IHDR] PASSED [ 61%] +student-tests/unit/test_images.py::test_broken_png_is_415[bytes after IEND (polyglot)] PASSED [ 61%] +student-tests/unit/test_images.py::test_broken_png_is_415[text] PASSED [ 61%] +student-tests/unit/test_images.py::test_broken_png_is_415[gif] PASSED [ 61%] +student-tests/unit/test_images.py::test_broken_png_is_415[two bytes of a signature] PASSED [ 62%] +student-tests/unit/test_images.py::test_pixel_limit_is_checked_from_the_header PASSED [ 62%] +student-tests/unit/test_images.py::test_png_verification_is_streaming_and_fast PASSED [ 62%] +student-tests/unit/test_images.py::test_jpeg_header_is_parsed_incrementally PASSED [ 62%] +student-tests/unit/test_images.py::test_valid_jpeg[base] SKIPPED (dj...) [ 62%] +student-tests/unit/test_images.py::test_valid_jpeg[prog] SKIPPED (dj...) [ 63%] +student-tests/unit/test_images.py::test_broken_jpeg_is_415[no scan data after SOS-] SKIPPED [ 63%] +student-tests/unit/test_images.py::test_broken_jpeg_is_415[truncated-] SKIPPED [ 63%] +student-tests/unit/test_images.py::test_good_filenames[photo.png] PASSED [ 63%] +student-tests/unit/test_images.py::test_good_filenames[\u0444\u043e\u0442\u043e \u043e\u0442\u043f\u0443\u0441\u043a\u0430.jpg] PASSED [ 64%] +student-tests/unit/test_images.py::test_good_filenames[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] PASSED [ 64%] +student-tests/unit/test_images.py::test_good_filenames[emoji \U0001f468\u200d\U0001f469\u200d\U0001f467.png] PASSED [ 64%] +student-tests/unit/test_images.py::test_good_filenames[ x ] PASSED [ 64%] +student-tests/unit/test_images.py::test_good_filenames[..x] PASSED [ 65%] +student-tests/unit/test_images.py::test_bad_filenames[] PASSED [ 65%] +student-tests/unit/test_images.py::test_bad_filenames[ ] PASSED [ 65%] +student-tests/unit/test_images.py::test_bad_filenames[\u3000] PASSED [ 65%] +student-tests/unit/test_images.py::test_bad_filenames[.] PASSED [ 65%] +student-tests/unit/test_images.py::test_bad_filenames[..] PASSED [ 66%] +student-tests/unit/test_images.py::test_bad_filenames[a/b.png] PASSED [ 66%] +student-tests/unit/test_images.py::test_bad_filenames[a\\b.png] PASSED [ 66%] +student-tests/unit/test_images.py::test_bad_filenames[a\x00b] PASSED [ 66%] +student-tests/unit/test_images.py::test_bad_filenames[c1\x85.png] PASSED [ 67%] +student-tests/unit/test_images.py::test_bad_filenames[tab\t.png] PASSED [ 67%] +student-tests/unit/test_images.py::test_bad_filenames[del\x7f.png] PASSED [ 67%] +student-tests/unit/test_images.py::test_bad_filenames[x\u2028y] PASSED [ 67%] +student-tests/unit/test_images.py::test_bad_filenames[photo\u202egnp.exe] PASSED [ 68%] +student-tests/unit/test_images.py::test_bad_filenames[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] PASSED [ 68%] +student-tests/unit/test_images.py::test_filename_must_be_single_and_present PASSED [ 68%] +student-tests/unit/test_images.py::test_query_must_be_valid_utf8 PASSED [ 68%] +student-tests/unit/test_lab7.py::test_dns_names_only_from_subject_alt_name PASSED [ 68%] +student-tests/unit/test_lab7.py::test_protocol_aborts_every_identity_outside_the_allowlist[sans0-True] PASSED [ 69%] +student-tests/unit/test_lab7.py::test_protocol_aborts_every_identity_outside_the_allowlist[sans1-False] PASSED [ 69%] +student-tests/unit/test_lab7.py::test_protocol_aborts_every_identity_outside_the_allowlist[sans2-False] PASSED [ 69%] +student-tests/unit/test_lab7.py::test_protocol_aborts_every_identity_outside_the_allowlist[sans3-False] PASSED [ 69%] +student-tests/unit/test_lab7.py::test_protocol_aborts_every_identity_outside_the_allowlist[None-False] PASSED [ 70%] +student-tests/unit/test_lab7.py::test_protocol_aborts_a_plaintext_transport PASSED [ 70%] +student-tests/unit/test_lab7.py::test_allowlist_cannot_be_empty PASSED [ 70%] +student-tests/unit/test_lab7.py::test_server_context_requires_client_certificates_of_the_internal_ca_only PASSED [ 70%] +student-tests/unit/test_lab7.py::test_argon2_parameters_are_configurable_but_never_below_the_minimum PASSED [ 71%] +student-tests/unit/test_lab7.py::test_hash_carries_the_configured_parameters_and_old_hashes_still_verify PASSED [ 71%] +student-tests/unit/test_lab7.py::test_limit_per_username_with_retry_after PASSED [ 71%] +student-tests/unit/test_lab7.py::test_limit_per_ip_and_reset_on_success PASSED [ 71%] +student-tests/unit/test_lab7.py::test_secrets_come_from_openbao_first PASSED [ 72%] +student-tests/unit/test_lab7.py::test_openbao_refusal_is_a_config_error_without_retry PASSED [ 72%] +student-tests/unit/test_lab7.py::test_pki_script_never_prints_key_material PASSED [ 72%] +student-tests/unit/test_pipeline.py::test_fit_rounds_down_without_upscaling[size0-256-expected0] PASSED [ 72%] +student-tests/unit/test_pipeline.py::test_fit_rounds_down_without_upscaling[size1-256-expected1] PASSED [ 72%] +student-tests/unit/test_pipeline.py::test_fit_rounds_down_without_upscaling[size2-256-expected2] PASSED [ 73%] +student-tests/unit/test_pipeline.py::test_fit_rounds_down_without_upscaling[size3-256-expected3] PASSED [ 73%] +student-tests/unit/test_pipeline.py::test_fit_rounds_down_without_upscaling[size4-256-expected4] PASSED [ 73%] +student-tests/unit/test_pipeline.py::test_fit_rounds_down_without_upscaling[size5-256-expected5] PASSED [ 73%] +student-tests/unit/test_pipeline.py::test_fit_rounds_down_without_upscaling[size6-256-expected6] PASSED [ 74%] +student-tests/unit/test_pipeline.py::test_fit_rounds_down_without_upscaling[size7-1280-expected7] PASSED [ 74%] +student-tests/unit/test_pipeline.py::test_center_square PASSED [ 74%] +student-tests/unit/test_pipeline.py::test_public_fixture_variants_match_the_contract PASSED [ 74%] +student-tests/unit/test_pipeline.py::test_small_image_is_not_upscaled_but_crop_is PASSED [ 75%] +student-tests/unit/test_pipeline.py::test_big_image_is_bounded_by_1280 PASSED [ 75%] +student-tests/unit/test_pipeline.py::test_exif_orientation_is_applied_and_dropped PASSED [ 75%] +student-tests/unit/test_pipeline.py::test_alpha_is_composited_on_white_for_jpeg_and_kept_for_webp PASSED [ 75%] +student-tests/unit/test_pipeline.py::test_metadata_is_not_copied PASSED [ 75%] +student-tests/unit/test_pipeline.py::test_png_modes_are_processed[RGBA] PASSED [ 76%] +student-tests/unit/test_pipeline.py::test_png_modes_are_processed[P] PASSED [ 76%] +student-tests/unit/test_pipeline.py::test_png_modes_are_processed[1] PASSED [ 76%] +student-tests/unit/test_pipeline.py::test_png_modes_are_processed[L] PASSED [ 76%] +student-tests/unit/test_pipeline.py::test_png_modes_are_processed[LA] PASSED [ 77%] +student-tests/unit/test_pipeline.py::test_png_modes_are_processed[RGB] PASSED [ 77%] +student-tests/unit/test_pipeline.py::test_16_bit_grey_is_scaled_not_clipped PASSED [ 77%] +student-tests/unit/test_pipeline.py::test_pipeline_versions_differ_in_bytes_not_in_geometry PASSED [ 77%] +student-tests/unit/test_pipeline.py::test_pixel_limit_is_checked_before_decoding PASSED [ 78%] +student-tests/unit/test_pipeline.py::test_child_process_protocol_round_trip PASSED [ 78%] +student-tests/unit/test_pipeline.py::test_encoded_message_matches_jobs_schema_and_carries_ids_only PASSED [ 78%] +student-tests/unit/test_pipeline.py::test_invalid_messages_are_rejected[change0] PASSED [ 78%] +student-tests/unit/test_pipeline.py::test_invalid_messages_are_rejected[change1] PASSED [ 79%] +student-tests/unit/test_pipeline.py::test_invalid_messages_are_rejected[change2] PASSED [ 79%] +student-tests/unit/test_pipeline.py::test_invalid_messages_are_rejected[change3] PASSED [ 79%] +student-tests/unit/test_pipeline.py::test_invalid_messages_are_rejected[change4] PASSED [ 79%] +student-tests/unit/test_pipeline.py::test_invalid_messages_are_rejected[change5] PASSED [ 79%] +student-tests/unit/test_pipeline.py::test_invalid_messages_are_rejected[change6] PASSED [ 80%] +student-tests/unit/test_pipeline.py::test_invalid_messages_are_rejected[change7] PASSED [ 80%] +student-tests/unit/test_pipeline.py::test_invalid_messages_are_rejected[change8] PASSED [ 80%] +student-tests/unit/test_pipeline.py::test_invalid_messages_are_rejected[change9] PASSED [ 80%] +student-tests/unit/test_pipeline.py::test_garbage_is_rejected PASSED [ 81%] +student-tests/unit/test_pipeline.py::test_backoff_is_full_jitter_and_capped PASSED [ 81%] +student-tests/unit/test_pipeline.py::test_pipeline_settings PASSED [ 81%] +student-tests/unit/test_telemetry.py::test_server_span_continues_incoming_traceparent PASSED [ 81%] +student-tests/unit/test_telemetry.py::test_without_traceparent_a_new_root_trace_is_started PASSED [ 82%] +student-tests/unit/test_telemetry.py::test_5xx_is_an_error_4xx_is_not PASSED [ 82%] +student-tests/unit/test_telemetry.py::test_health_probes_get_no_span_and_unknown_paths_one_label PASSED [ 82%] +student-tests/unit/test_telemetry.py::test_http_metric_attributes_are_low_cardinality_and_buckets_fit_seconds PASSED [ 82%] +student-tests/unit/test_telemetry.py::test_job_message_carries_traceparent_in_the_schema_field PASSED [ 82%] +student-tests/unit/test_telemetry.py::test_log_records_carry_trace_context_and_fields PASSED [ 83%] +student-tests/unit/test_telemetry.py::test_successful_probe_lines_are_not_exported_failed_ones_are PASSED [ 83%] +student-tests/unit/test_telemetry.py::test_child_span_only_inside_a_traced_operation PASSED [ 83%] +student-tests/unit/test_unit.py::test_valid_passwords[Twelve-chars] PASSED [ 83%] +student-tests/unit/test_unit.py::test_valid_passwords[\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f] PASSED [ 84%] +student-tests/unit/test_unit.py::test_valid_passwords[\u043f\u0430\u0440\u043e\u043b\u044c:\u0441:\u0434\u0432\u043e\u0435\u0442\u043e\u0447\u0438\u044f\u043c\u0438] PASSED [ 84%] +student-tests/unit/test_unit.py::test_valid_passwords[\U0001f600\U0001f600\U0001f600\U0001f600\U0001f600\U0001f600\U0001f600\U0001f600\U0001f600\U0001f600\U0001f600\U0001f600] PASSED [ 84%] +student-tests/unit/test_unit.py::test_valid_passwords[a b c d e f g] PASSED [ 84%] +student-tests/unit/test_unit.py::test_invalid_passwords[short-11ch] PASSED [ 85%] +student-tests/unit/test_unit.py::test_invalid_passwords[\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f\u044f] PASSED [ 85%] +student-tests/unit/test_unit.py::test_invalid_passwords[ ] PASSED [ 85%] +student-tests/unit/test_unit.py::test_invalid_passwords[\t\n\u3000\t\n\u3000\t\n\u3000\t\n\u3000\t\n\u3000] PASSED [ 85%] +student-tests/unit/test_unit.py::test_invalid_passwords[\ud800\ud800\ud800\ud800\ud800\ud800\ud800\ud800\ud800\ud800\ud800\ud800] PASSED [ 86%] +student-tests/unit/test_unit.py::test_invalid_passwords[None] PASSED [ 86%] +student-tests/unit/test_unit.py::test_invalid_passwords[123456789012] PASSED [ 86%] +student-tests/unit/test_unit.py::test_text_may_contain_nul_but_not_lone_surrogates PASSED [ 86%] +student-tests/unit/test_unit.py::test_cursor_roundtrip_and_binding PASSED [ 86%] +student-tests/unit/test_unit.py::test_broken_cursors_are_400_not_500[v1|m|3f2c7a5e-0b7d-4a35-9a43-8d1f0f3b2c11|253402300800000000|11111111-1111-4111-8111-111111111111] PASSED [ 87%] +student-tests/unit/test_unit.py::test_broken_cursors_are_400_not_500[v1|m|3f2c7a5e-0b7d-4a35-9a43-8d1f0f3b2c11|9999999999999999999|11111111-1111-4111-8111-111111111111] PASSED [ 87%] +student-tests/unit/test_unit.py::test_broken_cursors_are_400_not_500[v1|m|3f2c7a5e-0b7d-4a35-9a43-8d1f0f3b2c11|-1|11111111-1111-4111-8111-111111111111] PASSED [ 87%] +student-tests/unit/test_unit.py::test_broken_cursors_are_400_not_500[v1|m|3f2c7a5e-0b7d-4a35-9a43-8d1f0f3b2c11|1|not-a-uuid] PASSED [ 87%] +student-tests/unit/test_unit.py::test_broken_cursors_are_400_not_500[v1|m|3f2c7a5e-0b7d-4a35-9a43-8d1f0f3b2c11|1|11111111-1111-4111-8111-11111111111G] PASSED [ 88%] +student-tests/unit/test_unit.py::test_broken_cursors_are_400_not_500[v2|m|3f2c7a5e-0b7d-4a35-9a43-8d1f0f3b2c11|1|11111111-1111-4111-8111-111111111111] PASSED [ 88%] +student-tests/unit/test_unit.py::test_time_helpers_are_exact PASSED [ 88%] +student-tests/unit/test_unit.py::test_basic_is_parsed_and_password_may_contain_colons PASSED [ 88%] +student-tests/unit/test_unit.py::test_bad_basic_is_401_with_basic_challenge[None] PASSED [ 89%] +student-tests/unit/test_unit.py::test_bad_basic_is_401_with_basic_challenge[] PASSED [ 89%] +student-tests/unit/test_unit.py::test_bad_basic_is_401_with_basic_challenge[Basic] PASSED [ 89%] +student-tests/unit/test_unit.py::test_bad_basic_is_401_with_basic_challenge[Basic \xe9] PASSED [ 89%] +student-tests/unit/test_unit.py::test_bad_basic_is_401_with_basic_challenge[Basic !!!!] PASSED [ 89%] +student-tests/unit/test_unit.py::test_bad_basic_is_401_with_basic_challenge[Basic bm8tY29sb24=] PASSED [ 90%] +student-tests/unit/test_unit.py::test_bad_basic_is_401_with_basic_challenge[Basic //46cHc=] PASSED [ 90%] +student-tests/unit/test_unit.py::test_bad_basic_is_401_with_basic_challenge[Basic OnBhc3N3b3Jk] PASSED [ 90%] +student-tests/unit/test_unit.py::test_bad_basic_is_401_with_basic_challenge[Basic YWxpY2U6] PASSED [ 90%] +student-tests/unit/test_unit.py::test_bad_basic_is_401_with_basic_challenge[Basic 0JDQu9C40YHQsDpwdw==] PASSED [ 91%] +student-tests/unit/test_unit.py::test_bad_basic_is_401_with_basic_challenge[Bearer aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] PASSED [ 91%] +student-tests/unit/test_unit.py::test_bad_basic_is_401_with_basic_challenge[Basic AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA] PASSED [ 91%] +student-tests/unit/test_unit.py::test_bad_bearer_is_401_with_bearer_challenge[None] PASSED [ 91%] +student-tests/unit/test_unit.py::test_bad_bearer_is_401_with_bearer_challenge[] PASSED [ 92%] +student-tests/unit/test_unit.py::test_bad_bearer_is_401_with_bearer_challenge[Bearer] PASSED [ 92%] +student-tests/unit/test_unit.py::test_bad_bearer_is_401_with_bearer_challenge[Bearer short] PASSED [ 92%] +student-tests/unit/test_unit.py::test_bad_bearer_is_401_with_bearer_challenge[Bearer aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!] PASSED [ 92%] +student-tests/unit/test_unit.py::test_bad_bearer_is_401_with_bearer_challenge[Basic YWxpY2U6cGFzc3dvcmQtMTIz] PASSED [ 93%] +student-tests/unit/test_unit.py::test_bad_bearer_is_401_with_bearer_challenge[Token aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa] PASSED [ 93%] +student-tests/unit/test_unit.py::test_bad_bearer_is_401_with_bearer_challenge[Bearer \xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9\xe9] PASSED [ 93%] +student-tests/unit/test_unit.py::test_bearer_ok PASSED [ 93%] +student-tests/unit/test_unit.py::test_argon2id_hash_and_verify PASSED [ 93%] +student-tests/unit/test_unit.py::test_s3_settings_are_validated_and_contract_limits_cannot_be_raised PASSED [ 94%] +student-tests/unit/test_unit.py::test_settings_read_secret_files_and_contract_names PASSED [ 94%] +student-tests/unit/test_unit.py::test_valid_idempotency_keys[a] PASSED [ 94%] +student-tests/unit/test_unit.py::test_valid_idempotency_keys[kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk] PASSED [ 94%] +student-tests/unit/test_unit.py::test_valid_idempotency_keys[A-Za-z0-9._:-] PASSED [ 95%] +student-tests/unit/test_unit.py::test_valid_idempotency_keys[2026-10-16T10:00:00.1] PASSED [ 95%] +student-tests/unit/test_unit.py::test_invalid_idempotency_keys[None] PASSED [ 95%] +student-tests/unit/test_unit.py::test_invalid_idempotency_keys[] PASSED [ 95%] +student-tests/unit/test_unit.py::test_invalid_idempotency_keys[kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk] PASSED [ 96%] +student-tests/unit/test_unit.py::test_invalid_idempotency_keys[\u043a\u043b\u044e\u0447] PASSED [ 96%] +student-tests/unit/test_unit.py::test_invalid_idempotency_keys[a b] PASSED [ 96%] +student-tests/unit/test_unit.py::test_invalid_idempotency_keys[a/b] PASSED [ 96%] +student-tests/unit/test_unit.py::test_invalid_idempotency_keys[a,b] PASSED [ 96%] +student-tests/unit/test_unit.py::test_invalid_idempotency_keys[a\tb] PASSED [ 97%] +student-tests/unit/test_unit.py::test_invalid_idempotency_keys[a\x00b] PASSED [ 97%] +student-tests/unit/test_unit.py::test_invalid_idempotency_keys[*] PASSED [ 97%] +student-tests/unit/test_unit.py::test_invalid_idempotency_keys[\xe9] PASSED [ 97%] +student-tests/unit/test_unit.py::test_duplicate_keys_and_garbage_json_are_rejected[{"text":"a","text":"b"}] PASSED [ 98%] +student-tests/unit/test_unit.py::test_duplicate_keys_and_garbage_json_are_rejected[{"a":{"x":1,"x":2}}] PASSED [ 98%] +student-tests/unit/test_unit.py::test_duplicate_keys_and_garbage_json_are_rejected[\xff] PASSED [ 98%] +student-tests/unit/test_unit.py::test_duplicate_keys_and_garbage_json_are_rejected[{"text":"x"} {}] PASSED [ 98%] +student-tests/unit/test_unit.py::test_attachment_ids_absent_equals_empty_and_is_validated PASSED [ 99%] +student-tests/unit/test_unit.py::test_request_fingerprint_ignores_key_order_and_default_attachments PASSED [ 99%] +student-tests/unit/test_unit.py::test_instance_id_is_a_random_alias_stable_per_process_and_validated PASSED [ 99%] +student-tests/unit/test_unit.py::test_idempotency_ttl_cannot_be_below_24_hours PASSED [ 99%] +student-tests/unit/test_unit.py::test_message_write_path_setting PASSED [100%] + +============================ slowest 15 durations ============================= +61.16s call student-tests/test_balancing.py::test_full_restart_lb_rediscovers_all_replicas +60.93s call student-tests/test_sessions.py::test_restart_does_not_extend_ttl +56.99s call student-tests/test_storage_failures.py::test_s3_outage_is_503_and_text_keeps_working[stop] +55.48s call student-tests/test_sessions.py::test_postgres_session_store +54.64s call student-tests/test_observability.py::test_history_survives_restart_of_the_stores +52.70s call student-tests/test_pipeline_flow.py::test_worker_crash_after_s3_write_before_commit_republishes_without_duplicates +52.46s call student-tests/test_pipeline_flow.py::test_hung_worker_loses_its_lease_and_cannot_publish +50.53s call student-tests/test_pipeline_flow.py::test_worker_stopped_upload_202_content_409_restart_api_and_broker_then_ready +49.34s call student-tests/test_consistency.py::test_crash_after_staging_before_job_is_cleaned_by_janitor +48.36s call student-tests/test_pipeline_flow.py::test_memory_and_time_limits_of_the_worker +45.57s call student-tests/test_pipeline_flow.py::test_cleanup_racing_a_replay_never_deletes_the_replayed_source +43.27s call student-tests/test_pipeline_flow.py::test_graceful_worker_stop_finishes_the_running_attempt +41.90s call student-tests/test_pipeline_flow.py::test_queued_staging_is_never_deleted_even_after_retention +41.54s call student-tests/test_pipeline_flow.py::test_retry_exhausted_failed_registry_then_replay +41.46s call student-tests/test_storage_failures.py::test_s3_restart_keeps_objects +================= 425 passed, 4 skipped in 1919.83s (0:31:59) ================= + +[exit 0] diff --git a/evidence/test-security.txt b/evidence/test-security.txt new file mode 100644 index 0000000..8380a3c --- /dev/null +++ b/evidence/test-security.txt @@ -0,0 +1,7 @@ +# make test-security (недоверенный CA) +# 2026-11-28T14:15:46+00:00 + +$ .venv\Scripts\python.exe tests/security.py --base-url https://localhost:8443 --ca-file secrets\pki\public-ca.crt +PASS: trusted HTTPS works; untrusted CA rejected. This does NOT verify internal mTLS, OpenBao or hardening. + +[exit 0] diff --git a/evidence/trace-demo.txt b/evidence/trace-demo.txt new file mode 100644 index 0000000..696b8a5 --- /dev/null +++ b/evidence/trace-demo.txt @@ -0,0 +1,46 @@ +# Телеметрия по mTLS: trace + logs +# 2026-11-28T14:19:09+00:00 + +$ .venv\Scripts\python.exe scripts/trace_demo.py +upload: HTTP 202, status=queued, X-Request-Id=trace-demo-68ea29f5, X-Instance-Id=i-83def22f481a, X-Trace-Id=fcefd6efe84d1bd8a5c933e4b6b7f66d +sent traceparent: 00-fcefd6efe84d1bd8a5c933e4b6b7f66d-69c3a1cf82244c3e-01 +attachment f3fa88b3-5dbb-42b5-b1f5-a57d60c35f15: ready, variants=['thumbnail', 'crop', 'optimized'] + +Tempo: trace fcefd6efe84d1bd8a5c933e4b6b7f66d, 19 spans ++ 0.0 ms 37.6 ms [messenger-api] SERVER POST /api/v1/chats/{chat_id}/attachments {"http.route": "/api/v1/chats/{chat_id}/attachments", "http.response.status_code": "202"} + + 1.2 ms 2.4 ms [messenger-api] CLIENT db ensure_member {"db.client.connection.wait_time_ms": 0.572} + + 5.7 ms 5.1 ms [messenger-api] CLIENT db create_intent {"db.client.connection.wait_time_ms": 0.531} + + 11.2 ms 16.0 ms [messenger-api] CLIENT s3 put + + 27.6 ms 8.6 ms [messenger-api] CLIENT db enqueue {"db.client.connection.wait_time_ms": 0.651} + + 88.4 ms 5.7 ms [messenger-relay] PRODUCER messenger.jobs publish {"messenger.job.attempt": "1"} + + 94.5 ms 763.7 ms [messenger-worker] CONSUMER messenger.attachment-jobs process {"messenger.job.attempt": "1", "messenger.job.outcome": "succeeded"} + + 94.7 ms 12.1 ms [messenger-worker] CLIENT db jobs.claim {"db.client.connection.wait_time_ms": 0.55} + + 107.0 ms 9.7 ms [messenger-worker] INTERNAL s3 download + + 107.1 ms 8.6 ms [messenger-worker] CLIENT s3 get + + 117.0 ms 679.8 ms [messenger-worker] INTERNAL image render + + 797.1 ms 27.9 ms [messenger-worker] CLIENT s3 put + + 798.9 ms 25.6 ms [messenger-worker] CLIENT s3 put + + 800.4 ms 23.1 ms [messenger-worker] CLIENT s3 put + + 802.3 ms 23.5 ms [messenger-worker] CLIENT s3 put + + 826.1 ms 17.9 ms [messenger-worker] CLIENT db jobs.complete {"db.client.connection.wait_time_ms": 0.641} + + 844.3 ms 3.5 ms [messenger-worker] CLIENT db delete_staging {"db.client.connection.wait_time_ms": 0.581} + + 848.0 ms 3.3 ms [messenger-worker] CLIENT s3 delete + + 851.6 ms 5.6 ms [messenger-worker] CLIENT db delete_staging {"db.client.connection.wait_time_ms": 0.67} + +Loki: 4 log records with trace_id=fcefd6efe84d1bd8a5c933e4b6b7f66d + messenger-api attachment_queued span_id=c63846abe775f110 request_id=trace-demo-68ea29f5 + messenger-api request span_id=c63846abe775f110 request_id=trace-demo-68ea29f5 route=/api/v1/chats/{chat_id}/attachments status=202 + messenger-worker staging_deleted span_id=c5745bf8195fd208 + messenger-worker job_done span_id=c5745bf8195fd208 job_id=b42f1fef-a3aa-408f-a3af-f5383bcb587c outcome=succeeded + +Checks: + [PASS] API SERVER span continues our traceparent (parent = our span id) + [PASS] relay PRODUCER is inside the upload trace (ancestor = API SERVER span) + [PASS] worker CONSUMER is a child of the PRODUCER + [PASS] worker wrote to S3 inside the job (s3 put spans) + [PASS] worker committed the result (db jobs.complete span) + [PASS] API log record of the request has this trace_id and our X-Request-Id + [PASS] worker log record (job_done) has this trace_id +services in logs: ['messenger-api', 'messenger-worker'] + +[exit 0] diff --git a/security/THREAT_MODEL.md b/security/THREAT_MODEL.md index 8cc872a..7c6cdd9 100644 --- a/security/THREAT_MODEL.md +++ b/security/THREAT_MODEL.md @@ -51,7 +51,7 @@ api/relay/worker ──OTLP/HTTPS + client cert──► otel-collector ──mT | --- | --- | --- | --- | --- | | T1. Перехват/подмена трафика клиента: MITM на пути к ingress или фальшивый сервер с самоподписанным сертификатом | конфиденциальность Basic-пароля и Bearer-токена | только HTTPS 8443 (TLS 1.2+), сертификат `public-ca` с SAN `localhost`; клиент проверяет CA и hostname; открытого 8080 нет | `make test-security` (пустой trust store → ошибка проверки); `test_ingress_verifies_ca_and_hostname` (чужой hostname, внутренний CA → отказ); `test_no_plaintext_entry_point` | CA учебный; доверие к нему — ручная раздача `public-ca.crt`; отзыва (CRL/OCSP) нет | | T2. Обход LB: процесс в сети `edge` или украденный ключ worker обращается к `api:8443` напрямую и подставляет `X-Forwarded-For`, чтобы обойти лимит входа | только LB говорит с API; клиентский IP честный | mTLS: `CERT_REQUIRED` + только `internal-ca` + allowlist SAN `lb` в `connection_made`; у API нет опубликованных портов; health на loopback; HAProxy перезаписывает `X-Forwarded-For` | `make mtls-check`: без cert / чужой CA с SAN `lb` / cert `worker` → отказ, `lb` → 200, по каждой реплике, TLS 1.3 и 1.2; 8081 снаружи закрыт | кража ключа `lb` = полный обход (ротация и отзыв leaf — уровень 4) | -| T3. Подбор пароля через `POST /auth/sessions` (одного аккаунта или одного пароля по многим аккаунтам) + DoS дорогим Argon2 | пароль нельзя угадать перебором; CPU реплики не выжигается | Argon2id m=19 MiB, t=2, p=1 (замер ~31 мс/хеш, ≤2 хеша параллельно на реплику); лимит неудач 5/60 с на username и 50/300 с на IP в Valkey (общий для реплик), проверка ДО Argon2, 429 + `Retry-After`, верный пароль при блокировке тоже 429 | `test_failed_logins_are_rate_limited_with_retry_after` (5×401 → 429, Retry-After ≤ 60, другой аккаунт не задет); unit `test_limit_per_username/ip` | можно на 60 с заблокировать вход известному username; ботнет с многих IP не ограничен глобально | +| T3. Подбор пароля через `POST /auth/sessions` (одного аккаунта или одного пароля по многим аккаунтам) + DoS дорогим Argon2 | пароль нельзя угадать перебором; CPU реплики не выжигается | Argon2id m=19 MiB, t=2, p=1 (замер 30–50 мс/хеш при 1 CPU, ≤2 хеша параллельно на реплику); лимит неудач 5/60 с на username и 50/300 с на IP в Valkey (общий для реплик), проверка ДО Argon2, 429 + `Retry-After`, верный пароль при блокировке тоже 429 | `test_failed_logins_are_rate_limited_with_retry_after` (5×401 → 429, Retry-After ≤ 60, другой аккаунт не задет); unit `test_limit_per_username/ip` | можно на 60 с заблокировать вход известному username; ботнет с многих IP не ограничен глобально | | T4. Утечка базы: дамп `users` | пароли не восстанавливаются | только Argon2id-хеш (PHC, соль 16 байт на пароль); одинаковые пароли дают разные хеши | `test_argon2id_hash_carries_salt_and_parameters` | слабый пароль из словаря всё равно подбирается офлайн, только медленнее | | T5. Посторонний пользователь читает чужой чат или вложение, либо выдаёт себя за другого через `X-User-Id` | доступ только участникам; identity = сессия | Bearer-сессия → `user_id`; членство проверяется в SQL; чужое = 404; `X-User-Id` игнорируется; mTLS не заменяет сессию | `test_api.py::test_foreign_chat_is_indistinguishable_from_missing`, `test_x_user_id_basic_and_garbage_do_not_authenticate`, `test_attachments.py` (чужое → 404), `test_logout_revokes_only_this_token`, `test_sessions.py::test_short_ttl_expires` | — | | T6. Скомпрометирован worker: пытается читать пользователей/сообщения в БД, писать в чужие таблицы, публиковать задачи, читать секреты API, писать в S3 как admin | наименьшие права worker | роль `messenger_worker` (GRANT только jobs/attempts/attachments/variants/outbox/job_events); RabbitMQ user `worker` только consume; S3 `messenger-worker` без Admin/List; OpenBao policy `worker` = свой путь | `test_postgres_tls_only_and_roles_least_privilege` (worker: users/messages/sessions/DELETE/функция → permission denied); `make bao-check` (worker: чужие пути, запись, sys/* → 403); `s3-init` (worker: ListBuckets пуст) | worker законно читает и пишет все вложения (это его работа) |