Files
mtusi2026lab7/DEFENSE.md
T
sxdees 2f2047909f
Skeleton contracts / contracts (pull_request) Blocked by required conditions
ЛР7 на 4: HTTPS, mTLS, OpenBao AppRole и ротация leaf.
Smoke/security/grade4/persistence/failover пройдены; REPORT и DEFENSE.
2026-12-02 23:08:27 +03:00

60 lines
3.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Памятка к защите — лаб. 7, Гавриленко Владислав БПИ2303, цель 4
## Стенд (loopback)
| Сервис | Порт |
| --- | --- |
| HTTPS API (HAProxy) | **8443** |
| Broker mTLS (HAProxy TCP) | **5674** → `broker-gw:5671` |
| OpenBao | **8217** (`SNI openbao.messenger.lab`) |
| Grafana / Prometheus / Loki / Tempo | 3017 / 9107 / 3117 / 3217 |
| PostgreSQL / Redis | 5447 / 6397 |
Проект Compose: `gavrilenko-lab7`.
## Команды защиты
```sh
bash scripts/bootstrap-pki.sh
make up
curl --cacert secrets/ca.crt https://127.0.0.1:8443/health/ready
make test CA_FILE=secrets/ca.crt
make test-security
make grade4
make test-persistence ACTION_SCRIPT=scripts/restart.sh CA_FILE=secrets/ca.crt
docker compose -p gavrilenko-lab7 up -d --scale api=2
make test-failover ACTION_SCRIPT=scripts/stop-one.sh CA_FILE=secrets/ca.crt
bash scripts/rotate-leaf.sh
bash scripts/scan-images.sh
```
## Grade 4 — что показать
1. **Внешний TLS:** `make test-security` — отказ без `CA_FILE`, успех с `secrets/ca.crt`.
2. **LB→API mTLS:** student-test / curl с чужим client cert → отказ; `lb-client.pem` → успех (см. `student-tests/mtls_test.go`).
3. **Broker mTLS:** `TestMTLSBrokerRejectsEvilIdentity` — evil CN не в allowlist HAProxy; api/worker leaf → AMQP через `amqps://broker-gw:5671`.
4. **OTel mTLS:** collector TLS на 4318 + client CA; экспорт из API с client cert (`compose` env `OTEL_EXPORTER_OTLP_*`).
5. **OpenBao:** `VerifyAppRole` при старте; policies в `openbao/policies/`; нет root token в контейнерах api/worker.
6. **Ротация:** `scripts/rotate-leaf.sh` пересоздаёт LB client leaf и `force-recreate lb` без rebuild образов.
7. **Persistence/failover:** `scripts/restart.sh` + `scripts/stop-one.sh` + `tests/resilience.py` по HTTPS.
## PASS/FAIL matrix (2026-12-02, live)
| Проверка | Статус | Evidence |
| --- | --- | --- |
| `make check` | **PASS** | `evidence/make-check.txt` |
| `make validate` | **PASS** | `evidence/make-validate.txt` |
| HTTPS ready + `make test` | **PASS** | `evidence/https-ready.txt`, `evidence/make-test.txt` |
| `make test-security` | **PASS** | `evidence/make-test-security.txt` |
| `make grade4` | **PASS** | `evidence/make-grade4.txt` |
| OpenBao AppRole (integration) | **PASS** | `make grade4` (student `TestOpenBaoAppRole`) |
| Persistence | **PASS** | `evidence/make-test-persistence.txt` |
| Failover (stop-one) | **PASS** | `evidence/make-test-failover.txt` |
| Rotate leaf demo | **PASS** | `evidence/rotate-leaf.txt` |
| Image scan triage | **PASS** | `evidence/scan-images.txt` |
## Ответы на типовые вопросы
- **mTLS vs authZ:** TLS + CN allowlist на broker-gw — *кто* подключился; policies OpenBao / ACL API — *что* можно делать.
- **Почему не любой root-signed клиент — broker:** HAProxy проверяет subject CN (`messenger-api-broker` / `messenger-worker-broker`); evil leaf имеет другой CN.
- **Bootstrap trust:** оператор генерирует PKI локально; root/unseal OpenBao только в `secrets/bao-admin/`.