feat: drop capabilities, run read-only and non-root in every container, mTLS for the S3 gRPC gateway

Every service of the stand gets the x-hardening anchor (cap_drop ALL,
no-new-privileges, read-only root) with an empty exception table, tmpfs
with size limits, pids limits by measurement and non-root users for
PostgreSQL, Valkey, RabbitMQ and SeaweedFS. The S3 gateway gRPC accepts
only mTLS with the stand CA. make hardening_check checks inspect data,
processes and listeners against the compose model; a fast test keeps the
override files from removing restrictions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 05:23:13 +03:00
co-authored by Claude Opus 5.5
parent 1f45bfe011
commit 157b878289
26 changed files with 2639 additions and 130 deletions
+8 -4
View File
@@ -297,9 +297,10 @@ PROBES = {
# как healthcheck брокера: CLI от пользователя rabbitmq (CLI от root на
# пустом volume создал бы .erlang.cookie раньше сервера), узел
# rabbit@localhost — распределение только на loopback контейнера (change
# messaging-telemetry-mtls, design, решения 6, 7)
"rabbitmq": "gosu rabbitmq rabbitmq-diagnostics -q "
"check_port_connectivity",
# messaging-telemetry-mtls, design, решения 6, 7). С change
# container-hardening exec и так от пользователя контейнера (rabbitmq),
# gosu без capabilities не работает (setgroups — EPERM)
"rabbitmq": "rabbitmq-diagnostics -q check_port_connectivity",
}
PROBE_TIMEOUT_S = 30
# начало ключа карточки — копия CACHE_KEY_PREFIX из src/utils/constants.py:
@@ -1673,10 +1674,13 @@ def delete_object(project: str, key: str) -> str:
"exec weed shell -master=127.0.0.1:9333 2>&1",
stdin=f"fs.rm /buckets/{bucket}/{object_key(key)}\n",
)
# строка об истории команд weed shell (временный каталог; с change
# container-hardening /tmp у s3 — tmpfs) — не ошибка команды
failed = [
line
for line in output.splitlines()
if "error" in line.lower() or "not found" in line.lower()
if ("error" in line.lower() or "not found" in line.lower())
and "history" not in line.lower()
]
if failed:
raise HookError(f"fs.rm failed: {failed[0]}")