Лаба 4: SeaweedFS S3-хранилище и вложения (оценка 4)

Переиспользован стек lab3 (LB/2 реплики/Postgres/Redis/идемпотентность).
Добавлены: S3-хранилище байтов вложений (SeaweedFS вместо MinIO — публичные
MinIO-образы недоступны без авторизации), метаданные attachments в Postgres,
проверка изображений по содержимому с защитой от decompression bomb,
ограниченные S3-credentials, скрипт сверки orphan-объектов. make test/
test-persistence/test-failover/validate зелёные для обеих реплик; собраны
доказательства по превышению размера, MIME-спуфингу, чужим attachment_id,
приватности bucket, конкурентным загрузкам и orphan-очистке — см. REPORT.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 00:59:13 +03:00
co-authored by Claude Sonnet 5
parent ec540a1a72
commit 38268f63f8
23 changed files with 1584 additions and 16 deletions
+32
View File
@@ -0,0 +1,32 @@
worker_processes 1;
# A single worker keeps the round-robin counter shared and deterministic for
# the lab's small replica count; a production LB would instead rely on a
# shared/consistent balancing policy across workers.
events { worker_connections 1024; }
http {
upstream messenger_api {
# Passive health check: a backend failing 1 probe is removed for 3s,
# which keeps failover detection well under the 10s budget.
server api1:8080 max_fails=1 fail_timeout=3s;
server api2:8080 max_fails=1 fail_timeout=3s;
}
server {
listen 8080;
# Slightly above the app's own 10 MiB attachment limit so the API --
# not Nginx's default HTML error page -- produces the contract's
# JSON 413 envelope. The API still enforces the exact byte budget.
client_max_body_size 11M;
location / {
proxy_pass http://messenger_api;
proxy_connect_timeout 1s;
proxy_read_timeout 5s;
proxy_next_upstream error timeout http_502 http_503 http_504;
proxy_next_upstream_tries 2;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
}
+18
View File
@@ -0,0 +1,18 @@
{
"identities": [
{
"name": "messenger-api",
"credentials": [
{
"accessKey": "__S3_ACCESS_KEY_ID__",
"secretKey": "__S3_SECRET_ACCESS_KEY__"
}
],
"actions": [
"Read:messenger-attachments",
"Write:messenger-attachments",
"List:messenger-attachments"
]
}
]
}