forked from mtusi2026/mtusi2026lab7
- make security_audit runs the existing negative checks per trust-matrix row plus an ingress TLS probe and prints one summary - close the threat model TODOs and stale references - re-take the coverage exclusion evidence on the lab 7 stand Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5.6 KiB
5.6 KiB
Повтор отправки после рестарта API
- Шаги: синтетический пользователь (регистрация, вход по Basic) и чат;
POST /api/v1/chats/<chat>/messagesсIdempotency-Key;docker compose up -d --force-recreate api; ожидание/health/ready200 через LB; тот жеPOSTс тем же ключом и токеном; другое тело с тем же ключом;GETистории. Шаги выполнил разовый скрипт на stdlib вне репозитория (те же запросы, чтоdriver.py --port 8443 req … --key <ключ>скилла, по HTTPS с CA стенда), шаги выше повторяются руками - Дата: 2026-12-02, 03:43:12–03:43:24 UTC; код выхода 0
- Commit:
bb20855(веткаfeat/lab7-final); рабочее дерево — правки последнего шага, часть 2 (аудит матрицы, документы, файлыevidence/), код образа =HEAD - Стенд: проект compose
mtusi-lab7, две реплики за HAProxy (mTLS LB → API), снаружиhttps://localhost:8443, телеметрия включена, собранmake run_dockerиз рабочего дерева; пользователь и чат синтетические - Спек:
idempotency, «Повтор после рестарта API» (исключение сверки покрытия: тесты сервер не трогают) - Вывод обезличен: ключ заменён на
<key>; токена и пароля в выводе нет
Итог: новые контейнеры обеих реплик (другие id и StartedAt), повтор — тот же 201 и тот же Message от процесса, которого при первой отправке не было (X-Instance-Id с лабы 7 — случайный alias процесса: 513dedf9ffc4317b → fa5f73f7d6951ad6). В истории одно сообщение; другое тело с тем же ключом — 409. Сессия и ключ лежат в PostgreSQL, поэтому пересоздание реплик на них не влияет. Новые реплики прочитали секреты из OpenBao (распечатан) и стартовали без оператора; compose пересоздал только реплики, зависимости (postgres-bootstrap, migrate, s3-bootstrap) лишь повторно запустил — no-op; PostgreSQL не перезапускался.
--- before: api containers (name, id, StartedAt)
/mtusi-lab7-api-183 33d403c38cdd 2026-12-02T03:43:08.102264877Z
/mtusi-lab7-api-184 9e7d80b101e9 2026-12-02T03:33:20.806664799Z
--- first send
idempotency-key: <key>
201 x-request-id: 5a7c8b7337274b8aa081ce8e11ee2727 x-instance-id: 513dedf9ffc4317b
{
"id": "1be56546-251c-4dd2-b279-121894784ee7",
"chat_id": "912216c8-cd7b-41c6-a1a6-759015053198",
"sender_id": "6897efca-ae5f-4fb1-b7b5-fba47487ecad",
"text": "replay after restart",
"created_at": "2026-12-02T03:43:13.160820Z",
"attachment_ids": []
}
--- docker compose up -d --force-recreate api
Container mtusi-lab7-openbao-1 Running
Container mtusi-lab7-valkey-1 Running
Container mtusi-lab7-postgres-1 Running
Container mtusi-lab7-s3-1 Running
Container mtusi-lab7-api-183 Recreate
Container mtusi-lab7-api-184 Recreate
Container mtusi-lab7-api-183 Recreated
Container mtusi-lab7-api-184 Recreated
Container mtusi-lab7-postgres-1 Waiting
Container mtusi-lab7-s3-1 Waiting
Container mtusi-lab7-valkey-1 Waiting
Container mtusi-lab7-openbao-1 Waiting
Container mtusi-lab7-valkey-1 Healthy
Container mtusi-lab7-openbao-1 Healthy
Container mtusi-lab7-s3-1 Healthy
Container mtusi-lab7-postgres-1 Healthy
Container mtusi-lab7-s3-bootstrap-1 Starting
Container mtusi-lab7-postgres-bootstrap-1 Starting
Container mtusi-lab7-postgres-bootstrap-1 Started
Container mtusi-lab7-postgres-bootstrap-1 Waiting
Container mtusi-lab7-s3-bootstrap-1 Started
Container mtusi-lab7-s3-bootstrap-1 Waiting
Container mtusi-lab7-postgres-bootstrap-1 Exited
Container mtusi-lab7-migrate-1 Starting
Container mtusi-lab7-migrate-1 Started
Container mtusi-lab7-migrate-1 Waiting
Container mtusi-lab7-s3-bootstrap-1 Exited
Container mtusi-lab7-migrate-1 Exited
Container mtusi-lab7-api-183 Starting
Container mtusi-lab7-api-183 Started
Container mtusi-lab7-api-184 Starting
Container mtusi-lab7-api-184 Started
exit 0
LB ready: 200
--- after: api containers (name, id, StartedAt)
/mtusi-lab7-api-183 321799d1c4b6 2026-12-02T03:43:22.3324823Z
/mtusi-lab7-api-184 1ceaa51d8fc5 2026-12-02T03:43:22.472023925Z
--- repeat with the same key, the same session
idempotency-key: <key>
201 x-request-id: a11d8258564d4dd5ba1ceb0236bac8e4 x-instance-id: fa5f73f7d6951ad6
{
"id": "1be56546-251c-4dd2-b279-121894784ee7",
"chat_id": "912216c8-cd7b-41c6-a1a6-759015053198",
"sender_id": "6897efca-ae5f-4fb1-b7b5-fba47487ecad",
"text": "replay after restart",
"created_at": "2026-12-02T03:43:13.160820Z",
"attachment_ids": []
}
--- other body with the same key
idempotency-key: <key>
409 x-request-id: 77f9ce5e6f354c97aa4945c217442f0c x-instance-id: fa5f73f7d6951ad6
{
"error": {
"code": "conflict",
"message": "Idempotency key was already used with another request",
"request_id": "77f9ce5e6f354c97aa4945c217442f0c"
}
}
--- history
{"count": 1, "ids": ["1be56546-251c-4dd2-b279-121894784ee7"]}
--- compare
Message of the repeat = Message of the first send: yes
other instance answered the repeat: yes
PASS