Добавил TLS и защиту мессенджера для лабораторной 7

This commit is contained in:
2026-11-29 13:06:06 +03:00
parent 20afc2c790
commit d15d78efdf
100 changed files with 4067 additions and 62 deletions
+60
View File
@@ -0,0 +1,60 @@
Image mtusi-lab7-argon2-benchmark Building
#1 [internal] load local bake definitions
#1 reading from stdin 560B done
#1 DONE 0.0s
#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 441B done
#2 DONE 0.0s
#3 [internal] load metadata for docker.io/library/python:3.12.8-slim
#3 DONE 0.0s
#4 [internal] load .dockerignore
#4 transferring context: 196B done
#4 DONE 0.0s
#5 [1/7] FROM docker.io/library/python:3.12.8-slim@sha256:2199a62885a12290dc9c5be3ca0681d367576ab7bf037da120e564723292a2f0
#5 resolve docker.io/library/python:3.12.8-slim@sha256:2199a62885a12290dc9c5be3ca0681d367576ab7bf037da120e564723292a2f0 0.0s done
#5 DONE 0.0s
#6 [internal] load build context
#6 transferring context: 240.68kB 0.0s done
#6 DONE 0.0s
#7 [2/7] WORKDIR /app
#7 CACHED
#8 [3/7] COPY requirements-app.txt ./
#8 CACHED
#9 [4/7] RUN pip install --no-cache-dir -r requirements-app.txt
#9 CACHED
#10 [5/7] COPY app ./app
#10 DONE 0.1s
#11 [6/7] COPY migrations ./migrations
#11 DONE 0.0s
#12 [7/7] RUN useradd --create-home --uid 10001 appuser
#12 DONE 2.1s
#13 exporting to image
#13 exporting layers 0.1s done
#13 exporting manifest sha256:6013702a7a27591485235c82bf5d8420538cbac3214eef4ef1f8267a93453b2c 0.0s done
#13 exporting config sha256:19f9f287b6cb415f15a44bbf47e81ce5b68ed281e03782b91390b3427b8a5c7a 0.0s done
#13 exporting attestation manifest sha256:9c9fa250af27b3a850e903c7f61c68f82391d68650ff278802f7c5fc50c8bf26 0.0s done
#13 exporting manifest list sha256:cf6c7696d9110073b3d6b515d3d259959338444643c2b3d265ee574e29c7a60a 0.0s done
#13 naming to docker.io/library/mtusi-lab7-argon2-benchmark:latest done
#13 unpacking to docker.io/library/mtusi-lab7-argon2-benchmark:latest 0.1s done
#13 DONE 0.4s
#14 resolving provenance for metadata file
#14 DONE 0.0s
Image mtusi-lab7-argon2-benchmark Built
Container mtusi-lab7-argon2-benchmark-run-a2e33052a286 Creating
Container mtusi-lab7-argon2-benchmark-run-a2e33052a286 Created
python=3.12.8 os=Linux-6.18.33.2-microsoft-standard-WSL2-x86_64-with-glibc2.36 cpu_count=32
argon2id memory_kib=19456 iterations=2 parallelism=1 samples=5
latency_ms median=25.70 min=23.86 max=40.03
+19
View File
@@ -0,0 +1,19 @@
$ docker scout cves --only-severity critical,high --only-fixed local://python:3.12.8-slim
digest │ 8859bd6ca943
platform │ linux/amd64
vulnerabilities │ 9C 50H 0M 0L
5C 7H 0M 0L perl 5.36.0-7+deb12u1
4C 18H 0M 0L openssl 3.0.15-1~deb12u1
0C 8H 0M 0L gnutls28 3.7.9-2+deb12u3
0C 6H 0M 0L glibc 2.36-9+deb12u9
0C 3H 0M 0L pcre2 10.42-1
0C 2H 0M 0L dpkg 1.21.22
0C 1H 0M 0L apt 2.6.1
0C 1H 0M 0L krb5 1.20.1-2+deb12u2
0C 1H 0M 0L gnupg2 2.2.40-1.1
0C 1H 0M 0L pam 1.5.2-6+deb12u1
0C 1H 0M 0L xz-utils 5.4.1-0.2
0C 1H 0M 0L sqlite3 3.40.1-2+deb12u1
59 vulnerabilities found in 12 packages
CRITICAL 9
HIGH 50
+13
View File
@@ -0,0 +1,13 @@
secrets/pki/api1.crt: OK
secrets/pki/api2.crt: OK
secrets/pki/postgres.crt: OK
secrets/pki/redis.crt: OK
secrets/pki/s3.crt: OK
secrets/pki/openbao.crt: OK
secrets/pki/otel-collector.crt: OK
secrets/pki/lb.crt: OK
secrets/pki/lb-client.crt: OK
secrets/pki/api-client.crt: OK
secrets/pki/worker-client.crt: OK
secrets/pki/wrong-client.crt: OK
secrets/pki/foreign-client.crt: OK
+33
View File
@@ -0,0 +1,33 @@
$ docker compose --profile checks config --services
redis-acl-init
redis-cert-init
redis
openbao-cert-init
openbao-data-init
openbao
s3-cert-init
s3
s3-identity-init
s3-provision
s3-policy-test
argon2-benchmark
api-identity-init
postgres-cert-init
postgres
migrate-identity-init
migrate
api1
envoy-api1
openbao-policy-test
api2
envoy-api2
prometheus
worker-identity-init
tempo
grafana-cert-init
loki
grafana
lb
worker
mtls-test
otel-collector
+29
View File
@@ -0,0 +1,29 @@
SERVICE STATUS
api-identity-init Exited (0) 6 minutes ago
api1 Up 7 seconds (healthy)
api2 Up 7 seconds (healthy)
envoy-api1 Up 4 seconds
envoy-api2 Up 4 seconds
grafana Up 9 seconds
grafana-cert-init Exited (0) 11 hours ago
lb Up Less than a second (health: starting)
loki Up 9 seconds
migrate Exited (0) 6 minutes ago
migrate-identity-init Exited (0) 6 minutes ago
openbao Up 9 seconds (healthy)
openbao-cert-init Exited (0) 6 minutes ago
openbao-data-init Exited (0) 6 minutes ago
otel-collector Up 9 seconds
postgres Up 9 seconds (healthy)
postgres-cert-init Exited (0) 6 minutes ago
prometheus Up 10 seconds
redis Up 10 seconds (healthy)
redis-acl-init Exited (0) 6 minutes ago
redis-cert-init Exited (0) 6 minutes ago
s3 Up 10 seconds
s3-cert-init Exited (0) 6 minutes ago
s3-identity-init Exited (0) 6 minutes ago
s3-provision Exited (0) 6 minutes ago
tempo Up 9 seconds
worker Up 5 seconds
worker-identity-init Exited (0) 11 hours ago
+5
View File
@@ -0,0 +1,5 @@
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "https://localhost:8443" --ca-file "secrets/pki/ca.crt"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 78, "failed_attempts": 3, "first_recovery_seconds": 4.572}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
Stopped replica: api1
+5
View File
@@ -0,0 +1,5 @@
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "https://localhost:8443" --ca-file "secrets/pki/ca.crt"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 22, "failed_attempts": 6, "first_recovery_seconds": 4.448}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
Stopped replica: api2
+3
View File
@@ -0,0 +1,3 @@
PASS: Grafana prometheus proxy returned HTTP 200 with CA validation
PASS: Grafana loki proxy returned HTTP 200 with CA validation
PASS: Grafana tempo proxy returned HTTP 200 with CA validation
+1
View File
@@ -0,0 +1 @@
PASS: ten invalid logins returned 401; next login returned 429 with Retry-After
+2
View File
@@ -0,0 +1,2 @@
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
+2
View File
@@ -0,0 +1,2 @@
python3 tests/smoke.py --base-url "https://localhost:8443" --ca-file "secrets/pki/ca.crt"
PASS: lab7 public API scenario; infrastructure and grading evidence remain separate.
+10
View File
@@ -0,0 +1,10 @@
Container mtusi-lab7-mtls-test-run-db57cc8d2147 Creating
Container mtusi-lab7-mtls-test-run-db57cc8d2147 Created
PASS: api1: missing client certificate rejected during TLS identity validation
PASS: api1: foreign client CA rejected during TLS identity validation
PASS: api1: trusted CA with wrong URI SAN rejected during TLS identity validation
PASS: api1: allowlisted LB identity reached the API
PASS: api2: missing client certificate rejected during TLS identity validation
PASS: api2: foreign client CA rejected during TLS identity validation
PASS: api2: trusted CA with wrong URI SAN rejected during TLS identity validation
PASS: api2: allowlisted LB identity reached the API
+5
View File
@@ -0,0 +1,5 @@
Container mtusi-lab7-openbao-policy-test-run-0c95b1c294c1 Creating
Container mtusi-lab7-openbao-policy-test-run-0c95b1c294c1 Created
PASS: API reads its own scoped secret
PASS: API cannot read worker secret
PASS: API cannot write its secret path
+3
View File
@@ -0,0 +1,3 @@
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "https://localhost:8443" --ca-file "secrets/pki/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.
+1
View File
@@ -0,0 +1 @@
PASS: python3 -m compileall -q app student-tests
+2
View File
@@ -0,0 +1,2 @@
PASS: client verified the Redis server certificate for hostname redis
PASS: same Redis certificate rejected by client for unmatched hostname
+6
View File
@@ -0,0 +1,6 @@
$ git diff --exit-code -- README.md tests contracts/openapi.yaml
$ git check-ignore .env secrets/
.env
secrets/
PASS: .env, secrets directory and matching private key files are not tracked
$ git diff --check
+1
View File
@@ -0,0 +1 @@
PASS: declared body of 11000001 bytes rejected at ingress with HTTP 413
+9
View File
@@ -0,0 +1,9 @@
Lab7 evidence context
Дата: 2026-11-29, Europe/Moscow
Базовый commit: 20afc2c790d3e72f6b7666376c9834c1ced1a405
Изменения в рабочем дереве, commit лабораторной ещё не создан.
Linux 6.18.33.2-microsoft-standard-WSL2 x86_64 GNU/Linux
Docker 29.8.0; CPU=32; RAM=16598659072 bytes
Профиль: функциональные проверки на синтетических данных, 2 прогона failover по 15 секунд; отдельного нагрузочного прогона нет.
Argon2id: 5 повторов, контейнер 1 CPU / 512 MiB.
Лимиты: API по 1 CPU / 512 MiB, HAProxy 0.5 CPU / 128 MiB. Остальные лимиты заданы в compose.yaml.
+4
View File
@@ -0,0 +1,4 @@
Container mtusi-lab7-s3-policy-test-run-5e0b368fe769 Creating
Container mtusi-lab7-s3-policy-test-run-5e0b368fe769 Created
PASS: API and worker have permissions for the attachment pipeline
PASS: worker cannot read a stored original
+1
View File
@@ -0,0 +1 @@
RustFS bucket and scoped API/worker identities are ready.
+3
View File
@@ -0,0 +1,3 @@
API configuration: SESSION_TTL_SECONDS=5
$ python3 student-tests/session_expiry.py --base-url https://localhost:8443 --ca-file secrets/pki/ca.crt
PASS: an active Bearer session returned 401 after its declared expiry
+1
View File
@@ -0,0 +1 @@
PASS: API/job metrics, bounded metric labels, Loki logs and matching Tempo traces
+2
View File
@@ -0,0 +1,2 @@
python3 tests/security.py --base-url "https://localhost:8443" --ca-file "secrets/pki/ca.crt"
PASS: trusted HTTPS works; untrusted CA rejected. This does NOT verify internal mTLS, OpenBao or hardening.
+1
View File
@@ -0,0 +1 @@
PASS: queued upload survived API restart and worker completed original plus thumbnail