From 1dd020d0603910fa8723fba5382b392319f13644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D1=81=D0=BB=D0=BE=D0=B2?= Date: Fri, 20 Nov 2026 18:08:59 +0300 Subject: [PATCH 1/2] feat(security): add scoped identities, TLS boundaries and OpenBao bootstrap --- .dockerignore | 7 + .gitignore | 6 + Dockerfile | 28 + Makefile | 17 + REPORT.md | 51 +- compose.test.yaml | 10 + compose.yaml | 1517 ++++++++++++++++ contracts/trust-matrix.md | 61 +- evidence/dependency-scan-first.json | 9 + infra/fetch-source.go | 107 ++ infra/grafana/dashboards/messenger.json | 789 +++++++++ .../provisioning/dashboards/default.yaml | 10 + .../provisioning/datasources/default.yaml | 37 + infra/haproxy.cfg | 55 + infra/openbao/config.hcl | 14 + infra/openbao/policies/api.hcl | 4 + infra/openbao/policies/broker.hcl | 3 + infra/openbao/policies/cache.hcl | 3 + infra/openbao/policies/grafana.hcl | 3 + infra/openbao/policies/lb.hcl | 3 + infra/openbao/policies/loki.hcl | 3 + infra/openbao/policies/migrate.hcl | 4 + infra/openbao/policies/observer.hcl | 4 + infra/openbao/policies/openbao.hcl | 3 + infra/openbao/policies/operator.hcl | 11 + infra/openbao/policies/otel.hcl | 3 + infra/openbao/policies/postgres.hcl | 3 + infra/openbao/policies/prometheus.hcl | 3 + infra/openbao/policies/reconciler.hcl | 4 + infra/openbao/policies/relay.hcl | 4 + infra/openbao/policies/s3.hcl | 3 + infra/openbao/policies/tempo.hcl | 3 + infra/openbao/policies/worker.hcl | 4 + infra/otel/RUNBOOK.md | 50 + infra/otel/alerts.yaml | 53 + infra/otel/collector.yaml | 88 + infra/otel/loki.yaml | 44 + infra/otel/prometheus.yaml | 30 + infra/otel/tempo.yaml | 22 + infra/otel/versions.json | 7 + infra/s3-bootstrap.sh | 14 + infra/s3-entrypoint.sh | 6 + infra/s3-policy.json | 15 + infra/s3.Dockerfile | 49 + infra/tls/agent-api.json | 17 + infra/tls/agent-broker.json | 16 + infra/tls/agent-cache.json | 16 + infra/tls/agent-grafana.json | 20 + infra/tls/agent-lb.json | 21 + infra/tls/agent-loki.json | 16 + infra/tls/agent-migrate.json | 16 + infra/tls/agent-observer.json | 16 + infra/tls/agent-openbao.json | 20 + infra/tls/agent-otel.json | 16 + infra/tls/agent-postgres.json | 16 + infra/tls/agent-prometheus.json | 16 + infra/tls/agent-reconciler.json | 16 + infra/tls/agent-relay.json | 16 + infra/tls/agent-s3.json | 20 + infra/tls/agent-tempo.json | 16 + infra/tls/agent-worker.json | 16 + infra/tls/api.json | 33 + infra/tls/broker.json | 25 + infra/tls/cache.json | 24 + infra/tls/gateway.go | 631 +++++++ infra/tls/gateway_test.go | 122 ++ infra/tls/grafana.json | 42 + infra/tls/lb.json | 33 + infra/tls/loki.json | 36 + infra/tls/migrate.json | 14 + infra/tls/observer.json | 20 + infra/tls/otel.json | 88 + infra/tls/postgres.json | 29 + infra/tls/prometheus.json | 56 + infra/tls/reconciler.json | 14 + infra/tls/relay.json | 20 + infra/tls/s3.json | 39 + infra/tls/tempo.json | 47 + infra/tls/worker.json | 20 + migrations/001_core.sql | 36 + migrations/002_idempotency.sql | 10 + migrations/003_attachments.sql | 32 + migrations/004_pipeline.sql | 54 + migrations/005_observability.sql | 10 + migrations/006_security.sql | 32 + pyproject.toml | 60 + research/analyze_pipeline.py | 128 ++ research/analyze_slo.py | 249 +++ scripts/bao_operator.py | 351 ++++ scripts/bootstrap.py | 64 + scripts/bootstrap_security.py | 416 +++++ scripts/cluster.py | 83 + scripts/observe.py | 134 ++ scripts/prepare_dependencies.py | 265 +++ scripts/research_slo.py | 633 +++++++ scripts/restart.sh | 4 + scripts/rolling-update.sh | 3 + scripts/stand.py | 142 ++ scripts/stop-one.sh | 3 + scripts/stop-worker.sh | 3 + scripts/up_security.py | 115 ++ scripts/verify_clean.py | 286 +++ scripts/verify_cleanup.py | 223 +++ scripts/verify_cluster.py | 347 ++++ scripts/verify_observability_persistence.py | 145 ++ scripts/verify_pipeline.py | 687 ++++++++ scripts/verify_security.py | 58 + scripts/verify_telemetry.py | 340 ++++ security/THREAT_MODEL.md | 32 +- src/__init__.py | 0 src/__main__.py | 44 + src/api.py | 427 +++++ src/attachments.py | 144 ++ src/cache.py | 68 + src/cursor.py | 64 + src/database.py | 82 + src/domain.py | 45 + src/errors.py | 16 + src/identity.py | 65 + src/identity_init.py | 41 + src/images.py | 77 + src/logging_config.py | 17 + src/migrate.py | 51 + src/object_store.py | 102 ++ src/observer.py | 96 + src/operator.py | 123 ++ src/password.py | 36 + src/pipeline.py | 291 +++ src/reconcile.py | 122 ++ src/repository.py | 319 ++++ src/runtime.py | 66 + src/schemas.py | 65 + src/secure_http.py | 26 + src/security_probe.py | 328 ++++ src/service.py | 199 +++ src/settings.py | 41 + src/telemetry.py | 441 +++++ src/worker.py | 547 ++++++ student-tests/conftest.py | 125 ++ student-tests/test_api.py | 420 +++++ student-tests/test_attachments.py | 277 +++ student-tests/test_contract_edges.py | 26 + student-tests/test_history_acl.py | 23 + student-tests/test_idempotency.py | 77 + student-tests/test_sessions.py | 114 ++ student-unit/test_job_envelope.py | 119 ++ student-unit/test_security.py | 60 + student-unit/test_telemetry.py | 147 ++ uv.lock | 1564 +++++++++++++++++ 149 files changed, 16519 insertions(+), 68 deletions(-) create mode 100644 Dockerfile create mode 100644 compose.test.yaml create mode 100644 compose.yaml create mode 100644 evidence/dependency-scan-first.json create mode 100644 infra/fetch-source.go create mode 100644 infra/grafana/dashboards/messenger.json create mode 100644 infra/grafana/provisioning/dashboards/default.yaml create mode 100644 infra/grafana/provisioning/datasources/default.yaml create mode 100644 infra/haproxy.cfg create mode 100644 infra/openbao/config.hcl create mode 100644 infra/openbao/policies/api.hcl create mode 100644 infra/openbao/policies/broker.hcl create mode 100644 infra/openbao/policies/cache.hcl create mode 100644 infra/openbao/policies/grafana.hcl create mode 100644 infra/openbao/policies/lb.hcl create mode 100644 infra/openbao/policies/loki.hcl create mode 100644 infra/openbao/policies/migrate.hcl create mode 100644 infra/openbao/policies/observer.hcl create mode 100644 infra/openbao/policies/openbao.hcl create mode 100644 infra/openbao/policies/operator.hcl create mode 100644 infra/openbao/policies/otel.hcl create mode 100644 infra/openbao/policies/postgres.hcl create mode 100644 infra/openbao/policies/prometheus.hcl create mode 100644 infra/openbao/policies/reconciler.hcl create mode 100644 infra/openbao/policies/relay.hcl create mode 100644 infra/openbao/policies/s3.hcl create mode 100644 infra/openbao/policies/tempo.hcl create mode 100644 infra/openbao/policies/worker.hcl create mode 100644 infra/otel/RUNBOOK.md create mode 100644 infra/otel/alerts.yaml create mode 100644 infra/otel/collector.yaml create mode 100644 infra/otel/loki.yaml create mode 100644 infra/otel/prometheus.yaml create mode 100644 infra/otel/tempo.yaml create mode 100644 infra/otel/versions.json create mode 100644 infra/s3-bootstrap.sh create mode 100644 infra/s3-entrypoint.sh create mode 100644 infra/s3-policy.json create mode 100644 infra/s3.Dockerfile create mode 100644 infra/tls/agent-api.json create mode 100644 infra/tls/agent-broker.json create mode 100644 infra/tls/agent-cache.json create mode 100644 infra/tls/agent-grafana.json create mode 100644 infra/tls/agent-lb.json create mode 100644 infra/tls/agent-loki.json create mode 100644 infra/tls/agent-migrate.json create mode 100644 infra/tls/agent-observer.json create mode 100644 infra/tls/agent-openbao.json create mode 100644 infra/tls/agent-otel.json create mode 100644 infra/tls/agent-postgres.json create mode 100644 infra/tls/agent-prometheus.json create mode 100644 infra/tls/agent-reconciler.json create mode 100644 infra/tls/agent-relay.json create mode 100644 infra/tls/agent-s3.json create mode 100644 infra/tls/agent-tempo.json create mode 100644 infra/tls/agent-worker.json create mode 100644 infra/tls/api.json create mode 100644 infra/tls/broker.json create mode 100644 infra/tls/cache.json create mode 100644 infra/tls/gateway.go create mode 100644 infra/tls/gateway_test.go create mode 100644 infra/tls/grafana.json create mode 100644 infra/tls/lb.json create mode 100644 infra/tls/loki.json create mode 100644 infra/tls/migrate.json create mode 100644 infra/tls/observer.json create mode 100644 infra/tls/otel.json create mode 100644 infra/tls/postgres.json create mode 100644 infra/tls/prometheus.json create mode 100644 infra/tls/reconciler.json create mode 100644 infra/tls/relay.json create mode 100644 infra/tls/s3.json create mode 100644 infra/tls/tempo.json create mode 100644 infra/tls/worker.json create mode 100644 migrations/001_core.sql create mode 100644 migrations/002_idempotency.sql create mode 100644 migrations/003_attachments.sql create mode 100644 migrations/004_pipeline.sql create mode 100644 migrations/005_observability.sql create mode 100644 migrations/006_security.sql create mode 100644 pyproject.toml create mode 100644 research/analyze_pipeline.py create mode 100644 research/analyze_slo.py create mode 100644 scripts/bao_operator.py create mode 100644 scripts/bootstrap.py create mode 100644 scripts/bootstrap_security.py create mode 100644 scripts/cluster.py create mode 100644 scripts/observe.py create mode 100644 scripts/prepare_dependencies.py create mode 100644 scripts/research_slo.py create mode 100755 scripts/restart.sh create mode 100755 scripts/rolling-update.sh create mode 100644 scripts/stand.py create mode 100755 scripts/stop-one.sh create mode 100755 scripts/stop-worker.sh create mode 100644 scripts/up_security.py create mode 100644 scripts/verify_clean.py create mode 100644 scripts/verify_cleanup.py create mode 100644 scripts/verify_cluster.py create mode 100644 scripts/verify_observability_persistence.py create mode 100644 scripts/verify_pipeline.py create mode 100644 scripts/verify_security.py create mode 100644 scripts/verify_telemetry.py create mode 100644 src/__init__.py create mode 100644 src/__main__.py create mode 100644 src/api.py create mode 100644 src/attachments.py create mode 100644 src/cache.py create mode 100644 src/cursor.py create mode 100644 src/database.py create mode 100644 src/domain.py create mode 100644 src/errors.py create mode 100644 src/identity.py create mode 100644 src/identity_init.py create mode 100644 src/images.py create mode 100644 src/logging_config.py create mode 100644 src/migrate.py create mode 100644 src/object_store.py create mode 100644 src/observer.py create mode 100644 src/operator.py create mode 100644 src/password.py create mode 100644 src/pipeline.py create mode 100644 src/reconcile.py create mode 100644 src/repository.py create mode 100644 src/runtime.py create mode 100644 src/schemas.py create mode 100644 src/secure_http.py create mode 100644 src/security_probe.py create mode 100644 src/service.py create mode 100644 src/settings.py create mode 100644 src/telemetry.py create mode 100644 src/worker.py create mode 100644 student-tests/conftest.py create mode 100644 student-tests/test_api.py create mode 100644 student-tests/test_attachments.py create mode 100644 student-tests/test_contract_edges.py create mode 100644 student-tests/test_history_acl.py create mode 100644 student-tests/test_idempotency.py create mode 100644 student-tests/test_sessions.py create mode 100644 student-unit/test_job_envelope.py create mode 100644 student-unit/test_security.py create mode 100644 student-unit/test_telemetry.py create mode 100644 uv.lock diff --git a/.dockerignore b/.dockerignore index bc16e55..6dfe449 100644 --- a/.dockerignore +++ b/.dockerignore @@ -18,3 +18,10 @@ __pycache__ node_modules evidence .DS_Store + +operator/ +trust/ +.work* +.pytest_cache/ +.ruff_cache/ +student-unit/ diff --git a/.gitignore b/.gitignore index b5a7189..d274110 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,9 @@ coverage/ .vscode/ # Keep small, sanitized evidence summaries in evidence/ under version control. # Inspect git diff --cached: ignore rules are not a secret scanner. + +operator/ +trust/ +.work* +.pytest_cache/ +.ruff_cache/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c718a30 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,28 @@ +FROM library/golang:1.27.4-alpine@sha256:70bd7ddea8b6cbe5d6943cde279d6b67feb10cc924fb9100d1d8757c1575b280 AS gateway +WORKDIR /source +COPY infra/tls/*.go ./ +RUN CGO_ENABLED=0 GOMAXPROCS=2 go build -trimpath -ldflags="-s -w" -o /out/tls-gateway gateway.go + +FROM ghcr.io/astral-sh/uv:0.13.7@sha256:96f40d3904aad8d0bd010539001d36c8e2188b981e1334471a90c4a1d93bb490 AS uv +FROM python:3.14.7-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d AS builder +COPY --from=uv /uv /usr/local/bin/uv +WORKDIR /app +ENV UV_PYTHON_DOWNLOADS=never UV_LINK_MODE=copy +COPY pyproject.toml uv.lock ./ +RUN --mount=type=cache,target=/root/.cache/uv uv sync --locked --no-dev --no-install-project + +FROM python:3.14.7-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d AS runtime +ARG VCS_REF=unknown +LABEL org.opencontainers.image.revision=$VCS_REF +WORKDIR /app +ENV PATH="/app/.venv/bin:$PATH" PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 APP_HOST=0.0.0.0 APP_PORT=8080 +RUN groupadd --gid 10001 app && useradd --uid 10001 --gid app --no-create-home app +COPY --from=builder /app/.venv /app/.venv +COPY --from=gateway /out/tls-gateway /usr/local/bin/tls-gateway +COPY src /app/src +COPY migrations /app/migrations +USER 10001:10001 +EXPOSE 8080 +HEALTHCHECK --interval=10s --timeout=2s --start-period=10s --start-interval=1s --retries=3 CMD ["python", "-c", "import os,urllib.request; urllib.request.urlopen('http://127.0.0.1:'+os.getenv('APP_PORT','8080')+'/health/ready',timeout=1).read()"] +STOPSIGNAL SIGTERM +CMD ["python", "-m", "src"] diff --git a/Makefile b/Makefile index 5ad43ad..d31e2b4 100644 --- a/Makefile +++ b/Makefile @@ -31,3 +31,20 @@ test-failover: test-security: $(PYTHON) tests/security.py --base-url "$(BASE_URL)" $(TLS_ARGS) + +UV ?= uv +CA_FILE = trust/ca.pem +.PHONY: bootstrap up down lint unit test-student +bootstrap: + $(UV) run --locked python -m scripts.bootstrap_security +up: + $(UV) run --locked python -m scripts.up_security --build +down: + docker compose down +lint: + $(UV) run --locked ruff check src student-tests student-unit scripts --exclude scripts/check_contract.py --exclude scripts/validate_openapi.py + $(UV) run --locked ruff format --check src student-tests student-unit scripts --exclude scripts/check_contract.py --exclude scripts/validate_openapi.py +unit: + $(UV) run --locked python -m pytest student-unit -q +test-student: + BASE_URL="$(BASE_URL)" CA_FILE="$(CA_FILE)" $(UV) run --locked python -m pytest student-tests diff --git a/REPORT.md b/REPORT.md index 9801db4..bcab577 100644 --- a/REPORT.md +++ b/REPORT.md @@ -1,37 +1,40 @@ -# Отчёт — лабораторная 7 +# Лабораторная 7 — Маслов, БВТ2301 -- Автор, группа: TODO -- Целевая оценка; выбранный трек 5, если нужен: TODO -- Commit/PR: TODO после публикации -- Использованные источники, библиотеки и помощь ИИ: TODO +Цель — оценка 5, трек 2: жизненный цикл PKI и секретов. Собственный код ЛР6 перенесён поверх независимого skeleton ЛР7. README/COURSE/публичные tests/OpenAPI/check/validate сохранены; trust matrix заполнена как требует задание. -## Запуск из чистого clone +Текущий статус: реализация готовится к первому запуску. Пройдены 28 unit tests, offline/OpenAPI/lint, проверка конфигурации Compose. Сканирование pip-audit2.10.1 проверило 40 закреплённых runtime зависимостей и не нашло известных уязвимостей в своей базе на момент запуска (`evidence/dependency-scan-first.json`). Это не результат проверки образов или полного стенда. HTTP/mTLS/OpenBao/ротация/исследование/чистый clone пока не подтверждены. -TODO: версии runtime/образов, prerequisites, команды создания локальных secrets/.env, build, миграций, запуска, ожидания готовности, тестов и остановки. Указать необходимые действия оператора. Не вставлять секреты. Отдельно указать безопасную остановку и команду намеренного удаления учебных данных. +## Запуск оператора -## Архитектура и решения +Нужны Docker Desktop/Compose v2, Git и uv0.13.7. `uv sync --locked`, затем `make up PYTHON=.venv/bin/python`. Команда создаёт локальные CA/secrets, собирает образы и явно выполняет init/unseal/configure. Повторный `make up` сохраняет существующие ключи, пароли и состояние. Для обычного рестарта API операторский init/unseal не нужен: отдельные role agents продолжают renewal. -TODO: схема процессов/хранилищ, источник истины, транзакционные границы, ограничения. Что перенесено из lab6, что изменено в этой работе. Соответствие переменных из .env.example реальной конфигурации. +API `https://localhost:8443`, Grafana `https://localhost:3447`, S3 operator endpoint `https://localhost:9007`, OpenBao `https://localhost:8207`. Все host binds только 127.0.0.1. Grafana admin password — локальный `secrets/grafana_password`; операторские файлы находятся в `operator/`, не в Git. Проверка API: `make test test-security CA_FILE=trust/ca.pem PYTHON=.venv/bin/python`; полный собственный HTTP suite: `make test-student`; матрица: `uv run --locked python -m scripts.verify_security`. -## Доказательства критериев +Остановка `docker compose down` сохраняет named volumes. Не удалять operator/ и volumes по отдельности: CA, unseal shares и сохранённый Bao должны соответствовать друг другу. `python -m scripts.bao_operator status/unseal` использует проверяемый TLS и operator client cert; токены/shares не печатаются. При длительном seal/expiry требуется явный operator recovery, а не отключение TLS. -| Критерий README | Команда/сценарий | Наблюдаемый результат | Файл доказательства | -| --- | --- | --- | --- | -| Публичный smoke | make test | TODO | TODO | -| Остальные пункты уровня 3 | TODO | TODO | TODO | -| Все пункты уровня 4, если заявлен | TODO | TODO | TODO | -| Выбранный трек 5, если заявлен | TODO | TODO | TODO | +## Архитектура и границы -TODO: добавить отдельную строку для каждого заявленного критерия. PASS без команды и наблюдения не является доказательством. Проверка инфраструктурного hook требует подтверждения, какие реальные процессы/хранилища перезапущены. +TLS1.3, CA/SAN, mTLS с exact URI, раздельные роли БД/S3/Valkey и scoped cert auth/KV/PKI в OpenBao. Полное покрытие, порты, TTL, локальные transport boundaries и оправдание исключений: [trust matrix](contracts/trust-matrix.md). Угрозы и отрицательные проверки: [THREAT_MODEL](security/THREAT_MODEL.md). Конфиги gateway — `infra/tls`; политики создаёт `scripts/bao_operator.py`. -## Эксперименты и отказы +Root CA private key остаётся у оператора; intermediate key создаётся внутри persistent non-dev OpenBao. Auth tokens короткие, каждое приложение получает только собственные secrets, named volumes разделены по ролям. Snapshot secret имеет конечный срок и проверяется на API request/получении DB connection. S3 credentials читаются при каждой операции; DB conninfo — при новом подключении. Это статические рабочие PG/S3 accounts с управляемой ротацией, не заявляется динамический DB plugin. Сетевой доступ дополнительно требует короткого клиентского cert. -TODO: гипотеза, hardware/лимиты, версии, объём данных, профиль нагрузки, concurrency/arrival rate, длительность/прогрев, повторы, успешные RPS, ошибки, p50/p95/p99, CPU/RAM. Сохранить raw summary без tokens и объяснить ограничения измерения. +Пароли Argon2id: t3/m65536KiB/p4, 2 KDF slots/API. При успешном входе старый hash обновляется через compare-and-swap; неверный пароль не запускает rehash. SQL limiter общий для реплик: global burst8/refill2/s и account8/min, 429/Retry-After перед KDF. Хеши/session digest/credentials не экспортируются. JSON ограничен 64KiB/5с приёма; изображения и upload-worker сохраняют пределы ЛР5–6. -| Воздействие | Что ожидаем | Что наблюдали | Время восстановления / потеря данных | -| --- | --- | --- | --- | -| TODO | TODO | TODO | TODO | +Наблюдаемость и устойчивый pipeline сохранены: API принимает файл и jobs/outbox устойчиво, отдельный relay/worker, версии и fencing, конечные retries, ручной replay и cleanup. Collector сохраняет bounded queues и limiter; Grafana provisioning, три persistent хранилища и SLO rules перенесены. Полные повторные проверки ещё предстоят; результаты ЛР6 не выдаются за результаты ЛР7. -## Ограничения и следующие шаги +## Исследование на 5 -TODO: какие отказы выдерживаются и какие нет; что не реализовано; где учебное упрощение; какое улучшение подтверждено, а какое пока гипотеза. +Гипотеза: автоматическое обновление leaf и service tokens позволяет использовать короткие TTL; dual trust даёт безопасно заменить CA, а expiry/revocation приводят к ограниченному отказу без plaintext fallback. План: фиксированная синтетическая нагрузка, renewal, ротация S3 secret и leaf без image rebuild, отзыв старого leaf с новым TLS подключением, expiry/seal и восстановление, CA rollover с retirement старого trust. Измеряются ошибки, время восстановления, сохранность всех подтверждённых сообщений/заданий и отсутствие утечек. Результаты и ограничения заполняются после реального опыта. + +## Ответы на контрольные вопросы + +1. TLS шифрует поток и проверяет сервер через CA и SAN. В mTLS сервер также проверяет клиентский сертификат. Gateway затем сопоставляет URI с разрешённой ролью, а SQL/S3/broker/Bao ACL ограничивает конкретное действие. Проверка сертификата и разрешение операции — отдельные шаги. +2. CA может выдать удостоверение worker, API и LB. Подпись подтверждает доверенного издателя, но worker не становится LB: API принимает только URI lb. Поэтому нужен отдельный тест с чужой ролью, подписанной правильным CA. +3. Первое удостоверение создаёт локальный оператор из offline CA. Только собственный agent получает bootstrap leaf; приложения не получают CA private key/root token/unseal. Unseal выполняет оператор двумя shares из трёх защищённых файлов. В учебном стенде это один оператор, без имитации независимых хранителей. +4. Пока agent имеет действующий cert/token и Bao доступен, он обновляет удостоверение и секреты. При недоступном/sealed Bao обновление прекращается; cache имеет конечный срок и затем API/новые подключения отказывают. Обычный рестарт API использует продолжающий работать agent. После длительного истечения всех удостоверений оператор восстанавливает trust через явно описанный recovery. + +## Источники и ограничения + +Задание и собственная ЛР6; [OpenBao cert auth](https://openbao.org/docs/auth/cert/), [TLS listener](https://openbao.org/docs/configuration/listener/tcp/), [политики](https://openbao.org/docs/concepts/policies/), [OWASP password storage](https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html), [HAProxy3.2](https://docs.haproxy.org/3.2/configuration.html). Точные versions/digests находятся в Compose/lock. При проектировании, реализации, проверках и подготовке отчёта использована помощь ИИ; чужие студенческие решения/истории/измерения не использовались. + +Один локальный host и одиночные PG/S3/broker/OpenBao — ограничения доступности. Нет защиты от host root/потери диска. Короткие TTL демонстрационные. Финальные runtime результаты, image scan/triage и воспроизводимость не подтверждаются одним наличием конфигов. diff --git a/compose.test.yaml b/compose.test.yaml new file mode 100644 index 0000000..9de164b --- /dev/null +++ b/compose.test.yaml @@ -0,0 +1,10 @@ +services: + api: + environment: + PIPELINE_FAULTS: '1' + relay: + environment: + PIPELINE_FAULTS: '1' + worker: + environment: + PIPELINE_FAULTS: '1' diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..88a67c1 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,1517 @@ +name: mtusi-lab7-maslov +services: + postgres: + image: library/postgres:18.7@sha256:eb63372c1e05c755f55fa30cbd07aecc443676fc6c0fa90b9002d01537841e1a + environment: + POSTGRES_USER: messenger + POSTGRES_DB: messenger + POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password + PGDATA: /var/lib/postgresql/data/pgdata + secrets: + - postgres_password + volumes: + - postgres_data:/var/lib/postgresql + healthcheck: + test: + - CMD-SHELL + - pg_isready -U messenger -d messenger + interval: 2s + timeout: 2s + retries: 20 + cpus: 1 + mem_limit: 512m + memswap_limit: 512m + security_opt: + - no-new-privileges:true + read_only: true + pids_limit: 128 + tmpfs: + - /tmp:rw,noexec,nosuid,size=32m + - /var/run/postgresql:rw,nosuid,size=4m + command: + - postgres + - -c + - listen_addresses=127.0.0.1 + cap_drop: + - ALL + cap_add: + - CHOWN + - FOWNER + - SETUID + - SETGID + - DAC_OVERRIDE + cache: + image: valkey/valkey:8.1.12@sha256:5032c4dd7abe08d6fd9382054608183e2bf1f7e3895ef619b8784698454325f7 + command: + - valkey-server + - /run/secrets/valkey.conf + secrets: + - source: cache_config + target: cache.conf + - cache_admin + healthcheck: + test: + - CMD-SHELL + - REDISCLI_AUTH="$$(cat /run/secrets/cache_admin)" valkey-cli --user admin ping + interval: 2s + timeout: 2s + retries: 20 + cpus: 0.25 + mem_limit: 128m + memswap_limit: 128m + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + read_only: true + pids_limit: 128 + tmpfs: + - /tmp:rw,noexec,nosuid,size=32m + user: 999:999 + migrate: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + command: + - python + - -m + - src.runtime + - src.migrate + environment: + IDENTITY_ENABLED: '1' + SERVICE_ROLE: migrate + OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:14318 + secrets: [] + depends_on: + identity-migrate: + condition: service_started + cpus: 0.5 + mem_limit: 256m + read_only: true + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + pids_limit: 128 + tmpfs: + - /tmp:rw,noexec,nosuid,size=32m + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_migrate:/run/identity:ro + profiles: + - maintenance + healthcheck: + disable: true + api: + image: ${API_IMAGE:-mtusi-messenger:lab7} + build: + context: . + args: + VCS_REF: ${VCS_REF:-unknown} + scale: ${API_REPLICAS:-2} + environment: + APP_HOST: 127.0.0.1 + APP_PORT: '8080' + SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} + DB_POOL_SIZE: ${DB_POOL_SIZE:-10} + OTEL_ENABLED: ${OTEL_ENABLED:-1} + OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:14318 + APP_VERSION: ${VCS_REF:-development} + IDENTITY_ENABLED: '1' + SERVICE_ROLE: api + secrets: [] + depends_on: + identity-api: + condition: service_started + cpus: ${API_CPUS:-0.5} + mem_limit: 768m + memswap_limit: 768m + pids_limit: 128 + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=128m + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + stop_grace_period: 10s + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_api:/run/identity:ro + command: + - python + - -m + - src.runtime + - src + s3: + image: ${S3_IMAGE:-mtusi-storage:lab7-minio-20251015} + build: + context: . + dockerfile: infra/s3.Dockerfile + target: server + secrets: + - s3_root_user + - s3_root_password + volumes: + - s3_data:/data + cpus: 1 + mem_limit: 1024m + memswap_limit: 1024m + read_only: true + tmpfs: + - /tmp:rw,nosuid,size=32m + environment: + HOME: /tmp + security_opt: + - no-new-privileges:true + cap_drop: + - ALL + pids_limit: 128 + ports: + - 127.0.0.1:${S3_ADMIN_PORT:-9007}:9443 + reconciler: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + command: + - python + - -m + - src.runtime + - src.reconcile + - --apply + - --loop + environment: + STAGING_RETENTION_SECONDS: ${STAGING_RETENTION_SECONDS:-86400} + IDENTITY_ENABLED: '1' + SERVICE_ROLE: reconciler + OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:14318 + secrets: [] + depends_on: + identity-reconciler: + condition: service_started + cpus: 0.25 + mem_limit: 256m + memswap_limit: 256m + read_only: true + healthcheck: + disable: true + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + pids_limit: 128 + tmpfs: + - /tmp:rw,noexec,nosuid,size=32m + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_reconciler:/run/identity:ro + broker: + image: valkey/valkey:8.1.12@sha256:5032c4dd7abe08d6fd9382054608183e2bf1f7e3895ef619b8784698454325f7 + command: + - valkey-server + - /run/secrets/broker.conf + secrets: + - source: broker_config + target: broker.conf + - broker_admin + volumes: + - broker_data:/data + healthcheck: + test: + - CMD-SHELL + - REDISCLI_AUTH="$$(cat /run/secrets/broker_admin)" valkey-cli --user admin + ping + interval: 2s + timeout: 2s + retries: 20 + cpus: 0.5 + mem_limit: 256m + memswap_limit: 256m + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + read_only: true + pids_limit: 128 + tmpfs: + - /tmp:rw,noexec,nosuid,size=32m + user: 999:999 + depends_on: + identity-init: + condition: service_completed_successfully + relay: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + command: + - python + - -m + - src.runtime + - src.pipeline + environment: + JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5} + OTEL_ENABLED: ${OTEL_ENABLED:-1} + OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:14318 + APP_VERSION: ${VCS_REF:-development} + IDENTITY_ENABLED: '1' + SERVICE_ROLE: relay + secrets: [] + depends_on: + identity-relay: + condition: service_started + cpus: 0.25 + mem_limit: 192m + memswap_limit: 192m + read_only: true + healthcheck: + disable: true + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + pids_limit: 128 + tmpfs: + - /tmp:rw,noexec,nosuid,size=32m + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_relay:/run/identity:ro + worker: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + command: + - python + - -m + - src.runtime + - src.worker + environment: + WORKER_CONCURRENCY: ${WORKER_CONCURRENCY:-2} + JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5} + JOB_TIMEOUT_SECONDS: ${JOB_TIMEOUT_SECONDS:-20} + JOB_LEASE_SECONDS: ${JOB_LEASE_SECONDS:-23} + OTEL_ENABLED: ${OTEL_ENABLED:-1} + OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:14318 + APP_VERSION: ${VCS_REF:-development} + IDENTITY_ENABLED: '1' + SERVICE_ROLE: worker + secrets: [] + depends_on: + identity-worker: + condition: service_started + cpus: 2 + mem_limit: 1536m + memswap_limit: 1536m + pids_limit: 128 + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=64m + healthcheck: + disable: true + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + stop_grace_period: 25s + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_worker:/run/identity:ro + lb: + image: library/haproxy:3.2.27-alpine@sha256:7816a9801a6846b912bc37e48529808e2fa87c3c47992441940f68e393ebcfeb + ports: + - 127.0.0.1:${PUBLIC_PORT:-8443}:8443 + volumes: + - ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro + - ./trust:/trust:ro + - identity_lb:/run/identity:ro + depends_on: + identity-init: + condition: service_completed_successfully + cpus: 0.5 + mem_limit: 128m + memswap_limit: 128m + read_only: true + tmpfs: + - /tmp:rw,nosuid,size=4m + security_opt: + - no-new-privileges:true + stop_grace_period: 10s + cap_drop: + - ALL + pids_limit: 128 + user: 99:99 + entrypoint: + - haproxy + command: + - -W + - -db + - -f + - /usr/local/etc/haproxy/haproxy.cfg + observer: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + command: + - python + - -m + - src.runtime + - src.observer + environment: + OTEL_ENABLED: ${OTEL_ENABLED:-1} + OTEL_EXPORTER_OTLP_ENDPOINT: http://127.0.0.1:14318 + APP_VERSION: ${VCS_REF:-development} + IDENTITY_ENABLED: '1' + SERVICE_ROLE: observer + secrets: [] + depends_on: + identity-observer: + condition: service_started + cpus: 0.25 + mem_limit: 192m + memswap_limit: 192m + read_only: true + healthcheck: + disable: true + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + pids_limit: 128 + tmpfs: + - /tmp:rw,noexec,nosuid,size=32m + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_observer:/run/identity:ro + otel: + image: otel/opentelemetry-collector-contrib:0.165.0@sha256:e40d61f10c9a617cca1ffd1be4d7e2b3a4b0f0001798ff07e58cabe82e618cea + user: 10001:10001 + volumes: + - ./infra/otel/collector.yaml:/etc/otel/config.yaml:ro + - ./trust:/trust:ro + - identity_otel:/run/identity:ro + cpus: 0.5 + mem_limit: 384m + memswap_limit: 384m + environment: + GOMEMLIMIT: 224MiB + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=32m + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + pids_limit: 128 + command: + - --config=/etc/otel/config.yaml + prometheus: + image: prom/prometheus:v3.16.0@sha256:e04987641b57704f408e31f6373ba4138ecf27cb4a165d24aabb6c38fddd0f06 + user: 65534:65534 + volumes: + - ./infra/otel/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro + - ./infra/otel/alerts.yaml:/etc/prometheus/alerts.yaml:ro + - prometheus_data:/prometheus + - ./trust:/trust:ro + - identity_prometheus:/run/identity:ro + cpus: 0.5 + mem_limit: 384m + memswap_limit: 384m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=32m + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + pids_limit: 128 + command: + - --config.file=/etc/prometheus/prometheus.yaml + - --storage.tsdb.path=/prometheus + - --storage.tsdb.retention.time=24h + - --storage.tsdb.retention.size=256MB + - --web.listen-address=127.0.0.1:9090 + depends_on: + telemetry-init: + condition: service_completed_successfully + loki: + image: grafana/loki:3.7.10@sha256:b43c257ccfc925d4a50b8717cac61a3b51df8c48d01847936057e5c4075a24a7 + user: 10001:10001 + volumes: + - ./infra/otel/loki.yaml:/etc/loki/config.yaml:ro + - loki_data:/loki + - ./trust:/trust:ro + - identity_loki:/run/identity:ro + cpus: 0.5 + mem_limit: 384m + memswap_limit: 384m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=32m + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + pids_limit: 128 + command: + - -config.file=/etc/loki/config.yaml + depends_on: + telemetry-init: + condition: service_completed_successfully + tempo: + image: grafana/tempo:3.1.1@sha256:64e2fbd56d9c2b3412a4b430a58ea59e91a670b1e75f920a0c702213ad145044 + user: 10001:10001 + volumes: + - ./infra/otel/tempo.yaml:/etc/tempo/config.yaml:ro + - tempo_data:/var/tempo + - ./trust:/trust:ro + - identity_tempo:/run/identity:ro + cpus: 0.5 + mem_limit: 768m + memswap_limit: 768m + environment: + GOMEMLIMIT: 384MiB + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=32m + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + pids_limit: 128 + command: + - -config.file=/etc/tempo/config.yaml + depends_on: + telemetry-init: + condition: service_completed_successfully + grafana: + image: grafana/grafana:13.3.1@sha256:0615ec4fbd4072004b7d86b46ded63013a74b7d6eb1119273dd89e8fa25c13cf + user: 472:472 + volumes: + - ./infra/grafana/provisioning:/etc/grafana/provisioning:ro + - ./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro + - grafana_data:/var/lib/grafana + - ./trust:/trust:ro + - identity_grafana:/run/identity:ro + cpus: 0.5 + mem_limit: 384m + memswap_limit: 384m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=32m + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + pids_limit: 128 + environment: + GF_SECURITY_ADMIN_USER: admin + GF_SECURITY_ADMIN_PASSWORD__FILE: /run/secrets/grafana_password + GF_AUTH_ANONYMOUS_ENABLED: 'false' + GF_USERS_ALLOW_SIGN_UP: 'false' + GF_ANALYTICS_REPORTING_ENABLED: 'false' + GF_ANALYTICS_CHECK_FOR_UPDATES: 'false' + GF_ANALYTICS_CHECK_FOR_PLUGIN_UPDATES: 'false' + GF_PLUGINS_PREINSTALL_DISABLED: 'true' + GF_LOG_LEVEL: warn + GOMEMLIMIT: 256MiB + GF_SERVER_HTTP_ADDR: 127.0.0.1 + GF_SECURITY_COOKIE_SECURE: 'true' + GF_SERVER_ROOT_URL: https://localhost:${GRAFANA_PORT:-3447} + secrets: + - grafana_password + ports: + - 127.0.0.1:${GRAFANA_PORT:-3447}:3443 + depends_on: + telemetry-init: + condition: service_completed_successfully + telemetry-init: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 0:0 + command: + - python + - -c + - import os; [(os.makedirs(p,exist_ok=True),os.chown(p,u,u)) for p,u in [('/data/prometheus',65534),('/data/loki',10001),('/data/tempo',10001),('/data/grafana',472)]] + volumes: + - prometheus_data:/data/prometheus + - loki_data:/data/loki + - tempo_data:/data/tempo + - grafana_data:/data/grafana + read_only: true + cap_drop: + - ALL + cap_add: + - CHOWN + security_opt: + - no-new-privileges:true + cpus: 0.1 + mem_limit: 64m + healthcheck: + disable: true + pids_limit: 128 + tmpfs: + - /tmp:rw,noexec,nosuid,size=32m + identity-openbao: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 1000:1000 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-openbao.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_openbao:/run/identity + - ./secrets/bootstrap/openbao:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + restart: unless-stopped + identity-api: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-api.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_api:/run/identity + - ./secrets/bootstrap/api:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + restart: unless-stopped + identity-worker: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-worker.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_worker:/run/identity + - ./secrets/bootstrap/worker:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + restart: unless-stopped + identity-relay: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-relay.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_relay:/run/identity + - ./secrets/bootstrap/relay:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + restart: unless-stopped + identity-observer: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-observer.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_observer:/run/identity + - ./secrets/bootstrap/observer:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + restart: unless-stopped + identity-reconciler: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-reconciler.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_reconciler:/run/identity + - ./secrets/bootstrap/reconciler:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + restart: unless-stopped + identity-migrate: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-migrate.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_migrate:/run/identity + - ./secrets/bootstrap/migrate:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + profiles: + - maintenance + identity-lb: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 99:99 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-lb.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_lb:/run/identity + - ./secrets/bootstrap/lb:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + restart: unless-stopped + pid: service:lb + depends_on: + lb: + condition: service_started + lb-tls: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 99:99 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/lb.json + network_mode: service:lb + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_lb:/run/identity:ro + depends_on: + lb: + condition: service_started + cpus: 0.15 + mem_limit: 96m + memswap_limit: 96m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + pids_limit: 64 + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 48MiB + healthcheck: + disable: true + identity-postgres: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-postgres.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_postgres:/run/identity + - ./secrets/bootstrap/postgres:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + restart: unless-stopped + postgres-tls: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/postgres.json + network_mode: service:postgres + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_postgres:/run/identity:ro + depends_on: + postgres: + condition: service_started + cpus: 0.15 + mem_limit: 96m + memswap_limit: 96m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + pids_limit: 64 + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 48MiB + healthcheck: + disable: true + identity-s3: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-s3.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_s3:/run/identity + - ./secrets/bootstrap/s3:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + restart: unless-stopped + s3-tls: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/s3.json + network_mode: service:s3 + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_s3:/run/identity:ro + depends_on: + s3: + condition: service_started + cpus: 0.15 + mem_limit: 96m + memswap_limit: 96m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + pids_limit: 64 + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 48MiB + healthcheck: + disable: true + identity-broker: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-broker.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_broker:/run/identity + - ./secrets/bootstrap/broker:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + restart: unless-stopped + broker-tls: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/broker.json + network_mode: service:broker + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_broker:/run/identity:ro + depends_on: + broker: + condition: service_started + cpus: 0.15 + mem_limit: 96m + memswap_limit: 96m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + pids_limit: 64 + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 48MiB + healthcheck: + disable: true + identity-cache: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-cache.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_cache:/run/identity + - ./secrets/bootstrap/cache:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + restart: unless-stopped + cache-tls: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/cache.json + network_mode: service:cache + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_cache:/run/identity:ro + depends_on: + cache: + condition: service_started + cpus: 0.15 + mem_limit: 96m + memswap_limit: 96m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + pids_limit: 64 + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 48MiB + healthcheck: + disable: true + identity-otel: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-otel.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_otel:/run/identity + - ./secrets/bootstrap/otel:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + restart: unless-stopped + otel-tls: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/otel.json + network_mode: service:otel + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_otel:/run/identity:ro + depends_on: + otel: + condition: service_started + cpus: 0.15 + mem_limit: 96m + memswap_limit: 96m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + pids_limit: 64 + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 48MiB + healthcheck: + disable: true + identity-prometheus: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 65534:65534 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-prometheus.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_prometheus:/run/identity + - ./secrets/bootstrap/prometheus:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + restart: unless-stopped + prometheus-tls: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 65534:65534 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/prometheus.json + network_mode: service:prometheus + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_prometheus:/run/identity:ro + depends_on: + prometheus: + condition: service_started + cpus: 0.15 + mem_limit: 96m + memswap_limit: 96m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + pids_limit: 64 + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 48MiB + healthcheck: + disable: true + identity-loki: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-loki.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_loki:/run/identity + - ./secrets/bootstrap/loki:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + restart: unless-stopped + loki-tls: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/loki.json + network_mode: service:loki + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_loki:/run/identity:ro + depends_on: + loki: + condition: service_started + cpus: 0.15 + mem_limit: 96m + memswap_limit: 96m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + pids_limit: 64 + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 48MiB + healthcheck: + disable: true + identity-tempo: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-tempo.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_tempo:/run/identity + - ./secrets/bootstrap/tempo:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + restart: unless-stopped + tempo-tls: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 10001:10001 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/tempo.json + network_mode: service:tempo + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_tempo:/run/identity:ro + depends_on: + tempo: + condition: service_started + cpus: 0.15 + mem_limit: 96m + memswap_limit: 96m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + pids_limit: 64 + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 48MiB + healthcheck: + disable: true + identity-grafana: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 472:472 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/agent-grafana.json + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_grafana:/run/identity + - ./secrets/bootstrap/grafana:/bootstrap:ro + cpus: 0.1 + mem_limit: 64m + memswap_limit: 64m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + cap_drop: + - ALL + pids_limit: 32 + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 32MiB + healthcheck: + disable: true + restart: unless-stopped + grafana-tls: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 472:472 + entrypoint: + - /usr/local/bin/tls-gateway + command: + - /etc/tls/grafana.json + network_mode: service:grafana + volumes: + - ./infra/tls:/etc/tls:ro + - ./trust:/trust:ro + - identity_grafana:/run/identity:ro + depends_on: + grafana: + condition: service_started + cpus: 0.15 + mem_limit: 96m + memswap_limit: 96m + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=4m + pids_limit: 64 + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + environment: + GOMEMLIMIT: 48MiB + healthcheck: + disable: true + openbao: + image: openbao/openbao:2.7.3@sha256:ba4b133eb9586630024e71a617e66f37f29cc3534cdd46a6233e098ceded8dc9 + user: 1000:1000 + entrypoint: + - bao + command: + - server + - -config=/etc/openbao/config.hcl + volumes: + - ./infra/openbao/config.hcl:/etc/openbao/config.hcl:ro + - ./trust:/trust:ro + - identity_openbao:/run/identity:ro + - openbao_data:/data + ports: + - 127.0.0.1:${BAO_PORT:-8207}:8200 + environment: + BAO_LOG_LEVEL: warn + cpus: 0.5 + mem_limit: 256m + memswap_limit: 256m + pids_limit: 128 + read_only: true + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + tmpfs: + - /tmp:rw,noexec,nosuid,size=16m + depends_on: + identity-init: + condition: service_completed_successfully + identity-init: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + user: 0:0 + command: + - python + - -m + - src.identity_init + volumes: + - ./secrets/bootstrap:/bootstrap:ro + - openbao_data:/data/openbao + - broker_data:/data/broker + - identity_openbao:/identity/openbao + - identity_api:/identity/api + - identity_worker:/identity/worker + - identity_relay:/identity/relay + - identity_observer:/identity/observer + - identity_reconciler:/identity/reconciler + - identity_migrate:/identity/migrate + - identity_lb:/identity/lb + - identity_postgres:/identity/postgres + - identity_s3:/identity/s3 + - identity_broker:/identity/broker + - identity_cache:/identity/cache + - identity_otel:/identity/otel + - identity_prometheus:/identity/prometheus + - identity_loki:/identity/loki + - identity_tempo:/identity/tempo + - identity_grafana:/identity/grafana + environment: + IDENTITY_OWNERS: '{"openbao": 1000, "api": 10001, "worker": 10001, "relay": + 10001, "observer": 10001, "reconciler": 10001, "migrate": 10001, "lb": 99, + "postgres": 10001, "s3": 10001, "broker": 10001, "cache": 10001, "otel": 10001, + "prometheus": 65534, "loki": 10001, "tempo": 10001, "grafana": 472}' + cpus: 0.1 + mem_limit: 64m + read_only: true + cap_drop: + - ALL + cap_add: + - CHOWN + - DAC_OVERRIDE + security_opt: + - no-new-privileges:true + healthcheck: + disable: true + operator-probe: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + profiles: + - operator + user: 0:0 + entrypoint: + - python + command: + - -m + - src.security_probe + volumes: + - ./trust:/trust:ro + - ./secrets/probe:/probe-fixtures:ro + - identity_api:/identities/api:ro + - identity_worker:/identities/worker:ro + - identity_relay:/identities/relay:ro + - identity_lb:/identities/lb:ro + - identity_reconciler:/identities/reconciler:ro + - identity_observer:/identities/observer:ro + - identity_otel:/identities/otel:ro + - identity_grafana:/identities/grafana:ro + cap_drop: + - ALL + cap_add: + - DAC_READ_SEARCH + security_opt: + - no-new-privileges:true + read_only: true + tmpfs: + - /tmp:rw,noexec,nosuid,size=8m + cpus: 0.5 + mem_limit: 192m + pids_limit: 64 + healthcheck: + disable: true +secrets: + postgres_password: + file: ./secrets/postgres_password + s3_root_user: + file: ./secrets/s3_root_user + s3_root_password: + file: ./secrets/s3_root_password + grafana_password: + file: ./secrets/grafana_password + broker_admin: + file: ./secrets/broker_admin + cache_admin: + file: ./secrets/cache_admin + broker_config: + file: ./secrets/broker.conf + cache_config: + file: ./secrets/cache.conf +volumes: + broker_data: null + s3_data: null + postgres_data: null + prometheus_data: null + loki_data: null + tempo_data: null + grafana_data: null + identity_openbao: null + identity_api: null + identity_worker: null + identity_relay: null + identity_observer: null + identity_reconciler: null + identity_migrate: null + identity_lb: null + identity_postgres: null + identity_s3: null + identity_broker: null + identity_cache: null + identity_otel: null + identity_prometheus: null + identity_loki: null + identity_tempo: null + identity_grafana: null + openbao_data: null diff --git a/contracts/trust-matrix.md b/contracts/trust-matrix.md index 0c2a977..4dbcec9 100644 --- a/contracts/trust-matrix.md +++ b/contracts/trust-matrix.md @@ -1,37 +1,42 @@ -# Матрица доверия — заполнить в решении lab7 +# Матрица доверия — Маслов, БВТ2301 -Это обязательная матрица покрытия. Для каждой строки укажите реальный порт, endpoint, CA, service identity, проверку SAN/ACL, срок жизни credentials и команду положительного/отрицательного теста. TLS шифрует и подтверждает сервер; mTLS также проверяет клиента. При доверенном CA всё равно нужно ограничивать разрешённую identity. Plaintext hop допустим только внутри закрытого локального transport/proxy boundary, без опубликованного обхода; границу и rationale нужно доказать. +Один локальный стенд, отдельная сеть Compose. В сетевых соединениях используется TLS 1.3 с проверкой цепочки и DNS/IP SAN. Удостоверение сервиса — URI `spiffe://messenger/<роль>`. Gateway проверяет текущий CA, срок сертификата, список отозванных серийных номеров и разрешённую роль; HTTP дополнительно ограничен методом и путём. Конфигурации находятся в `infra/tls/*.json`. Наличие конфигурации не заменяет проверку: фактические результаты должны быть в `evidence/security-*.json` и REPORT. -| Связь | Минимум на 3 | Дополнительно на 4 | Доказательство / конфиг | -| --- | --- | --- | --- | -| Клиент → ingress/LB | TLS, CA + hostname, Bearer | Проверка expiry/revocation сессии и общего login rate limit | TODO | -| LB → API (все реплики) | mTLS + allowlist LB identity | Ротация leaf без обхода проверки | TODO | -| API/worker → PostgreSQL | TLS verify-full + раздельные ограниченные DB roles | Ротация credentials; mTLS — допустимое усиление | TODO | -| API/worker → S3 | TLS + разные scoped credentials/prefix rights | Проверка denied prefix и ротация | TODO | -| API/worker → broker | TLS + разные producer/consumer identities и ACL | mTLS + ограничение допустимых SAN/ролей | TODO | -| API/worker → Collector | TLS; сеть/аутентификация запрещает произвольный ingest | mTLS с раздельными identities | TODO | -| Collector → telemetry backends | TLS + scoped backend credentials или mTLS | Ротация и проверка least privilege | TODO | -| Grafana → data sources | TLS с проверкой сервера, ограниченная identity | Отрицательные проверки доступа | TODO | -| API/worker/agent → OpenBao | TLS + сервисный auth + scoped policy | Renewal/expiry/revocation | TODO | -| Оператор → OpenBao/Grafana/S3 admin | TLS + authentication, доступ локальный/через защищённый канал | Разделение operator/application roles | TODO | -| API → Redis/Valkey, если используется | TLS + ACL/пароль с минимальными правами | Ротация; mTLS по возможности | TODO | -| Replication/кластерные каналы, если добавлены | TLS/mTLS либо подтверждённый шифрованный transport | Проверка заявленной модели отказа | TODO | +| Связь | Endpoint и защита | Разрешение и срок | Проверка | +|---|---|---|---| +| Клиент → LB | `https://localhost:8443`, CA `trust/ca.pem`, SAN localhost/127.0.0.1 | Bearer, сессия 3600 с; общий SQL limiter до Argon2 | `make test test-security CA_FILE=trust/ca.pem`; HTTP suite | +| LB → все API | `api:8443`, mTLS; DNS SAN api; только URI lb | Роль lb, без обхода на API:8080; leaf 120 с | `python -m scripts.verify_security`: все адреса DNS API, правильный / отсутствующий / чужой CA / другая доверенная роль | +| API/worker/relay/observer/reconciler → PostgreSQL | `postgres:5443`, PG SSLRequest + mTLS, `sslmode=verify-full`, `gssencmode=disable` | Разные `svc_<роль>`, SCRAM, без SUPERUSER/CREATEROLE; нет доступа worker к users/sessions; TLS соединение ≤45 с | operator probe: SELECT 1 и запрещённые SQL; `scripts/prepare_dependencies.py` | +| API/worker/reconciler → S3 | `https://s3:9443`, mTLS + отдельные SigV4 accounts | API: PUT staging/GET objects; worker: GET objects/PUT versioned; reconciler: LIST/GET/DELETE objects; нет admin | operator probe: разрешённые PUT/GET, запрещённые prefix/DELETE/admin; собственные тестовые объекты удаляются | +| API → broker | N/A: API устойчиво пишет jobs/outbox в PG; producer — отдельный relay | API не получает broker password и не входит в allowlist broker | API-cert → broker должен быть отклонён | +| Relay/worker → broker | `broker:6380`, mTLS; разные URI relay/worker + разные Valkey ACL | relay XADD/WAITAOF; worker XGROUP/XREADGROUP/XAUTOCLAIM/XACK/XDEL; нет CONFIG; соединение ≤45 с | operator probe: PING после auth, CONFIG denied, три отрицательных TLS случая | +| API/worker/relay/observer → Collector | `otel:4438`, mTLS; только перечисленные URI | Только POST `/v1/`; отдельные идентичности API и worker | operator probe: реальный OTLP POST и неверные cert; pipeline в `infra/otel/collector.yaml` | +| Collector → Loki/Tempo | `loki:3310/otlp`, `tempo:4438/v1/traces`, mTLS, URI otel | Только ingest; Grafana не может писать ingest | Gateway allowlist и проверки матрицы; bounded exporter queues сохранены | +| Grafana → Prometheus/Loki/Tempo | `prometheus:9900`, `loki:3310`, `tempo:3320`, mTLS, URI grafana | Запросы; нет ingest/операторских изменений | Реальные datasource queries и запрещённые методы | +| Prometheus → Collector/LB/Loki/Tempo | `otel:18889`, `otel:18888`, `lb:18404`, `loki:3310`, `tempo:3320`, mTLS | Только GET metrics; URI prometheus | Prometheus up/actual series и negative route tests | +| Role agents → OpenBao | `https://openbao:8200`, native mTLS + cert auth с exact CN и URI | Только own KV v2 path и own PKI role. Auth token 120 с, max 600 с; bounded KV snapshot ≤60 с; рабочий leaf 120 с | operator probe: own secret 200, чужой secret/policy write/foreign PKI 403; renewal и expiry research | +| Оператор → OpenBao/Grafana/S3 | localhost `8207`/`3447`/`9007`, проверяемый TLS; Bao/S3 также operator client cert | Scoped operator policy; Grafana Basic; S3 отдельный root account только у оператора | CLI оператора; app/worker не монтируют operator/ и admin credentials | +| API → cache | `cache:6380`, mTLS URI api + Valkey ACL | Только GET/SET `user:*`, TTL карточки 30 с; нет sessions/passwords в cache | TLS/ACL probe, публичные бизнес-тесты | +| Репликация БД/S3/broker | N/A: одиночные PG/S3/broker с persistent volumes | Отказ реплики API переносится; отказ хоста/диска остаётся ограничением | HTTPS failover/persistence; не заявляется HA хранилищ | -Нет выбранного компонента — отметьте N/A с причиной, а не оставляйте пустую строку. Внутренний публичный health listener, если нужен, минимален и изолирован; через него нельзя обращаться к бизнес-API без mTLS. Отдельно задокументируйте scrape/health/bootstrap каналы: они тоже не должны создавать обход. +## Закрытая локальная граница -## Обязательные отрицательные проверки +Native listener каждого сервиса доступен только на 127.0.0.1 в его network namespace. Gateway разделяет namespace через `network_mode: service:<имя>`; API запускает gateway и Python сервер в одном контейнере. Прямые 8080/5432/6379/9000/4318/8889/9090/3100/3200/3000/8404 проверяются из отдельного контейнера и должны отказывать. На host опубликованы только 8443 и локальные административные TLS endpoints. -1. HTTPS с правильным CA/hostname проходит; с пустым/чужим CA и неправильным hostname — ошибка верификации, не «сервер недоступен». -2. LB→API: без client cert, с cert чужого CA, с запрещённой identity от доверенного CA — отказ; с разрешённой LB identity — успех. -3. На 4 повторите набор для broker и Collector; ограничение на network policy не заменяет проверку identity. -4. Пользователь вне чата не читает metadata/content и не прикрепляет чужой файл; поддельный X-User-Id не меняет Bearer identity. -5. OpenBao app policy читает только свой secret/path; запись policy и чтение чужого path запрещены. Worker не получает admin credentials API/БД/S3. -6. На 4 отзовите secret/cert и дождитесь контролируемого эффекта с учётом действующих соединений, TLS resumption и cache/TTL. Покажите новое подключение, иначе тест отзыва может ничего не проверить. +Часть продуктов умеет native TLS, но единый gateway выбран для одинакового обновления коротких сертификатов и точной проверки URI/отзыва. Локальные HTTP выходы Collector/Grafana/Prometheus и OTLP SDK тоже слушают только 127.0.0.1: gateway на каждом новом сетевом соединении читает текущие сертификат и CA, проверяет SAN и server URI. Это явно ограниченный локальный HTTP hop; сетевые границы шифруются. Публичного HTTP fallback нет. PostgreSQL native Unix socket остаётся только для operator bootstrap внутри контейнера PG. -## Bootstrap и эксплуатация +## Bootstrap, renewal и отзыв -В репозитории только открытые конфиги, policy templates и scripts. CA private key, leaf keys, root token, unseal shares и SecretID не коммитятся, не запекаются в образ и не печатаются в отчёте. Для локального стенда оператор создаёт их вне Git и передаёт через files/secrets с ограниченными правами. Опишите, кто имеет доступ к CA/unseal, что нужно после рестарта OpenBao и как восстановить работу. +`make up` выполняет явные шаги оператора. Root CA private key находится в `operator/` (0700, файлы 0600) и не монтируется в контейнеры. Root CA — 365 дней; intermediate — 30 дней, его ключ создаётся внутри OpenBao. Bootstrap cert сервиса — 30 минут, доступен только собственному agent; рабочий ключ сохраняется в собственном named volume (0700/0600). Обычный рестарт API использует продолжавший работать отдельный agent. -OpenBao не использует dev-mode. Выберите persistent storage и auth метод (например AppRole с короткоживущим SecretID/response wrapping, cert auth или иная обоснованная identity). Не подменяйте root token постоянной переменной BAO_TOKEN в приложении. Рабочие tokens имеют policy, TTL и renewal/re-auth сценарий. Статические KV secrets на 3 допустимы при реальном чтении через сервисную identity; динамические DB credentials — хорошее расширение, но не обязательное название технологии. +OpenBao работает с persistent file storage, вне dev-mode. Init создаёт 3 shares, threshold 2; файлы остаются у оператора, не монтируются в Bao/apps. В учебном стенде один оператор хранит все три защищённых файла; разделение между независимыми держателями не моделируется. Первичный root token используется только для установки auth/policies/PKI/KV/audit, затем отзывается и удаляется. У оператора cert-auth с отдельной policy и коротким token. -Разрешённый компромисс учебного стенда: ручной operator init/unseal, если он безопасно документирован и не нужен при каждом обычном рестарте API. Автоматическое хранение всех unseal shares рядом с OpenBao без защиты не считается решённым bootstrap. +Каждая роль получает только собственные KV и PKI разрешения. Agent опрашивает Bao каждые 15 с, обновляет leaf до истечения, сохраняет пары через атомарную смену каталога; snapshot secrets имеет конечный срок. После expiry запросы/новые подключения завершаются контролируемым отказом. Длительная остановка/seal Bao требует явного operator recovery; статического бессрочного секрета для автоматического обхода нет. + +Сертификат сервера Bao тоже короткий и обновляется native `tls_auto_reload`; CA bundle при rollover перечитывается через явный restart/unseal. HAProxy перечитывает leaf через master-worker SIGUSR2, без пересборки. Отзыв проверяется новым TLS подключением; HTTP закрывает соединение после ответа, PG/broker ограничены 45 с и сроком клиентского cert. Список serial deny не подменяет отзыв token/рабочего пароля при компрометации всей роли: эти действия оператор выполняет отдельно. + +## Права файлов и исключения + +Локальная `secrets/` имеет 0700. Отдельные bind files читаемы сервисным UID Docker Desktop; каждому agent смонтирован только его bootstrap каталог. Рабочие keys/snapshots в named volumes имеют 0600 и читаются собственным UID. App/worker — UID10001, read_only, drop ALL, no-new-privileges, bounded tmpfs/pids/CPU/RAM. Stateful данные находятся в отдельных томах. + +Одноразовый identity-init использует UID0 и только CHOWN/DAC_OVERRIDE для начальной подготовки томов; после завершения не работает. Официальный PG entrypoint использует ограниченный набор прав для init/drop-uid. Operator probe запускается только явно с profile operator, read_only и DAC_READ_SEARCH для чтения проверяемых service identities; это инструмент оператора, в приложение он не встраивается и root CA/unseal туда не передаются. Docker socket, host network и privileged отсутствуют. diff --git a/evidence/dependency-scan-first.json b/evidence/dependency-scan-first.json new file mode 100644 index 0000000..9ff93ea --- /dev/null +++ b/evidence/dependency-scan-first.json @@ -0,0 +1,9 @@ +{ + "scanner": "pip-audit 2.10.1", + "scope": "locked runtime dependencies, no dev group", + "lock_sha256": "0fb0fa939296df200ddeda2ad6379a9f1e99ff08fbcfc0ec8020b2a1115cf820", + "scanned_dependencies": 40, + "vulnerable_dependencies": [], + "scan_completed": true, + "recorded_at": "2026-11-20T15:08:38.146220+00:00" +} diff --git a/infra/fetch-source.go b/infra/fetch-source.go new file mode 100644 index 0000000..48506ca --- /dev/null +++ b/infra/fetch-source.go @@ -0,0 +1,107 @@ +// Fetch the immutable module ZIP in bounded HTTP ranges. The subsequent +// go mod download validates its h1 checksum through the Go checksum database. +package main + +import ( + "fmt" + "io" + "net/http" + "os" + "path/filepath" + "sync" + "time" +) + +func main() { + const version = "v0.0.0-20251015172955-9e49d5e7a648" + const total int64 = 25342606 + const chunk int64 = 512 * 1024 + const source = "https://proxy.golang.org/github.com/minio/minio/@v/" + version + ".zip" + directory := "/go/pkg/mod/cache/download/github.com/minio/minio/@v" + if err := os.MkdirAll(directory, 0755); err != nil { + panic(err) + } + target := filepath.Join(directory, version+".zip") + if info, err := os.Stat(target); err == nil && info.Size() == total { + fmt.Println("Source ZIP cached; Go will validate checksum") + return + } + client := &http.Client{Timeout: 90 * time.Second} + jobs := make(chan int64) + errors := make(chan error, 64) + var group sync.WaitGroup + for worker := 0; worker < 8; worker++ { + group.Add(1) + go func() { + defer group.Done() + for start := range jobs { + end := min(start+chunk, total) - 1 + part := fmt.Sprintf("%s.part-%d", target, start) + if info, err := os.Stat(part); err == nil && info.Size() == end-start+1 { + continue + } + var last error + for attempt := 0; attempt < 4; attempt++ { + req, _ := http.NewRequest("GET", source, nil) + req.Header.Set("Range", fmt.Sprintf("bytes=%d-%d", start, end)) + response, err := client.Do(req) + if err != nil { + last = fmt.Errorf("source range request failed") + continue + } + expected := fmt.Sprintf("bytes %d-%d/%d", start, end, total) + if response.StatusCode != 206 || response.Header.Get("Content-Range") != expected { + response.Body.Close() + last = fmt.Errorf("unexpected source range response: HTTP %d", response.StatusCode) + continue + } + data, err := io.ReadAll(io.LimitReader(response.Body, end-start+2)) + response.Body.Close() + if err != nil || int64(len(data)) != end-start+1 { + last = fmt.Errorf("incomplete source range") + continue + } + if err := os.WriteFile(part, data, 0644); err != nil { + last = err + continue + } + last = nil + fmt.Printf("Source part %d verified\n", start/chunk+1) + break + } + if last != nil { + errors <- last + } + } + }() + } + for start := int64(0); start < total; start += chunk { + jobs <- start + } + close(jobs) + group.Wait() + close(errors) + for err := range errors { + panic(err) + } + out, err := os.Create(target + ".partial") + if err != nil { + panic(err) + } + for start := int64(0); start < total; start += chunk { + part, err := os.Open(fmt.Sprintf("%s.part-%d", target, start)) + if err != nil { + panic(err) + } + if _, err := io.Copy(out, part); err != nil { + panic(err) + } + part.Close() + } + if err := out.Close(); err != nil { + panic(err) + } + if err := os.Rename(target+".partial", target); err != nil { + panic(err) + } +} diff --git a/infra/grafana/dashboards/messenger.json b/infra/grafana/dashboards/messenger.json new file mode 100644 index 0000000..68a6d1d --- /dev/null +++ b/infra/grafana/dashboards/messenger.json @@ -0,0 +1,789 @@ +{ + "uid": "messenger-lab6", + "title": "Мессенджер: диагностика и SLO", + "schemaVersion": 41, + "version": 1, + "editable": false, + "timezone": "utc", + "refresh": "5s", + "time": { + "from": "now-30m", + "to": "now" + }, + "tags": [ + "lab6", + "slo" + ], + "panels": [ + { + "id": 1, + "title": "Запросы через балансировщик, в секунду", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 0, + "y": 0, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "sum(rate(haproxy_backend_http_responses_total{proxy=\"messenger\"}[1m]))", + "refId": "A", + "legendFormat": "все бизнес-запросы", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "Health requests use a separate backend and are excluded. Includes ingress 503 with no API available.", + "fieldConfig": { + "defaults": { + "unit": "reqps" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 2, + "title": "Доля ответов 5xx", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 12, + "y": 0, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "sum(rate(haproxy_backend_http_responses_total{proxy=\"messenger\",code=\"5xx\"}[1m])) / clamp_min(sum(rate(haproxy_backend_http_responses_total{proxy=\"messenger\"}[1m])),0.001)", + "refId": "A", + "legendFormat": "ошибки 5xx", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "", + "fieldConfig": { + "defaults": { + "unit": "percentunit" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 3, + "title": "API: p50 / p95 / p99, секунды", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 0, + "y": 8, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "histogram_quantile(0.5, sum by(le) (rate(messenger_http_duration_seconds_bucket[2m])))", + "refId": "A", + "legendFormat": "p50", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + }, + { + "expr": "histogram_quantile(0.95, sum by(le) (rate(messenger_http_duration_seconds_bucket[2m])))", + "refId": "B", + "legendFormat": "p95", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + }, + { + "expr": "histogram_quantile(0.99, sum by(le) (rate(messenger_http_duration_seconds_bucket[2m])))", + "refId": "C", + "legendFormat": "p99", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "Quantiles from combined histogram buckets; complete ASGI response, no average of replica quantiles.", + "fieldConfig": { + "defaults": { + "unit": "s" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 4, + "title": "Очередь: ожидающие задания", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 12, + "y": 8, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "max(messenger_queue_depth)", + "refId": "A", + "legendFormat": "ожидают", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "Logical PostgreSQL jobs in queued state, not count of duplicate stream notifications.", + "fieldConfig": { + "defaults": { + "unit": "short" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 5, + "title": "Возраст старейшего незавершённого задания", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 0, + "y": 16, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "max(messenger_oldest_job_age_seconds)", + "refId": "A", + "legendFormat": "возраст", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "", + "fieldConfig": { + "defaults": { + "unit": "s" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 6, + "title": "Обработчик: занято / доступно", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 12, + "y": 16, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "sum(messenger_worker_busy)", + "refId": "A", + "legendFormat": "занято", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + }, + { + "expr": "sum(messenger_worker_capacity)", + "refId": "B", + "legendFormat": "всего мест", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "", + "fieldConfig": { + "defaults": { + "unit": "short" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 7, + "title": "Соединения PostgreSQL", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 0, + "y": 24, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "sum by(service_name) (messenger_db_pool_used)", + "refId": "A", + "legendFormat": "{{service_name}} занято", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + }, + { + "expr": "sum by(service_name) (messenger_db_pool_waiting)", + "refId": "B", + "legendFormat": "{{service_name}} ожидают", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "", + "fieldConfig": { + "defaults": { + "unit": "short" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 8, + "title": "Попытки обработки по результату", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 12, + "y": 24, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "sum by(outcome) (rate(messenger_job_attempts_total[2m]))", + "refId": "A", + "legendFormat": "{{outcome}}", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "", + "fieldConfig": { + "defaults": { + "unit": "ops" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 9, + "title": "Длительность попытки обработки: p95", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 0, + "y": 32, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "histogram_quantile(0.95,sum by(le)(rate(messenger_job_duration_seconds_bucket[2m])))", + "refId": "A", + "legendFormat": "p95", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "", + "fieldConfig": { + "defaults": { + "unit": "s" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 10, + "title": "От приёма до ready: p50 / p95 / p99", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 12, + "y": 32, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "histogram_quantile(0.5,sum by(le)(rate(messenger_time_to_ready_seconds_bucket[2m])))", + "refId": "A", + "legendFormat": "p50", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + }, + { + "expr": "histogram_quantile(0.95,sum by(le)(rate(messenger_time_to_ready_seconds_bucket[2m])))", + "refId": "B", + "legendFormat": "p95", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + }, + { + "expr": "histogram_quantile(0.99,sum by(le)(rate(messenger_time_to_ready_seconds_bucket[2m])))", + "refId": "C", + "legendFormat": "p99", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "Only completed publications have a duration. Deadline SLI below also counts unfinished tasks.", + "fieldConfig": { + "defaults": { + "unit": "s" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 11, + "title": "SLO API за 30 минут: цель 99%", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 0, + "y": 40, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "1 - sum(increase(haproxy_backend_http_responses_total{proxy=\"messenger\",code=\"5xx\"}[30m])) / clamp_min(sum(increase(haproxy_backend_http_responses_total{proxy=\"messenger\"}[30m])),1)", + "refId": "A", + "legendFormat": "доступность", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "", + "fieldConfig": { + "defaults": { + "unit": "percentunit" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 12, + "title": "SLO ready за 30 минут: 99% не позже 10 секунд", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 12, + "y": 40, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "sum(increase(messenger_slo_decisions_total{outcome=\"good\"}[30m])) / clamp_min(sum(increase(messenger_slo_decisions_total[30m])),1)", + "refId": "A", + "legendFormat": "доля вовремя", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "Durable one-time decisions per non-obsolete logical job; unfinished jobs become bad at ten seconds. Synthetic 320x200 profile.", + "fieldConfig": { + "defaults": { + "unit": "percentunit" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 13, + "title": "CPU процессов, ядра", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 0, + "y": 48, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "sum by(service_name)(rate(messenger_process_cpu_seconds_total[1m]))", + "refId": "A", + "legendFormat": "{{service_name}}", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "", + "fieldConfig": { + "defaults": { + "unit": "short" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 14, + "title": "Память процессов", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 12, + "y": 48, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "max by(service_name)(messenger_process_memory_bytes)", + "refId": "A", + "legendFormat": "{{service_name}}", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "", + "fieldConfig": { + "defaults": { + "unit": "bytes" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 15, + "title": "Буфер экспорта Collector", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 0, + "y": 56, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "otelcol_exporter_queue_size", + "refId": "A", + "legendFormat": "{{exporter}}", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + }, + { + "expr": "otelcol_exporter_queue_capacity", + "refId": "B", + "legendFormat": "{{exporter}} capacity", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "", + "fieldConfig": { + "defaults": { + "unit": "short" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 16, + "title": "Ошибки отправки трасс и логов", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 12, + "y": 56, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "sum(rate(otelcol_exporter_send_failed_spans[1m]))", + "refId": "A", + "legendFormat": "spans/s", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + }, + { + "expr": "sum(rate(otelcol_exporter_send_failed_log_records[1m]))", + "refId": "B", + "legendFormat": "logs/s", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "", + "fieldConfig": { + "defaults": { + "unit": "short" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 17, + "title": "Состояния локальных alerts", + "type": "timeseries", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + }, + "gridPos": { + "x": 0, + "y": 64, + "w": 12, + "h": 8 + }, + "targets": [ + { + "expr": "ALERTS{alertstate=\"firing\"}", + "refId": "A", + "legendFormat": "{{alertname}}", + "datasource": { + "type": "prometheus", + "uid": "prometheus" + } + } + ], + "description": "", + "fieldConfig": { + "defaults": { + "unit": "short" + }, + "overrides": [] + }, + "options": { + "legend": { + "displayMode": "list", + "placement": "bottom" + } + } + }, + { + "id": 18, + "title": "Связанные логи API и обработчика", + "type": "logs", + "datasource": { + "type": "loki", + "uid": "loki" + }, + "gridPos": { + "x": 12, + "y": 64, + "w": 12, + "h": 8 + }, + "targets": [ + { + "refId": "A", + "expr": "{service_name=~\"messenger-api|messenger-worker\"}", + "queryType": "range", + "datasource": { + "type": "loki", + "uid": "loki" + } + } + ], + "options": { + "showTime": true, + "wrapLogMessage": true, + "sortOrder": "Descending" + }, + "description": "Filter structured metadata trace_id in Explore; open the same ID in the Traces datasource." + } + ], + "annotations": { + "list": [] + } +} diff --git a/infra/grafana/provisioning/dashboards/default.yaml b/infra/grafana/provisioning/dashboards/default.yaml new file mode 100644 index 0000000..a68450e --- /dev/null +++ b/infra/grafana/provisioning/dashboards/default.yaml @@ -0,0 +1,10 @@ +apiVersion: 1 +providers: +- name: Messenger + orgId: 1 + folder: Laboratory 6 + type: file + disableDeletion: true + editable: false + options: + path: /var/lib/grafana/dashboards diff --git a/infra/grafana/provisioning/datasources/default.yaml b/infra/grafana/provisioning/datasources/default.yaml new file mode 100644 index 0000000..7cb9994 --- /dev/null +++ b/infra/grafana/provisioning/datasources/default.yaml @@ -0,0 +1,37 @@ +apiVersion: 1 +datasources: +- name: Metrics + uid: prometheus + type: prometheus + access: proxy + url: http://127.0.0.1:13909 + isDefault: true + editable: false + jsonData: + httpMethod: POST + timeInterval: 5s +- name: Logs + uid: loki + type: loki + access: proxy + url: http://127.0.0.1:13310 + editable: false + jsonData: + derivedFields: + - name: TraceID + matcherType: label + matcherRegex: trace_id + url: $${__value.raw} + datasourceUid: tempo +- name: Traces + uid: tempo + type: tempo + access: proxy + url: http://127.0.0.1:13320 + editable: false + jsonData: + tracesToLogsV2: + datasourceUid: loki + filterByTraceID: true + spanStartTimeShift: -1m + spanEndTimeShift: 1m diff --git a/infra/haproxy.cfg b/infra/haproxy.cfg new file mode 100644 index 0000000..609faec --- /dev/null +++ b/infra/haproxy.cfg @@ -0,0 +1,55 @@ +global + log stdout format raw local0 + maxconn 512 + ssl-default-bind-options ssl-min-ver TLSv1.3 no-tls-tickets + ssl-default-server-options ssl-min-ver TLSv1.3 no-tls-tickets + hard-stop-after 10s + mworker-max-reloads 2 + stats socket /tmp/admin.sock mode 600 level admin + +defaults + mode http + log global + log-format "http status=%ST duration_ms=%Ta" + timeout connect 1s + timeout client 15s + timeout server 8s + timeout http-request 10s + timeout http-keep-alive 5s + retries 0 + option httpclose + +resolvers docker + nameserver dns 127.0.0.11:53 + resolve_retries 3 + timeout resolve 1s + timeout retry 1s + hold valid 1s + hold obsolete 1s + hold nx 1s + +frontend public + bind :8443 ssl crt /run/identity/current/bundle.pem + use_backend health if { path_beg /health/ } + default_backend messenger + +backend messenger + balance roundrobin + option httpchk + http-check send meth GET uri /health/ready ver HTTP/1.1 hdr Host api + http-check expect status 200 + default-server check inter 1s fastinter 250ms fall 2 rise 1 resolvers docker init-addr libc,none resolve-prefer ipv4 + server-template api 1-8 api:8443 ssl verify required ca-file /trust/ca.pem crt /run/identity/current/bundle.pem sni str(api) check-sni api verifyhost api no-ssl-reuse + +backend health + balance roundrobin + option httpchk + http-check send meth GET uri /health/ready ver HTTP/1.1 hdr Host api + http-check expect status 200 + default-server check inter 1s fall 2 rise 1 resolvers docker init-addr libc,none + server-template api 1-8 api:8443 ssl verify required ca-file /trust/ca.pem crt /run/identity/current/bundle.pem sni str(api) check-sni api verifyhost api no-ssl-reuse + +frontend internal_metrics + bind 127.0.0.1:8404 + http-request use-service prometheus-exporter if { path /metrics } + http-request deny diff --git a/infra/openbao/config.hcl b/infra/openbao/config.hcl new file mode 100644 index 0000000..d43cdf2 --- /dev/null +++ b/infra/openbao/config.hcl @@ -0,0 +1,14 @@ +disable_mlock = true +ui = false +api_addr = "https://openbao:8200" +storage "file" { path = "/data/storage" } +listener "tcp" { + address = "0.0.0.0:8200" + tls_min_version = "tls13" + tls_cert_file = "/run/identity/current/cert.pem" + tls_key_file = "/run/identity/current/key.pem" + tls_client_ca_file = "/trust/ca.pem" + tls_require_and_verify_client_cert = true + tls_auto_reload = true + tls_auto_reload_interval = "5s" +} diff --git a/infra/openbao/policies/api.hcl b/infra/openbao/policies/api.hcl new file mode 100644 index 0000000..33818ce --- /dev/null +++ b/infra/openbao/policies/api.hcl @@ -0,0 +1,4 @@ +path "pki/issue/api" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } +path "secret/data/api" { capabilities = ["read"] } diff --git a/infra/openbao/policies/broker.hcl b/infra/openbao/policies/broker.hcl new file mode 100644 index 0000000..6ceabac --- /dev/null +++ b/infra/openbao/policies/broker.hcl @@ -0,0 +1,3 @@ +path "pki/issue/broker" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } diff --git a/infra/openbao/policies/cache.hcl b/infra/openbao/policies/cache.hcl new file mode 100644 index 0000000..e0062cb --- /dev/null +++ b/infra/openbao/policies/cache.hcl @@ -0,0 +1,3 @@ +path "pki/issue/cache" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } diff --git a/infra/openbao/policies/grafana.hcl b/infra/openbao/policies/grafana.hcl new file mode 100644 index 0000000..0b4b066 --- /dev/null +++ b/infra/openbao/policies/grafana.hcl @@ -0,0 +1,3 @@ +path "pki/issue/grafana" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } diff --git a/infra/openbao/policies/lb.hcl b/infra/openbao/policies/lb.hcl new file mode 100644 index 0000000..789a704 --- /dev/null +++ b/infra/openbao/policies/lb.hcl @@ -0,0 +1,3 @@ +path "pki/issue/lb" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } diff --git a/infra/openbao/policies/loki.hcl b/infra/openbao/policies/loki.hcl new file mode 100644 index 0000000..3a717f8 --- /dev/null +++ b/infra/openbao/policies/loki.hcl @@ -0,0 +1,3 @@ +path "pki/issue/loki" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } diff --git a/infra/openbao/policies/migrate.hcl b/infra/openbao/policies/migrate.hcl new file mode 100644 index 0000000..724810f --- /dev/null +++ b/infra/openbao/policies/migrate.hcl @@ -0,0 +1,4 @@ +path "pki/issue/migrate" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } +path "secret/data/migrate" { capabilities = ["read"] } diff --git a/infra/openbao/policies/observer.hcl b/infra/openbao/policies/observer.hcl new file mode 100644 index 0000000..782990e --- /dev/null +++ b/infra/openbao/policies/observer.hcl @@ -0,0 +1,4 @@ +path "pki/issue/observer" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } +path "secret/data/observer" { capabilities = ["read"] } diff --git a/infra/openbao/policies/openbao.hcl b/infra/openbao/policies/openbao.hcl new file mode 100644 index 0000000..65748a9 --- /dev/null +++ b/infra/openbao/policies/openbao.hcl @@ -0,0 +1,3 @@ +path "pki/issue/openbao" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } diff --git a/infra/openbao/policies/operator.hcl b/infra/openbao/policies/operator.hcl new file mode 100644 index 0000000..e51e5a9 --- /dev/null +++ b/infra/openbao/policies/operator.hcl @@ -0,0 +1,11 @@ +path "pki/*" { capabilities = ["create", "read", "update", "delete", "list", "sudo"] } +path "auth/cert/*" { capabilities = ["create", "read", "update", "delete", "list"] } +path "secret/*" { capabilities = ["create", "read", "update", "delete", "list"] } +path "sys/policies/acl/messenger-*" { capabilities = ["create", "read", "update", "delete", "list"] } +path "sys/mounts/pki/tune" { capabilities = ["read", "update", "sudo"] } +path "sys/seal" { capabilities = ["update", "sudo"] } +path "auth/token/lookup-self" { capabilities = ["read"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/accessors" { capabilities = ["list", "sudo"] } +path "auth/token/lookup-accessor" { capabilities = ["update", "sudo"] } +path "auth/token/revoke-accessor" { capabilities = ["update", "sudo"] } diff --git a/infra/openbao/policies/otel.hcl b/infra/openbao/policies/otel.hcl new file mode 100644 index 0000000..29b3a40 --- /dev/null +++ b/infra/openbao/policies/otel.hcl @@ -0,0 +1,3 @@ +path "pki/issue/otel" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } diff --git a/infra/openbao/policies/postgres.hcl b/infra/openbao/policies/postgres.hcl new file mode 100644 index 0000000..23c3e95 --- /dev/null +++ b/infra/openbao/policies/postgres.hcl @@ -0,0 +1,3 @@ +path "pki/issue/postgres" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } diff --git a/infra/openbao/policies/prometheus.hcl b/infra/openbao/policies/prometheus.hcl new file mode 100644 index 0000000..248e6bd --- /dev/null +++ b/infra/openbao/policies/prometheus.hcl @@ -0,0 +1,3 @@ +path "pki/issue/prometheus" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } diff --git a/infra/openbao/policies/reconciler.hcl b/infra/openbao/policies/reconciler.hcl new file mode 100644 index 0000000..a201832 --- /dev/null +++ b/infra/openbao/policies/reconciler.hcl @@ -0,0 +1,4 @@ +path "pki/issue/reconciler" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } +path "secret/data/reconciler" { capabilities = ["read"] } diff --git a/infra/openbao/policies/relay.hcl b/infra/openbao/policies/relay.hcl new file mode 100644 index 0000000..d4d6571 --- /dev/null +++ b/infra/openbao/policies/relay.hcl @@ -0,0 +1,4 @@ +path "pki/issue/relay" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } +path "secret/data/relay" { capabilities = ["read"] } diff --git a/infra/openbao/policies/s3.hcl b/infra/openbao/policies/s3.hcl new file mode 100644 index 0000000..03b6a0f --- /dev/null +++ b/infra/openbao/policies/s3.hcl @@ -0,0 +1,3 @@ +path "pki/issue/s3" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } diff --git a/infra/openbao/policies/tempo.hcl b/infra/openbao/policies/tempo.hcl new file mode 100644 index 0000000..7f8cd0a --- /dev/null +++ b/infra/openbao/policies/tempo.hcl @@ -0,0 +1,3 @@ +path "pki/issue/tempo" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } diff --git a/infra/openbao/policies/worker.hcl b/infra/openbao/policies/worker.hcl new file mode 100644 index 0000000..c726182 --- /dev/null +++ b/infra/openbao/policies/worker.hcl @@ -0,0 +1,4 @@ +path "pki/issue/worker" { capabilities = ["create", "update"] } +path "auth/token/renew-self" { capabilities = ["update"] } +path "auth/token/lookup-self" { capabilities = ["read"] } +path "secret/data/worker" { capabilities = ["read"] } diff --git a/infra/otel/RUNBOOK.md b/infra/otel/RUNBOOK.md new file mode 100644 index 0000000..d9bec99 --- /dev/null +++ b/infra/otel/RUNBOOK.md @@ -0,0 +1,50 @@ +# Диагностика по сохранённой телеметрии + +Открой dashboard «Мессенджер: диагностика и SLO», временная зона UTC. +Сопоставляй время оповещения с метриками, трассами и связанными логами. + +## API errors + +Признак: ApiHighErrorRate, ApiFastBurn или ApiSlowBurn. Числитель доступности: +`sum(rate(haproxy_backend_http_responses_total{proxy="messenger",code="5xx"}[2m]))`. +Знаменатель — тот же backend со всеми code. Health использует другой backend. +Сравни API histogram, DB pool used/waiting и worker busy. В Traces найди +ошибочный server span и вложенный db.postgresql или s3.*. Длинная DB-операция +с ошибкой и занятым пулом при нормальной очереди указывает на БД. Отсутствие +API span при ingress503 может означать отсутствие готовых API. Один5xx не +доказывает причину. Через trace_id найди соответствующий Logs record. +После исправления проверь новые сообщения, спад5xx, resolved и прежние данные. + +## Queue age + +Признак: QueueLagGrowing, ReadyFastBurn или ReadySlowBurn. Сравни логические +queued jobs PG, oldest job age и worker busy/capacity. Upload202 при росте +ожидающей очереди и отсутствии новых worker spans указывает на обработчик. +Если попытки идут и содержат DB/S3 ошибки, причина может быть в зависимости. +Найди путь upload→producer→consumer→S3/DB. Histogram ready содержит только +завершения, поэтому отдельно проверь deadline SLI для незавершённых jobs. +После восстановления проверь тот же attachment_id, original, спад и resolved. + +## Telemetry backend + +Проверь backend health, Collector queue и accepted/sent/failed счётчики. +Failed attempts не равны числу уникально потерянных spans: пакет повторяется. +После слива очередей сравни изменение accepted-minus-sent и исходное состояние. +SDK queues traces/logs512records, timeout0.75s; Collector memory limiter192MiB, +batch≤256, очереди logs/traces по32пакета, один sender и finite retry≤10s. +При отказе telemetry может теряться; измеряй память и настоящие бизнес-запросы. +После восстановления найди новую трассу и лог, а не только старый screenshot. + +## SLO и окна + +Учебный профиль: синтетические PNG320×200, upload не чаще одного каждые3s, +закреплённые CPU/RAM. API цель99%ответов без5xx за30m на ingress. Jobs цель99% +ready≤10s от PG created_at принимающей транзакции до committed_at публикации. +Начальная граница консервативно включает завершение принимающей транзакции. +Однократные durable good/bad решения учитывают failed и незавершённые после10s. +Ручной replay не стирает прежний bad; устаревшие до решения jobs исключены. +Burn rate = доля плохих событий/0.01. Быстрое правило: burn>14.4 в30s и2m, +непрерывно45s. Длительное: burn>6 в2m и5m, непрерывно60s. Короткие окна выбраны +для воспроизводимого стенда, а не универсальной production paging policy. +Измеряются краткий всплеск/длительная деградация/firing/resolved/ложные события. +Точность времени ограничена polling2s, scrape/evaluation5s и экспортом. diff --git a/infra/otel/alerts.yaml b/infra/otel/alerts.yaml new file mode 100644 index 0000000..f0a9114 --- /dev/null +++ b/infra/otel/alerts.yaml @@ -0,0 +1,53 @@ +groups: + - name: messenger-slo + interval: 5s + rules: + - alert: ApiHighErrorRate + expr: sum(rate(haproxy_backend_http_responses_total{proxy="messenger",code="5xx"}[2m])) / clamp_min(sum(rate(haproxy_backend_http_responses_total{proxy="messenger"}[2m])),0.001) > 0.05 + for: 20s + labels: {severity: warning, signal: api} + annotations: + summary: More than 5 percent business responses are 5xx + runbook: infra/otel/RUNBOOK.md#api-errors + - alert: QueueLagGrowing + expr: max(messenger_oldest_job_age_seconds) > 20 and max(messenger_queue_depth) > 0 + for: 10s + labels: {severity: warning, signal: ready} + annotations: + summary: Oldest unfinished attachment exceeds 20 seconds + runbook: infra/otel/RUNBOOK.md#queue-age + - alert: ApiFastBurn + expr: (sum(rate(haproxy_backend_http_responses_total{proxy="messenger",code="5xx"}[30s])) / clamp_min(sum(rate(haproxy_backend_http_responses_total{proxy="messenger"}[30s])),0.001) / 0.01 > 14.4) and (sum(rate(haproxy_backend_http_responses_total{proxy="messenger",code="5xx"}[2m])) / clamp_min(sum(rate(haproxy_backend_http_responses_total{proxy="messenger"}[2m])),0.001) / 0.01 > 14.4) + for: 45s + labels: {severity: critical, signal: api, burn: fast} + annotations: + summary: API burns the one-percent error budget in both fast windows + runbook: infra/otel/RUNBOOK.md#api-errors + - alert: ApiSlowBurn + expr: (sum(rate(haproxy_backend_http_responses_total{proxy="messenger",code="5xx"}[2m])) / clamp_min(sum(rate(haproxy_backend_http_responses_total{proxy="messenger"}[2m])),0.001) / 0.01 > 6) and (sum(rate(haproxy_backend_http_responses_total{proxy="messenger",code="5xx"}[5m])) / clamp_min(sum(rate(haproxy_backend_http_responses_total{proxy="messenger"}[5m])),0.001) / 0.01 > 6) + for: 60s + labels: {severity: critical, signal: api, burn: slow} + annotations: + summary: API burns the error budget across two longer windows + runbook: infra/otel/RUNBOOK.md#api-errors + - alert: ReadyFastBurn + expr: (sum(rate(messenger_slo_decisions_total{outcome="bad"}[30s])) / clamp_min(sum(rate(messenger_slo_decisions_total[30s])),0.001) / 0.01 > 14.4) and (sum(rate(messenger_slo_decisions_total{outcome="bad"}[2m])) / clamp_min(sum(rate(messenger_slo_decisions_total[2m])),0.001) / 0.01 > 14.4) + for: 45s + labels: {severity: critical, signal: ready, burn: fast} + annotations: + summary: Attachment deadline SLO burns the error budget + runbook: infra/otel/RUNBOOK.md#queue-age + - alert: ReadySlowBurn + expr: (sum(rate(messenger_slo_decisions_total{outcome="bad"}[2m])) / clamp_min(sum(rate(messenger_slo_decisions_total[2m])),0.001) / 0.01 > 6) and (sum(rate(messenger_slo_decisions_total{outcome="bad"}[5m])) / clamp_min(sum(rate(messenger_slo_decisions_total[5m])),0.001) / 0.01 > 6) + for: 60s + labels: {severity: critical, signal: ready, burn: slow} + annotations: + summary: Sustained misses of the attachment ten-second deadline + runbook: infra/otel/RUNBOOK.md#queue-age + - alert: CollectorUnavailable + expr: up{job="collector"} == 0 + for: 15s + labels: {severity: warning, signal: telemetry} + annotations: + summary: Collector self metrics are unavailable + runbook: infra/otel/RUNBOOK.md#telemetry-backend diff --git a/infra/otel/collector.yaml b/infra/otel/collector.yaml new file mode 100644 index 0000000..1ec1e30 --- /dev/null +++ b/infra/otel/collector.yaml @@ -0,0 +1,88 @@ +receivers: + otlp: + protocols: + http: + endpoint: 127.0.0.1:4318 +processors: + memory_limiter: + check_interval: 1s + limit_mib: 192 + spike_limit_mib: 32 + batch: + timeout: 1s + send_batch_size: 128 + send_batch_max_size: 256 +exporters: + prometheus: + endpoint: 127.0.0.1:8889 + metric_expiration: 15s + resource_constant_labels: + included: + - service.name + - service.instance.id + - service.version + - deployment.environment.name + otlp_http/tempo: + endpoint: http://127.0.0.1:14319 + timeout: 2s + sending_queue: + queue_size: 32 + num_consumers: 1 + block_on_overflow: false + retry_on_failure: + initial_interval: 1s + max_interval: 2s + max_elapsed_time: 10s + otlp_http/loki: + endpoint: http://127.0.0.1:13310/otlp + timeout: 2s + sending_queue: + queue_size: 32 + num_consumers: 1 + block_on_overflow: false + retry_on_failure: + initial_interval: 1s + max_interval: 2s + max_elapsed_time: 10s +extensions: + health_check: + endpoint: 127.0.0.1:13133 +service: + extensions: + - health_check + telemetry: + logs: + level: warn + metrics: + level: detailed + readers: + - pull: + exporter: + prometheus: + host: 127.0.0.1 + port: 8888 + pipelines: + traces: + receivers: + - otlp + processors: + - memory_limiter + - batch + exporters: + - otlp_http/tempo + logs: + receivers: + - otlp + processors: + - memory_limiter + - batch + exporters: + - otlp_http/loki + metrics: + receivers: + - otlp + processors: + - memory_limiter + - batch + exporters: + - prometheus diff --git a/infra/otel/loki.yaml b/infra/otel/loki.yaml new file mode 100644 index 0000000..df69d03 --- /dev/null +++ b/infra/otel/loki.yaml @@ -0,0 +1,44 @@ +auth_enabled: false +server: + http_listen_port: 3100 + log_level: warn + http_listen_address: 127.0.0.1 + grpc_listen_address: 127.0.0.1 +common: + path_prefix: /loki + replication_factor: 1 + ring: + kvstore: + store: inmemory + storage: + filesystem: + chunks_directory: /loki/chunks + rules_directory: /loki/rules +schema_config: + configs: + - from: 2026-01-01 + store: tsdb + object_store: filesystem + schema: v13 + index: + prefix: index_ + period: 24h +limits_config: + allow_structured_metadata: true + ingestion_rate_mb: 4 + ingestion_burst_size_mb: 8 + volume_enabled: true + otlp_config: + resource_attributes: + ignore_defaults: true + attributes_config: + - action: index_label + attributes: + - service.name + - action: structured_metadata + attributes: + - service.instance.id + - service.version + - deployment.environment.name +analytics: + reporting_enabled: false diff --git a/infra/otel/prometheus.yaml b/infra/otel/prometheus.yaml new file mode 100644 index 0000000..a50bcf8 --- /dev/null +++ b/infra/otel/prometheus.yaml @@ -0,0 +1,30 @@ +global: + scrape_interval: 5s + evaluation_interval: 5s +rule_files: +- /etc/prometheus/alerts.yaml +scrape_configs: +- job_name: application_otlp + static_configs: + - targets: + - 127.0.0.1:18889 +- job_name: collector + static_configs: + - targets: + - 127.0.0.1:18888 +- job_name: ingress + static_configs: + - targets: + - 127.0.0.1:18404 +- job_name: prometheus + static_configs: + - targets: + - localhost:9090 +- job_name: tempo + static_configs: + - targets: + - 127.0.0.1:13200 +- job_name: loki + static_configs: + - targets: + - 127.0.0.1:13100 diff --git a/infra/otel/tempo.yaml b/infra/otel/tempo.yaml new file mode 100644 index 0000000..a85e764 --- /dev/null +++ b/infra/otel/tempo.yaml @@ -0,0 +1,22 @@ +target: all +stream_over_http_enabled: true +server: + http_listen_port: 3200 + log_level: warn + http_listen_address: 127.0.0.1 + grpc_listen_address: 127.0.0.1 +distributor: + receivers: + otlp: + protocols: + http: + endpoint: 127.0.0.1:4318 +storage: + trace: + backend: local + wal: + path: /var/tempo/wal + local: + path: /var/tempo/blocks +usage_report: + reporting_enabled: false diff --git a/infra/otel/versions.json b/infra/otel/versions.json new file mode 100644 index 0000000..822dfc6 --- /dev/null +++ b/infra/otel/versions.json @@ -0,0 +1,7 @@ +{ + "otel": "otel/opentelemetry-collector-contrib:0.165.0@sha256:e40d61f10c9a617cca1ffd1be4d7e2b3a4b0f0001798ff07e58cabe82e618cea", + "prometheus": "prom/prometheus:v3.16.0@sha256:e04987641b57704f408e31f6373ba4138ecf27cb4a165d24aabb6c38fddd0f06", + "loki": "grafana/loki:3.7.10@sha256:b43c257ccfc925d4a50b8717cac61a3b51df8c48d01847936057e5c4075a24a7", + "tempo": "grafana/tempo:3.1.1@sha256:64e2fbd56d9c2b3412a4b430a58ea59e91a670b1e75f920a0c702213ad145044", + "grafana": "grafana/grafana:13.3.1@sha256:0615ec4fbd4072004b7d86b46ded63013a74b7d6eb1119273dd89e8fa25c13cf" +} diff --git a/infra/s3-bootstrap.sh b/infra/s3-bootstrap.sh new file mode 100644 index 0000000..5732c25 --- /dev/null +++ b/infra/s3-bootstrap.sh @@ -0,0 +1,14 @@ +#!/bin/sh +set -eu +root_user=$(cat /run/secrets/s3_root_user) +root_password=$(cat /run/secrets/s3_root_password) +api_key=$(cat /run/secrets/s3_access_key) +api_secret=$(cat /run/secrets/s3_secret_key) +# Credentials are passed only inside this isolated bootstrap container. +mc alias set local http://s3:9000 "$root_user" "$root_password" >/dev/null 2>&1 +mc mb --ignore-existing local/messenger >/dev/null 2>&1 +mc anonymous set none local/messenger >/dev/null 2>&1 +mc admin user add local "$api_key" "$api_secret" >/dev/null 2>&1 +mc admin policy create local messenger-api /policy.json >/dev/null 2>&1 +mc admin policy attach local messenger-api --user "$api_key" >/dev/null 2>&1 +printf '%s\n' 'Private bucket and scoped application policy ready' diff --git a/infra/s3-entrypoint.sh b/infra/s3-entrypoint.sh new file mode 100644 index 0000000..595c2b7 --- /dev/null +++ b/infra/s3-entrypoint.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -eu +export MINIO_ROOT_USER="$(cat /run/secrets/s3_root_user)" +export MINIO_ROOT_PASSWORD="$(cat /run/secrets/s3_root_password)" +export MINIO_BROWSER=off +exec minio server /data --address 127.0.0.1:9000 --console-address 127.0.0.1:9001 diff --git a/infra/s3-policy.json b/infra/s3-policy.json new file mode 100644 index 0000000..f7ec8fb --- /dev/null +++ b/infra/s3-policy.json @@ -0,0 +1,15 @@ +{ + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": ["s3:GetBucketLocation", "s3:ListBucket"], + "Resource": ["arn:aws:s3:::messenger"] + }, + { + "Effect": "Allow", + "Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"], + "Resource": ["arn:aws:s3:::messenger/objects/*"] + } + ] +} diff --git a/infra/s3.Dockerfile b/infra/s3.Dockerfile new file mode 100644 index 0000000..d971a03 --- /dev/null +++ b/infra/s3.Dockerfile @@ -0,0 +1,49 @@ +FROM golang:1.24.8-bookworm@sha256:4ed690d6649d63c312b99a6120025ec79ce3b542968a37da53d6236c7c61a848 AS toolchain +ENV CGO_ENABLED=0 GOMAXPROCS=2 GOFLAGS=-p=2 GOTOOLCHAIN=local + +FROM toolchain AS minio-build +WORKDIR /source +COPY infra/fetch-source.go /tmp/fetch-source.go +RUN --mount=type=cache,target=/go/pkg/mod,sharing=locked \ + --mount=type=cache,target=/root/.cache/go-build,sharing=locked \ + go run /tmp/fetch-source.go && \ + for attempt in 1 2 3 4; do \ + go mod download -json github.com/minio/minio@v0.0.0-20251015172955-9e49d5e7a648 && break; \ + test "$attempt" -lt 4 || exit 1; sleep 1; \ + done && \ + cp -a /go/pkg/mod/github.com/minio/minio@v0.0.0-20251015172955-9e49d5e7a648/. /source/ +RUN --mount=type=cache,target=/go/pkg/mod,sharing=locked \ + --mount=type=cache,target=/root/.cache/go-build,sharing=locked \ + for attempt in 1 2 3; do \ + timeout 900s go build -trimpath -ldflags='-s -w -X github.com/minio/minio/cmd.Version=2025-10-15T17:29:55Z -X github.com/minio/minio/cmd.ReleaseTag=RELEASE.2025-10-15T17-29-55Z -X github.com/minio/minio/cmd.CommitID=9e49d5e7a648f00e26f2246f4dc28e6b07f8c84a' -o /out/minio . && break; \ + test "$attempt" -lt 3 || exit 1; sleep 1; \ + done + +FROM toolchain AS mc-build +WORKDIR /source +RUN git init . && git remote add origin https://github.com/minio/mc.git && \ + git fetch --depth 1 origin 7394ce0dd2a80935aded936b09fa12cbb3cb8096 && git checkout --detach FETCH_HEAD +RUN --mount=type=cache,target=/go/pkg/mod,sharing=locked \ + --mount=type=cache,target=/root/.cache/go-build,sharing=locked \ + go build -trimpath -ldflags='-s -w' -o /out/mc . + +FROM python:3.14.7-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d AS server +LABEL org.opencontainers.image.revision=9e49d5e7a648f00e26f2246f4dc28e6b07f8c84a org.opencontainers.image.version=RELEASE.2025-10-15T17-29-55Z +COPY --from=minio-build /out/minio /usr/local/bin/minio +COPY --from=minio-build /source/LICENSE /licenses/minio.LICENSE +COPY --chmod=755 infra/s3-entrypoint.sh /usr/local/bin/s3-entrypoint +RUN mkdir /data && chown 10001:10001 /data +USER 10001:10001 +ENTRYPOINT ["/usr/local/bin/s3-entrypoint"] +EXPOSE 9000 +HEALTHCHECK --interval=2s --timeout=2s --start-period=10s --retries=30 CMD ["python","-c","import urllib.request; urllib.request.urlopen('http://127.0.0.1:9000/minio/health/ready',timeout=1).read()"] + +FROM python:3.14.7-slim-trixie@sha256:51dafde81dbdb6ebde285137a295cf18a47ca95234fe388a343719cb97305b3d AS bootstrap +LABEL org.opencontainers.image.revision=7394ce0dd2a80935aded936b09fa12cbb3cb8096 org.opencontainers.image.version=RELEASE.2025-08-13T08-35-41Z +COPY --from=mc-build /out/mc /usr/local/bin/mc +COPY --from=mc-build /source/LICENSE /licenses/mc.LICENSE +COPY --chmod=755 infra/s3-bootstrap.sh /usr/local/bin/s3-bootstrap +COPY infra/s3-policy.json /policy.json +USER 10001:10001 +ENV MC_CONFIG_DIR=/tmp/mc +ENTRYPOINT ["/usr/local/bin/s3-bootstrap"] diff --git a/infra/tls/agent-api.json b/infra/tls/agent-api.json new file mode 100644 index 0000000..07d8eec --- /dev/null +++ b/infra/tls/agent-api.json @@ -0,0 +1,17 @@ +{ + "role": "api", + "dns": [ + "api", + "localhost" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "bootstrap": "/bootstrap", + "kv": true +} diff --git a/infra/tls/agent-broker.json b/infra/tls/agent-broker.json new file mode 100644 index 0000000..0892cf8 --- /dev/null +++ b/infra/tls/agent-broker.json @@ -0,0 +1,16 @@ +{ + "role": "broker", + "dns": [ + "broker" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "bootstrap": "/bootstrap", + "kv": false +} diff --git a/infra/tls/agent-cache.json b/infra/tls/agent-cache.json new file mode 100644 index 0000000..107663c --- /dev/null +++ b/infra/tls/agent-cache.json @@ -0,0 +1,16 @@ +{ + "role": "cache", + "dns": [ + "cache" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "bootstrap": "/bootstrap", + "kv": false +} diff --git a/infra/tls/agent-grafana.json b/infra/tls/agent-grafana.json new file mode 100644 index 0000000..602d005 --- /dev/null +++ b/infra/tls/agent-grafana.json @@ -0,0 +1,20 @@ +{ + "role": "grafana", + "dns": [ + "grafana", + "localhost" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "ip": [ + "127.0.0.1" + ], + "bootstrap": "/bootstrap", + "kv": false +} diff --git a/infra/tls/agent-lb.json b/infra/tls/agent-lb.json new file mode 100644 index 0000000..44f2c29 --- /dev/null +++ b/infra/tls/agent-lb.json @@ -0,0 +1,21 @@ +{ + "role": "lb", + "dns": [ + "lb", + "localhost" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "ip": [ + "127.0.0.1" + ], + "bootstrap": "/bootstrap", + "kv": false, + "reload_pid_one": true +} diff --git a/infra/tls/agent-loki.json b/infra/tls/agent-loki.json new file mode 100644 index 0000000..689547c --- /dev/null +++ b/infra/tls/agent-loki.json @@ -0,0 +1,16 @@ +{ + "role": "loki", + "dns": [ + "loki" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "bootstrap": "/bootstrap", + "kv": false +} diff --git a/infra/tls/agent-migrate.json b/infra/tls/agent-migrate.json new file mode 100644 index 0000000..e535a5c --- /dev/null +++ b/infra/tls/agent-migrate.json @@ -0,0 +1,16 @@ +{ + "role": "migrate", + "dns": [ + "migrate" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "bootstrap": "/bootstrap", + "kv": true +} diff --git a/infra/tls/agent-observer.json b/infra/tls/agent-observer.json new file mode 100644 index 0000000..b1341b1 --- /dev/null +++ b/infra/tls/agent-observer.json @@ -0,0 +1,16 @@ +{ + "role": "observer", + "dns": [ + "observer" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "bootstrap": "/bootstrap", + "kv": true +} diff --git a/infra/tls/agent-openbao.json b/infra/tls/agent-openbao.json new file mode 100644 index 0000000..5bc6fd7 --- /dev/null +++ b/infra/tls/agent-openbao.json @@ -0,0 +1,20 @@ +{ + "role": "openbao", + "dns": [ + "openbao", + "localhost" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "ip": [ + "127.0.0.1" + ], + "bootstrap": "/bootstrap", + "kv": false +} diff --git a/infra/tls/agent-otel.json b/infra/tls/agent-otel.json new file mode 100644 index 0000000..316c204 --- /dev/null +++ b/infra/tls/agent-otel.json @@ -0,0 +1,16 @@ +{ + "role": "otel", + "dns": [ + "otel" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "bootstrap": "/bootstrap", + "kv": false +} diff --git a/infra/tls/agent-postgres.json b/infra/tls/agent-postgres.json new file mode 100644 index 0000000..f90bd2a --- /dev/null +++ b/infra/tls/agent-postgres.json @@ -0,0 +1,16 @@ +{ + "role": "postgres", + "dns": [ + "postgres" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "bootstrap": "/bootstrap", + "kv": false +} diff --git a/infra/tls/agent-prometheus.json b/infra/tls/agent-prometheus.json new file mode 100644 index 0000000..8c2c9b6 --- /dev/null +++ b/infra/tls/agent-prometheus.json @@ -0,0 +1,16 @@ +{ + "role": "prometheus", + "dns": [ + "prometheus" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "bootstrap": "/bootstrap", + "kv": false +} diff --git a/infra/tls/agent-reconciler.json b/infra/tls/agent-reconciler.json new file mode 100644 index 0000000..774e12a --- /dev/null +++ b/infra/tls/agent-reconciler.json @@ -0,0 +1,16 @@ +{ + "role": "reconciler", + "dns": [ + "reconciler" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "bootstrap": "/bootstrap", + "kv": true +} diff --git a/infra/tls/agent-relay.json b/infra/tls/agent-relay.json new file mode 100644 index 0000000..ec8713d --- /dev/null +++ b/infra/tls/agent-relay.json @@ -0,0 +1,16 @@ +{ + "role": "relay", + "dns": [ + "relay" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "bootstrap": "/bootstrap", + "kv": true +} diff --git a/infra/tls/agent-s3.json b/infra/tls/agent-s3.json new file mode 100644 index 0000000..0d78fc1 --- /dev/null +++ b/infra/tls/agent-s3.json @@ -0,0 +1,20 @@ +{ + "role": "s3", + "dns": [ + "s3", + "localhost" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "ip": [ + "127.0.0.1" + ], + "bootstrap": "/bootstrap", + "kv": false +} diff --git a/infra/tls/agent-tempo.json b/infra/tls/agent-tempo.json new file mode 100644 index 0000000..57c5e27 --- /dev/null +++ b/infra/tls/agent-tempo.json @@ -0,0 +1,16 @@ +{ + "role": "tempo", + "dns": [ + "tempo" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "bootstrap": "/bootstrap", + "kv": false +} diff --git a/infra/tls/agent-worker.json b/infra/tls/agent-worker.json new file mode 100644 index 0000000..b486738 --- /dev/null +++ b/infra/tls/agent-worker.json @@ -0,0 +1,16 @@ +{ + "role": "worker", + "dns": [ + "worker" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": false, + "servers": [], + "outbounds": [], + "bootstrap": "/bootstrap", + "kv": true +} diff --git a/infra/tls/api.json b/infra/tls/api.json new file mode 100644 index 0000000..d6e98e4 --- /dev/null +++ b/infra/tls/api.json @@ -0,0 +1,33 @@ +{ + "role": "api", + "dns": [ + "api", + "localhost" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": true, + "servers": [ + { + "listen": "0.0.0.0:8443", + "target": "127.0.0.1:8080", + "protocol": "http", + "allow": { + "spiffe://messenger/lb": [ + "* /" + ] + }, + "public": false + } + ], + "outbounds": [ + { + "listen": "127.0.0.1:14318", + "target": "https://otel:4438", + "server_identity": "spiffe://messenger/otel" + } + ] +} diff --git a/infra/tls/broker.json b/infra/tls/broker.json new file mode 100644 index 0000000..f52c92b --- /dev/null +++ b/infra/tls/broker.json @@ -0,0 +1,25 @@ +{ + "role": "broker", + "dns": [ + "broker" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": true, + "servers": [ + { + "listen": "0.0.0.0:6380", + "target": "127.0.0.1:6379", + "protocol": "tcp", + "allow": { + "spiffe://messenger/relay": [], + "spiffe://messenger/worker": [], + "spiffe://messenger/operator": [] + } + } + ], + "outbounds": [] +} diff --git a/infra/tls/cache.json b/infra/tls/cache.json new file mode 100644 index 0000000..027e044 --- /dev/null +++ b/infra/tls/cache.json @@ -0,0 +1,24 @@ +{ + "role": "cache", + "dns": [ + "cache" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": true, + "servers": [ + { + "listen": "0.0.0.0:6380", + "target": "127.0.0.1:6379", + "protocol": "tcp", + "allow": { + "spiffe://messenger/api": [], + "spiffe://messenger/operator": [] + } + } + ], + "outbounds": [] +} diff --git a/infra/tls/gateway.go b/infra/tls/gateway.go new file mode 100644 index 0000000..b909004 --- /dev/null +++ b/infra/tls/gateway.go @@ -0,0 +1,631 @@ +// A bounded TLS boundary; cleartext targets must bind only to loopback. +package main + +import ( + "bytes" + "context" + "crypto/tls" + "crypto/x509" + "encoding/binary" + "encoding/json" + "errors" + "fmt" + "io" + "log" + "net" + "net/http" + "net/http/httputil" + "net/url" + "os" + "os/signal" + "path/filepath" + "strconv" + "strings" + "sync" + "syscall" + "time" +) + +type Boundary struct { + Listen string `json:"listen"` + Target string `json:"target"` + Protocol string `json:"protocol"` + // Identity -> allowed HTTP method/path prefixes; an empty list denies HTTP. + Allow map[string][]string `json:"allow"` + Public bool `json:"public"` +} +type Outbound struct { + Listen string `json:"listen"` + Target string `json:"target"` + Identity string `json:"server_identity"` +} +type Config struct { + Outbounds []Outbound `json:"outbounds"` + ServeOnly bool `json:"serve_only"` + ReloadPIDOne bool `json:"reload_pid_one"` + Role string `json:"role"` + DNS []string `json:"dns"` + IP []string `json:"ip"` + Bao string `json:"bao"` + Trust string `json:"trust"` + Bootstrap string `json:"bootstrap"` + Identity string `json:"identity"` + Revoked string `json:"revoked"` + TTL string `json:"ttl"` + KV bool `json:"kv"` + Servers []Boundary `json:"servers"` +} +type Agent struct { + c Config + mu sync.Mutex + token string + tokenUntil time.Time +} + +func event(name string) { log.Print("{\"event\":\"" + name + "\"}") } +func trust(c Config) (*x509.CertPool, error) { + raw, e := os.ReadFile(c.Trust) + if e != nil { + return nil, e + } + pool := x509.NewCertPool() + if !pool.AppendCertsFromPEM(raw) { + return nil, errors.New("invalid trust bundle") + } + return pool, nil +} +func material(c Config) (tls.Certificate, error) { + base := filepath.Join(c.Identity, "current") + if real, e := filepath.EvalSymlinks(base); e == nil { + base = real + } else { + base = c.Bootstrap + } + return tls.LoadX509KeyPair(filepath.Join(base, "cert.pem"), filepath.Join(base, "key.pem")) +} +func revoked(c Config, cert *x509.Certificate) bool { + raw, e := os.ReadFile(c.Revoked) + if e != nil { + return true + } // missing policy fails closed + var entries map[string]bool + if json.Unmarshal(raw, &entries) != nil { + return true + } + return entries[strings.ToLower(cert.SerialNumber.Text(16))] +} +func peer(c Config, state tls.ConnectionState, b Boundary) (string, error) { + if b.Public { + return "", nil + } + if len(state.VerifiedChains) == 0 || len(state.PeerCertificates) == 0 { + return "", errors.New("client certificate required") + } + cert := state.PeerCertificates[0] + roots, err := trust(c) + if err != nil { + return "", err + } + intermediates := x509.NewCertPool() + for _, item := range state.PeerCertificates[1:] { + intermediates.AddCert(item) + } + if _, err = cert.Verify(x509.VerifyOptions{Roots: roots, Intermediates: intermediates, KeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}}); err != nil { + return "", errors.New("current trust denies client") + } + if time.Now().Before(cert.NotBefore) || !time.Now().Before(cert.NotAfter) || revoked(c, cert) { + return "", errors.New("client certificate unavailable") + } + for _, identity := range cert.URIs { + if _, ok := b.Allow[identity.String()]; ok { + return identity.String(), nil + } + } + return "", errors.New("client identity denied") +} +func serverTLS(c Config, b Boundary) *tls.Config { + return &tls.Config{MinVersion: tls.VersionTLS13, SessionTicketsDisabled: true, GetConfigForClient: func(_ *tls.ClientHelloInfo) (*tls.Config, error) { + cert, e := material(c) + if e != nil { + return nil, e + } + roots, e := trust(c) + if e != nil { + return nil, e + } + conf := &tls.Config{MinVersion: tls.VersionTLS13, Certificates: []tls.Certificate{cert}, ClientCAs: roots, SessionTicketsDisabled: true} + if !b.Public { + conf.ClientAuth = tls.RequireAndVerifyClientCert + conf.VerifyConnection = func(s tls.ConnectionState) error { _, e := peer(c, s, b); return e } + } + return conf, nil + }} +} +func atomicFile(path string, raw []byte) error { + temp := path + ".new" + if e := os.WriteFile(temp, raw, 0600); e != nil { + return e + } + return os.Rename(temp, path) +} +func (a *Agent) request(method, path string, body any, authenticated bool) (map[string]any, error) { + cert, e := material(a.c) + if e != nil { + return nil, e + } + roots, e := trust(a.c) + if e != nil { + return nil, e + } + transport := &http.Transport{TLSClientConfig: &tls.Config{MinVersion: tls.VersionTLS13, RootCAs: roots, Certificates: []tls.Certificate{cert}}, DisableKeepAlives: true, ResponseHeaderTimeout: 4 * time.Second} + defer transport.CloseIdleConnections() + client := &http.Client{Transport: transport, Timeout: 5 * time.Second} + var encoded []byte + if body != nil { + encoded, e = json.Marshal(body) + if e != nil { + return nil, e + } + } + request, e := http.NewRequest(method, a.c.Bao+"/v1/"+path, bytes.NewReader(encoded)) + if e != nil { + return nil, e + } + request.Header.Set("Content-Type", "application/json") + if authenticated { + request.Header.Set("X-Vault-Token", a.token) + } + response, e := client.Do(request) + if e != nil { + return nil, errors.New("identity service unavailable") + } + defer response.Body.Close() + if response.StatusCode >= 300 { + return nil, fmt.Errorf("identity service status %d", response.StatusCode) + } + var data map[string]any + e = json.NewDecoder(io.LimitReader(response.Body, 1024*1024)).Decode(&data) + return data, e +} +func (a *Agent) refresh() error { + a.mu.Lock() + defer a.mu.Unlock() + now := time.Now() + if a.token != "" && time.Until(a.tokenUntil) < 95*time.Second { + result, err := a.request("POST", "auth/token/renew-self", map[string]string{"increment": "120s"}, true) + if err == nil { + auth, ok := result["auth"].(map[string]any) + if !ok { + return errors.New("invalid renewal response") + } + ttl, ok := auth["lease_duration"].(float64) + if !ok || ttl < 1 { + return errors.New("invalid renewed lease") + } + a.tokenUntil = now.Add(time.Duration(ttl * float64(time.Second))) + event("identity.token_renewed") + } else { + a.token = "" + } + } + if a.token == "" { + // The exact CN+URI constraints select the correct role. Omitting name + // permits old/new CA roles to coexist safely during trust rollover. + result, err := a.request("POST", "auth/cert/login", map[string]string{}, false) + if err != nil { + return err + } + auth, ok := result["auth"].(map[string]any) + if !ok { + return errors.New("invalid auth response") + } + a.token, ok = auth["client_token"].(string) + if !ok { + return errors.New("missing service token") + } + ttl, ok := auth["lease_duration"].(float64) + if !ok || ttl < 1 { + return errors.New("invalid service lease") + } + a.tokenUntil = now.Add(time.Duration(ttl * float64(time.Second))) + event("identity.authenticated") + } + + cert, e := material(a.c) + _, currentErr := os.Stat(filepath.Join(a.c.Identity, "current")) + _, initializedErr := os.Stat(filepath.Join(a.c.Identity, "agent.json")) + renew := initializedErr != nil || currentErr != nil || e != nil || cert.Leaf == nil || time.Until(cert.Leaf.NotAfter) < 80*time.Second + if renew { + request := map[string]any{"common_name": a.c.Role, "alt_names": strings.Join(a.c.DNS, ","), "uri_sans": "spiffe://messenger/" + a.c.Role, "ttl": a.c.TTL} + if len(a.c.IP) > 0 { + request["ip_sans"] = strings.Join(a.c.IP, ",") + } + result, e := a.request("POST", "pki/issue/"+a.c.Role, request, true) + if e != nil { + return e + } + data, ok := result["data"].(map[string]any) + if !ok { + return errors.New("invalid PKI response") + } + crt, ok := data["certificate"].(string) + if !ok { + return errors.New("missing certificate") + } + key, ok := data["private_key"].(string) + if !ok { + return errors.New("missing private key") + } + if chain, ok := data["ca_chain"].([]any); ok { + for _, item := range chain { + crt += "\n" + item.(string) + } + } + parsed, e := tls.X509KeyPair([]byte(crt), []byte(key)) + if e != nil { + return e + } + dir, e := os.MkdirTemp(a.c.Identity, "generation-") + if e != nil { + return e + } + if e = os.WriteFile(filepath.Join(dir, "cert.pem"), []byte(crt), 0600); e != nil { + return e + } + if e = os.WriteFile(filepath.Join(dir, "key.pem"), []byte(key), 0600); e != nil { + return e + } + if e = os.WriteFile(filepath.Join(dir, "bundle.pem"), []byte(crt+"\n"+key), 0600); e != nil { + return e + } + link := filepath.Join(a.c.Identity, "next") + os.Remove(link) + if e = os.Symlink(filepath.Base(dir), link); e != nil { + return e + } + if e = os.Rename(link, filepath.Join(a.c.Identity, "current")); e != nil { + return e + } + // Retain only the current and immediately previous generations, bounding tmpfs. + entries, _ := os.ReadDir(a.c.Identity) + for _, entry := range entries { + if entry.IsDir() && strings.HasPrefix(entry.Name(), "generation-") && entry.Name() != filepath.Base(dir) { + info, _ := entry.Info() + if info != nil && now.Sub(info.ModTime()) > 3*time.Minute { + os.RemoveAll(filepath.Join(a.c.Identity, entry.Name())) + } + } + } + if parsed.Leaf == nil { + return errors.New("unparsed certificate") + } + event("identity.certificate_issued") + if a.c.ReloadPIDOne { + if e = syscall.Kill(1, syscall.SIGUSR2); e != nil { + return errors.New("certificate reload failed") + } + } + } + if a.c.KV { + result, e := a.request("GET", "secret/data/"+a.c.Role, nil, true) + if e != nil { + return e + } + outer, ok := result["data"].(map[string]any) + if !ok { + return errors.New("invalid secret response") + } + values, ok := outer["data"].(map[string]any) + if !ok { + return errors.New("invalid secret values") + } + expiry := now.Add(60 * time.Second) + if a.tokenUntil.Before(expiry) { + expiry = a.tokenUntil + } + data, e := json.Marshal(map[string]any{"fetched_at": now.Unix(), "valid_until": expiry.Unix(), "values": values}) + if e != nil { + return e + } + if e = atomicFile(filepath.Join(a.c.Identity, "secrets.json"), data); e != nil { + return e + } + } + return atomicFile(filepath.Join(a.c.Identity, "agent.json"), []byte(`{"refreshed_at":`+strconv.FormatInt(now.Unix(), 10)+`}`)) +} + +type boundedListener struct { + net.Listener + slots chan struct{} +} +type boundedConn struct { + net.Conn + once sync.Once + release func() +} + +func (c *boundedConn) Close() error { e := c.Conn.Close(); c.once.Do(c.release); return e } +func (l *boundedListener) Accept() (net.Conn, error) { + for { + c, e := l.Listener.Accept() + if e != nil { + return nil, e + } + select { + case l.slots <- struct{}{}: + return &boundedConn{Conn: c, release: func() { <-l.slots }}, nil + default: + c.Close() + } + } +} +func runHTTP(c Config, b Boundary) error { + target, e := url.Parse("http://" + b.Target) + if e != nil { + return e + } + proxy := httputil.NewSingleHostReverseProxy(target) + proxy.Transport = &http.Transport{MaxIdleConns: 32, MaxIdleConnsPerHost: 16, ResponseHeaderTimeout: 8 * time.Second, IdleConnTimeout: 30 * time.Second} + proxy.ErrorLog = log.New(io.Discard, "", 0) + proxy.ErrorHandler = func(w http.ResponseWriter, r *http.Request, e error) { + w.Header().Set("Connection", "close") + http.Error(w, "Protected service unavailable", 503) + } + handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // Force a fresh handshake after each response: no indefinitely cached + // certificate identity across rollover, expiry or serial revocation. + w.Header().Set("Connection", "close") + identity, e := peer(c, *r.TLS, b) + if e != nil { + w.Header().Set("Connection", "close") + http.Error(w, "Client identity denied", 403) + return + } + allowed := b.Public + for _, rule := range b.Allow[identity] { + parts := strings.SplitN(rule, " ", 2) + if len(parts) == 2 && (parts[0] == "*" || parts[0] == r.Method) && strings.HasPrefix(r.URL.Path, parts[1]) { + allowed = true + } + } + if !allowed { + http.Error(w, "Operation denied", 403) + return + } + r.Header.Del("X-Forwarded-Client-Cert") + r.Header.Del("X-TLS-Identity") + proxy.ServeHTTP(w, r) + }) + listener, e := net.Listen("tcp", b.Listen) + if e != nil { + return e + } + listener = &boundedListener{Listener: listener, slots: make(chan struct{}, 128)} + server := &http.Server{Handler: handler, TLSConfig: serverTLS(c, b), ReadHeaderTimeout: 5 * time.Second, IdleTimeout: 30 * time.Second, MaxHeaderBytes: 32768, ErrorLog: log.New(io.Discard, "", 0)} + return server.Serve(tls.NewListener(listener, server.TLSConfig)) +} + +// Native clients use a private loopback endpoint when their certificate +// reload behavior cannot meet the short credential lifetime. Every network +// connection is verified mTLS; configuration cannot publish this HTTP hop. +func runOutbound(c Config, b Outbound) error { + target, e := url.Parse(b.Target) + if e != nil || target.Scheme != "https" || target.Hostname() == "" { + return errors.New("outbound TLS target required") + } + host, _, e := net.SplitHostPort(b.Listen) + if e != nil || host != "127.0.0.1" { + return errors.New("outbound listener must be loopback") + } + proxy := httputil.NewSingleHostReverseProxy(target) + proxy.Transport = &http.Transport{ + DisableKeepAlives: true, MaxConnsPerHost: 32, ResponseHeaderTimeout: 8 * time.Second, + DialTLSContext: func(ctx context.Context, network, address string) (net.Conn, error) { + cert, e := material(c) + if e != nil { + return nil, e + } + roots, e := trust(c) + if e != nil { + return nil, e + } + config := &tls.Config{MinVersion: tls.VersionTLS13, RootCAs: roots, Certificates: []tls.Certificate{cert}, ServerName: target.Hostname(), VerifyConnection: func(state tls.ConnectionState) error { + if len(state.VerifiedChains) == 0 || len(state.PeerCertificates) == 0 { + return errors.New("unverified protected server") + } + leaf := state.PeerCertificates[0] + if revoked(c, leaf) { + return errors.New("protected server revoked") + } + if b.Identity != "" { + found := false + for _, identity := range leaf.URIs { + if identity.String() == b.Identity { + found = true + } + } + if !found { + return errors.New("protected server identity denied") + } + } + return nil + }} + dialer := tls.Dialer{NetDialer: &net.Dialer{Timeout: 2 * time.Second}, Config: config} + return dialer.DialContext(ctx, network, address) + }, + } + proxy.ErrorLog = log.New(io.Discard, "", 0) + proxy.ErrorHandler = func(w http.ResponseWriter, r *http.Request, e error) { + w.Header().Set("Connection", "close") + http.Error(w, "Protected destination unavailable", 503) + } + listener, e := net.Listen("tcp", b.Listen) + if e != nil { + return e + } + listener = &boundedListener{Listener: listener, slots: make(chan struct{}, 64)} + handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Connection", "close") + proxy.ServeHTTP(w, r) + }) + server := &http.Server{Handler: handler, ReadHeaderTimeout: 5 * time.Second, IdleTimeout: 10 * time.Second, MaxHeaderBytes: 32768, ErrorLog: log.New(io.Discard, "", 0)} + return server.Serve(listener) +} +func runTCP(c Config, b Boundary) error { + listener, e := net.Listen("tcp", b.Listen) + if e != nil { + return e + } + slots := make(chan struct{}, 128) + for { + raw, e := listener.Accept() + if e != nil { + return e + } + select { + case slots <- struct{}{}: + default: + raw.Close() + continue + } + go func() { + defer func() { <-slots }() + defer raw.Close() + raw.SetDeadline(time.Now().Add(5 * time.Second)) + if b.Protocol == "postgres" { + request := make([]byte, 8) + if _, e := io.ReadFull(raw, request); e != nil { + return + } + if binary.BigEndian.Uint32(request[:4]) != 8 || binary.BigEndian.Uint32(request[4:]) != 80877103 { + return + } + if _, e := raw.Write([]byte{'S'}); e != nil { + return + } + } + client := tls.Server(raw, serverTLS(c, b)) + if e := client.Handshake(); e != nil { + return + } + target, e := net.DialTimeout("tcp", b.Target, 2*time.Second) + if e != nil { + return + } + defer target.Close() + // Bound a previously authenticated connection even after expiry/revocation. + deadline := time.Now().Add(45 * time.Second) + state := client.ConnectionState() + if len(state.PeerCertificates) > 0 && state.PeerCertificates[0].NotAfter.Before(deadline) { + deadline = state.PeerCertificates[0].NotAfter + } + client.SetDeadline(deadline) + target.SetDeadline(deadline) + done := make(chan struct{}, 1) + go func() { io.Copy(target, client); done <- struct{}{} }() + io.Copy(client, target) + client.Close() + target.Close() + <-done + }() + } +} +func main() { + if len(os.Args) != 2 { + event("gateway.invalid_configuration") + os.Exit(2) + } + raw, e := os.ReadFile(os.Args[1]) + if e != nil { + event("gateway.invalid_configuration") + os.Exit(2) + } + var c Config + if json.Unmarshal(raw, &c) != nil || c.Role == "" { + event("gateway.invalid_configuration") + os.Exit(2) + } + if c.TTL == "" { + c.TTL = "120s" + } + if e = os.MkdirAll(c.Identity, 0700); e != nil { + event("gateway.identity_directory_unavailable") + os.Exit(2) + } + for _, b := range c.Servers { + host, _, err := net.SplitHostPort(b.Target) + if err != nil || (host != "127.0.0.1" && host != "[::1]" && host != "::1") { + event("gateway.nonlocal_target_denied") + os.Exit(2) + } + } + agent := &Agent{c: c} + ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGINT) + defer stop() + // Bootstrap failures never start a cleartext fallback listener. + if !c.ServeOnly { + for { + if e = agent.refresh(); e == nil { + break + } + event("identity.refresh_failed") + select { + case <-ctx.Done(): + return + case <-time.After(3 * time.Second): + } + } + go func() { + ticker := time.NewTicker(15 * time.Second) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if agent.refresh() != nil { + event("identity.refresh_failed") + } + } + } + }() + } else { + for { + cert, err := material(c) + if err == nil && cert.Leaf != nil && time.Now().Before(cert.Leaf.NotAfter) { + break + } + select { + case <-ctx.Done(): + return + case <-time.After(time.Second): + } + } + } + + for _, boundary := range c.Servers { + go func(b Boundary) { + var e error + if b.Protocol == "http" { + e = runHTTP(c, b) + } else { + e = runTCP(c, b) + } + if e != nil { + event("gateway.listener_failed") + stop() + } + }(boundary) + } + for _, outbound := range c.Outbounds { + go func(b Outbound) { + if e := runOutbound(c, b); e != nil { + event("gateway.outbound_failed") + stop() + } + }(outbound) + } + + event("gateway.ready") + <-ctx.Done() +} diff --git a/infra/tls/gateway_test.go b/infra/tls/gateway_test.go new file mode 100644 index 0000000..86ebbc9 --- /dev/null +++ b/infra/tls/gateway_test.go @@ -0,0 +1,122 @@ +package main + +import ( + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "crypto/tls" + "crypto/x509" + "crypto/x509/pkix" + "encoding/json" + "encoding/pem" + "math/big" + "net/url" + "os" + "path/filepath" + "testing" + "time" +) + +type authority struct { + cert *x509.Certificate + key *ecdsa.PrivateKey + pem []byte +} + +func root(t *testing.T) authority { + t.Helper() + key, e := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if e != nil { + t.Fatal(e) + } + template := &x509.Certificate{SerialNumber: big.NewInt(time.Now().UnixNano()), Subject: pkix.Name{CommonName: "Synthetic test CA"}, NotBefore: time.Now().Add(-time.Hour), NotAfter: time.Now().Add(time.Hour), IsCA: true, BasicConstraintsValid: true, KeyUsage: x509.KeyUsageCertSign} + der, e := x509.CreateCertificate(rand.Reader, template, template, &key.PublicKey, key) + if e != nil { + t.Fatal(e) + } + cert, e := x509.ParseCertificate(der) + if e != nil { + t.Fatal(e) + } + return authority{cert, key, pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: der})} +} +func client(t *testing.T, ca authority, role string, expired bool) *x509.Certificate { + t.Helper() + key, e := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) + if e != nil { + t.Fatal(e) + } + identity, _ := url.Parse("spiffe://messenger/" + role) + expiry := time.Now().Add(time.Minute) + if expired { + expiry = time.Now().Add(-time.Minute) + } + template := &x509.Certificate{SerialNumber: big.NewInt(time.Now().UnixNano()), Subject: pkix.Name{CommonName: role}, NotBefore: time.Now().Add(-time.Hour), NotAfter: expiry, URIs: []*url.URL{identity}, ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}, KeyUsage: x509.KeyUsageDigitalSignature} + der, e := x509.CreateCertificate(rand.Reader, template, ca.cert, &key.PublicKey, ca.key) + if e != nil { + t.Fatal(e) + } + cert, e := x509.ParseCertificate(der) + if e != nil { + t.Fatal(e) + } + return cert +} +func TestClientAuthorizationUsesCurrentChainIdentityExpiryAndRevocation(t *testing.T) { + ca := root(t) + foreign := root(t) + directory := t.TempDir() + conf := Config{Trust: filepath.Join(directory, "ca.pem"), Revoked: filepath.Join(directory, "revoked.json")} + if e := os.WriteFile(conf.Trust, ca.pem, 0600); e != nil { + t.Fatal(e) + } + if e := os.WriteFile(conf.Revoked, []byte(`{}`), 0600); e != nil { + t.Fatal(e) + } + boundary := Boundary{Allow: map[string][]string{"spiffe://messenger/lb": {"* /"}}} + good := client(t, ca, "lb", false) + state := func(leaf *x509.Certificate, issuer authority) tls.ConnectionState { + return tls.ConnectionState{PeerCertificates: []*x509.Certificate{leaf, issuer.cert}, VerifiedChains: [][]*x509.Certificate{{leaf, issuer.cert}}} + } + cases := []struct { + name string + state tls.ConnectionState + allowed bool + }{ + {"authorized", state(good, ca), true}, + {"no_certificate", tls.ConnectionState{}, false}, + {"trusted_but_wrong_role", state(client(t, ca, "worker", false), ca), false}, + {"foreign_authority", state(client(t, foreign, "lb", false), foreign), false}, + {"expired", state(client(t, ca, "lb", true), ca), false}, + } + for _, test := range cases { + t.Run(test.name, func(t *testing.T) { + _, e := peer(conf, test.state, boundary) + if (e == nil) != test.allowed { + t.Fatalf("authorization mismatch: allowed=%v error=%v", test.allowed, e) + } + }) + } + raw, _ := json.Marshal(map[string]bool{good.SerialNumber.Text(16): true}) + if e := os.WriteFile(conf.Revoked, raw, 0600); e != nil { + t.Fatal(e) + } + if _, e := peer(conf, state(good, ca), boundary); e == nil { + t.Fatal("revoked client accepted on previously authenticated connection") + } + if e := os.WriteFile(conf.Revoked, []byte(`{}`), 0600); e != nil { + t.Fatal(e) + } + if e := os.WriteFile(conf.Trust, foreign.pem, 0600); e != nil { + t.Fatal(e) + } + if _, e := peer(conf, state(good, ca), boundary); e == nil { + t.Fatal("retired authority accepted from cached verified chain") + } + if e := os.Remove(conf.Revoked); e != nil { + t.Fatal(e) + } + if _, e := peer(conf, state(good, ca), boundary); e == nil { + t.Fatal("missing revocation policy did not fail closed") + } +} diff --git a/infra/tls/grafana.json b/infra/tls/grafana.json new file mode 100644 index 0000000..5035455 --- /dev/null +++ b/infra/tls/grafana.json @@ -0,0 +1,42 @@ +{ + "role": "grafana", + "dns": [ + "grafana", + "localhost" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": true, + "servers": [ + { + "listen": "0.0.0.0:3443", + "target": "127.0.0.1:3000", + "protocol": "http", + "allow": {}, + "public": true + } + ], + "outbounds": [ + { + "listen": "127.0.0.1:13909", + "target": "https://prometheus:9900", + "server_identity": "spiffe://messenger/prometheus" + }, + { + "listen": "127.0.0.1:13310", + "target": "https://loki:3310", + "server_identity": "spiffe://messenger/loki" + }, + { + "listen": "127.0.0.1:13320", + "target": "https://tempo:3320", + "server_identity": "spiffe://messenger/tempo" + } + ], + "ip": [ + "127.0.0.1" + ] +} diff --git a/infra/tls/lb.json b/infra/tls/lb.json new file mode 100644 index 0000000..c795905 --- /dev/null +++ b/infra/tls/lb.json @@ -0,0 +1,33 @@ +{ + "role": "lb", + "dns": [ + "lb", + "localhost" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": true, + "servers": [ + { + "listen": "0.0.0.0:18404", + "target": "127.0.0.1:8404", + "protocol": "http", + "allow": { + "spiffe://messenger/prometheus": [ + "GET /metrics" + ], + "spiffe://messenger/operator": [ + "GET /metrics" + ] + }, + "public": false + } + ], + "outbounds": [], + "ip": [ + "127.0.0.1" + ] +} diff --git a/infra/tls/loki.json b/infra/tls/loki.json new file mode 100644 index 0000000..b2d8002 --- /dev/null +++ b/infra/tls/loki.json @@ -0,0 +1,36 @@ +{ + "role": "loki", + "dns": [ + "loki" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": true, + "servers": [ + { + "listen": "0.0.0.0:3310", + "target": "127.0.0.1:3100", + "protocol": "http", + "allow": { + "spiffe://messenger/grafana": [ + "GET /", + "POST /api/" + ], + "spiffe://messenger/prometheus": [ + "GET /metrics" + ], + "spiffe://messenger/operator": [ + "GET /" + ], + "spiffe://messenger/otel": [ + "POST /otlp/" + ] + }, + "public": false + } + ], + "outbounds": [] +} diff --git a/infra/tls/migrate.json b/infra/tls/migrate.json new file mode 100644 index 0000000..4b78029 --- /dev/null +++ b/infra/tls/migrate.json @@ -0,0 +1,14 @@ +{ + "role": "migrate", + "dns": [ + "migrate" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": true, + "servers": [], + "outbounds": [] +} diff --git a/infra/tls/observer.json b/infra/tls/observer.json new file mode 100644 index 0000000..5902e8a --- /dev/null +++ b/infra/tls/observer.json @@ -0,0 +1,20 @@ +{ + "role": "observer", + "dns": [ + "observer" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": true, + "servers": [], + "outbounds": [ + { + "listen": "127.0.0.1:14318", + "target": "https://otel:4438", + "server_identity": "spiffe://messenger/otel" + } + ] +} diff --git a/infra/tls/otel.json b/infra/tls/otel.json new file mode 100644 index 0000000..72ec4c6 --- /dev/null +++ b/infra/tls/otel.json @@ -0,0 +1,88 @@ +{ + "role": "otel", + "dns": [ + "otel" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": true, + "servers": [ + { + "listen": "0.0.0.0:4438", + "target": "127.0.0.1:4318", + "protocol": "http", + "allow": { + "spiffe://messenger/api": [ + "POST /v1/" + ], + "spiffe://messenger/worker": [ + "POST /v1/" + ], + "spiffe://messenger/relay": [ + "POST /v1/" + ], + "spiffe://messenger/observer": [ + "POST /v1/" + ], + "spiffe://messenger/operator": [ + "POST /v1/" + ] + }, + "public": false + }, + { + "listen": "0.0.0.0:18889", + "target": "127.0.0.1:8889", + "protocol": "http", + "allow": { + "spiffe://messenger/prometheus": [ + "GET /metrics" + ], + "spiffe://messenger/operator": [ + "GET /metrics" + ] + }, + "public": false + }, + { + "listen": "0.0.0.0:18888", + "target": "127.0.0.1:8888", + "protocol": "http", + "allow": { + "spiffe://messenger/prometheus": [ + "GET /metrics" + ], + "spiffe://messenger/operator": [ + "GET /metrics" + ] + }, + "public": false + }, + { + "listen": "0.0.0.0:13333", + "target": "127.0.0.1:13133", + "protocol": "http", + "allow": { + "spiffe://messenger/operator": [ + "GET /" + ] + }, + "public": false + } + ], + "outbounds": [ + { + "listen": "127.0.0.1:13310", + "target": "https://loki:3310", + "server_identity": "spiffe://messenger/loki" + }, + { + "listen": "127.0.0.1:14319", + "target": "https://tempo:4438", + "server_identity": "spiffe://messenger/tempo" + } + ] +} diff --git a/infra/tls/postgres.json b/infra/tls/postgres.json new file mode 100644 index 0000000..6185604 --- /dev/null +++ b/infra/tls/postgres.json @@ -0,0 +1,29 @@ +{ + "role": "postgres", + "dns": [ + "postgres" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": true, + "servers": [ + { + "listen": "0.0.0.0:5443", + "target": "127.0.0.1:5432", + "protocol": "postgres", + "allow": { + "spiffe://messenger/api": [], + "spiffe://messenger/worker": [], + "spiffe://messenger/relay": [], + "spiffe://messenger/observer": [], + "spiffe://messenger/reconciler": [], + "spiffe://messenger/migrate": [], + "spiffe://messenger/operator": [] + } + } + ], + "outbounds": [] +} diff --git a/infra/tls/prometheus.json b/infra/tls/prometheus.json new file mode 100644 index 0000000..05bbfea --- /dev/null +++ b/infra/tls/prometheus.json @@ -0,0 +1,56 @@ +{ + "role": "prometheus", + "dns": [ + "prometheus" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": true, + "servers": [ + { + "listen": "0.0.0.0:9900", + "target": "127.0.0.1:9090", + "protocol": "http", + "allow": { + "spiffe://messenger/grafana": [ + "GET /api/", + "POST /api/v1/query" + ], + "spiffe://messenger/operator": [ + "GET /" + ] + }, + "public": false + } + ], + "outbounds": [ + { + "listen": "127.0.0.1:18889", + "target": "https://otel:18889", + "server_identity": "spiffe://messenger/otel" + }, + { + "listen": "127.0.0.1:18888", + "target": "https://otel:18888", + "server_identity": "spiffe://messenger/otel" + }, + { + "listen": "127.0.0.1:18404", + "target": "https://lb:18404", + "server_identity": "spiffe://messenger/lb" + }, + { + "listen": "127.0.0.1:13200", + "target": "https://tempo:3320", + "server_identity": "spiffe://messenger/tempo" + }, + { + "listen": "127.0.0.1:13100", + "target": "https://loki:3310", + "server_identity": "spiffe://messenger/loki" + } + ] +} diff --git a/infra/tls/reconciler.json b/infra/tls/reconciler.json new file mode 100644 index 0000000..d71959a --- /dev/null +++ b/infra/tls/reconciler.json @@ -0,0 +1,14 @@ +{ + "role": "reconciler", + "dns": [ + "reconciler" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": true, + "servers": [], + "outbounds": [] +} diff --git a/infra/tls/relay.json b/infra/tls/relay.json new file mode 100644 index 0000000..8626935 --- /dev/null +++ b/infra/tls/relay.json @@ -0,0 +1,20 @@ +{ + "role": "relay", + "dns": [ + "relay" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": true, + "servers": [], + "outbounds": [ + { + "listen": "127.0.0.1:14318", + "target": "https://otel:4438", + "server_identity": "spiffe://messenger/otel" + } + ] +} diff --git a/infra/tls/s3.json b/infra/tls/s3.json new file mode 100644 index 0000000..d7099f2 --- /dev/null +++ b/infra/tls/s3.json @@ -0,0 +1,39 @@ +{ + "role": "s3", + "dns": [ + "s3", + "localhost" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": true, + "servers": [ + { + "listen": "0.0.0.0:9443", + "target": "127.0.0.1:9000", + "protocol": "http", + "allow": { + "spiffe://messenger/api": [ + "* /" + ], + "spiffe://messenger/worker": [ + "* /" + ], + "spiffe://messenger/reconciler": [ + "* /" + ], + "spiffe://messenger/operator": [ + "* /" + ] + }, + "public": false + } + ], + "outbounds": [], + "ip": [ + "127.0.0.1" + ] +} diff --git a/infra/tls/tempo.json b/infra/tls/tempo.json new file mode 100644 index 0000000..7280638 --- /dev/null +++ b/infra/tls/tempo.json @@ -0,0 +1,47 @@ +{ + "role": "tempo", + "dns": [ + "tempo" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": true, + "servers": [ + { + "listen": "0.0.0.0:3320", + "target": "127.0.0.1:3200", + "protocol": "http", + "allow": { + "spiffe://messenger/grafana": [ + "GET /", + "POST /api/" + ], + "spiffe://messenger/prometheus": [ + "GET /metrics" + ], + "spiffe://messenger/operator": [ + "GET /" + ] + }, + "public": false + }, + { + "listen": "0.0.0.0:4438", + "target": "127.0.0.1:4318", + "protocol": "http", + "allow": { + "spiffe://messenger/otel": [ + "POST /v1/traces" + ], + "spiffe://messenger/operator": [ + "POST /v1/traces" + ] + }, + "public": false + } + ], + "outbounds": [] +} diff --git a/infra/tls/worker.json b/infra/tls/worker.json new file mode 100644 index 0000000..52b039b --- /dev/null +++ b/infra/tls/worker.json @@ -0,0 +1,20 @@ +{ + "role": "worker", + "dns": [ + "worker" + ], + "bao": "https://openbao:8200", + "trust": "/trust/ca.pem", + "revoked": "/trust/revoked.json", + "identity": "/run/identity", + "ttl": "120s", + "serve_only": true, + "servers": [], + "outbounds": [ + { + "listen": "127.0.0.1:14318", + "target": "https://otel:4438", + "server_identity": "spiffe://messenger/otel" + } + ] +} diff --git a/migrations/001_core.sql b/migrations/001_core.sql new file mode 100644 index 0000000..f1c3acf --- /dev/null +++ b/migrations/001_core.sql @@ -0,0 +1,36 @@ +CREATE TABLE users ( + id uuid PRIMARY KEY, + username text NOT NULL UNIQUE CHECK (username ~ '^[a-z0-9_]{3,32}$'), + display_name text NOT NULL CHECK (char_length(display_name) BETWEEN 1 AND 100), + password_hash text NOT NULL, + created_at timestamptz NOT NULL +); +CREATE TABLE chats ( + id uuid PRIMARY KEY, + title text NOT NULL CHECK (char_length(title) BETWEEN 1 AND 100), + created_at timestamptz NOT NULL +); +CREATE TABLE members ( + chat_id uuid NOT NULL REFERENCES chats(id), + user_id uuid NOT NULL REFERENCES users(id), + position integer NOT NULL CHECK (position BETWEEN 0 AND 99), + PRIMARY KEY (chat_id, user_id), + UNIQUE (chat_id, position) +); +CREATE INDEX members_user_chat_idx ON members(user_id,chat_id); +CREATE TABLE messages ( + id uuid PRIMARY KEY, + chat_id uuid NOT NULL REFERENCES chats(id), + sender_id uuid NOT NULL, + text text NOT NULL CHECK (char_length(text) BETWEEN 1 AND 4000), + created_at timestamptz NOT NULL, + FOREIGN KEY (chat_id, sender_id) REFERENCES members(chat_id,user_id) +); +CREATE INDEX messages_history_idx ON messages(chat_id,created_at,id); +CREATE TABLE sessions ( + token_digest bytea PRIMARY KEY CHECK (octet_length(token_digest)=32), + user_id uuid NOT NULL REFERENCES users(id), + created_at timestamptz NOT NULL, + expires_at timestamptz NOT NULL CHECK (expires_at > created_at) +); +CREATE INDEX sessions_expiry_idx ON sessions(expires_at); diff --git a/migrations/002_idempotency.sql b/migrations/002_idempotency.sql new file mode 100644 index 0000000..759451e --- /dev/null +++ b/migrations/002_idempotency.sql @@ -0,0 +1,10 @@ +CREATE TABLE idempotency ( + user_id uuid NOT NULL REFERENCES users(id), + chat_id uuid NOT NULL REFERENCES chats(id), + key text NOT NULL CHECK (key ~ '^[A-Za-z0-9._:-]{1,128}$'), + body_hash bytea NOT NULL CHECK (octet_length(body_hash)=32), + message_id uuid NOT NULL REFERENCES messages(id), + expires_at timestamptz NOT NULL, + PRIMARY KEY(user_id, chat_id, key) +); +CREATE INDEX idempotency_expiry_idx ON idempotency(expires_at); diff --git a/migrations/003_attachments.sql b/migrations/003_attachments.sql new file mode 100644 index 0000000..f5d88aa --- /dev/null +++ b/migrations/003_attachments.sql @@ -0,0 +1,32 @@ +ALTER TABLE messages DROP CONSTRAINT messages_text_check; +ALTER TABLE messages ADD CHECK (char_length(text) <= 4000); +ALTER TABLE messages ADD UNIQUE(chat_id,id); +CREATE TABLE attachments ( + id uuid PRIMARY KEY, + chat_id uuid NOT NULL REFERENCES chats(id), + owner_id uuid NOT NULL, + filename text NOT NULL CHECK(char_length(filename) BETWEEN 1 AND 255), + content_type text NOT NULL CHECK(content_type IN ('image/png','image/jpeg')), + size_bytes bigint NOT NULL CHECK(size_bytes BETWEEN 1 AND 10485760), + sha256 text NOT NULL CHECK(sha256 ~ '^[a-f0-9]{64}$'), + object_key text NOT NULL UNIQUE, + state text NOT NULL CHECK(state IN ('pending','ready','failed')), + error_code text, + uploader_instance text NOT NULL, + expires_at timestamptz NOT NULL, + created_at timestamptz NOT NULL DEFAULT clock_timestamp(), + updated_at timestamptz NOT NULL DEFAULT clock_timestamp(), + UNIQUE(chat_id,id), + FOREIGN KEY(chat_id,owner_id) REFERENCES members(chat_id,user_id) +); +CREATE INDEX attachments_state_created_idx ON attachments(state,created_at,id); +CREATE TABLE message_attachments ( + message_id uuid NOT NULL, + chat_id uuid NOT NULL, + attachment_id uuid NOT NULL, + position integer NOT NULL CHECK(position BETWEEN 0 AND 9), + PRIMARY KEY(message_id,attachment_id), + UNIQUE(message_id,position), + FOREIGN KEY(chat_id,message_id) REFERENCES messages(chat_id,id), + FOREIGN KEY(chat_id,attachment_id) REFERENCES attachments(chat_id,id) +); diff --git a/migrations/004_pipeline.sql b/migrations/004_pipeline.sql new file mode 100644 index 0000000..477316f --- /dev/null +++ b/migrations/004_pipeline.sql @@ -0,0 +1,54 @@ +ALTER TABLE attachments DROP CONSTRAINT attachments_state_check; +ALTER TABLE attachments ADD CHECK(state IN ('queued','processing','ready','failed')); +ALTER TABLE attachments ADD COLUMN pipeline_version integer NOT NULL DEFAULT 1 CHECK(pipeline_version>=1); +ALTER TABLE attachments ADD COLUMN published_version integer; +CREATE TABLE upload_reservations ( + id uuid PRIMARY KEY, object_key text UNIQUE NOT NULL, + expires_at timestamptz NOT NULL DEFAULT clock_timestamp()+interval '120 seconds' +); +CREATE TABLE jobs ( + id uuid PRIMARY KEY, attachment_id uuid NOT NULL REFERENCES attachments(id), + pipeline_version integer NOT NULL CHECK(pipeline_version>=1), source_key text NOT NULL, + state text NOT NULL CHECK(state IN ('queued','processing','ready','failed','obsolete')), + attempt integer NOT NULL DEFAULT 0, cycle integer NOT NULL DEFAULT 1, + fence bigint NOT NULL DEFAULT 0, lease_owner text, lease_until timestamptz, + next_at timestamptz NOT NULL DEFAULT clock_timestamp(), error_code text, + created_at timestamptz NOT NULL DEFAULT clock_timestamp(), updated_at timestamptz NOT NULL DEFAULT clock_timestamp(), + UNIQUE(attachment_id,pipeline_version) +); +CREATE INDEX jobs_due_idx ON jobs(state,next_at); +CREATE TABLE outbox ( + id bigserial PRIMARY KEY, job_id uuid NOT NULL REFERENCES jobs(id), + payload jsonb NOT NULL, due_at timestamptz NOT NULL DEFAULT clock_timestamp(), + published_at timestamptz +); +CREATE INDEX outbox_due_idx ON outbox(due_at,id) WHERE published_at IS NULL; +CREATE TABLE attachment_variants ( + attachment_id uuid NOT NULL REFERENCES attachments(id), pipeline_version integer NOT NULL, + name text NOT NULL CHECK(name IN ('original','thumbnail','crop','optimized')), + object_key text UNIQUE NOT NULL, content_type text NOT NULL, + size_bytes bigint NOT NULL, sha256 text NOT NULL, + width integer, height integer, + PRIMARY KEY(attachment_id,pipeline_version,name) +); +CREATE TABLE effect_publications ( + attachment_id uuid NOT NULL, pipeline_version integer NOT NULL, + job_id uuid NOT NULL REFERENCES jobs(id), fence bigint NOT NULL, + committed_at timestamptz NOT NULL DEFAULT clock_timestamp(), + PRIMARY KEY(attachment_id,pipeline_version) +); +CREATE TABLE pipeline_audit ( + id bigserial PRIMARY KEY, job_id uuid NOT NULL, action text NOT NULL, + operator text NOT NULL, reason text NOT NULL, + created_at timestamptz NOT NULL DEFAULT clock_timestamp() +); +-- Fault injection is disabled unless PIPELINE_FAULTS=1; no public endpoint. +CREATE TABLE pipeline_faults ( + id bigserial PRIMARY KEY, target uuid NOT NULL, phase text NOT NULL, + action text NOT NULL CHECK(action IN ('wait','crash','transient','permanent','hang')), + remaining integer NOT NULL DEFAULT 1, hit_at timestamptz, released_at timestamptz +); +CREATE TABLE pipeline_events ( + id bigserial PRIMARY KEY, job_id uuid, event text NOT NULL, + detail jsonb NOT NULL DEFAULT '{}', created_at timestamptz NOT NULL DEFAULT clock_timestamp() +); diff --git a/migrations/005_observability.sql b/migrations/005_observability.sql new file mode 100644 index 0000000..f3ad5f7 --- /dev/null +++ b/migrations/005_observability.sql @@ -0,0 +1,10 @@ +ALTER TABLE jobs ADD COLUMN traceparent text NOT NULL DEFAULT ''; +ALTER TABLE jobs ADD COLUMN tracestate text NOT NULL DEFAULT ''; +CREATE TABLE job_slo_observations ( + job_id uuid PRIMARY KEY REFERENCES jobs(id), + outcome text NOT NULL CHECK(outcome IN ('good','bad')), + decided_at timestamptz NOT NULL DEFAULT clock_timestamp(), + histogram_epoch uuid +); +CREATE INDEX job_slo_epoch_idx ON job_slo_observations(histogram_epoch); +CREATE INDEX effect_publications_time_idx ON effect_publications(committed_at,job_id); diff --git a/migrations/006_security.sql b/migrations/006_security.sql new file mode 100644 index 0000000..5683af9 --- /dev/null +++ b/migrations/006_security.sql @@ -0,0 +1,32 @@ +-- Only the owner can touch buckets. Callers get a fixed, serialized function. +CREATE TABLE login_buckets ( + bucket text PRIMARY KEY, tokens double precision NOT NULL, + updated_at timestamptz NOT NULL +); +CREATE INDEX login_buckets_expiry_idx ON login_buckets(updated_at); +CREATE FUNCTION login_wait(account text) RETURNS integer +LANGUAGE plpgsql SECURITY DEFINER SET search_path = public, pg_temp AS $$ +DECLARE + moment timestamptz := clock_timestamp(); + global_tokens double precision; account_tokens double precision; +BEGIN + IF account !~ '^[a-f0-9]{64}$' THEN RAISE EXCEPTION 'Invalid limiter key'; END IF; + INSERT INTO login_buckets VALUES ('global',8,moment) ON CONFLICT DO NOTHING; + SELECT least(8.0,tokens+extract(epoch FROM moment-updated_at)*2.0) + INTO global_tokens FROM login_buckets WHERE bucket='global' FOR UPDATE; + -- Reject before creating arbitrary account buckets: a name flood cannot + -- grow state faster than the two admitted attempts per second. + IF global_tokens<1 THEN RETURN ceil((1-global_tokens)/2.0)::integer; END IF; + INSERT INTO login_buckets VALUES ('account:'||account,8,moment) ON CONFLICT DO NOTHING; + SELECT least(8.0,tokens+extract(epoch FROM moment-updated_at)*(8.0/60.0)) + INTO account_tokens FROM login_buckets WHERE bucket='account:'||account FOR UPDATE; + IF account_tokens<1 THEN RETURN ceil((1-account_tokens)/(8.0/60.0))::integer; END IF; + UPDATE login_buckets SET tokens=global_tokens-1,updated_at=moment WHERE bucket='global'; + UPDATE login_buckets SET tokens=account_tokens-1,updated_at=moment WHERE bucket='account:'||account; + DELETE FROM login_buckets WHERE bucket IN ( + SELECT bucket FROM login_buckets WHERE updated_at'global' ORDER BY updated_at LIMIT 128 + ); + RETURN 0; +END $$; +REVOKE ALL ON FUNCTION login_wait(text) FROM PUBLIC; diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..cea9d15 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,60 @@ +[project] +name = "mtusi-messenger-lab7" +version = "1.0.0" +requires-python = ">=3.14,<3.15" +dependencies = [ + "fastapi==0.143.3", + "pydantic==2.14.1", + "uvicorn==0.54.0", + "psycopg[binary,pool]==3.3.6", + "argon2-cffi>=25,<26", + "redis==8.1.0", + "minio==7.2.20", + "pillow==13.0.0", + "opentelemetry-api==1.45.2", + "opentelemetry-sdk==1.45.2", + "opentelemetry-exporter-otlp-proto-http==1.45.2", + "psutil==7.1.3", + "cryptography==50.0.2", +] + +[dependency-groups] +dev = [ + "pytest>=8,<10", + "httpx>=0.28,<1", + "ruff>=0.14,<1", + "openapi-spec-validator==0.7.2", + "psutil>=7,<8", + "matplotlib>=3.10,<4", + "pyyaml==6.0.3", + "pip-audit==2.10.1", +] + +[tool.ruff] +line-length = 79 +target-version = "py314" +include = ["src/**/*.py", "student-tests/**/*.py", "student-unit/**/*.py", "research/**/*.py", "scripts/**/*.py"] + +[tool.ruff.lint] +select = ["E", "F", "I", "B", "UP"] + +[tool.ruff.per-file-target-version] +"scripts/*.py" = "py39" + +# SQL и генерируемые Markdown-таблицы в инструментах не разрываем. +[tool.ruff.lint.per-file-ignores] +"research/*.py" = ["E501"] +"scripts/*.py" = ["E501"] + +# Keep SQL statements together; the formatter controls executable statements. +"src/attachments.py" = ["E501"] +"src/pipeline.py" = ["E501"] +"src/worker.py" = ["E501"] +"src/operator.py" = ["E501"] +"src/reconcile.py" = ["E501"] +"src/observer.py" = ["E501"] + +[tool.pytest.ini_options] +testpaths = ["student-tests"] +addopts = "-ra" + diff --git a/research/analyze_pipeline.py b/research/analyze_pipeline.py new file mode 100644 index 0000000..7a9e0d8 --- /dev/null +++ b/research/analyze_pipeline.py @@ -0,0 +1,128 @@ +"""Summarize measured fault invariants and child resource samples.""" + +import argparse +import csv +import json +from pathlib import Path + +import matplotlib + +matplotlib.use("Agg") +import matplotlib.pyplot as plt + + +def effects(case): + for key in ["effect", "v1", "v2"]: + if key in case: + yield key, case[key] + for i, item in enumerate(case.get("effects", [])): + yield str(i + 1), item + + +def main(): + p = argparse.ArgumentParser() + p.add_argument("input", type=Path) + p.add_argument("--output", required=True, type=Path) + a = p.parse_args() + d = json.loads(a.input.read_text()) + assert d["complete"] and d.get("scope", "all") == "all" + rows = [] + for case in d["cases"]: + for role, e in effects(case): + j = e["job"] + rows.append( + dict( + case=case["case"], + role=role, + job_id=j["id"], + version=j["pipeline_version"], + attempt=j["attempt"], + cycle=j["cycle"], + fence=j["fence"], + state=j["state"], + publications=e["publications"], + variant_rows=len(e["variants"]), + physical_keys=len(e["physical_keys"]), + ) + ) + a.output.mkdir(parents=True, exist_ok=True) + with (a.output / "effects.csv").open("w") as f: + writer = csv.DictWriter(f, fieldnames=list(rows[0])) + writer.writeheader() + writer.writerows(rows) + ready = [r for r in rows if r["state"] == "ready"] + assert all( + r["publications"] == 1 + and r["variant_rows"] == 4 + and r["physical_keys"] == 4 + for r in ready + ) + stale = [r for r in rows if r["state"] == "obsolete"] + assert all(r["publications"] == 0 for r in stale) + job_ids = {r["job_id"] for r in rows} + samples = [ + x["detail"] + for x in d["worker_metrics"] + if str(x["job_id"]) in job_ids + and x["detail"].get("result") == "ready" + and "rss_peak_mib" in x["detail"] + ] + stats = { + "source_commit": d["source_commit"], + "cases": len(d["cases"]), + "observed_ready_effects": len(ready), + "observed_obsolete_effects": len(stale), + "all_ready_have_one_publication_and_four_variants": True, + "all_obsolete_have_zero_publications": True, + "successful_child_samples": len(samples), + "child_elapsed_range_seconds": [ + min(x["seconds"] for x in samples), + max(x["seconds"] for x in samples), + ], + "child_cpu_range_seconds": [ + min(x["cpu_seconds"] for x in samples), + max(x["cpu_seconds"] for x in samples), + ], + "child_peak_rss_range_mib": [ + min(x["rss_peak_mib"] for x in samples), + max(x["rss_peak_mib"] for x in samples), + ], + "scope": "process self metrics, no queue lag or throughput claim; fault-free and retry children only where a result was returned", + } + (a.output / "summary.json").write_text(json.dumps(stats, indent=2) + "\n") + fig, axes = plt.subplots(1, 2, figsize=(13, 5), layout="constrained") + axes[0].bar( + range(1, len(rows) + 1), + [r["publications"] for r in rows], + color=[ + "#246b8e" if r["state"] == "ready" else "#d17d20" for r in rows + ], + ) + axes[0].axhline(1, color="#5b6870", linestyle="--", linewidth=1) + axes[0].set( + xlabel="Effect observation (CSV row)", + ylabel="Committed publications", + title="One publication per ready version; stale v1 = 0", + yticks=[0, 1], + ) + axes[1].scatter( + [x["seconds"] for x in samples], + [x["rss_peak_mib"] for x in samples], + color="#246b8e", + s=35, + alpha=0.8, + ) + axes[1].set( + xlabel="Child elapsed, seconds", + ylabel="Child peak RSS, MiB", + title=f"{len(samples)} completed child samples (synthetic320×200)", + ) + for ax in axes: + ax.grid(axis="y", alpha=0.2) + fig.savefig(a.output / "pipeline-results.png", dpi=150) + plt.close(fig) + print(json.dumps(stats, indent=2)) + + +if __name__ == "__main__": + main() diff --git a/research/analyze_slo.py b/research/analyze_slo.py new file mode 100644 index 0000000..6e9c35e --- /dev/null +++ b/research/analyze_slo.py @@ -0,0 +1,249 @@ +"""Derive tables and a figure from completed observations, never simulated data.""" + +import argparse +import csv +import json +import math +from collections import Counter +from pathlib import Path + +import matplotlib + +matplotlib.use("Agg") +import matplotlib.pyplot as plt + + +def quantile(values, fraction): + ordered = sorted(values) + return ( + ordered[max(0, math.ceil(len(ordered) * fraction) - 1)] + if ordered + else None + ) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("input", type=Path) + parser.add_argument("--output", type=Path, required=True) + args = parser.parse_args() + report = json.loads(args.input.read_text()) + assert report["complete"] and report["scope"] == "full30m" + assert report["elapsed_seconds"] >= 1800 + with (args.input.parent / report["requests_csv"]).open() as stream: + requests = list(csv.DictReader(stream)) + samples = report["samples"] + origin = samples[0]["at"] + summaries = [] + for phase in report["phases"]: + rows = [r for r in requests if r["phase"] == phase["name"]] + successful = [ + float(r["seconds"]) for r in rows if r["status"] == "201" + ] + elapsed = phase["end"] - phase["start"] + summaries.append( + { + "phase": phase["name"], + "seconds": round(elapsed, 3), + "started_requests": len(rows), + "statuses": dict(Counter(r["status"] for r in rows)), + "successful_rps": round(len(successful) / elapsed, 3), + "success_p50_ms": round(quantile(successful, 0.5) * 1000, 3) + if successful + else None, + "success_p95_ms": round(quantile(successful, 0.95) * 1000, 3) + if successful + else None, + "success_p99_ms": round(quantile(successful, 0.99) * 1000, 3) + if successful + else None, + "critical_firing_names": sorted( + n + for n in phase["firing"] + if n + in { + "ApiFastBurn", + "ApiSlowBurn", + "ReadyFastBurn", + "ReadySlowBurn", + } + ), + "warning_firing_names": sorted( + n + for n in phase["firing"] + if n + not in { + "ApiFastBurn", + "ApiSlowBurn", + "ReadyFastBurn", + "ReadySlowBurn", + } + ), + } + ) + intervals = {} + for name in sorted({a["name"] for s in samples for a in s["alerts"]}): + segments, start = [], None + for sample in samples: + active = any( + a["name"] == name and a["state"] == "firing" + for a in sample["alerts"] + ) + if active and start is None: + start = sample["at"] + elif not active and start is not None: + segments.append([start, sample["at"]]) + start = None + if start is not None: + segments.append([start, samples[-1]["at"]]) + intervals[name] = segments + gap = [ + b["at"] - a["at"] for a, b in zip(samples, samples[1:], strict=False) + ] + memory = [ + s["signals"]["collector_memory"] / 1024**2 + for s in samples + if s["signals"]["collector_memory"] is not None + ] + summary = { + "source_commit": report["source_commit"], + "runtime_versions": report["runtime_versions"], + "elapsed_seconds": report["elapsed_seconds"], + "sample_count": len(samples), + "sample_gap_seconds": { + "min": min(gap), + "median": quantile(gap, 0.5), + "max": max(gap), + }, + "client_quantile_method": "nearest rank of successful end-to-end writes; not histogram interpolation", + "phases": summaries, + "incidents": report["incidents"], + "firing_intervals_unix_seconds": intervals, + "short_spikes": report["short_spikes"], + "collector_rss_mib": {"min": min(memory), "max": max(memory)}, + "collector_max_queued_packets_sum": max( + s["signals"]["collector_queue"] or 0 for s in samples + ), + "collector_queue_capacity_sum": max( + s["signals"]["collector_queue_capacity"] or 0 for s in samples + ), + "backend_outage": report["backend_outage"], + "preservation": report["preservation"], + "final_30m_sli": report["final_30m_sli"], + } + args.output.mkdir(parents=True, exist_ok=True) + (args.output / "summary.json").write_text( + json.dumps(summary, ensure_ascii=False, indent=2) + "\n" + ) + with (args.output / "phases.csv").open("w") as stream: + writer = csv.DictWriter(stream, fieldnames=list(summaries[0])) + writer.writeheader() + writer.writerows(summaries) + x = [(s["at"] - origin) / 60 for s in samples] + fig, axes = plt.subplots( + 4, 1, figsize=(12, 12), sharex=True, layout="constrained" + ) + for axis in axes: + axis.grid(alpha=0.2) + for phase in report["phases"]: + if ( + phase["name"].endswith("_sustained") + or phase["name"] == "backend_unavailable" + ): + color = ( + "#cf704e" + if phase["name"].startswith("api") + else "#8b79b5" + if phase["name"].startswith("ready") + else "#85919d" + ) + axis.axvspan( + (phase["start"] - origin) / 60, + (phase["end"] - origin) / 60, + color=color, + alpha=0.15, + ) + axes[0].plot( + x, + [(s["signals"]["api_error_ratio_1m"] or 0) * 100 for s in samples], + color="#b04a32", + label="API 5xx ratio, rolling 1 min", + ) + axes[0].axhline(1, color="black", ls=":", label="1% error budget") + axes[0].set_ylabel("5xx, %") + axes[0].legend(loc="upper right") + axes[0].set_title( + "Actual 30-minute SLO experiment: DB delay, stopped worker, unavailable telemetry stores" + ) + axes[1].plot( + x, + [s["signals"]["queue_depth"] for s in samples], + color="#386a9b", + label="Queued jobs", + ) + axes[1].set_ylabel("Jobs") + other = axes[1].twinx() + other.plot( + x, + [s["signals"]["oldest_job_age"] for s in samples], + color="#8b579d", + label="Oldest unfinished job", + ) + other.axhline(20, ls=":", color="#8b579d") + other.set_ylabel("Age, seconds") + axes[1].legend(loc="upper left") + other.legend(loc="upper right") + alert_names = [ + "ApiFastBurn", + "ApiSlowBurn", + "ReadyFastBurn", + "ReadySlowBurn", + ] + for index, name in enumerate(alert_names): + axes[2].broken_barh( + [ + ((start - origin) / 60, (end - start) / 60) + for start, end in intervals.get(name, []) + ], + (index - 0.3, 0.6), + facecolors="#bd523c", + ) + axes[2].set_yticks(range(4), alert_names) + axes[2].set_ylim(-0.6, 3.6) + axes[2].set_ylabel("Critical alert firing") + axes[3].plot( + x, + [ + s["signals"]["collector_memory"] / 1024**2 + if s["signals"]["collector_memory"] is not None + else None + for s in samples + ], + color="#347465", + label="Collector RSS", + ) + axes[3].axhline( + report["container_limits"]["otel"]["mem_limit"] / 1024**2, + ls=":", + color="black", + label="Container memory limit", + ) + axes[3].set_ylabel("MiB") + axes[3].set_xlabel("Minutes from first observation") + other = axes[3].twinx() + other.plot( + x, + [s["signals"]["collector_queue"] for s in samples], + color="#9c6e2e", + label="Queued telemetry packets, sum", + ) + other.set_ylabel("Packets") + axes[3].legend(loc="upper left") + other.legend(loc="upper right") + fig.savefig(args.output / "slo-timeline.png", dpi=150) + plt.close(fig) + print("PASS: measured phase statistics, alert intervals and timeline") + + +if __name__ == "__main__": + main() diff --git a/scripts/bao_operator.py b/scripts/bao_operator.py new file mode 100644 index 0000000..252dc0c --- /dev/null +++ b/scripts/bao_operator.py @@ -0,0 +1,351 @@ +"""Explicit operator init/unseal/configure; no unseal material enters containers.""" + +import argparse +import json +import os +import ssl +import time + +import httpx +from cryptography import x509 + +from scripts.bootstrap_security import ( + OPERATOR, + ROLES, + ROOT, + TRUST, + ca, + public, + sign_intermediate, + write_private, +) + + +class Operator: + def __init__(self): + context = ssl.create_default_context(cafile=TRUST / "ca.pem") + context.minimum_version = ssl.TLSVersion.TLSv1_3 + context.load_cert_chain( + OPERATOR / "client/cert.pem", OPERATOR / "client/key.pem" + ) + self.http = httpx.Client( + base_url="https://localhost:" + + os.getenv("BAO_PORT", "8207") + + "/v1/", + verify=context, + trust_env=False, + timeout=10, + ) + self.token = None + + def close(self): + self.http.close() + + def call(self, method, path, payload=None, *, token=None): + response = self.http.request( + method, + path, + json=payload, + headers={"X-Vault-Token": token} if token else {}, + ) + if response.status_code >= 300: + raise RuntimeError( + "Operator request denied/unavailable: " + + path + + " status " + + str(response.status_code) + ) + return response.json() if response.content else {} + + def init(self): + if self.call("GET", "sys/init")["initialized"]: + return + result = self.call( + "POST", "sys/init", {"secret_shares": 3, "secret_threshold": 2} + ) + for index, key in enumerate(result["keys_base64"]): + write_private( + OPERATOR / ("unseal-" + str(index + 1) + ".json"), + json.dumps({"key": key}) + "\n", + ) + write_private(OPERATOR / "bootstrap-root-token", result["root_token"]) + + def unseal(self): + state = self.call("GET", "sys/seal-status") + if not state["sealed"]: + return + for index in [1, 2]: + share = json.loads( + (OPERATOR / ("unseal-" + str(index) + ".json")).read_text() + ) + state = self.call("POST", "sys/unseal", {"key": share["key"]}) + if not state["sealed"]: + return + raise RuntimeError("Unseal threshold not reached") + + def authenticate(self): + cached = OPERATOR / "operator-token.json" + if cached.exists(): + data = json.loads(cached.read_text()) + if data["expires_at"] > time.time() + 30: + self.token = data["token"] + return self.token + result = self.call("POST", "auth/cert/login", {})["auth"] + self.token = result["client_token"] + write_private( + cached, + json.dumps( + { + "token": self.token, + "expires_at": time.time() + result["lease_duration"], + } + ) + + "\n", + ) + return self.token + + def authorized(self, method, path, payload=None): + return self.call( + method, path, payload, token=self.token or self.authenticate() + ) + + def configure(self): + marker = OPERATOR / "configured.json" + if marker.exists(): + self.authenticate() + self.authorized("GET", "auth/token/lookup-self") + return + token = (OPERATOR / "bootstrap-root-token").read_text().strip() + + def root(method, path, payload=None): + return self.call(method, path, payload, token=token) + + mounts = root("GET", "sys/mounts") + mounts = mounts.get("data", mounts) + if "secret/" not in mounts: + root( + "POST", + "sys/mounts/secret", + {"type": "kv", "options": {"version": "2"}}, + ) + if "pki/" not in mounts: + root( + "POST", + "sys/mounts/pki", + {"type": "pki", "config": {"max_lease_ttl": "720h"}}, + ) + auth = root("GET", "sys/auth") + auth = auth.get("data", auth) + if "cert/" not in auth: + root("POST", "sys/auth/cert", {"type": "cert"}) + issuer_marker = OPERATOR / "initial-issuer.json" + if not issuer_marker.exists(): + csr = root( + "POST", + "pki/intermediate/generate/internal", + { + "common_name": "Messenger service intermediate", + "key_type": "ec", + "key_bits": 256, + }, + )["data"]["csr"] + key, cert = ca() + intermediate = sign_intermediate( + key, cert, x509.load_pem_x509_csr(csr.encode()) + ) + imported = root( + "POST", + "pki/intermediate/set-signed", + { + "certificate": ( + public(intermediate) + public(cert) + ).decode() + }, + ) + issuers = imported["data"]["imported_issuers"] + selected = None + for issuer in issuers: + details = root("GET", "pki/issuer/" + issuer)["data"] + loaded = x509.load_pem_x509_certificate( + details["certificate"].encode() + ) + if loaded.serial_number == intermediate.serial_number: + selected = issuer + assert selected, "Imported signing intermediate not found" + root( + "POST", + "pki/config/issuers", + {"default": selected, "default_follows_latest_issuer": False}, + ) + write_private( + issuer_marker, + json.dumps( + { + "configured": True, + "imported_issuers": imported.get("data", {}).get( + "imported_issuers", [] + ), + } + ) + + "\n", + ) + _, cert = ca() + material = json.loads((OPERATOR / "service-secrets.json").read_text()) + for role, cfg in ROLES.items(): + policy = ( + ROOT / "infra/openbao/policies" / (role + ".hcl") + ).read_text() + if cfg["kv"]: + root( + "POST", + "secret/data/" + role, + {"data": material["services"][role]["values"]}, + ) + root( + "PUT", "sys/policies/acl/messenger-" + role, {"policy": policy} + ) + root( + "POST", + "pki/roles/" + role, + { + "allowed_domains": cfg["dns"], + "allow_bare_domains": True, + "allow_subdomains": False, + "allow_wildcard_certificates": False, + "allow_any_name": False, + "allow_localhost": "localhost" in cfg["dns"], + "allow_ip_sans": bool(cfg.get("ip")), + "allowed_uri_sans": ["spiffe://messenger/" + role], + "enforce_hostnames": True, + "key_type": "ec", + "key_bits": 256, + "server_flag": True, + "client_flag": True, + "ttl": "120s", + "max_ttl": "120s", + "issuer_ref": "default", + }, + ) + root( + "POST", + "auth/cert/certs/" + role + "-v1", + { + "display_name": role, + "certificate": public(cert).decode(), + "allowed_common_names": [role], + "allowed_uri_sans": ["spiffe://messenger/" + role], + "token_policies": ["messenger-" + role], + "token_ttl": "120s", + "token_max_ttl": "600s", + "token_no_default_policy": True, + }, + ) + operator_policy = ( + ROOT / "infra/openbao/policies/operator.hcl" + ).read_text() + root( + "PUT", + "sys/policies/acl/messenger-operator", + {"policy": operator_policy}, + ) + root( + "POST", + "auth/cert/certs/operator-v1", + { + "display_name": "operator", + "certificate": public(cert).decode(), + "allowed_common_names": ["operator"], + "allowed_uri_sans": ["spiffe://messenger/operator"], + "token_policies": ["messenger-operator"], + "token_ttl": "900s", + "token_max_ttl": "3600s", + "token_no_default_policy": True, + }, + ) + audit = root("GET", "sys/audit") + audit = audit.get("data", audit) + if "file/" not in audit: + root( + "PUT", + "sys/audit/file", + { + "type": "file", + "options": { + "file_path": "/data/audit/audit.log", + "mode": "0600", + }, + }, + ) + created = root( + "POST", + "auth/token/create-orphan", + { + "policies": ["messenger-operator"], + "ttl": "900s", + "renewable": True, + "no_default_policy": True, + }, + )["auth"] + write_private( + OPERATOR / "operator-token.json", + json.dumps( + { + "token": created["client_token"], + "expires_at": time.time() + created["lease_duration"], + } + ) + + "\n", + ) + root("POST", "auth/token/revoke-self", {}) + write_private( + marker, + json.dumps({"configured": True, "root_token_revoked": True}) + + "\n", + ) + (OPERATOR / "bootstrap-root-token").unlink() + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "action", choices=["init", "unseal", "configure", "status", "seal"] + ) + args = parser.parse_args() + operator = Operator() + try: + if args.action == "init": + operator.init() + operator.unseal() + operator.configure() + elif args.action == "unseal": + operator.unseal() + elif args.action == "configure": + operator.configure() + elif args.action == "seal": + operator.authorized("POST", "sys/seal", {}) + else: + state = operator.call("GET", "sys/seal-status") + print( + json.dumps( + { + k: state[k] + for k in [ + "initialized", + "sealed", + "version", + "storage_type", + ] + if k in state + } + ) + ) + if args.action != "status": + print( + "Operator action completed; no tokens or unseal shares printed" + ) + finally: + operator.close() + + +if __name__ == "__main__": + main() diff --git a/scripts/bootstrap.py b/scripts/bootstrap.py new file mode 100644 index 0000000..43681d0 --- /dev/null +++ b/scripts/bootstrap.py @@ -0,0 +1,64 @@ +"""Создаёт только отсутствующие локальные файлы; секреты не печатает.""" + +import os +import secrets +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] + + +def create(path, value): + try: + fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o644) + except FileExistsError: + return + with os.fdopen(fd, "w") as stream: + stream.write(value + "\n") + + +def main(): + directory = ROOT / "secrets" + directory.mkdir(mode=0o700, exist_ok=True) + pg = directory / "postgres_password" + cache = directory / "cache_password" + create(pg, secrets.token_urlsafe(32)) + create(cache, secrets.token_urlsafe(32)) + create( + directory / "database_url", + "postgresql://messenger:" + + pg.read_text().strip() + + "@postgres:5432/messenger", + ) + create( + directory / "cache_url", + "redis://:" + cache.read_text().strip() + "@cache:6379/0", + ) + create( + directory / "valkey.conf", + "bind 0.0.0.0\nprotected-mode yes\nport 6379\nmaxmemory 64mb\n" + 'maxmemory-policy allkeys-lru\nsave ""\nappendonly no\nrequirepass ' + + cache.read_text().strip(), + ) + create(directory / "s3_root_user", secrets.token_hex(10)) + create(directory / "s3_root_password", secrets.token_urlsafe(32)) + create(directory / "s3_access_key", secrets.token_hex(10)) + create(directory / "s3_secret_key", secrets.token_urlsafe(32)) + create(directory / "grafana_password", secrets.token_urlsafe(32)) + create(directory / "broker_password", secrets.token_urlsafe(32)) + create( + directory / "broker_url", + "redis://:" + + (directory / "broker_password").read_text().strip() + + "@broker:6379/0", + ) + create( + directory / "broker.conf", + "bind 0.0.0.0\nprotected-mode yes\nport 6379\nappendonly yes\nappendfsync always\nmaxmemory 192mb\nmaxmemory-policy noeviction\ndir /data\nrequirepass " + + (directory / "broker_password").read_text().strip(), + ) + create(ROOT / ".env", (ROOT / ".env.example").read_text().rstrip()) + print("Local configuration ready; existing files preserved") + + +if __name__ == "__main__": + main() diff --git a/scripts/bootstrap_security.py b/scripts/bootstrap_security.py new file mode 100644 index 0000000..f828c2a --- /dev/null +++ b/scripts/bootstrap_security.py @@ -0,0 +1,416 @@ +"""Operator-only offline trust/bootstrap generation; never prints key material.""" + +import argparse +import hashlib +import ipaddress +import json +import os +import secrets +from datetime import UTC, datetime, timedelta +from pathlib import Path +from urllib.parse import quote + +from cryptography import x509 +from cryptography.hazmat.primitives import hashes, serialization +from cryptography.hazmat.primitives.asymmetric import ec +from cryptography.x509.oid import ExtendedKeyUsageOID, NameOID + +ROOT = Path(__file__).resolve().parents[1] +OPERATOR = ROOT / "operator" +SECRET = ROOT / "secrets" +TRUST = ROOT / "trust" +ROLES = { + "openbao": { + "dns": ["openbao", "localhost"], + "ip": ["127.0.0.1"], + "uid": 1000, + "kv": False, + }, + "api": {"dns": ["api", "localhost"], "uid": 10001, "kv": True}, + "worker": {"dns": ["worker"], "uid": 10001, "kv": True}, + "relay": {"dns": ["relay"], "uid": 10001, "kv": True}, + "observer": {"dns": ["observer"], "uid": 10001, "kv": True}, + "reconciler": {"dns": ["reconciler"], "uid": 10001, "kv": True}, + "migrate": {"dns": ["migrate"], "uid": 10001, "kv": True}, + "lb": { + "dns": ["lb", "localhost"], + "ip": ["127.0.0.1"], + "uid": 99, + "kv": False, + }, + "postgres": {"dns": ["postgres"], "uid": 10001, "kv": False}, + "s3": { + "dns": ["s3", "localhost"], + "ip": ["127.0.0.1"], + "uid": 10001, + "kv": False, + }, + "broker": {"dns": ["broker"], "uid": 10001, "kv": False}, + "cache": {"dns": ["cache"], "uid": 10001, "kv": False}, + "otel": {"dns": ["otel"], "uid": 10001, "kv": False}, + "prometheus": {"dns": ["prometheus"], "uid": 65534, "kv": False}, + "loki": {"dns": ["loki"], "uid": 10001, "kv": False}, + "tempo": {"dns": ["tempo"], "uid": 10001, "kv": False}, + "grafana": { + "dns": ["grafana", "localhost"], + "ip": ["127.0.0.1"], + "uid": 472, + "kv": False, + }, +} + + +def write_private(path, content, *, mode=0o600): + path.parent.mkdir(parents=True, exist_ok=True) + raw = content.encode() if isinstance(content, str) else content + temporary = path.with_name(path.name + ".new") + fd = os.open(temporary, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, mode) + try: + os.fchmod(fd, mode) + with os.fdopen(fd, "wb") as stream: + stream.write(raw) + stream.flush() + os.fsync(stream.fileno()) + except BaseException: + temporary.unlink(missing_ok=True) + raise + temporary.replace(path) + + +def key_bytes(key): + return key.private_bytes( + serialization.Encoding.PEM, + serialization.PrivateFormat.PKCS8, + serialization.NoEncryption(), + ) + + +def public(cert): + return cert.public_bytes(serialization.Encoding.PEM) + + +def make_root(): + key = ec.generate_private_key(ec.SECP256R1()) + name = x509.Name( + [ + x509.NameAttribute( + NameOID.COMMON_NAME, + "Messenger lab root " + secrets.token_hex(4), + ) + ] + ) + now = datetime.now(UTC) + cert = ( + x509.CertificateBuilder() + .subject_name(name) + .issuer_name(name) + .public_key(key.public_key()) + .serial_number(x509.random_serial_number()) + .not_valid_before(now - timedelta(minutes=1)) + .not_valid_after(now + timedelta(days=365)) + .add_extension( + x509.BasicConstraints(ca=True, path_length=1), critical=True + ) + .add_extension( + x509.KeyUsage( + digital_signature=True, + content_commitment=False, + key_encipherment=False, + data_encipherment=False, + key_agreement=False, + key_cert_sign=True, + crl_sign=True, + encipher_only=False, + decipher_only=False, + ), + critical=True, + ) + .add_extension( + x509.SubjectKeyIdentifier.from_public_key(key.public_key()), + critical=False, + ) + .sign(key, hashes.SHA256()) + ) + return key, cert + + +def sign_leaf(ca_key, ca_cert, role, dns, ips=(), *, seconds=1800): + key = ec.generate_private_key(ec.SECP256R1()) + now = datetime.now(UTC) + names = [x509.DNSName(name) for name in dns] + names += [x509.IPAddress(ipaddress.ip_address(ip)) for ip in ips] + names += [x509.UniformResourceIdentifier("spiffe://messenger/" + role)] + cert = ( + x509.CertificateBuilder() + .subject_name( + x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, role)]) + ) + .issuer_name(ca_cert.subject) + .public_key(key.public_key()) + .serial_number(x509.random_serial_number()) + .not_valid_before(now - timedelta(seconds=30)) + .not_valid_after(now + timedelta(seconds=seconds)) + .add_extension( + x509.BasicConstraints(ca=False, path_length=None), critical=True + ) + .add_extension(x509.SubjectAlternativeName(names), critical=False) + .add_extension( + x509.ExtendedKeyUsage( + [ + ExtendedKeyUsageOID.CLIENT_AUTH, + ExtendedKeyUsageOID.SERVER_AUTH, + ] + ), + critical=False, + ) + .add_extension( + x509.KeyUsage( + digital_signature=True, + content_commitment=False, + key_encipherment=False, + data_encipherment=False, + key_agreement=False, + key_cert_sign=False, + crl_sign=False, + encipher_only=False, + decipher_only=False, + ), + critical=True, + ) + .add_extension( + x509.AuthorityKeyIdentifier.from_issuer_public_key( + ca_key.public_key() + ), + critical=False, + ) + .sign(ca_key, hashes.SHA256()) + ) + return key, cert + + +def sign_intermediate(ca_key, ca_cert, csr): + now = datetime.now(UTC) + assert csr.is_signature_valid + return ( + x509.CertificateBuilder() + .subject_name(csr.subject) + .issuer_name(ca_cert.subject) + .public_key(csr.public_key()) + .serial_number(x509.random_serial_number()) + .not_valid_before(now - timedelta(seconds=30)) + .not_valid_after(now + timedelta(days=30)) + .add_extension( + x509.BasicConstraints(ca=True, path_length=0), critical=True + ) + .add_extension( + x509.KeyUsage( + digital_signature=True, + content_commitment=False, + key_encipherment=False, + data_encipherment=False, + key_agreement=False, + key_cert_sign=True, + crl_sign=True, + encipher_only=False, + decipher_only=False, + ), + critical=True, + ) + .add_extension( + x509.SubjectKeyIdentifier.from_public_key(csr.public_key()), + critical=False, + ) + .add_extension( + x509.AuthorityKeyIdentifier.from_issuer_public_key( + ca_key.public_key() + ), + critical=False, + ) + .sign(ca_key, hashes.SHA256()) + ) + + +def ca(): + return ( + serialization.load_pem_private_key( + (OPERATOR / "ca-key.pem").read_bytes(), password=None + ), + x509.load_pem_x509_certificate((OPERATOR / "ca.pem").read_bytes()), + ) + + +def generate(): + for directory in [OPERATOR, SECRET]: + directory.mkdir(mode=0o700, exist_ok=True) + directory.chmod(0o700) + TRUST.mkdir(mode=0o755, exist_ok=True) + if not (OPERATOR / "ca-key.pem").exists(): + key, cert = make_root() + write_private(OPERATOR / "ca-key.pem", key_bytes(key)) + write_private(OPERATOR / "ca.pem", public(cert)) + key, cert = ca() + if not (TRUST / "ca.pem").exists(): + write_private(TRUST / "ca.pem", public(cert), mode=0o644) + write_private(TRUST / "revoked.json", "{}\n", mode=0o644) + for role, cfg in { + **ROLES, + "openbao": {"dns": ["openbao", "localhost"], "ip": ["127.0.0.1"]}, + "operator": {"dns": ["operator"]}, + }.items(): + directory = ( + (OPERATOR / "client") + if role == "operator" + else SECRET / "bootstrap" / role + ) + renew_operator = ( + role == "operator" + and (directory / "cert.pem").exists() + and x509.load_pem_x509_certificate( + (directory / "cert.pem").read_bytes() + ).not_valid_after_utc + < datetime.now(UTC) + timedelta(hours=1) + ) + if not (directory / "key.pem").exists() or renew_operator: + leaf_key, leaf = sign_leaf( + key, + cert, + role, + cfg["dns"], + cfg.get("ip", ()), + seconds=86400 if role in {"operator", "openbao"} else 1800, + ) + directory.mkdir(parents=True, exist_ok=True) + directory.chmod(0o700 if role == "operator" else 0o755) + mode = 0o600 if role == "operator" else 0o644 + write_private( + directory / "key.pem", key_bytes(leaf_key), mode=mode + ) + write_private( + directory / "cert.pem", public(leaf) + public(cert), mode=mode + ) + write_private( + directory / "bundle.pem", + public(leaf) + public(cert) + key_bytes(leaf_key), + mode=mode, + ) + path = OPERATOR / "service-secrets.json" + if path.exists(): + raw = json.loads(path.read_text()) + else: + raw = { + name: secrets.token_urlsafe(32) + for name in [ + "postgres_password", + "s3_root_password", + "broker_admin", + "cache_admin", + "cache_api", + "grafana_password", + ] + } + raw["s3_root_user"] = "operator-" + secrets.token_hex(12) + raw["services"] = {} + for role in [ + "api", + "worker", + "relay", + "observer", + "reconciler", + "migrate", + ]: + pwd = secrets.token_urlsafe(32) + values = { + "DATABASE_URL": "postgresql://" + + ("messenger" if role == "migrate" else "svc_" + role) + + ":" + + quote( + raw["postgres_password"] if role == "migrate" else pwd, + safe="", + ) + + "@postgres:5443/messenger?sslmode=verify-full&gssencmode=disable&sslrootcert=/trust/ca.pem&sslcert=/run/identity/current/cert.pem&sslkey=/run/identity/current/key.pem" + } + service = {"database_password": pwd, "values": values} + if role == "api": + values["CACHE_URL"] = ( + "rediss://api:" + raw["cache_api"] + "@cache:6380/0" + ) + if role in {"relay", "worker"}: + service["broker_password"] = secrets.token_urlsafe(32) + values["BROKER_URL"] = ( + "rediss://" + + role + + ":" + + service["broker_password"] + + "@broker:6380/0" + ) + if role in {"api", "worker", "reconciler"}: + values.update( + S3_ACCESS_KEY=role + "-" + secrets.token_hex(12), + S3_SECRET_KEY=secrets.token_urlsafe(32), + ) + raw["services"][role] = service + write_private(path, json.dumps(raw, indent=2) + "\n") + for name in [ + "postgres_password", + "s3_root_user", + "s3_root_password", + "grafana_password", + ]: + write_private(SECRET / name, raw[name] + "\n", mode=0o644) + for name in ["broker", "cache"]: + admin = raw[name + "_admin"] + lines = [ + "bind 127.0.0.1", + "port 6379", + "protected-mode yes", + 'save ""', + "maxmemory 64mb" if name == "cache" else "maxmemory 192mb", + "maxmemory-policy allkeys-lru" + if name == "cache" + else "maxmemory-policy noeviction", + "user default off", + "user admin on #" + + hashlib.sha256(admin.encode()).hexdigest() + + " ~* &* +@all", + ] + if name == "cache": + lines += [ + "user api on #" + + hashlib.sha256(raw["cache_api"].encode()).hexdigest() + + " ~user:* +get +set +ping +select +client|setinfo +client|setname" + ] + else: + lines += ["appendonly yes", "appendfsync always", "dir /data"] + for role, commands in [ + ("relay", "+xadd +waitaof"), + ( + "worker", + "+xgroup|create +xreadgroup +xautoclaim +xack +xdel", + ), + ]: + lines += [ + "user " + + role + + " on #" + + hashlib.sha256( + raw["services"][role]["broker_password"].encode() + ).hexdigest() + + " ~attachments +ping +select +client|setinfo +client|setname " + + commands + ] + write_private( + SECRET / (name + ".conf"), "\n".join(lines) + "\n", mode=0o644 + ) + write_private(SECRET / (name + "_admin"), admin + "\n", mode=0o644) + + +def main(): + argparse.ArgumentParser(description=__doc__).parse_args() + generate() + print( + "Local operator trust, scoped service credentials and bootstrap certificates prepared; existing secrets retained" + ) + + +if __name__ == "__main__": + main() diff --git a/scripts/cluster.py b/scripts/cluster.py new file mode 100644 index 0000000..e418d0e --- /dev/null +++ b/scripts/cluster.py @@ -0,0 +1,83 @@ +"""Явные операторские действия только над API текущего Compose-проекта.""" + +import json +import os +import subprocess +import sys +import time +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] + + +def command(*args): + return subprocess.check_output(args, cwd=ROOT, text=True).strip() + + +def containers(): + ids = command("docker", "compose", "ps", "-q", "api").split() + return json.loads(command("docker", "inspect", *ids)) if ids else [] + + +def alias(cid): + code = ( + "import urllib.request; r=urllib.request.urlopen(" + "'http://127.0.0.1:8080/health/live',timeout=2); " + "print(r.headers['X-Instance-Id'])" + ) + return command("docker", "exec", cid, "python", "-c", code) + + +def wait_count(count): + deadline = time.monotonic() + 60 + while time.monotonic() < deadline: + data = containers() + if len(data) == count and all( + c["State"].get("Health", {}).get("Status") == "healthy" + for c in data + ): + # DNS и проверки HAProxy должны успеть увидеть новый адрес. + time.sleep(3) + return + time.sleep(0.5) + raise TimeoutError("Replica readiness") + + +def main(): + action = sys.argv[1] + data = containers() + if action == "stop": + target = os.environ["TARGET_INSTANCE_ID"] + matches = [c for c in data if alias(c["Id"]) == target] + if len(matches) != 1 or len(data) < 2: + raise RuntimeError("Target must identify one running replica") + command("docker", "stop", "--time", "10", matches[0]["Id"]) + print("Selected API stopped") + elif action == "rolling": + count = len(data) + if count < 2: + raise RuntimeError("Need at least two replicas") + # Сначала добавляется готовая реплика, затем удаляется одна старая. + for old in data: + command( + "docker", + "compose", + "up", + "-d", + "--no-deps", + "--no-recreate", + "--scale", + f"api={count + 1}", + "api", + ) + wait_count(count + 1) + command("docker", "stop", "--time", "10", old["Id"]) + command("docker", "rm", old["Id"]) + wait_count(count) + print("Sequential replacement completed") + else: + raise ValueError("Unknown action") + + +if __name__ == "__main__": + main() diff --git a/scripts/observe.py b/scripts/observe.py new file mode 100644 index 0000000..bc334e5 --- /dev/null +++ b/scripts/observe.py @@ -0,0 +1,134 @@ +"""Read-only queries through an internal probe, without exposing admin ports.""" + +import base64 +import json +import time +from urllib.parse import urlencode + +from scripts.stand import compose + +ENDPOINTS = { + "prometheus": "http://prometheus:9090", + "loki": "http://loki:3100", + "tempo": "http://tempo:3200", + "otel": "http://otel:13133", +} + + +def fetch(service, path, *, params=None, json_result=True): + url = ENDPOINTS[service] + path + if params: + url += "?" + urlencode(params, doseq=True) + code = ( + "import urllib.request; " + f"r=urllib.request.urlopen(urllib.request.Request({url!r},headers={{'Accept':'application/json'}}),timeout=8); " + "print(r.read().decode())" + ) + text = compose("exec", "-T", "observer", "python", "-c", code) + return json.loads(text) if json_result else text + + +def query(expression, *, at=None): + params = {"query": expression} + if at is not None: + params["time"] = str(at) + result = fetch("prometheus", "/api/v1/query", params=params) + assert result["status"] == "success" + return result["data"]["result"] + + +def scalar(expression): + result = query(expression) + return float(result[0]["value"][1]) if result else 0.0 + + +def queries(expressions): + urls = { + name: ENDPOINTS["prometheus"] + + "/api/v1/query?" + + urlencode({"query": expression}) + for name, expression in expressions.items() + } + code = ( + "import json,urllib.request\n" + f"urls={urls!r}\n" + "result={}\n" + "for name,url in urls.items():\n" + " with urllib.request.urlopen(url,timeout=8) as r: result[name]=json.load(r)['data']['result']\n" + "print(json.dumps(result))" + ) + return json.loads(compose("exec", "-T", "observer", "python", "-c", code)) + + +def logs(trace_id, *, start=None): + return fetch( + "loki", + "/loki/api/v1/query_range", + params={ + "query": '{service_name=~"messenger-api|messenger-worker|messenger-relay"} | trace_id="' + + trace_id + + '"', + "start": str(int((start or time.time() - 3600) * 1e9)), + "end": str(time.time_ns()), + "limit": 500, + }, + ) + + +def normalize_id(value): + if not value: + return "" + if len(value) in {16, 32} and all(c in "0123456789abcdef" for c in value): + return value + return base64.b64decode(value).hex() + + +def spans(trace_id): + result = fetch("tempo", "/api/traces/" + trace_id) + flattened = [] + for batch in result.get("batches", result.get("resourceSpans", [])): + resource = { + a["key"]: next(iter(a["value"].values())) + for a in batch.get("resource", {}).get("attributes", []) + } + for scope in batch.get("scopeSpans", []): + for item in scope.get("spans", []): + flattened.append( + { + "service": resource.get("service.name"), + "version": resource.get("service.version"), + "instance": resource.get("service.instance.id"), + "name": item["name"], + "kind": item.get("kind"), + "trace_id": normalize_id(item.get("traceId")), + "span_id": normalize_id(item.get("spanId")), + "parent_span_id": normalize_id( + item.get("parentSpanId") + ), + "duration_seconds": ( + int(item["endTimeUnixNano"]) + - int(item["startTimeUnixNano"]) + ) + / 1e9, + "status": item.get("status", {}), + "attributes": { + a["key"]: next(iter(a["value"].values())) + for a in item.get("attributes", []) + }, + } + ) + return flattened + + +def wait(condition, *, timeout=90, interval=1): + end = time.monotonic() + timeout + last_error = None + while time.monotonic() < end: + try: + result = condition() + if result: + return result + except (RuntimeError, ValueError, KeyError) as exc: + last_error = type(exc).__name__ + time.sleep(interval) + raise TimeoutError("Telemetry observation not reached: " + str(last_error)) diff --git a/scripts/prepare_dependencies.py b/scripts/prepare_dependencies.py new file mode 100644 index 0000000..f015e26 --- /dev/null +++ b/scripts/prepare_dependencies.py @@ -0,0 +1,265 @@ +"""Operator-only, idempotent SQL roles and scoped S3 accounts.""" + +import json +import ssl +import time + +import urllib3 +from minio import Minio +from minio.credentials import StaticProvider +from minio.minioadmin import MinioAdmin +from psycopg import sql + +from scripts.bootstrap_security import OPERATOR, TRUST +from scripts.stand import compose + + +def postgres(raw): + # The bootstrap SQL channel is the server's local Unix socket. No password + # or SQL literal is placed in argv; stdin and output are never recorded. + statements = [ + "REVOKE ALL ON SCHEMA public FROM PUBLIC; REVOKE ALL ON DATABASE messenger FROM PUBLIC;" + ] + grants = { + "api": { + "SELECT": [ + "users", + "sessions", + "chats", + "members", + "messages", + "idempotency", + "attachments", + "message_attachments", + "upload_reservations", + "jobs", + "outbox", + "attachment_variants", + "effect_publications", + ], + "INSERT": [ + "users", + "sessions", + "chats", + "members", + "messages", + "idempotency", + "attachments", + "message_attachments", + "upload_reservations", + "jobs", + "outbox", + ], + "UPDATE": ["users", "idempotency", "jobs"], + "DELETE": ["sessions", "upload_reservations"], + }, + "worker": { + "SELECT": [ + "jobs", + "attachments", + "attachment_variants", + "effect_publications", + "pipeline_faults", + ], + "INSERT": [ + "attachment_variants", + "effect_publications", + "pipeline_events", + "outbox", + ], + "UPDATE": ["jobs", "attachments", "pipeline_faults"], + }, + "relay": { + "SELECT": ["jobs", "outbox", "attachments"], + "INSERT": ["pipeline_events", "outbox"], + "UPDATE": ["jobs", "attachments", "outbox"], + }, + "observer": { + "SELECT": [ + "jobs", + "effect_publications", + "pipeline_events", + "job_slo_observations", + ], + "INSERT": ["job_slo_observations"], + "UPDATE": ["job_slo_observations"], + }, + "reconciler": { + "SELECT": [ + "jobs", + "attachments", + "attachment_variants", + "upload_reservations", + "message_attachments", + "effect_publications", + ], + "UPDATE": ["jobs", "attachments"], + "DELETE": [ + "attachments", + "attachment_variants", + "upload_reservations", + "jobs", + "outbox", + "job_slo_observations", + ], + }, + } + # SQL literals use psycopg's own adapter; names are fixed local roles. + for role, permissions in grants.items(): + name = "svc_" + role + password = raw["services"][role]["database_password"] + statements.append( + "DO $$ BEGIN IF NOT EXISTS(SELECT 1 FROM pg_roles WHERE rolname='" + + name + + "') THEN CREATE ROLE " + + name + + " LOGIN; END IF; END $$;" + ) + statements.append( + sql.SQL( + "ALTER ROLE {} WITH LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS PASSWORD {};" + ) + .format(sql.Identifier(name), sql.Literal(password)) + .as_string() + ) + statements.append( + "GRANT CONNECT ON DATABASE messenger TO " + + name + + "; GRANT USAGE ON SCHEMA public TO " + + name + + ";" + ) + statements.append( + "REVOKE ALL ON ALL TABLES IN SCHEMA public FROM " + name + ";" + ) + statements.append( + "REVOKE ALL ON ALL SEQUENCES IN SCHEMA public FROM " + name + ";" + ) + for action, tables in permissions.items(): + statements.append( + "GRANT " + + action + + " ON " + + ",".join(tables) + + " TO " + + name + + ";" + ) + # Only append-only technical event/outbox IDs use sequences. + sequences = { + "api": ["outbox_id_seq"], + "worker": ["outbox_id_seq", "pipeline_events_id_seq"], + "relay": ["outbox_id_seq", "pipeline_events_id_seq"], + }.get(role, []) + if sequences: + statements.append( + "GRANT USAGE ON SEQUENCE " + + ",".join(sequences) + + " TO " + + name + + ";" + ) + statements.append("GRANT EXECUTE ON FUNCTION login_wait(text) TO svc_api;") + result = compose( + "exec", + "-T", + "postgres", + "psql", + "-q", + "-U", + "messenger", + "-d", + "messenger", + "-v", + "ON_ERROR_STOP=1", + input="\n".join(statements), + ) + assert "ERROR" not in result + + +def s3(raw): + context = ssl.create_default_context(cafile=TRUST / "ca.pem") + context.minimum_version = ssl.TLSVersion.TLSv1_3 + context.load_cert_chain( + OPERATOR / "client/cert.pem", OPERATOR / "client/key.pem" + ) + pool = urllib3.PoolManager( + ssl_context=context, + timeout=urllib3.Timeout(connect=2, read=10), + retries=False, + ) + credentials = StaticProvider(raw["s3_root_user"], raw["s3_root_password"]) + admin = MinioAdmin( + "localhost:9007", + credentials=credentials, + secure=True, + http_client=pool, + ) + client = Minio( + "localhost:9007", + credentials=credentials, + secure=True, + http_client=pool, + region="us-east-1", + ) + for attempt in range(60): + try: + if not client.bucket_exists("messenger"): + client.make_bucket("messenger") + break + except Exception: + if attempt == 59: + raise RuntimeError("S3 TLS bootstrap unavailable") from None + time.sleep(1) + for role in ["api", "worker", "reconciler"]: + statements = [ + { + "Effect": "Allow", + "Action": ["s3:GetBucketLocation"], + "Resource": ["arn:aws:s3:::messenger"], + } + ] + + def allow(actions, resource, condition=None, statements=statements): + statement = { + "Effect": "Allow", + "Action": actions, + "Resource": [resource], + } + if condition: + statement["Condition"] = condition + statements.append(statement) + + allow(["s3:GetObject"], "arn:aws:s3:::messenger/objects/*") + if role == "api": + allow(["s3:PutObject"], "arn:aws:s3:::messenger/objects/staging/*") + if role == "worker": + allow(["s3:PutObject"], "arn:aws:s3:::messenger/objects/*/v*/*") + if role == "reconciler": + allow(["s3:DeleteObject"], "arn:aws:s3:::messenger/objects/*") + allow( + ["s3:ListBucket"], + "arn:aws:s3:::messenger", + {"StringLike": {"s3:prefix": ["objects/*"]}}, + ) + values = raw["services"][role]["values"] + admin.policy_add( + "messenger-" + role, + policy={"Version": "2012-10-17", "Statement": statements}, + ) + admin.user_add(values["S3_ACCESS_KEY"], values["S3_SECRET_KEY"]) + admin.attach_policy( + ["messenger-" + role], user=values["S3_ACCESS_KEY"] + ) + pool.clear() + + +def main(): + raw = json.loads((OPERATOR / "service-secrets.json").read_text()) + postgres(raw) + s3(raw) + print("SQL role grants and scoped S3 accounts prepared; no values printed") + + +if __name__ == "__main__": + main() diff --git a/scripts/research_slo.py b/scripts/research_slo.py new file mode 100644 index 0000000..483a26f --- /dev/null +++ b/scripts/research_slo.py @@ -0,0 +1,633 @@ +"""Thirty-minute controlled SLO study with real DB/worker/backend failures.""" + +import argparse +import csv +import io +import json +import math +import os +import threading +import time +from collections import Counter +from concurrent.futures import ThreadPoolExecutor +from datetime import UTC, datetime +from uuid import uuid4 + +import httpx +from PIL import Image + +os.environ.setdefault("COMPOSE_FILE", "compose.yaml:compose.test.yaml") +from scripts.observe import fetch, logs, queries, spans, wait +from scripts.stand import BASE, ROOT, actor, auth, command, compose, ready, sql + +ERRORS = 'haproxy_backend_http_responses_total{proxy="messenger",code="5xx"}' +RESPONSES = 'haproxy_backend_http_responses_total{proxy="messenger"}' +SIGNALS = { + "api_error_ratio_1m": f"sum(rate({ERRORS}[1m])) / clamp_min(sum(rate({RESPONSES}[1m])),0.001)", + "queue_depth": "max(messenger_queue_depth)", + "oldest_job_age": "max(messenger_oldest_job_age_seconds)", + "worker_busy": "sum(messenger_worker_busy)", + "worker_attempts": "sum(messenger_job_attempts_total)", + "pool_used": 'sum(messenger_db_pool_used{service_name="messenger-api"})', + "pool_waiting": 'sum(messenger_db_pool_waiting{service_name="messenger-api"})', + "http_p95": "histogram_quantile(0.95,sum by(le)(rate(messenger_http_duration_seconds_bucket[1m])))", + "slo_good": 'sum(messenger_slo_decisions_total{outcome="good"})', + "slo_bad": 'sum(messenger_slo_decisions_total{outcome="bad"})', + "collector_received_spans": "sum(otelcol_receiver_accepted_spans)", + "collector_sent_spans": "sum(otelcol_exporter_sent_spans)", + "collector_received_logs": "sum(otelcol_receiver_accepted_log_records)", + "collector_sent_logs": "sum(otelcol_exporter_sent_log_records)", + "collector_failed_spans": "sum(otelcol_exporter_send_failed_spans)", + "collector_queue": "sum(otelcol_exporter_queue_size)", + "collector_queue_capacity": "sum(otelcol_exporter_queue_capacity)", + "collector_memory": 'otelcol_process_memory_rss{job="collector"}', + "app_memory": "sum(messenger_process_memory_bytes)", +} +BURN_ALERTS = {"ApiFastBurn", "ApiSlowBurn", "ReadyFastBurn", "ReadySlowBurn"} + + +def snapshot(phase): + observed = queries(SIGNALS) + values = {} + for key, rows in observed.items(): + value = float(rows[0]["value"][1]) if rows else None + values[key] = ( + value if value is not None and math.isfinite(value) else None + ) + alerts = fetch("prometheus", "/api/v1/alerts")["data"]["alerts"] + return { + "at": time.time(), + "phase": phase, + "signals": values, + "alerts": [ + { + "name": a["labels"]["alertname"], + "state": a["state"], + "active_at": a.get("activeAt"), + } + for a in alerts + ], + } + + +def firing(samples): + return { + a["name"] + for sample in samples + for a in sample["alerts"] + if a["state"] == "firing" + } + + +class Workload: + def __init__(self, client, headers, chat): + self.client, self.headers, self.chat = client, headers, chat + self.stop = threading.Event() + self.phase = "warmup" + self.requests = [] + self.uploads = [] + self.lock = threading.Lock() + self.slots = threading.BoundedSemaphore(16) + self.pool = ThreadPoolExecutor(max_workers=16) + image = io.BytesIO() + Image.new("RGB", (320, 200), (39, 102, 157)).save(image, "PNG") + self.raw = image.getvalue() + self.threads = [ + threading.Thread(target=self.schedule_messages), + threading.Thread(target=self.schedule_uploads), + ] + + def write(self): + started, phase, trace_id = time.time(), self.phase, uuid4().hex + status, identity = 0, "" + try: + response = self.client.post( + f"/api/v1/chats/{self.chat}/messages", + headers={ + **self.headers, + "Idempotency-Key": uuid4().hex, + "traceparent": "00-" + + trace_id + + "-" + + uuid4().hex[:16] + + "-01", + }, + json={"text": "Synthetic SLO message " + uuid4().hex}, + ) + status = response.status_code + if status == 201: + identity = response.json()["id"] + except httpx.HTTPError: + pass + finally: + with self.lock: + self.requests.append( + [ + started, + phase, + status, + time.time() - started, + trace_id, + identity, + ] + ) + self.slots.release() + + def schedule_messages(self): + next_at = time.monotonic() + while not self.stop.is_set(): + if self.slots.acquire(blocking=False): + self.pool.submit(self.write) + else: + with self.lock: + self.requests.append( + [time.time(), self.phase, -1, 0, "", ""] + ) + next_at += 0.25 + self.stop.wait(max(0, next_at - time.monotonic())) + + def schedule_uploads(self): + while not self.stop.is_set(): + started, phase, trace_id = time.time(), self.phase, uuid4().hex + status, identity = 0, "" + try: + response = self.client.post( + f"/api/v1/chats/{self.chat}/attachments", + params={"filename": "synthetic-slo.png"}, + content=self.raw, + headers={ + **self.headers, + "Content-Type": "image/png", + "traceparent": "00-" + + trace_id + + "-" + + uuid4().hex[:16] + + "-01", + }, + ) + status = response.status_code + if status == 202: + identity = response.json()["id"] + except httpx.HTTPError: + pass + with self.lock: + self.uploads.append( + [started, phase, status, identity, trace_id] + ) + self.stop.wait(max(0, 5 - (time.time() - started))) + + def start(self): + for thread in self.threads: + thread.start() + + def close(self): + self.stop.set() + for thread in self.threads: + thread.join(20) + self.pool.shutdown(wait=True) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--output", default="evidence/slo-research-first.json") + parser.add_argument("--minimum-seconds", type=int, default=1800) + args = parser.parse_args() + output = ROOT / args.output + assert not output.exists(), "Choose a new output path" + report = { + "date": datetime.now(UTC).isoformat(), + "source_commit": command(["git", "rev-parse", "HEAD"]), + "scope": "full30m" + if args.minimum_seconds >= 1800 + else "short-development", + "profile": { + "messages_per_second": 4, + "max_inflight": 16, + "upload_every_seconds": 5, + "image_pixels": [320, 200], + }, + "complete": False, + "samples": [], + "phases": [], + } + study_started = time.monotonic() + output.parent.mkdir(parents=True, exist_ok=True) + load = None + trigger = "lab6_slo_delay_" + uuid4().hex[:8] + with httpx.Client( + base_url=BASE, + timeout=8, + trust_env=False, + limits=httpx.Limits(max_connections=24, max_keepalive_connections=24), + ) as client: + ready(timeout=90) + config = json.loads(compose("config", "--format", "json")) + report["container_limits"] = { + name: { + k: int(service[k]) + if k in {"mem_limit", "memswap_limit", "scale"} + else service[k] + for k in ["cpus", "mem_limit", "memswap_limit", "scale"] + if k in service + } + for name, service in config["services"].items() + } + report["docker_vm"] = json.loads( + command( + [ + "docker", + "info", + "--format", + '{"cpus":{{.NCPU}},"memory_bytes":{{.MemTotal}}}', + ] + ) + ) + report["runtime_versions"] = sorted( + { + row["metric"].get("service_version", "unknown") + for row in queries( + {"versions": "messenger_process_memory_bytes"} + )["versions"] + } + ) + user, _, session = actor(client) + headers = auth(session) + response = client.post( + "/api/v1/chats", + headers=headers, + json={ + "title": "Synthetic SLO experiment", + "member_ids": [user["id"]], + }, + ) + assert response.status_code == 201 + chat = response.json()["id"] + load = Workload(client, headers, chat) + workload = load + + def save(): + output.write_text( + json.dumps(report, ensure_ascii=False, indent=2) + "\n" + ) + + def hold(name, seconds, *, until_clear=None, max_seconds=None): + load.phase = name + phase = { + "name": name, + "start": time.time(), + "planned_seconds": seconds, + "maximum_seconds": max_seconds or seconds, + } + report["phases"].append(phase) + minimum_end = time.monotonic() + seconds + deadline = time.monotonic() + (max_seconds or seconds) + start_index = len(report["samples"]) + while time.monotonic() < deadline: + sample = snapshot(name) + report["samples"].append(sample) + save() + if ( + until_clear is not None + and time.monotonic() >= minimum_end + and not until_clear.intersection(firing([sample])) + ): + break + time.sleep(min(5, max(0, deadline - time.monotonic()))) + phase["end"] = time.time() + phase["firing"] = sorted(firing(report["samples"][start_index:])) + return phase + + def db_delay(on): + if on: + sql( + f"CREATE FUNCTION {trigger}() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN IF NEW.chat_id='{chat}'::uuid THEN PERFORM pg_sleep(3); END IF; RETURN NEW; END $$; CREATE TRIGGER {trigger} BEFORE INSERT ON messages FOR EACH ROW EXECUTE FUNCTION {trigger}()" + ) + else: + sql( + f"DROP TRIGGER IF EXISTS {trigger} ON messages; DROP FUNCTION IF EXISTS {trigger}()" + ) + + try: + load.start() + warm = hold("warmup", 300) + settled = [ + s for s in report["samples"] if s["at"] >= warm["end"] - 60 + ] + assert not BURN_ALERTS.intersection(firing(settled)), ( + "Baseline is not clean" + ) + assert ( + report["samples"][-1]["signals"]["collector_memory"] + is not None + ) + report["baseline"] = snapshot("baseline") + for signal in ["api", "ready"]: + if signal == "api": + activate, restore = ( + lambda: db_delay(True), + lambda: db_delay(False), + ) + else: + + def activate(): + return compose("stop", "--timeout", "1", "worker") + + def restore(): + return compose( + "up", "-d", "--no-deps", "--no-recreate", "worker" + ) + + brief_started = time.time() + activate() + brief = hold(signal + "_brief", 5) + restore() + settle = hold( + signal + "_brief_recovery", 120 if signal == "api" else 60 + ) + assert not BURN_ALERTS.intersection( + brief["firing"] + settle["firing"] + ), "Brief incident triggered paging" + report.setdefault("short_spikes", []).append( + { + "signal": signal, + "action_started": brief_started, + "paging_events": 0, + } + ) + action_started = time.time() + activate() + action_finished = time.time() + degraded = hold( + signal + "_sustained", 180 if signal == "api" else 150 + ) + restore_started = time.time() + restore() + restore_finished = time.time() + expected = ( + {"ApiFastBurn", "ApiSlowBurn", "ApiHighErrorRate"} + if signal == "api" + else {"ReadyFastBurn", "ReadySlowBurn", "QueueLagGrowing"} + ) + recovered = hold( + signal + "_recovery", + 150 if signal == "api" else 240, + until_clear=expected, + max_seconds=600, + ) + assert expected <= set(degraded["firing"]), ( + signal, + degraded["firing"], + ) + last = report["samples"][-1] + assert not expected.intersection(firing([last])), ( + "Incident alerts did not resolve" + ) + points = [ + s + for s in report["samples"] + if action_finished <= s["at"] <= recovered["end"] + ] + timings = {} + for name in sorted(expected): + first = next( + s["at"] for s in points if name in firing([s]) + ) + resolved = next( + s["at"] + for s in points + if s["at"] >= restore_finished + and name not in firing([s]) + ) + timings[name] = { + "detect_seconds": round(first - action_finished, 3), + "resolve_seconds": round( + resolved - restore_finished, 3 + ), + } + report.setdefault("incidents", []).append( + { + "signal": signal, + "action_started": action_started, + "action_finished": action_finished, + "restore_started": restore_started, + "restore_finished": restore_finished, + "timings": timings, + } + ) + if signal == "api": + candidates = [ + r + for r in load.requests + if action_finished <= r[0] <= restore_started + and r[2] >= 500 + ] + assert candidates + items = wait( + lambda identity=candidates[0][4]: spans(identity) + ) + assert any( + s["name"] == "db.postgresql" + and s["duration_seconds"] >= 2 + and s["status"].get("code") in {2, "STATUS_CODE_ERROR"} + for s in items + ) + report["database_diagnostic_trace"] = items + else: + assert ( + max( + s["signals"]["oldest_job_age"] or 0 for s in points + ) + > 20 + ) + assert ( + max(s["signals"]["queue_depth"] or 0 for s in points) + > 0 + ) + accepted = [ + r + for r in load.uploads + if action_finished <= r[0] <= restore_started + and r[2] == 202 + ] + assert accepted + report["worker_recovered_trace"] = wait( + lambda identity=accepted[0][4]: spans(identity) + ) + report["worker_recovered_attachment"] = accepted[0][3] + outage_before = snapshot("backend_before") + outage_started = time.time() + compose("stop", "--timeout", "1", "loki", "tempo") + outage = hold("backend_unavailable", 90) + points = [ + s + for s in report["samples"] + if s["phase"] == "backend_unavailable" + ] + assert max( + s["signals"]["collector_failed_spans"] or 0 for s in points + ) > (outage_before["signals"]["collector_failed_spans"] or 0) + assert all( + s["signals"]["collector_queue"] is not None + and s["signals"]["collector_queue_capacity"] is not None + and s["signals"]["collector_memory"] is not None + for s in points + ) + assert all( + (s["signals"]["collector_queue"] or 0) + <= (s["signals"]["collector_queue_capacity"] or 0) + for s in points + ) + assert ( + max(s["signals"]["collector_memory"] for s in points) + < report["container_limits"]["otel"]["mem_limit"] + ) + assert not BURN_ALERTS.intersection(outage["firing"]) + during = [ + r for r in load.requests if r[1] == "backend_unavailable" + ] + assert during and all(r[2] == 201 for r in during) + before_ready = sql( + "SELECT count(*) FROM attachments WHERE state='ready'" + ) + compose("up", "-d", "--no-deps", "--no-recreate", "loki", "tempo") + wait(lambda: fetch("loki", "/ready", json_result=False)) + wait(lambda: fetch("tempo", "/ready", json_result=False)) + hold("backend_recovery", 60) + restored = next( + r + for r in reversed(load.uploads) + if r[1] == "backend_recovery" and r[2] == 202 + ) + wait( + lambda: any( + s["name"] == "attachment.process" + for s in spans(restored[4]) + ) + ) + wait(lambda: logs(restored[4]).get("data", {}).get("result")) + report["backend_outage"] = { + "started": outage_started, + "finished": outage["end"], + "before": outage_before, + "after": snapshot("backend_after"), + "ready_count_before_backend_recovery": int(before_ready), + "successful_writes_during_outage": len(during), + "restored_trace_id": restored[4], + "queue_bounded": True, + "collector_rss_below_limit": True, + "send_failure_counter_counts_attempts_not_unique_loss": True, + } + remaining = args.minimum_seconds - ( + time.monotonic() - study_started + ) + if remaining > 0: + hold("steady_after_recovery", remaining) + load.close() + load = None + # Read through the public API: a successful SQL insert alone is not + # proof that every acknowledged message remains accessible. + seen, cursor = set(), None + while True: + page = client.get( + f"/api/v1/chats/{chat}/messages", + headers=headers, + params={ + "limit": 100, + **({"cursor": cursor} if cursor else {}), + }, + ) + page.raise_for_status() + data = page.json() + ids = [row["id"] for row in data["items"]] + assert len(ids) == len(set(ids)) and not seen.intersection(ids) + seen.update(ids) + cursor = data.get("next_cursor") + if not cursor: + break + expected_messages = { + r[5] for r in workload.requests if r[2] == 201 + } + assert seen == expected_messages + accepted_uploads = [r for r in workload.uploads if r[2] == 202] + for row in accepted_uploads: + + def completed(identity=row[3]): + response = client.get( + f"/api/v1/attachments/{identity}", headers=headers + ) + return ( + response.status_code == 200 + and response.json()["status"] == "ready" + ) + + wait(completed, timeout=120) + for row in accepted_uploads[ + :: max(1, len(accepted_uploads) // 10) + ]: + response = client.get( + f"/api/v1/attachments/{row[3]}/content", headers=headers + ) + assert ( + response.status_code == 200 + and response.content == workload.raw + ) + report["preservation"] = { + "acknowledged_messages": len(expected_messages), + "accessible_messages": len(seen), + "accepted_uploads": len(accepted_uploads), + "all_accepted_uploads_ready": True, + "sampled_originals_match": True, + } + report["rules"] = fetch("prometheus", "/api/v1/rules") + report["final_30m_sli"] = queries( + { + "api_good_ratio": f"1 - sum(increase({ERRORS}[30m])) / clamp_min(sum(increase({RESPONSES}[30m])),1)", + "ready_good_ratio": 'sum(increase(messenger_slo_decisions_total{outcome="good"}[30m])) / clamp_min(sum(increase(messenger_slo_decisions_total[30m])),1)', + } + ) + report["complete"] = True + finally: + try: + db_delay(False) + finally: + compose( + "up", + "-d", + "--no-deps", + "--no-recreate", + "worker", + "loki", + "tempo", + ) + if load is not None: + load.close() + report["elapsed_seconds"] = round( + time.monotonic() - study_started, 3 + ) + request_path = output.with_name(output.stem + "-requests.csv") + with request_path.open("w") as stream: + writer = csv.writer(stream) + writer.writerow( + [ + "timestamp", + "phase", + "status", + "seconds", + "trace_id", + "message_id", + ] + ) + writer.writerows(workload.requests) + report["requests_csv"] = request_path.name + report["request_statuses"] = dict( + Counter(str(r[2]) for r in workload.requests) + ) + report["uploads"] = workload.uploads + save() + print( + "PASS: short/sustained SLO incidents, detection/resolution and controlled false paging" + ) + + +if __name__ == "__main__": + main() diff --git a/scripts/restart.sh b/scripts/restart.sh new file mode 100755 index 0000000..f123bd9 --- /dev/null +++ b/scripts/restart.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu +docker compose restart api postgres cache s3 broker relay worker lb +docker compose up -d --no-build --no-recreate --wait diff --git a/scripts/rolling-update.sh b/scripts/rolling-update.sh new file mode 100755 index 0000000..40ce490 --- /dev/null +++ b/scripts/rolling-update.sh @@ -0,0 +1,3 @@ +#!/bin/sh +set -eu +exec python3 scripts/cluster.py rolling diff --git a/scripts/stand.py b/scripts/stand.py new file mode 100644 index 0000000..315d830 --- /dev/null +++ b/scripts/stand.py @@ -0,0 +1,142 @@ +import json +import os +import subprocess +import time +from pathlib import Path +from uuid import uuid4 + +import httpx + +ROOT = Path(__file__).resolve().parents[1] +BASE = os.environ.get("BASE_URL", "https://localhost:8443") + + +def command(args, *, input=None): + result = subprocess.run( + args, cwd=ROOT, input=input, capture_output=True, text=True + ) + if result.returncode: + raise RuntimeError( + "Command failed: " + + args[0] + + "; " + + result.stderr.replace(str(ROOT), "") + ) + return result.stdout.strip() + + +def compose(*args, input=None): + return command(["docker", "compose", *args], input=input) + + +def sql(query, *, database="messenger"): + return compose( + "exec", + "-T", + "postgres", + "psql", + "-U", + "messenger", + "-d", + database, + "-A", + "-t", + "-v", + "ON_ERROR_STOP=1", + "-c", + query, + ) + + +def cache(command_name, *args): + script = ( + 'export REDISCLI_AUTH="$(cat /run/secrets/cache_password)"; ' + 'exec valkey-cli "$@"' + ) + return compose( + "exec", "-T", "cache", "sh", "-c", script, "sh", command_name, *args + ) + + +def ready(base=BASE, *, timeout=30): + end = time.monotonic() + timeout + import ssl + + context = ssl.create_default_context(cafile=ROOT / "trust/ca.pem") + with httpx.Client( + base_url=base, trust_env=False, timeout=6, verify=context + ) as client: + while time.monotonic() < end: + try: + if client.get("/health/ready").status_code == 200: + return + except httpx.HTTPError: + pass + time.sleep(0.2) + raise TimeoutError("API readiness") + + +def actor(client): + username = "verify_" + uuid4().hex[:20] + password = "Synthetic-" + uuid4().hex + ":🌍" + result = client.post( + "/api/v1/users", + json={ + "username": username, + "display_name": "Synthetic", + "password": password, + }, + ) + assert result.status_code == 201 + user = result.json() + session = client.post( + "/api/v1/auth/sessions", auth=httpx.BasicAuth(username, password) + ) + assert session.status_code == 201 + return user, password, session.json() + + +def auth(session): + return {"Authorization": "Bearer " + session["token"]} + + +def extra_api(*, ttl=3600, pool_size=1): + name = "mtusi-lab6-test-" + uuid4().hex[:10] + compose( + "run", + "-d", + "--no-deps", + "--name", + name, + "-e", + "SESSION_TTL_SECONDS=" + str(ttl), + "-e", + "DB_POOL_SIZE=" + str(pool_size), + "-p", + "127.0.0.1::8080", + "api", + ) + try: + info = json.loads(command(["docker", "inspect", name]))[0] + base = ( + "http://127.0.0.1:" + + info["NetworkSettings"]["Ports"]["8080/tcp"][0]["HostPort"] + ) + ready(base) + return name, base + except Exception: + command(["docker", "rm", "-f", name]) + raise + + +def instances(): + data = {} + for role in ["api", "postgres", "cache"]: + cid = compose("ps", "-q", role) + info = json.loads(command(["docker", "inspect", cid]))[0] + data[role] = { + "container": cid[:12], + "pid": info["State"]["Pid"], + "started_at": info["State"]["StartedAt"], + } + return data diff --git a/scripts/stop-one.sh b/scripts/stop-one.sh new file mode 100755 index 0000000..a066590 --- /dev/null +++ b/scripts/stop-one.sh @@ -0,0 +1,3 @@ +#!/bin/sh +set -eu +exec python3 scripts/cluster.py stop diff --git a/scripts/stop-worker.sh b/scripts/stop-worker.sh new file mode 100755 index 0000000..2f4ef64 --- /dev/null +++ b/scripts/stop-worker.sh @@ -0,0 +1,3 @@ +#!/bin/sh +set -eu +docker compose stop --timeout 1 worker diff --git a/scripts/up_security.py b/scripts/up_security.py new file mode 100644 index 0000000..c41964f --- /dev/null +++ b/scripts/up_security.py @@ -0,0 +1,115 @@ +"""Explicit local operator bootstrap; an ordinary API restart needs no unseal.""" + +import argparse +import json +import os +import subprocess +import time + +from scripts.bao_operator import Operator +from scripts.bootstrap_security import OPERATOR, generate +from scripts.prepare_dependencies import main as dependencies +from scripts.prepare_dependencies import postgres +from scripts.stand import ROOT, command, compose, ready + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--build", action="store_true") + args = parser.parse_args() + generate() + os.environ.setdefault("VCS_REF", command(["git", "rev-parse", "HEAD"])) + if args.build: + subprocess.run( + ["docker", "compose", "build", "api", "s3"], cwd=ROOT, check=True + ) + compose("run", "--rm", "--no-deps", "identity-init") + compose( + "up", "-d", "--no-deps", "openbao", "postgres", "cache", "broker", "s3" + ) + operator = Operator() + try: + for attempt in range(90): + try: + operator.call("GET", "sys/init") + break + except Exception: + if attempt == 89: + raise RuntimeError( + "OpenBao TLS startup unavailable" + ) from None + time.sleep(1) + operator.init() + operator.unseal() + operator.configure() + finally: + operator.close() + agents = [ + "identity-" + r + for r in [ + "openbao", + "api", + "worker", + "relay", + "observer", + "reconciler", + "postgres", + "cache", + "broker", + "s3", + "otel", + "prometheus", + "loki", + "tempo", + "grafana", + ] + ] + compose("up", "-d", "--no-deps", *agents) + compose("up", "-d", "--no-deps", "postgres-tls") + compose( + "--profile", "maintenance", "up", "-d", "--no-deps", "identity-migrate" + ) + try: + compose( + "--profile", "maintenance", "run", "--rm", "--no-deps", "migrate" + ) + finally: + compose("--profile", "maintenance", "stop", "identity-migrate") + postgres(json.loads((OPERATOR / "service-secrets.json").read_text())) + compose("up", "-d", "--no-deps", "telemetry-init") + compose("wait", "telemetry-init") + backends = ["otel", "prometheus", "loki", "tempo", "grafana", "lb"] + compose("up", "-d", "--no-deps", *backends) + gates = [ + r + "-tls" + for r in [ + "postgres", + "s3", + "cache", + "broker", + "otel", + "prometheus", + "loki", + "tempo", + "grafana", + "lb", + ] + ] + compose("up", "-d", "--no-deps", *gates, "identity-lb") + dependencies() + compose( + "up", + "-d", + "--no-deps", + "api", + "relay", + "worker", + "observer", + "reconciler", + ) + ready(timeout=120) + print("Secure stand ready at https://localhost:8443; values remain local") + + +if __name__ == "__main__": + main() diff --git a/scripts/verify_clean.py b/scripts/verify_clean.py new file mode 100644 index 0000000..14fcf45 --- /dev/null +++ b/scripts/verify_clean.py @@ -0,0 +1,286 @@ +import argparse +import atexit +import json +import os +import socket +import subprocess +import tempfile +from datetime import UTC, datetime +from pathlib import Path +from uuid import uuid4 + +ROOT = Path(__file__).resolve().parents[1] +PROGRESS = {} + + +def save_incomplete(): + receipt = PROGRESS.get("receipt") + if receipt and receipt.get("result") != "PASS": + target = PROGRESS["output"].with_name( + PROGRESS["output"].stem + "-failed.json" + ) + if target.exists(): + target = target.with_name( + target.stem + "-" + uuid4().hex[:8] + target.suffix + ) + target.parent.mkdir(parents=True, exist_ok=True) + target.write_text( + json.dumps( + {**receipt, "result": "INCOMPLETE"}, + ensure_ascii=False, + indent=2, + ) + + "\n" + ) + + +atexit.register(save_incomplete) + + +def run(args, *, cwd, env, expected=0): + result = subprocess.run( + args, cwd=cwd, env=env, capture_output=True, text=True + ) + + def redact(text): + return ( + text.replace(str(cwd), "") + .replace(str(ROOT), "") + .replace(str(Path.home()), "") + ) + + if result.returncode != expected: + if "receipt" in PROGRESS: + PROGRESS["receipt"]["failed_action"] = redact(" ".join(args)) + raise RuntimeError(redact(result.stdout + result.stderr)) + return redact(result.stdout.strip()) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--output", default="evidence/clean-clone.json") + args = parser.parse_args() + output = ROOT / args.output + if output.exists(): + raise SystemExit("Choose new output path") + assert not subprocess.check_output( + ["git", "status", "--porcelain"], cwd=ROOT + ) + sha = subprocess.check_output( + ["git", "rev-parse", "HEAD"], cwd=ROOT, text=True + ).strip() + identity = uuid4().hex[:10] + project = "mtusi-lab6-clean-" + identity + with socket.socket() as reservation: + reservation.bind(("127.0.0.1", 0)) + public_port = str(reservation.getsockname()[1]) + with socket.socket() as grafana_reservation: + grafana_reservation.bind(("127.0.0.1", 0)) + grafana_port = str(grafana_reservation.getsockname()[1]) + env = { + **os.environ, + "COMPOSE_PROJECT_NAME": project, + "API_IMAGE": "mtusi-messenger:lab6-clean-" + identity, + "PUBLIC_PORT": public_port, + "GRAFANA_PORT": grafana_port, + "VCS_REF": sha, + "COMPOSE_FILE": "compose.yaml:compose.test.yaml", + "NO_PROXY": "localhost,127.0.0.1", + "no_proxy": "localhost,127.0.0.1", + } + receipt = { + "date": datetime.now(UTC).isoformat(), + "source_commit": sha, + "fresh_secrets_environment_and_volumes": True, + "command": "python scripts/verify_clean.py", + "fixed_host_port_for_restart": int(public_port), + } + PROGRESS.update(receipt=receipt, output=output) + with tempfile.TemporaryDirectory(prefix="mtusi-lab6-clean-") as temporary: + clone = Path(temporary) / "lab6" + run( + [ + "git", + "clone", + "--no-hardlinks", + "--branch", + "solution/bvt2301-maslov", + str(ROOT), + str(clone), + ], + cwd=ROOT, + env=env, + ) + for name in [".env", ".venv", "secrets"]: + assert not (clone / name).exists() + run(["uv", "sync", "--locked"], cwd=clone, env=env) + receipt["static_checks"] = run( + ["make", "check", "validate", "lint", "PYTHON=.venv/bin/python"], + cwd=clone, + env=env, + ) + receipt["unit_tests"] = run(["make", "unit"], cwd=clone, env=env) + run(["make", "bootstrap"], cwd=clone, env=env) + try: + run( + ["docker", "compose", "up", "-d", "--build", "--wait"], + cwd=clone, + env=env, + ) + env["BASE_URL"] = "http://127.0.0.1:" + public_port + receipt["smoke"] = run( + ["make", "test", "BASE_URL=" + env["BASE_URL"]], + cwd=clone, + env=env, + ) + receipt["http_tests"] = run( + [".venv/bin/pytest", "student-tests", "-q"], cwd=clone, env=env + ) + for module, extra in [ + ("verify_telemetry", []), + ( + "verify_observability_persistence", + ["--causal-evidence", "evidence/clean-telemetry.json"], + ), + ]: + name = ( + "telemetry" + if module == "verify_telemetry" + else "observability-persistence" + ) + run( + [ + ".venv/bin/python", + "-m", + "scripts." + module, + "--output", + "evidence/clean-" + name + ".json", + *extra, + ], + cwd=clone, + env=env, + ) + receipt[name] = json.loads( + (clone / ("evidence/clean-" + name + ".json")).read_text() + ) + run( + [ + ".venv/bin/python", + "-m", + "scripts.verify_cluster", + "--output", + "evidence/clean-cluster.json", + ], + cwd=clone, + env=env, + ) + for command_args in [ + [ + ".venv/bin/python", + "-m", + "scripts.verify_cleanup", + "seed", + "--seed", + "evidence/clean-gc-seed.json", + ], + [ + ".venv/bin/python", + "-m", + "scripts.verify_pipeline", + "--output", + "evidence/clean-pipeline.json", + ], + [ + ".venv/bin/python", + "-m", + "scripts.verify_cleanup", + "verify", + "--seed", + "evidence/clean-gc-seed.json", + "--output", + "evidence/clean-cleanup.json", + ], + ]: + run(command_args, cwd=clone, env=env) + receipt["pipeline"] = json.loads( + (clone / "evidence/clean-pipeline.json").read_text() + ) + receipt["cleanup"] = json.loads( + (clone / "evidence/clean-cleanup.json").read_text() + ) + receipt["cluster"] = json.loads( + (clone / "evidence/clean-cluster.json").read_text() + ) + import hashlib + + expected = { + p.name: hashlib.sha256(p.read_bytes()).hexdigest() + for p in (clone / "src").glob("*.py") + } + ids = run( + ["docker", "compose", "ps", "-q", "api"], cwd=clone, env=env + ).split() + assert len(ids) == 2 + code = ( + "import hashlib,json,pathlib; print(json.dumps({p.name:" + "hashlib.sha256(p.read_bytes()).hexdigest() for p in pathlib.Path('/app/src').glob('*.py')}))" + ) + ids += run( + [ + "docker", + "compose", + "ps", + "-q", + "worker", + "relay", + "reconciler", + "controller", + "observer", + ], + cwd=clone, + env=env, + ).split() + assert len(ids) == 7 + for cid in ids: + actual = json.loads( + run( + ["docker", "exec", cid, "python", "-c", code], + cwd=clone, + env=env, + ) + ) + assert actual == expected + info = json.loads( + run(["docker", "inspect", cid], cwd=clone, env=env) + )[0] + assert ( + info["Config"]["Labels"][ + "org.opencontainers.image.revision" + ] + == sha + ) + assert not info["HostConfig"]["PortBindings"] + receipt[ + "all_seven_application_roles_runtime_hashes_and_revision_match" + ] = True + receipt["fsck"] = run( + ["git", "fsck", "--full"], cwd=clone, env=env + ) + receipt["checks_completed"] = True + finally: + assert project.startswith("mtusi-lab6-clean-") + run( + ["docker", "compose", "down", "--volumes", "--remove-orphans"], + cwd=clone, + env=env, + ) + receipt["result"] = "PASS" + output.parent.mkdir(parents=True, exist_ok=True) + output.write_text(json.dumps(receipt, ensure_ascii=False, indent=2) + "\n") + print( + "PASS: fresh clone, build, HTTP tests, failover, rolling, persistence and runtime hashes" + ) + + +if __name__ == "__main__": + main() diff --git a/scripts/verify_cleanup.py b/scripts/verify_cleanup.py new file mode 100644 index 0000000..e4e622c --- /dev/null +++ b/scripts/verify_cleanup.py @@ -0,0 +1,223 @@ +"""Real S3 retention test: seed is separate from verification output.""" + +import argparse +import json +import time +from datetime import datetime, timezone +from pathlib import Path +from uuid import uuid4 + +import httpx + +from scripts.stand import BASE, ROOT, actor, auth, command, compose, ready +from scripts.verify_pipeline import inside, operator, wait + + +def seed(path): + if path.exists(): + raise ValueError("Choose a new seed file") + ready() + compose("stop", "--timeout", "1", "reconciler") + raw = (ROOT / "tests/fixtures/sample.png").read_bytes() + with httpx.Client(base_url=BASE, trust_env=False, timeout=20) as c: + user, _, session = actor(c) + headers = auth(session) + result = c.post( + "/api/v1/chats", + headers=headers, + json={ + "title": "Cleanup synthetic seed", + "member_ids": [user["id"]], + }, + ) + assert result.status_code == 201 + chat = result.json()["id"] + r = c.post( + f"/api/v1/chats/{chat}/attachments", + headers={**headers, "Content-Type": "image/png"}, + params={"filename": "retained.png"}, + content=raw, + ) + assert r.status_code == 202 + attachment = r.json()["id"] + wait( + lambda: ( + c.get( + "/api/v1/attachments/" + attachment, headers=headers + ).json()["status"] + == "ready" + ) + ) + job = inside( + f"with db.connection() as c: r=c.execute('SELECT id FROM jobs WHERE attachment_id=%s',({attachment!r},)).fetchone()\nprint(json.dumps(str(r['id'])))" + ) + data = { + "seed_id": uuid4().hex, + "source_commit": command(["git", "rev-parse", "HEAD"]), + "date": datetime.now(timezone.utc).isoformat(), + "ready_attachment": attachment, + "ready_job": job, + "chat": chat, + "owner": user["id"], + } + # Real old v1 objects will become obsolete after v2 is ready. + second = operator(job, version=2) + wait( + lambda: inside( + f"with db.connection() as c: r=c.execute('SELECT state FROM jobs WHERE id=%s',({second!r},)).fetchone()\nprint(json.dumps(r['state']=='ready'))" + ) + ) + data["version2_job"] = second + data["orphan"] = f"objects/cleanup-{data['seed_id']}/old-orphan" + data["failed_id"] = str(uuid4()) + data["active_id"] = str(uuid4()) + data["reservation_id"] = str(uuid4()) + data["expired_reservation_id"] = str(uuid4()) + data["failed_source"] = f"objects/staging/{data['failed_id']}/original" + data["active_source"] = f"objects/staging/{data['active_id']}/original" + data["reservation_key"] = ( + f"objects/staging/{data['reservation_id']}/original" + ) + data["expired_reservation_key"] = ( + f"objects/staging/{data['expired_reservation_id']}/original" + ) + inside(f"""from pathlib import Path +raw=Path('/app/src/__init__.py').read_bytes() or b'fixture' +keys={json.dumps([data[k] for k in ["orphan", "failed_source", "active_source", "reservation_key", "expired_reservation_key"]])} +for key in keys: store.put(key=key,stream=io.BytesIO(raw),size=len(raw),content_type='image/png',sha256=hashlib.sha256(raw).hexdigest()) +with db.connection() as c, c.transaction(): + for identity,state in [({data["failed_id"]!r},'failed'),({data["active_id"]!r},'processing')]: + key='objects/staging/'+identity+'/original' + c.execute(\"INSERT INTO attachments(id,chat_id,owner_id,filename,content_type,size_bytes,sha256,object_key,state,error_code,uploader_instance,expires_at) VALUES(%s,%s,%s,'synthetic.png','image/png',%s,%s,%s,%s,%s,'cleanup-fixture',clock_timestamp())\",(identity,{chat!r},{user["id"]!r},len(raw),hashlib.sha256(raw).hexdigest(),key,state,'invalid_image' if state=='failed' else None)) + c.execute(\"INSERT INTO jobs(id,attachment_id,pipeline_version,source_key,state,attempt,lease_until,updated_at,error_code) VALUES(%s,%s,1,%s,%s,1,clock_timestamp()+interval '1 hour',clock_timestamp()-interval '2 days',%s)\",(uuid4(),identity,key,state,'invalid_image' if state=='failed' else None)) + c.execute(\"INSERT INTO upload_reservations(id,object_key,expires_at) VALUES(%s,%s,clock_timestamp()+interval '1 hour'),(%s,%s,clock_timestamp()-interval '1 second')\",({data["reservation_id"]!r},{data["reservation_key"]!r},{data["expired_reservation_id"]!r},{data["expired_reservation_key"]!r})) +print('true')""") + data["seeded_unix"] = time.time() + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n") + print( + "PASS: retention seed created; real S3 age must reach300s", flush=True + ) + + +def verify(seed_path, output): + if output.exists(): + raise ValueError("Choose a new output path") + data = json.loads(seed_path.read_text()) + report = { + "source_commit": command(["git", "rev-parse", "HEAD"]), + "seed": seed_path.name, + "complete": False, + } + try: + compose("stop", "--timeout", "1", "reconciler") + + def age(): + return inside( + f"h=store.head(key={data['orphan']!r})\nassert h is not None\nwith db.connection() as c: now=c.execute('SELECT clock_timestamp() now').fetchone()['now']\nprint(json.dumps((now-h.last_modified).total_seconds()))" + ) + + while age() < 302: + time.sleep(min(5, 303 - age())) + report["real_s3_age_seconds"] = age() + fresh = f"objects/cleanup-{data['seed_id']}/fresh-orphan" + inside( + f"b=b'fresh'\nstore.put(key={fresh!r},stream=io.BytesIO(b),size=len(b),content_type='image/png',sha256=hashlib.sha256(b).hexdigest())\nprint('true')" + ) + oldkeys = [ + data["orphan"], + data["failed_source"], + data["expired_reservation_key"], + ] + [ + f"objects/{data['ready_attachment']}/v1/{v}" + for v in ["original", "thumbnail", "crop", "optimized"] + ] + protected = [data["active_source"], data["reservation_key"], fresh] + [ + f"objects/{data['ready_attachment']}/v2/{v}" + for v in ["original", "thumbnail", "crop", "optimized"] + ] + before = inside( + f"print(json.dumps({{k:store.head(key=k) is not None for k in {oldkeys + protected!r}}}))" + ) + assert all(before.values()) + dry = inside( + "print(json.dumps(reconcile(db,store,apply=False,grace=300)))" + ) + candidates = {a["key"] for a in dry["actions"]} + assert set(oldkeys) <= candidates and not set(protected) & candidates + afterdry = inside( + f"print(json.dumps({{k:store.head(key=k) is not None for k in {oldkeys + protected!r}}}))" + ) + assert afterdry == before + applied = inside( + "print(json.dumps(reconcile(db,store,apply=True,grace=300)))" + ) + repeat = inside( + "print(json.dumps(reconcile(db,store,apply=True,grace=300)))" + ) + assert not repeat["actions"] + after = inside( + f"print(json.dumps({{k:store.head(key=k) is not None for k in {oldkeys + protected!r}}}))" + ) + assert all(not after[k] for k in oldkeys) and all( + after[k] for k in protected + ) + failed = inside( + f"with db.connection() as c: j=c.execute('SELECT id,error_code FROM jobs WHERE attachment_id=%s',({data['failed_id']!r},)).fetchone()\nprint(json.dumps(j,default=str))" + ) + assert failed["error_code"] == "source_expired" + try: + operator(failed["id"]) + except RuntimeError: + replay_refused = True + else: + raise AssertionError("Expired source replay must fail") + # Expired reservation was removed, so a delayed API cannot commit its handoff. + fenced = inside( + f"with db.connection() as c: r=c.execute('SELECT count(*) n FROM upload_reservations WHERE id=%s AND expires_at>clock_timestamp()',({data['expired_reservation_id']!r},)).fetchone()\nprint(json.dumps(r['n']==0))" + ) + assert fenced + report.update( + dry_run=dry, + apply=applied, + repeat=repeat, + before=before, + after=after, + dry_run_unchanged=True, + active_current_and_fresh_protected=True, + expired_source_replay_refused=replay_refused, + expired_writer_fenced=fenced, + complete=True, + ) + finally: + # Remove only this fixture's artificial active reservation/job; never real jobs. + inside( + f"with db.connection() as c, c.transaction():\n c.execute(\"UPDATE jobs SET state='failed',error_code='fixture_complete',lease_until=NULL WHERE attachment_id=%s\",({data['active_id']!r},))\n c.execute(\"UPDATE attachments SET state='failed',error_code='fixture_complete' WHERE id=%s\",({data['active_id']!r},))\n c.execute('DELETE FROM upload_reservations WHERE id=%s',({data['reservation_id']!r},))\nprint('true')" + ) + compose("up", "-d", "--no-deps", "--no-recreate", "reconciler") + output.parent.mkdir(parents=True, exist_ok=True) + output.write_text( + json.dumps(report, ensure_ascii=False, indent=2) + "\n" + ) + print( + "PASS: real retention, dry-run/apply/repeat, current/active/fresh protection", + flush=True, + ) + + +def main(): + p = argparse.ArgumentParser() + p.add_argument("action", choices=["seed", "verify"]) + p.add_argument("--seed", required=True, type=Path) + p.add_argument("--output", type=Path) + a = p.parse_args() + if a.action == "seed": + seed(a.seed) + else: + if a.output is None: + p.error("output required") + verify(a.seed, a.output) + + +if __name__ == "__main__": + main() diff --git a/scripts/verify_cluster.py b/scripts/verify_cluster.py new file mode 100644 index 0000000..19be419 --- /dev/null +++ b/scripts/verify_cluster.py @@ -0,0 +1,347 @@ +"""Проверки реальных процессов, failover, rolling и общей идемпотентности.""" + +import argparse +import json +import os +import subprocess +import threading +import time +from concurrent.futures import ThreadPoolExecutor +from datetime import datetime, timezone +from pathlib import Path +from uuid import uuid4 + +import httpx + +from scripts import cluster +from scripts.stand import BASE, ROOT, actor, auth, command, compose, ready, sql + + +def snapshot(): + ids = compose("ps", "-q").split() + result = [] + for c in json.loads(command(["docker", "inspect", *ids])): + role = c["Config"]["Labels"]["com.docker.compose.service"] + entry = { + "role": role, + "container": c["Id"][:12], + "pid": c["State"]["Pid"], + "started_at": c["State"]["StartedAt"], + "ports": c["HostConfig"]["PortBindings"], + "cpu_nano": c["HostConfig"]["NanoCpus"], + "memory_limit": c["HostConfig"]["Memory"], + } + if role == "api": + entry["instance"] = cluster.alias(c["Id"]) + assert not entry["ports"] + result.append(entry) + return result + + +def exercise(client, session, chat, action, *, seconds=15): + path = f"/api/v1/chats/{chat['id']}/messages" + observations, confirmed, errors, reads = [], {}, 0, 0 + started = time.monotonic() + finished = threading.Event() + action_result = {} + + def operate(): + time.sleep(0.5) + try: + action() + except BaseException as exc: + action_result["error"] = type(exc).__name__ + finally: + action_result["finished"] = round(time.monotonic() - started, 3) + finished.set() + + thread = threading.Thread(target=operate) + thread.start() + key = uuid4().hex + try: + while ( + time.monotonic() - started < seconds + or not finished.is_set() + or time.monotonic() - started + < action_result.get("finished", 0) + 2 + ): + h = {**auth(session), "Idempotency-Key": key} + try: + r = client.post(path, headers=h, json={"text": key}) + if r.status_code != 201: + errors += 1 + continue + m = r.json() + confirmed[m["id"]] = m + observations.append( + { + "at": round(time.monotonic() - started, 3), + "instance": r.headers["x-instance-id"], + } + ) + key = uuid4().hex + read = client.get( + path, headers=auth(session), params={"limit": 100} + ) + reads += read.status_code == 200 + errors += read.status_code != 200 + except httpx.HTTPError: + errors += 1 + time.sleep(0.04) + finally: + thread.join(timeout=90) + assert not action_result.get("error"), action_result + found, cursor = [], None + while True: + r = client.get( + path, + headers=auth(session), + params={"limit": 100, **({"cursor": cursor} if cursor else {})}, + ) + assert r.status_code == 200 + page = r.json() + found.extend(page["items"]) + cursor = page["next_cursor"] + if not cursor: + break + by_id = {m["id"]: m for m in found} + assert all(by_id.get(k) == v for k, v in confirmed.items()) + texts = [m["text"] for m in found] + assert len(texts) == len(set(texts)) + recovery = next( + ( + x["at"] + for x in observations + if x["at"] >= action_result["finished"] + ), + None, + ) + assert recovery is not None and (seconds > 20 or recovery <= 10) + elapsed = time.monotonic() - started + return { + "confirmed_writes": len(confirmed), + "successful_reads": reads, + "errors": errors, + "successful_rps": round((len(confirmed) + reads) / elapsed, 2), + "first_success_after_action_seconds": recovery, + "action": action_result, + "observations": observations, + "confirmed_preserved": True, + "duplicate_texts": False, + } + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--output", default="evidence/cluster-repeat.json") + args = parser.parse_args() + report = { + "date": datetime.now(timezone.utc).isoformat(), + "source_commit": command(["git", "rev-parse", "HEAD"]), + "complete": False, + } + output = Path(args.output) + output.parent.mkdir(parents=True, exist_ok=True) + try: + ready() + initial = snapshot() + apis = [c for c in initial if c["role"] == "api"] + assert len(apis) == 2 and len({c["pid"] for c in apis}) == 2 + report["before"] = initial + with httpx.Client(base_url=BASE, trust_env=False, timeout=8) as client: + user, _, session = actor(client) + r = client.post( + "/api/v1/chats", + headers=auth(session), + json={ + "title": "Cluster verification", + "member_ids": [user["id"]], + }, + ) + assert r.status_code == 201 + chat = r.json() + path = f"/api/v1/chats/{chat['id']}/messages" + key = uuid4().hex + + def repeat(_): + with httpx.Client( + base_url=BASE, trust_env=False, timeout=8 + ) as c: + r = c.post( + path, + headers={**auth(session), "Idempotency-Key": key}, + json={"text": "Same concurrent request"}, + ) + assert r.status_code == 201 + return r.json(), r.headers["x-instance-id"] + + with ThreadPoolExecutor(max_workers=10) as pool: + repeated = list(pool.map(repeat, range(30))) + assert len({m[0]["id"] for m in repeated}) == 1 + assert len({m[1] for m in repeated}) == 2 + report["parallel_replay"] = { + "requests": 30, + "messages": 1, + "instances": sorted({m[1] for m in repeated}), + } + # Сбой второй записи транзакции не должен оставить сообщение. + fault_key = uuid4().hex + fault_text = "Atomic rollback " + fault_key + sql( + "CREATE FUNCTION student_idempo_fault() RETURNS trigger " + "LANGUAGE plpgsql AS $$ BEGIN IF NEW.key='" + + fault_key + + "' THEN RAISE EXCEPTION 'synthetic'; END IF; RETURN NEW; END $$; " + "CREATE TRIGGER student_idempo_fault BEFORE INSERT ON idempotency " + "FOR EACH ROW EXECUTE FUNCTION student_idempo_fault()" + ) + try: + failed = client.post( + path, + headers={**auth(session), "Idempotency-Key": fault_key}, + json={"text": fault_text}, + ) + assert failed.status_code == 500 + assert ( + sql( + "SELECT count(*) FROM messages WHERE text='" + + fault_text + + "'" + ) + == "0" + ) + finally: + sql( + "DROP TRIGGER student_idempo_fault ON idempotency; " + "DROP FUNCTION student_idempo_fault()" + ) + retried = client.post( + path, + headers={**auth(session), "Idempotency-Key": fault_key}, + json={"text": fault_text}, + ) + assert retried.status_code == 201 + report["atomic_rollback_and_5xx_retry"] = True + sql( + "UPDATE idempotency SET expires_at=clock_timestamp()-interval '1 second' " + "WHERE key='" + fault_key + "'" + ) + expired = client.post( + path, + headers={**auth(session), "Idempotency-Key": fault_key}, + json={"text": "New retention window"}, + ) + assert expired.status_code == 201 + assert expired.json()["id"] != retried.json()["id"] + report["expired_key_can_be_reused"] = True + # Отдельный чат каждой серии: проверки дубликатов не смешивают тексты. + report["failovers"] = [] + for api in apis: + + def stop(target=api["instance"]): + env = {**os.environ, "TARGET_INSTANCE_ID": target} + subprocess.run( + ["scripts/stop-one.sh"], + cwd=ROOT, + env=env, + check=True, + capture_output=True, + text=True, + ) + + r = client.post( + "/api/v1/chats", + headers=auth(session), + json={"title": "Failover", "member_ids": [user["id"]]}, + ) + result = exercise(client, session, r.json(), stop) + assert api["instance"] not in [ + o["instance"] for o in result["observations"][-5:] + ] + assert ( + command( + [ + "docker", + "inspect", + "-f", + "{{.State.Running}}", + api["container"], + ] + ) + == "false" + ) + result["stopped"] = api + report["failovers"].append(result) + compose("up", "-d", "--no-build", "--wait") + ready() + r = client.post( + "/api/v1/chats", + headers=auth(session), + json={"title": "Rolling", "member_ids": [user["id"]]}, + ) + before_roll = snapshot() + report["rolling"] = exercise( + client, + session, + r.json(), + lambda: command(["scripts/rolling-update.sh"]), + seconds=45, + ) + after_roll = snapshot() + assert not ( + {c["container"] for c in before_roll if c["role"] == "api"} + & {c["container"] for c in after_roll if c["role"] == "api"} + ) + report["rolling"]["before"] = before_roll + report["rolling"]["after"] = after_roll + replay = repeat(0)[0] + assert replay == repeated[0][0] + report["replay_after_replacement"] = True + before = snapshot() + env = { + **os.environ, + "NO_PROXY": "localhost,127.0.0.1", + "no_proxy": "localhost,127.0.0.1", + } + for mode, hook in [ + ("failover", "scripts/stop-one.sh"), + ("persistence", "scripts/restart.sh"), + ]: + if mode == "persistence": + compose("up", "-d", "--no-build", "--wait") + ready() + before = snapshot() + run = subprocess.run( + [ + ".venv/bin/python", + "tests/resilience.py", + "--mode", + mode, + "--action-script", + hook, + "--base-url", + BASE, + ], + cwd=ROOT, + env=env, + capture_output=True, + text=True, + ) + assert run.returncode == 0, run.stdout + run.stderr + report["public_" + mode] = run.stdout.strip() + after = snapshot() + for role in ["postgres", "cache", "s3", "broker", "lb"]: + old = next(c for c in before if c["role"] == role) + new = next(c for c in after if c["role"] == role) + assert old["started_at"] != new["started_at"] + report["after_persistence"] = after + report["complete"] = True + finally: + output.write_text( + json.dumps(report, ensure_ascii=False, indent=2) + "\n" + ) + print("PASS: process failover, rolling, replay and full persistence") + + +if __name__ == "__main__": + main() diff --git a/scripts/verify_observability_persistence.py b/scripts/verify_observability_persistence.py new file mode 100644 index 0000000..13e2a59 --- /dev/null +++ b/scripts/verify_observability_persistence.py @@ -0,0 +1,145 @@ +"""Restart actual stores and compare data accepted before the restart.""" + +import argparse +import json +import os +import time +from datetime import UTC, datetime + +import httpx + +os.environ.setdefault("COMPOSE_FILE", "compose.yaml:compose.test.yaml") +from scripts.observe import fetch, logs, query, spans, wait +from scripts.stand import ROOT, command, compose + + +def instances(): + result = {} + for role in ["prometheus", "loki", "tempo", "grafana"]: + cid = compose("ps", "-q", role) + data = json.loads(command(["docker", "inspect", cid]))[0] + result[role] = { + "started_at": data["State"]["StartedAt"], + "volumes": sorted( + m["Name"] for m in data["Mounts"] if m["Type"] == "volume" + ), + "read_only": data["HostConfig"]["ReadonlyRootfs"], + "cap_drop": data["HostConfig"]["CapDrop"], + "user": data["Config"]["User"], + } + return result + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + "--causal-evidence", default="evidence/telemetry-first.json" + ) + parser.add_argument( + "--output", default="evidence/observability-persistence-first.json" + ) + args = parser.parse_args() + output = ROOT / args.output + assert not output.exists() + causal = json.loads((ROOT / args.causal_evidence).read_text()) + assert causal["complete"] + identity = causal["causal_uploads"][0]["trace_id"] + timestamp = time.time() - 20 + historical = query("sum(messenger_http_requests_total)", at=timestamp) + assert historical and spans(identity) and logs(identity)["data"]["result"] + report = { + "date": datetime.now(UTC).isoformat(), + "source_commit": command(["git", "rev-parse", "HEAD"]), + "trace_id": identity, + "historical_query_at": timestamp, + "historical_before": historical, + "before": instances(), + "complete": False, + } + password = (ROOT / "secrets/grafana_password").read_text().strip() + base = "http://127.0.0.1:" + os.getenv("GRAFANA_PORT", "3006") + with httpx.Client( + base_url=base, auth=("admin", password), timeout=10, trust_env=False + ) as grafana: + preferences = grafana.get("/api/user/preferences") + preferences.raise_for_status() + previous = preferences.json() + temporary = { + **previous, + "theme": "light" if previous.get("theme") != "light" else "dark", + } + try: + changed = grafana.put("/api/user/preferences", json=temporary) + changed.raise_for_status() + compose("restart", "prometheus", "loki", "tempo", "grafana") + for role, path in [ + ("prometheus", "/-/ready"), + ("loki", "/ready"), + ("tempo", "/ready"), + ]: + wait( + lambda role=role, path=path: fetch( + role, path, json_result=False + ), + timeout=120, + ) + + def grafana_ready(): + try: + response = grafana.get("/api/health") + return ( + response.status_code == 200 + and response.json()["database"] == "ok" + ) + except httpx.HTTPError: + return False + + wait(grafana_ready, timeout=120) + wait(lambda: spans(identity), timeout=120) + wait(lambda: logs(identity)["data"]["result"], timeout=120) + report["historical_after"] = query( + "sum(messenger_http_requests_total)", at=timestamp + ) + assert report["historical_after"] == historical + assert ( + grafana.get("/api/user/preferences").json()["theme"] + == temporary["theme"] + ) + report["after"] = instances() + for role, before in report["before"].items(): + after = report["after"][role] + assert before["started_at"] != after["started_at"] + assert ( + before["volumes"] == after["volumes"] and before["volumes"] + ) + assert after["read_only"] and after["user"] not in { + "", + "0", + "0:0", + "root", + } + assert "ALL" in after["cap_drop"] + report.update( + stored_trace_survives=True, + stored_logs_survive=True, + historical_metric_survives=True, + grafana_sqlite_preference_survives=True, + complete=True, + ) + finally: + try: + grafana.put( + "/api/user/preferences", json=previous + ).raise_for_status() + finally: + output.parent.mkdir(parents=True, exist_ok=True) + output.write_text( + json.dumps(report, ensure_ascii=False, indent=2) + "\n" + ) + print( + "PASS: metrics, traces, logs and Grafana state survive real store restarts" + ) + + +if __name__ == "__main__": + main() diff --git a/scripts/verify_pipeline.py b/scripts/verify_pipeline.py new file mode 100644 index 0000000..28e9385 --- /dev/null +++ b/scripts/verify_pipeline.py @@ -0,0 +1,687 @@ +"""Repeatable fault injection for grade 5, track 2; synthetic data only.""" + +import argparse +import hashlib +import io +import json +import os +import time +from concurrent.futures import ThreadPoolExecutor +from datetime import datetime, timezone +from uuid import uuid4 + +import httpx +from PIL import Image + +os.environ.setdefault("COMPOSE_FILE", "compose.yaml:compose.test.yaml") +os.environ.setdefault("NO_PROXY", "localhost,127.0.0.1") +os.environ.setdefault("no_proxy", "localhost,127.0.0.1") +from scripts.stand import BASE, ROOT, actor, auth, command, compose, ready + +PREFIX = """import io,json,hashlib,time,urllib.request +from uuid import UUID,uuid4 +from psycopg.types.json import Jsonb +from src.pipeline import database,broker,envelope,STREAM,GROUP +from src.object_store import ObjectStore,BUCKET +from src.operator import change +from src.reconcile import reconcile +db,store,queue=database(),ObjectStore(),broker() +""" + + +def inside(code): + cid = compose("ps", "-q", "controller").split()[0] + return json.loads( + command( + ["docker", "exec", "-i", cid, "python", "-"], input=PREFIX + code + ) + ) + + +def wait(fn, timeout=90): + end = time.monotonic() + timeout + while time.monotonic() < end: + value = fn() + if value: + return value + time.sleep(0.15) + raise TimeoutError("Fault scenario condition not reached") + + +def stop(role): + compose("stop", "--timeout", "1", role) + + +def start(role): + compose("up", "-d", "--no-deps", "--no-recreate", role) + + +def row(job): + return inside( + f"with db.connection() as c: r=c.execute('SELECT * FROM jobs WHERE id=%s',({job!r},)).fetchone()\nprint(json.dumps(r,default=str))" + ) + + +def inject(job, phase, action, remaining=1): + return inside( + f"with db.connection() as c: r=c.execute('INSERT INTO pipeline_faults(target,phase,action,remaining) VALUES(%s,%s,%s,%s) RETURNING id',({job!r},{phase!r},{action!r},{remaining})).fetchone()\nprint(json.dumps(r['id']))" + ) + + +def hit(identity): + return inside( + f"with db.connection() as c: r=c.execute('SELECT hit_at IS NOT NULL hit FROM pipeline_faults WHERE id=%s',({identity},)).fetchone()\nprint(json.dumps(r['hit']))" + ) + + +def operator(job, version=None): + return inside( + f"print(json.dumps(change(db,store,job_id=UUID({job!r}),operator='synthetic-verifier',reason='Explicit fault matrix replay',version={version!r})))" + ) + + +def duplicate(job, count=5): + return inside( + f"with db.connection() as c: r=c.execute('SELECT * FROM jobs WHERE id=%s',({job!r},)).fetchone()\ne=envelope(r)\nids=[queue.xadd(STREAM,{{'job':json.dumps(e)}}) for _ in range({count})]\nprint(json.dumps(ids))" + ) + + +def inspect_effect(job, *, pending=False): + return inside(f"""with db.connection() as c: + j=c.execute('SELECT * FROM jobs WHERE id=%s',({job!r},)).fetchone() + v=c.execute('SELECT name,object_key,sha256,size_bytes FROM attachment_variants WHERE attachment_id=%s AND pipeline_version=%s ORDER BY name',(j['attachment_id'],j['pipeline_version'])).fetchall() + p=c.execute('SELECT count(*) n FROM effect_publications WHERE attachment_id=%s AND pipeline_version=%s',(j['attachment_id'],j['pipeline_version'])).fetchone()['n'] + e=c.execute('SELECT event,detail,created_at FROM pipeline_events WHERE job_id=%s ORDER BY id',({job!r},)).fetchall() +keys=[o.object_name for o in store.objects() if o.object_name.startswith(f"objects/{{j['attachment_id']}}/v{{j['pipeline_version']}}/")] +pending_entries=[] +if {pending!r}: + for item in queue.xpending_range(STREAM,GROUP,'-','+',1000): + entry=item['message_id'] + messages=queue.xrange(STREAM,min=entry,max=entry) + if messages and json.loads(messages[0][1].get('job','{{}}')).get('job_id')==str(j['id']): pending_entries.append(entry) +print(json.dumps({{'job':j,'variants':v,'publications':p,'physical_keys':keys,'events':e,'pending_stream_entries':pending_entries}},default=str))""") + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--output", default="evidence/pipeline-repeat.json") + parser.add_argument("--repeats", type=int, default=2) + parser.add_argument( + "--start-at", choices=["all", "versions"], default="all" + ) + args = parser.parse_args() + output = ROOT / args.output + if output.exists(): + raise ValueError("Choose a new output path") + report = { + "source_commit": command(["git", "rev-parse", "HEAD"]), + "date": datetime.now(timezone.utc).isoformat(), + "track": 2, + "scope": args.start_at, + "complete": False, + "cases": [], + } + output.parent.mkdir(parents=True, exist_ok=True) + + def save(name, details): + report["cases"].append({"case": name, **details}) + output.write_text( + json.dumps(report, ensure_ascii=False, indent=2) + "\n" + ) + print("PASS:", name, flush=True) + + try: + ready() + # Check instrumentation is really enabled and production default is off. + cid = compose("ps", "-q", "api").split()[0] + assert ( + command( + [ + "docker", + "exec", + cid, + "python", + "-c", + "import os;print(os.getenv('PIPELINE_FAULTS'))", + ] + ) + == "1" + ) + stop("reconciler") + with httpx.Client( + base_url=BASE, trust_env=False, timeout=25 + ) as client: + user, _, session = actor(client) + h = auth(session) + c = client.post( + "/api/v1/chats", + headers=h, + json={ + "title": "Pipeline synthetic faults", + "member_ids": [user["id"]], + }, + ) + assert c.status_code == 201 + chat = c.json()["id"] + raw_io = io.BytesIO() + Image.new("RGBA", (320, 200), (20, 50, 170, 120)).save( + raw_io, format="PNG" + ) + raw = raw_io.getvalue() + + def upload(): + r = client.post( + f"/api/v1/chats/{chat}/attachments", + headers={**h, "Content-Type": "image/png"}, + params={"filename": "synthetic.png"}, + content=raw, + ) + assert r.status_code == 202, r.text + a = r.json() + assert a["status"] == "queued" and not a["variants"] + j = inside( + f"with db.connection() as c: r=c.execute('SELECT id FROM jobs WHERE attachment_id=%s',({a['id']!r},)).fetchone()\nprint(json.dumps(str(r['id'])))" + ) + return a, j + + def metadata(a): + r = client.get("/api/v1/attachments/" + a["id"], headers=h) + assert r.status_code == 200, r.text + return r.json() + + def until(a, state="ready", timeout=90): + return wait( + lambda: ( + r if (r := metadata(a))["status"] == state else None + ), + timeout, + ) + + def confirm(a, j): + until(a) + downloaded = client.get( + f"/api/v1/attachments/{a['id']}/content", headers=h + ) + assert ( + downloaded.status_code == 200 and downloaded.content == raw + ) + m = metadata(a) + assert ( + m["sha256"] == hashlib.sha256(raw).hexdigest() + and m["error_code"] is None + ) + assert {v["name"] for v in m["variants"]} == { + "thumbnail", + "crop", + "optimized", + } + for v in m["variants"]: + r = client.get( + f"/api/v1/attachments/{a['id']}/content", + headers=h, + params={"variant": v["name"]}, + ) + assert ( + r.status_code == 200 + and hashlib.sha256(r.content).hexdigest() + == v["sha256"] + ) + with Image.open(io.BytesIO(r.content)) as image: + assert ( + image.size + == { + "thumbnail": (256, 160), + "crop": (128, 128), + "optimized": (320, 200), + }[v["name"]] + ) + assert not image.getexif() + effect = inspect_effect(j) + assert ( + effect["publications"] == 1 + and len(effect["variants"]) == 4 + and len(effect["physical_keys"]) == 4 + ) + return effect + + if args.start_at == "all": + # Source-only crash before the DB handoff must never be reported as accepted. + stop("worker") + stop("relay") + marker = inject(chat, "api_after_staging", "wait") + before = inside( + f"with db.connection() as c: n=c.execute('SELECT count(*) n FROM attachments WHERE chat_id=%s',({chat!r},)).fetchone()['n']\nprint(json.dumps(n))" + ) + pool = ThreadPoolExecutor(max_workers=1) + future = pool.submit( + lambda: client.post( + f"/api/v1/chats/{chat}/attachments", + headers={**h, "Content-Type": "image/png"}, + params={"filename": "unconfirmed.png"}, + content=raw, + ) + ) + wait(lambda marker=marker: hit(marker)) + compose("kill", "-s", "SIGKILL", "api") + try: + response = future.result(15) + assert response.status_code != 202 + except httpx.HTTPError: + pass + pool.shutdown() + start("api") + ready() + after = inside( + f"with db.connection() as c: n=c.execute('SELECT count(*) n FROM attachments WHERE chat_id=%s',({chat!r},)).fetchone()['n']\nprint(json.dumps(n))" + ) + assert before == after + save( + "staging_before_handoff_crash", + { + "no_202": True, + "no_attachment_or_job_created": True, + "orphan_retained_for_cleanup": True, + }, + ) + # API durable commit/outbox survives restart without a broker or worker. + stop("broker") + a, j = upload() + linked = client.post( + f"/api/v1/chats/{chat}/messages", + headers={**h, "Idempotency-Key": uuid4().hex}, + json={"text": "", "attachment_ids": [a["id"]]}, + ) + assert linked.status_code == 201 + assert ( + client.get( + f"/api/v1/attachments/{a['id']}/content", headers=h + ).status_code + == 409 + ) + compose("restart", "api") + ready() + start("broker") + start("relay") + start("worker") + effect = confirm(a, j) + save( + "commit_before_publish_and_worker_stopped", + { + "attachment": a["id"], + "effect": effect, + "queued_link_allowed": True, + "api_and_broker_restarted": True, + "broker_stopped_during_upload": True, + }, + ) + # Broker-volume survival with a confirmed, still-unconsumed stream entry. + stop("worker") + a, j = upload() + wait( + lambda: inside( + f"with db.connection() as c: r=c.execute('SELECT count(*) n FROM outbox WHERE job_id=%s AND published_at IS NOT NULL',({j!r},)).fetchone()\nprint(json.dumps(r['n']>0))" + ) + ) + stop("relay") + ids = inside("print(json.dumps(queue.xrange(STREAM)))") + compose("kill", "-s", "SIGKILL", "broker") + start("broker") + wait(lambda: inside("print(json.dumps(queue.ping()))")) + restored = inside("print(json.dumps(queue.xrange(STREAM)))") + assert restored == ids, {"before": ids, "after": restored} + start("relay") + start("worker") + save( + "confirmed_broker_entry_survives_sigkill", + { + "effect": confirm(a, j), + "same_stream_entries": True, + "entry_count": len(ids), + }, + ) + # Confirm succeeded, PG marker did not: relay recovery may publish a duplicate. + stop("worker") + stop("relay") + a, j = upload() + marker = inject(j, "relay_after_publish", "crash") + start("relay") + wait(lambda marker=marker: hit(marker)) + time.sleep(0.5) + unpublished = inside( + f"with db.connection() as c: r=c.execute('SELECT count(*) n FROM outbox WHERE job_id=%s AND published_at IS NULL',({j!r},)).fetchone()\nprint(json.dumps(r['n']))" + ) + assert unpublished >= 1 + start("relay") + start("worker") + save( + "relay_crash_after_xadd_before_pg_marker", + { + "unpublished_after_crash": unpublished, + "effect": confirm(a, j), + }, + ) + # Repeated before/after effect and commit/ack windows. + for repeat in range(args.repeats): + for phase in [ + "before_effect", + "after_effect", + "after_commit", + ]: + stop("worker") + a, j = upload() + marker = inject(j, phase, "wait") + start("worker") + wait(lambda marker=marker: hit(marker)) + at_crash = inspect_effect( + j, pending=phase == "after_commit" + ) + assert at_crash["job"]["state"] == ( + "ready" + if phase == "after_commit" + else "processing" + ) + assert at_crash["publications"] == ( + 1 if phase == "after_commit" else 0 + ) + assert len(at_crash["physical_keys"]) == ( + 0 if phase == "before_effect" else 4 + ) + if phase == "after_commit": + assert at_crash["pending_stream_entries"], ( + "Result must be committed while notification is still unacknowledged" + ) + assert not any( + e["event"] == "child_finished" + for e in at_crash["events"] + ) + compose("kill", "-s", "SIGKILL", "worker") + start("worker") + effect = confirm(a, j) + if phase == "after_commit": + wait( + lambda j=j: any( + e["event"] == "duplicate_decision" + and e["detail"]["state"] == "ready" + for e in inspect_effect(j)["events"] + ) + ) + wait( + lambda j=j: inside( + f"print(json.dumps(not any(json.loads(fields.get('job','{{}}')).get('job_id')=={j!r} for _,fields in queue.xrange(STREAM))))" + ) + ) + effect = inspect_effect(j) + else: + assert effect["job"]["attempt"] >= 2 + save( + f"{phase}_sigkill_repeat_{repeat + 1}", + {"at_crash": at_crash, "effect": effect}, + ) + stop("worker") + a, j = upload() + inject(j, "before_effect", "transient") + start("worker") + effect = confirm(a, j) + assert effect["job"]["attempt"] == 2 + save("transient_retry_with_jitter", {"effect": effect}) + stop("worker") + a, j = upload() + marker = inject(j, "before_effect", "hang") + start("worker") + wait(lambda: hit(marker)) + limits = inside( + f"with db.connection() as c: r=c.execute(\"SELECT detail FROM pipeline_events WHERE job_id=%s AND event='worker_resource_limits' ORDER BY id DESC LIMIT 1\",({j!r},)).fetchone()\nprint(json.dumps(r['detail']))" + ) + assert limits["address_space_bytes"] == [805306368, 805306368] + assert limits["memory.max"] == "1610612736" + effect = confirm(a, j) + assert any( + e["event"] == "retry" + and e["detail"]["code"] == "worker_timeout" + for e in effect["events"] + ) + save( + "hung_child_killed_and_retried", + {"effect": effect, "observed_limits": limits}, + ) + stop("worker") + a, j = upload() + inject(j, "before_effect", "permanent") + start("worker") + failed = until(a, "failed") + assert failed["error_code"] == "invalid_image" + assert ( + client.get( + f"/api/v1/attachments/{a['id']}/content", headers=h + ).status_code + == 409 + ) + r = client.post( + f"/api/v1/chats/{chat}/messages", + headers={**h, "Idempotency-Key": uuid4().hex}, + json={"text": "", "attachment_ids": [a["id"]]}, + ) + assert r.status_code == 409 + assert operator(j) == j + effect = confirm(a, j) + assert effect["job"]["cycle"] == 2 + try: + operator(j) + except RuntimeError: + pass + else: + raise AssertionError("Replay of ready must be rejected") + save( + "permanent_failed_registry_and_audited_replay", + { + "failed": failed, + "effect": effect, + "ready_replay_rejected": True, + }, + ) + stop("worker") + a, j = upload() + inject(j, "before_effect", "transient", remaining=5) + start("worker") + failed = until(a, "failed", timeout=150) + assert ( + failed["error_code"] == "retry_exhausted" + and row(j)["attempt"] == 5 + ) + operator(j) + save( + "finite_retry_exhaustion_then_explicit_replay", + {"failed": failed, "effect": confirm(a, j)}, + ) + # Reverse notification order and add concurrent copies: one publication/key. + stop("worker") + stop("relay") + a, j = upload() + b, k = upload() + duplicate(k, 8) + duplicate(j, 8) + start("worker") + start("relay") + ea = confirm(a, j) + confirm(b, k) + duplicate(j, 10) + duplicate(k, 10) + wait( + lambda: any( + e["event"] == "duplicate_decision" + for e in inspect_effect(j)["events"] + ) + ) + assert ( + inspect_effect(j)["job"]["attempt"] == ea["job"]["attempt"] + ) + save( + "reordered_and_duplicate_notifications", + { + "effects": [inspect_effect(j), inspect_effect(k)], + "added_duplicates": 36, + "no_extra_attempt_after_ready": True, + }, + ) + # Hold v1 after its PUTs, complete v2 on the other bounded slot, release old CAS. + for repeat in range(args.repeats): + stop("worker") + a, j = upload() + marker = inject(j, "after_effect", "wait") + # Keep one controller process hot throughout the narrow stale-writer window. + code = f"""from src.pipeline import event +with db.connection() as c: event(c,UUID({j!r}),'version_controller_waiting') +end=time.monotonic()+45 +while True: + with db.connection() as c: hit=c.execute('SELECT hit_at FROM pipeline_faults WHERE id=%s',({marker},)).fetchone()['hit_at'] + if hit: break + if time.monotonic()>end: raise TimeoutError('v1 hook never hit') + time.sleep(.05) +k=change(db,store,job_id=UUID({j!r}),operator='synthetic-verifier',reason='Held stale writer race',version=2) +end=time.monotonic()+10 +while True: + with db.connection() as c: ready=c.execute('SELECT state FROM jobs WHERE id=%s',(k,)).fetchone()['state']=='ready' + if ready: break + if time.monotonic()>end: raise TimeoutError('v2 did not finish inside live v1 budget') + time.sleep(.05) +with db.connection() as c: + hashes=c.execute('SELECT name,sha256 FROM attachment_variants WHERE attachment_id=%s AND pipeline_version=2 ORDER BY name',({a["id"]!r},)).fetchall() + c.execute('UPDATE pipeline_faults SET released_at=clock_timestamp() WHERE id=%s',({marker},)) +end=time.monotonic()+10 +while True: + with db.connection() as c: stale=c.execute("SELECT count(*) n FROM pipeline_events WHERE job_id=%s AND event='stale_completion_rejected'",({j!r},)).fetchone()['n'] + if stale: break + if time.monotonic()>end: raise TimeoutError('Old completion was not rejected') + time.sleep(.05) +print(json.dumps({{'job_id':k,'hashes':{{r['name']:r['sha256'] for r in hashes}}}})) +""" + with ThreadPoolExecutor(max_workers=1) as hot: + future = hot.submit(inside, code) + wait( + lambda j=j: inside( + f"with db.connection() as c: n=c.execute(\"SELECT count(*) n FROM pipeline_events WHERE job_id=%s AND event='version_controller_waiting'\",({j!r},)).fetchone()['n']\nprint(json.dumps(n>0))" + ) + ) + start("worker") + race = future.result(timeout=45) + k = race["job_id"] + hashes = race["hashes"] + confirm(a, k) + duplicate(j, 12) + wait( + lambda j=j: any( + e["event"] == "duplicate_decision" + for e in inspect_effect(j)["events"] + ) + ) + assert hashes == { + v["name"]: v["sha256"] for v in confirm(a, k)["variants"] + } + assert inspect_effect(j)["publications"] == 0 + save( + f"stale_v1_after_v2_repeat_{repeat + 1}", + { + "v1": inspect_effect(j), + "v2": inspect_effect(k), + "new_hashes_unchanged": True, + }, + ) + # No arbitrary URL/bytes fields in queue envelopes. + invalid = inside( + "bad={'schema_version':1,'url':'http://example.invalid/raw'}\nqueue.xadd(STREAM,{'job':json.dumps(bad)})\nprint('true')" + ) + assert invalid + wait( + lambda: inside( + "with db.connection() as c: r=c.execute(\"SELECT count(*) n FROM pipeline_events WHERE event='invalid_envelope'\").fetchone()\nprint(json.dumps(r['n']>0))" + ) + ) + save( + "malformed_notification_rejected", {"durable_diagnostic": True} + ) + # Private bucket, bounded IAM, and download after uploader process dies. + a, j = upload() + confirm(a, j) + key = f"objects/{a['id']}/v1/original" + security = inside(f"""from minio.error import S3Error +from urllib.error import HTTPError +try: urllib.request.urlopen('http://s3:9000/'+BUCKET+'/' + {key!r},timeout=3) +except HTTPError as e: anonymous=e.code +else: raise AssertionError('Anonymous access allowed') +denials={{}} +for name,fn in [('create_bucket',lambda:store.client.make_bucket('forbidden-'+uuid4().hex)),('write_outside_prefix',lambda:store.client.put_object(BUCKET,'outside-'+uuid4().hex,io.BytesIO(b'x'),1)),('list_other_bucket',lambda:list(store.client.list_objects('forbidden-'+uuid4().hex)))]: + try: fn() + except S3Error as e: denials[name]=e.code + else: raise AssertionError('IAM allowed forbidden action') +print(json.dumps({{'anonymous':anonymous,'iam':denials}}))""") + assert security["anonymous"] == 403 and set( + security["iam"].values() + ) == {"AccessDenied"} + selected = None + for cid in compose("ps", "-q", "api").split(): + alias = command( + [ + "docker", + "exec", + cid, + "python", + "-c", + "import urllib.request;print(urllib.request.urlopen('http://127.0.0.1:8080/health/live').headers['X-Instance-Id'])", + ] + ) + uploader = inside( + f"with db.connection() as c: r=c.execute('SELECT uploader_instance FROM attachments WHERE id=%s',({a['id']!r},)).fetchone()\nprint(json.dumps(r['uploader_instance']))" + ) + if alias == uploader: + selected = cid + assert selected + command(["docker", "stop", "--time", "1", selected]) + ready() + wait( + lambda: ( + client.get( + f"/api/v1/attachments/{a['id']}/content", headers=h + ).status_code + == 200 + ) + ) + downloaded = client.get( + f"/api/v1/attachments/{a['id']}/content", headers=h + ) + assert ( + downloaded.content == raw + and downloaded.headers["X-Instance-Id"] != uploader + ) + start("api") + ready() + save( + "private_iam_and_other_api_download", + { + "security": security, + "attachment": a["id"], + "uploader": uploader, + "downloader": downloaded.headers["X-Instance-Id"], + "sha256": hashlib.sha256(raw).hexdigest(), + }, + ) + report["worker_metrics"] = inside( + "with db.connection() as c: r=c.execute(\"SELECT job_id,detail FROM pipeline_events WHERE event='child_finished' ORDER BY id\").fetchall()\nprint(json.dumps(r,default=str))" + ) + report["audit"] = inside( + "with db.connection() as c: r=c.execute('SELECT job_id,action,operator,reason,created_at FROM pipeline_audit ORDER BY id').fetchall()\nprint(json.dumps(r,default=str))" + ) + report["complete"] = True + finally: + for role in ["api", "broker", "relay", "worker", "reconciler"]: + try: + start(role) + except Exception: + pass + output.write_text( + json.dumps(report, ensure_ascii=False, indent=2) + "\n" + ) + print("PASS: versioned pipeline scope=" + args.start_at, flush=True) + + +if __name__ == "__main__": + main() diff --git a/scripts/verify_security.py b/scripts/verify_security.py new file mode 100644 index 0000000..ccd6024 --- /dev/null +++ b/scripts/verify_security.py @@ -0,0 +1,58 @@ +"""Prepare public/negative fixtures and run the operator-only matrix probe.""" + +import argparse +import json +from datetime import UTC, datetime + +from scripts.bootstrap_security import ( + SECRET, + key_bytes, + make_root, + public, + sign_leaf, + write_private, +) +from scripts.stand import ROOT, command, compose + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--output", default="evidence/security-first.json") + args = parser.parse_args() + output = ROOT / args.output + assert not output.exists(), "Choose a new receipt path" + fixture = SECRET / "probe" + fixture.mkdir(mode=0o755, exist_ok=True) + root_key, root_cert = make_root() + key, leaf = sign_leaf(root_key, root_cert, "lb", ["lb"]) + write_private(fixture / "foreign-ca.pem", public(root_cert), mode=0o644) + write_private( + fixture / "foreign/cert.pem", + public(leaf) + public(root_cert), + mode=0o644, + ) + write_private(fixture / "foreign/key.pem", key_bytes(key), mode=0o644) + result = json.loads( + compose( + "--profile", + "operator", + "run", + "--rm", + "--no-deps", + "operator-probe", + ) + ) + result.update( + date=datetime.now(UTC).isoformat(), + source_commit=command(["git", "rev-parse", "HEAD"]), + ) + output.parent.mkdir(parents=True, exist_ok=True) + output.write_text(json.dumps(result, ensure_ascii=False, indent=2) + "\n") + assert result["complete"] + print( + "PASS: real mTLS identities, server CA/hostname, closed plaintext boundaries and worker least privilege" + ) + + +if __name__ == "__main__": + main() diff --git a/scripts/verify_telemetry.py b/scripts/verify_telemetry.py new file mode 100644 index 0000000..d2a8765 --- /dev/null +++ b/scripts/verify_telemetry.py @@ -0,0 +1,340 @@ +"""Actual API-to-worker causality, log correlation, provisioning and privacy.""" + +import argparse +import hashlib +import io +import json +import os +from datetime import UTC, datetime +from uuid import uuid4 + +import httpx +from PIL import Image + +os.environ.setdefault("COMPOSE_FILE", "compose.yaml:compose.test.yaml") +from scripts.observe import fetch, logs, query, spans, wait +from scripts.stand import BASE, ROOT, actor, auth, command, compose, ready, sql + + +def verify_chain(items, trace_id, *, retry): + assert items and {s["trace_id"] for s in items} == {trace_id} + by_id = {s["span_id"]: s for s in items} + producers = [s for s in items if s["kind"] == "SPAN_KIND_PRODUCER"] + consumers = [s for s in items if s["kind"] == "SPAN_KIND_CONSUMER"] + processing = [s for s in items if s["name"] == "attachment.process"] + assert producers and consumers and processing + assert {s["service"] for s in items} >= { + "messenger-api", + "messenger-relay", + "messenger-worker", + } + for consumer in consumers: + assert ( + by_id[consumer["parent_span_id"]]["kind"] == "SPAN_KIND_PRODUCER" + ) + for process in processing: + assert by_id[process["parent_span_id"]]["kind"] == "SPAN_KIND_CONSUMER" + assert any( + s["name"] == "s3.put" and s["service"] == "messenger-worker" + for s in items + ) + assert any( + s["name"] == "db.postgresql" and s["service"] == "messenger-worker" + for s in items + ) + if retry: + assert len(processing) >= 2 + assert any( + s["status"].get("code") in {2, "STATUS_CODE_ERROR"} + for s in processing + ) + return items + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--output", default="evidence/telemetry-first.json") + args = parser.parse_args() + output = ROOT / args.output + assert not output.exists(), "Choose a new output path" + report = { + "date": datetime.now(UTC).isoformat(), + "source_commit": command(["git", "rev-parse", "HEAD"]), + "complete": False, + } + output.parent.mkdir(parents=True, exist_ok=True) + try: + ready(timeout=90) + for service, path in [ + ("prometheus", "/-/ready"), + ("loki", "/ready"), + ("tempo", "/ready"), + ("otel", "/"), + ]: + wait(lambda s=service, p=path: fetch(s, p, json_result=False)) + report["backends_ready"] = True + buffer = io.BytesIO() + Image.new("RGB", (320, 200), (24, 110, 153)).save(buffer, "PNG") + raw = buffer.getvalue() + sentinel = "PrivacyProbe-" + uuid4().hex + with httpx.Client( + base_url=BASE, timeout=15, trust_env=False + ) as client: + user, _, session = actor(client) + headers = auth(session) + chat = client.post( + "/api/v1/chats", + headers=headers, + json={ + "title": "Synthetic telemetry", + "member_ids": [user["id"]], + }, + ).json()["id"] + message = client.post( + f"/api/v1/chats/{chat}/messages", + headers={**headers, "Idempotency-Key": uuid4().hex}, + json={"text": sentinel}, + ) + assert message.status_code == 201 + cases = [] + for retry in [False, True]: + if retry: + compose("stop", "--timeout", "1", "worker") + trace_id = uuid4().hex + trace_header = ( + "00-" + trace_id + "-" + uuid4().hex[:16] + "-01" + ) + accepted = client.post( + f"/api/v1/chats/{chat}/attachments", + params={"filename": sentinel + ".png"}, + headers={ + **headers, + "Content-Type": "image/png", + "traceparent": trace_header, + }, + content=raw, + ) + assert ( + accepted.status_code == 202 + and accepted.json()["status"] == "queued" + ) + attachment = accepted.json()["id"] + job = sql( + f"SELECT id FROM jobs WHERE attachment_id='{attachment}'::uuid" + ) + if retry: + sql( + f"INSERT INTO pipeline_faults(target,phase,action,remaining) VALUES('{job}'::uuid,'before_effect','transient',1)" + ) + compose("up", "-d", "--no-deps", "--no-recreate", "worker") + + def finished(identity=attachment): + response = client.get( + f"/api/v1/attachments/{identity}", headers=headers + ) + return ( + response.status_code == 200 + and response.json()["status"] == "ready" + ) + + wait(finished, timeout=90) + original = client.get( + f"/api/v1/attachments/{attachment}/content", + headers=headers, + ) + assert original.content == raw + + def traced(identity=trace_id, retry_expected=retry): + items = spans(identity) + if len( + [s for s in items if s["name"] == "attachment.process"] + ) < (2 if retry_expected else 1): + return None + if any(s["kind"] == "SPAN_KIND_CONSUMER" for s in items): + # Independent export batches may arrive in a different + # order. Require the whole chain before accepting it. + try: + return verify_chain( + items, identity, retry=retry_expected + ) + except (AssertionError, KeyError): + return None + + items = wait(traced, timeout=90) + + def correlated(identity=trace_id): + result = logs(identity) + streams = result.get("data", {}).get("result", []) + services = { + x["stream"].get("service_name") for x in streams + } + return ( + result + if {"messenger-api", "messenger-worker"} <= services + else None + ) + + correlated_logs = wait(correlated, timeout=90) + span_ids = {s["span_id"] for s in items} + streams = correlated_logs["data"]["result"] + assert all( + row["stream"].get("span_id") in span_ids for row in streams + ) + assert any( + row["stream"].get("request_id") + == accepted.headers["X-Request-Id"] + for row in streams + ) + exported = json.dumps( + {"spans": items, "logs": correlated_logs} + ) + assert ( + sentinel not in exported + and session["token"] not in exported + ) + cases.append( + { + "retry": retry, + "attachment_id": attachment, + "job_id": job, + "trace_id": trace_id, + "request_id": accepted.headers["X-Request-Id"], + "original_sha256": hashlib.sha256(raw).hexdigest(), + "attempt": int( + sql( + f"SELECT attempt FROM jobs WHERE id='{job}'::uuid" + ) + ), + "spans": items, + "correlated_logs": correlated_logs, + } + ) + report["causal_uploads"] = cases + assert cases[1]["attempt"] >= 2 + report["privacy_sentinels_absent_from_traces_and_logs"] = True + names = wait( + lambda: fetch("prometheus", "/api/v1/label/__name__/values")[ + "data" + ] + ) + required = { + "messenger_http_requests_total", + "messenger_http_duration_seconds_bucket", + "messenger_job_attempts_total", + "messenger_job_duration_seconds_bucket", + "messenger_time_to_ready_seconds_bucket", + "messenger_queue_depth", + "messenger_oldest_job_age_seconds", + "messenger_db_pool_used", + "messenger_db_pool_waiting", + "messenger_worker_busy", + "messenger_worker_capacity", + "messenger_process_cpu_seconds_total", + "messenger_process_memory_bytes", + "messenger_slo_decisions_total", + } + wait( + lambda: ( + required + <= set( + fetch("prometheus", "/api/v1/label/__name__/values")[ + "data" + ] + ) + ) + ) + names = fetch("prometheus", "/api/v1/label/__name__/values")["data"] + report["metric_names"] = [ + n for n in names if n.startswith("messenger_") + ] + series = fetch( + "prometheus", + "/api/v1/series", + params={"match[]": '{__name__=~"messenger_.*"}'}, + )["data"] + forbidden = { + "user_id", + "chat_id", + "message_id", + "attachment_id", + "job_id", + "request_id", + "trace_id", + "filename", + } + assert all(not forbidden.intersection(s) for s in series) + assert all(sentinel not in json.dumps(s) for s in series) + report["metric_series_count"] = len(series) + report["metric_labels_low_cardinality"] = True + url = "http://127.0.0.1:" + os.getenv("GRAFANA_PORT", "3006") + password = (ROOT / "secrets/grafana_password").read_text().strip() + with httpx.Client( + base_url=url, auth=("admin", password), trust_env=False, timeout=15 + ) as grafana: + dashboard = grafana.get("/api/dashboards/uid/messenger-lab6") + dashboard.raise_for_status() + imported = dashboard.json()["dashboard"] + assert len(imported["panels"]) == 18 + sources = grafana.get("/api/datasources").json() + assert {s["uid"] for s in sources} == { + "prometheus", + "loki", + "tempo", + } + checks = {} + for uid in ["prometheus", "loki", "tempo"]: + r = grafana.get(f"/api/datasources/uid/{uid}/health") + r.raise_for_status() + assert r.json()["status"] == "OK", uid + checks[uid] = r.json()["status"] + result = grafana.post( + "/api/ds/query", + json={ + "queries": [ + { + "refId": "A", + "datasource": { + "uid": "prometheus", + "type": "prometheus", + }, + "expr": "sum(messenger_http_requests_total)", + "instant": True, + "format": "table", + "intervalMs": 5000, + "maxDataPoints": 10, + } + ], + "from": "now-5m", + "to": "now", + }, + ) + result.raise_for_status() + assert result.json()["results"]["A"]["frames"] + report["grafana"] = { + "dashboard_uid": imported["uid"], + "panels": len(imported["panels"]), + "datasources_health": checks, + "actual_query_frames": len( + result.json()["results"]["A"]["frames"] + ), + } + report["quantiles"] = { + str(q): query( + f"histogram_quantile({q},sum by(le)(rate(messenger_http_duration_seconds_bucket[2m])))" + ) + for q in [0.5, 0.95, 0.99] + } + assert all(report["quantiles"].values()) + report["complete"] = True + finally: + compose("up", "-d", "--no-deps", "--no-recreate", "worker") + output.write_text( + json.dumps(report, ensure_ascii=False, indent=2) + "\n" + ) + print( + "PASS: causal API/publish/consumer/child/DB/S3, retry, correlated logs, privacy and Grafana" + ) + + +if __name__ == "__main__": + main() diff --git a/security/THREAT_MODEL.md b/security/THREAT_MODEL.md index 31da287..7d51897 100644 --- a/security/THREAT_MODEL.md +++ b/security/THREAT_MODEL.md @@ -1,19 +1,19 @@ -# Модель угроз — заполнить +# Модель угроз — Маслов, БВТ2301 -## Активы и акторы +Активы: сообщения/изображения, session token hashes/password hashes, задания и их состояние, service secrets/private keys, достоверность telemetry. Акторы: внешний анонимный клиент, пользователь вне чата, процесс с чужим service cert, скомпрометированный worker, оператор. Доверяем локальному оператору/ОС и контролю доступа к Docker; захват host/root выходит за модель. -TODO: пользовательские credentials/сессии, сообщения/вложения, service identities, CA/secrets, telemetry. Акторы: участник чата, посторонний пользователь, внешний клиент, скомпрометированный сервис, оператор. Опишите доступ атакующего и границы учебного стенда. +| Угроза | Контроль | Воспроизводимая проверка | +|---|---|---| +| Перехват или подмена ingress | TLS1.3, проверка собственного CA и SAN | `make test-security`; чужой CA/неправильный hostname дают verification error | +| Чужой сервис выдаёт себя за LB | Обязательный client cert и exact URI allowlist всех API | `verify_security`: no cert/foreign CA/trusted worker cert denied, lb allowed | +| Обход gateway через native порт | Loopback-only backend в отдельной локальной transport boundary, нет public API ports | Внешний operator probe проверяет 12 закрытых native портов | +| Пользователь читает чужой файл/чат | Bearer → SQL membership; metadata/content/attach проходят одинаковый ACL | 112 HTTP проверок, включая outsider, forged X-User-Id, logout/expiry | +| Worker читает пароль/сессии или меняет конфигурацию очереди | Отдельная SQL роль, S3 prefix policy, broker ACL и mTLS role | Worker SELECT users/sessions/CREATE ROLE/CONFIG/forbidden PUT/DELETE denied | +| Worker получает секрет API или повышает права через Bao | Exact CN+URI cert auth, own KV v2/own PKI only, no default/root policy | Own read200; foreign read/policy write/foreign PKI403 | +| Истёкший или отозванный cert продолжает работать | Короткий leaf, новая TLS проверка, serial deny, HTTP close/L4≤45с, bounded secret snapshot | Lifecycle research: свежие подключения после expiry/revoke, измеренные error/recovery | +| Подбор пароля перегружает Argon2 и RAM | Общий SQL rate limiter до KDF, глобальный burst8/refill2/s, account8/min; 2 KDF slots/API | Конкурентный login DoS, 429 Retry-After, время/RSS; успешный legacy hash rehash | +| Вложение расходует память/CPU или зависает | 10MiB/предел pixels, isolated child, RLIMIT_AS768MiB, worker CPU2/RAM1536MiB, timeout/lease | HTTP file guards и pipeline failure matrix; JSON≤64KiB/receive≤5с | +| Telemetry раскрывает пароль/token/body/key | Явные allowlists, IDs вне labels, generic errors, scoped audit с HMAC values | Canary в запросе и поиск по Loki/Tempo, low-cardinality проверка | +| Образ или библиотека содержат уязвимость | Pinned versions/digests, реальный dependency/image scan, triage применимости | Scan receipts + разбор исправлений/остаточных рисков в REPORT | -## Границы доверия - -TODO: схема и ссылка на заполненную contracts/trust-matrix.md; публичные/внутренние интерфейсы, процессы, секреты и их выдача. - -| Угроза и конкретный путь | Нарушаемый инвариант | Контроль | Отрицательный тест | Остаточное ограничение | -| --- | --- | --- | --- | --- | -| TODO | TODO | TODO | TODO | TODO | - -На 4 минимум 6 конкретных угроз. Не заменяйте сценарии словами «SQL injection», «безопасный Docker», «mTLS включён» без пути и проверки. - -## Lifecycle и инциденты - -TODO: bootstrap, expiry/renewal, revoke/rotation, компрометация identity, sealed OpenBao и восстановление. Указать владельца CA/unseal и способ защиты bootstrap credentials. Сопоставить scan findings с реальной применимостью и исправлением/остаточным риском. +Ограничения: один host и одиночные stateful сервисы; нет защиты от потери диска. Общая роль API разделяет cert между репликами; pod identity отдельно не моделируется. Gateway и native backend доверяют процессам своего network namespace. Доступ к Docker равносилен доступу оператора. Короткие TTL демонстрационные и требуют доступности OpenBao; после длительного seal нужен явный recovery. До завершения runtime-проверок настройки не считаются доказанными свойствами. diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/__main__.py b/src/__main__.py new file mode 100644 index 0000000..20228f9 --- /dev/null +++ b/src/__main__.py @@ -0,0 +1,44 @@ +import json +import logging +import os +import signal +import sys + + +def early_stop(signum, _frame): + print( + json.dumps({"event": "stopped_before_startup", "signal": signum}), + flush=True, + ) + sys.exit(0) + + +signal.signal(signal.SIGTERM, early_stop) +signal.signal(signal.SIGINT, early_stop) + +import uvicorn # noqa: E402 + +from src.logging_config import JsonFormatter # noqa: E402 + + +def main() -> None: + host = os.environ.get("APP_HOST", "127.0.0.1") + port = int(os.environ.get("APP_PORT", "8080")) + if not 1 <= port <= 65535: + raise ValueError("APP_PORT must be between 1 and 65535") + handler = logging.StreamHandler(sys.stdout) + handler.setFormatter(JsonFormatter()) + logging.basicConfig(level=logging.INFO, handlers=[handler], force=True) + uvicorn.run( + "src.api:app", + host=host, + port=port, + workers=1, + access_log=False, + timeout_graceful_shutdown=5, + log_config=None, + ) + + +if __name__ == "__main__": + main() diff --git a/src/api.py b/src/api.py new file mode 100644 index 0000000..5442bfb --- /dev/null +++ b/src/api.py @@ -0,0 +1,427 @@ +import hashlib +import json +import logging +import tempfile +from collections.abc import AsyncIterator +from contextlib import asynccontextmanager +from datetime import datetime +from functools import partial +from urllib.parse import quote +from uuid import UUID, uuid4 + +from anyio import Semaphore, fail_after, to_thread +from fastapi import FastAPI, Request +from fastapi.encoders import jsonable_encoder +from pydantic import ValidationError +from starlette.exceptions import HTTPException +from starlette.requests import ClientDisconnect +from starlette.responses import JSONResponse, Response, StreamingResponse + +from src import identity, images, telemetry +from src.attachments import Attachments +from src.cache import UserCache +from src.cursor import parse_uuid +from src.database import Database +from src.domain import timestamp +from src.errors import DomainError, invalid +from src.object_store import ObjectStore +from src.password import Passwords +from src.repository import PostgresRepository +from src.schemas import CreateChat, CreateMessage, CreateUser, Input +from src.service import MessengerService +from src.settings import Settings + +logger = logging.getLogger("messenger") +INSTANCE_ID = uuid4().hex + + +def response(data: object, *, status: int = 200) -> JSONResponse: + return JSONResponse( + jsonable_encoder( + data, custom_encoder={datetime: timestamp, UUID: str} + ), + status_code=status, + ) + + +async def body(request: Request, model: type[Input]) -> Input: + try: + data = bytearray() + with fail_after(5): + async for chunk in request.stream(): + data.extend(chunk) + if len(data) > 65536: + raise DomainError( + 413, "payload_too_large", "JSON byte limit exceeded" + ) + return model.model_validate( + json.loads( + data.decode("utf-8"), + parse_constant=lambda _: (_ for _ in ()).throw(ValueError()), + ) + ) + except TimeoutError: + raise DomainError( + 503, "unavailable", "Request receive timeout" + ) from None + except ValueError, ValidationError, UnicodeError, RecursionError: + raise invalid() from None + + +def pagination(request: Request) -> tuple[int, str | None]: + limits = request.query_params.getlist("limit") + cursors = request.query_params.getlist("cursor") + if len(limits) > 1 or len(cursors) > 1: + raise invalid() + raw = limits[0] if limits else "50" + if not raw.isascii() or not raw.isdecimal(): + raise invalid() + raw = raw.lstrip("0") or "0" + if len(raw) > 3: + raise invalid() + limit = int(raw) + if not 1 <= limit <= 100: + raise invalid() + return limit, cursors[0] if cursors else None + + +def service(request: Request) -> MessengerService: + return request.app.state.service + + +async def run_io(function, **kwargs): + return await to_thread.run_sync(partial(function, **kwargs)) + + +async def actor(request: Request): + return await run_io( + service(request).identify, value=request.headers.get("authorization") + ) + + +@asynccontextmanager +async def lifespan(app: FastAPI) -> AsyncIterator[None]: + telemetry.configure("messenger-api", instance=INSTANCE_ID) + settings = Settings.load() + database = Database(url=settings.database_url, size=settings.pool_size) + cache = UserCache(url=settings.cache_url) + store = ObjectStore() + try: + await run_io(database.open) + passwords = await run_io(Passwords) + app.state.database = database + app.state.store = store + app.state.upload_slots = Semaphore(2) + app.state.attachments = Attachments( + database=database, store=store, instance=INSTANCE_ID + ) + app.state.service = MessengerService( + repository=PostgresRepository(database=database, cache=cache), + passwords=passwords, + session_ttl=settings.session_ttl, + ) + app.state.ready = True + yield + finally: + app.state.ready = False + await run_io(store.close) + await run_io(cache.close) + await run_io(database.close) + await run_io(telemetry.stop) + + +app = FastAPI( + lifespan=lifespan, docs_url=None, redoc_url=None, openapi_url=None +) +app.add_middleware(telemetry.TelemetryMiddleware) + + +@app.middleware("http") +async def request_context(request: Request, call_next): + request_id = str(uuid4()) + request.state.request_id = request_id + try: + try: + identity.ensure() + except DomainError as error: + return await domain_error(request, error) + result = await call_next(request) + except Exception: + logger.error( + json.dumps({"event": "internal_error", "request_id": request_id}) + ) + result = response( + { + "error": { + "code": "internal_error", + "message": "Internal error", + "request_id": request_id, + } + }, + status=500, + ) + result.headers["X-Request-Id"] = request_id + result.headers["X-Instance-Id"] = INSTANCE_ID + return result + + +@app.exception_handler(DomainError) +async def domain_error(request: Request, error: DomainError): + result = response( + { + "error": { + "code": error.code, + "message": error.message, + "request_id": request.state.request_id, + } + }, + status=error.status, + ) + result.headers.update(error.headers) + return result + + +@app.exception_handler(HTTPException) +async def http_error(request: Request, error: HTTPException): + code = "not_found" if error.status_code == 404 else "invalid_request" + return response( + { + "error": { + "code": code, + "message": "Resource not found" + if error.status_code == 404 + else "Invalid request", + "request_id": request.state.request_id, + } + }, + status=error.status_code, + ) + + +@app.get("/health/live") +async def live(): + return response({"status": "ok"}) + + +@app.get("/health/ready") +async def ready(): + if not getattr(app.state, "ready", False): + raise DomainError(503, "unavailable", "Not ready") + await run_io(app.state.database.ping) + await run_io(app.state.store.ping) + return response({"status": "ok"}) + + +@app.post("/api/v1/users") +async def register(request: Request): + data = await body(request, CreateUser) + return response( + await run_io(service(request).register, **data.model_dump()), + status=201, + ) + + +@app.get("/api/v1/users/me") +async def current(request: Request): + return response(await actor(request)) + + +@app.post("/api/v1/chats") +async def create_chat(request: Request): + user = await actor(request) + data = await body(request, CreateChat) + return response( + await run_io( + service(request).create_chat, actor_id=user.id, **data.model_dump() + ), + status=201, + ) + + +@app.get("/api/v1/chats") +async def list_chats(request: Request): + user = await actor(request) + limit, cursor = pagination(request) + return response( + await run_io( + service(request).chats, + actor_id=user.id, + limit=limit, + cursor=cursor, + ) + ) + + +@app.get("/api/v1/chats/{chat_id}") +async def get_chat(request: Request, chat_id: str): + user = await actor(request) + return response( + await run_io( + service(request).get_chat, + actor_id=user.id, + chat_id=parse_uuid(chat_id), + ) + ) + + +@app.post("/api/v1/chats/{chat_id}/messages") +async def send(request: Request, chat_id: str): + user = await actor(request) + cid = parse_uuid(chat_id) + await run_io(service(request).get_chat, actor_id=user.id, chat_id=cid) + data = await body(request, CreateMessage) + return response( + await run_io( + service(request).send, + actor_id=user.id, + chat_id=cid, + idempotency_key=request.headers.get("idempotency-key"), + **data.model_dump(), + ), + status=201, + ) + + +@app.get("/api/v1/chats/{chat_id}/messages") +async def history(request: Request, chat_id: str): + user = await actor(request) + cid = parse_uuid(chat_id) + chat = await run_io( + service(request).get_chat, actor_id=user.id, chat_id=cid + ) + limit, cursor = pagination(request) + return response( + await run_io( + service(request).history, + actor_id=user.id, + chat=chat, + limit=limit, + cursor=cursor, + ) + ) + + +@app.post("/api/v1/auth/sessions") +async def login(request: Request): + return response( + await run_io( + service(request).login, + authorization=request.headers.get("authorization"), + ), + status=201, + ) + + +@app.delete("/api/v1/auth/sessions/current") +async def logout(request: Request): + await run_io( + service(request).logout, + authorization=request.headers.get("authorization"), + ) + return Response(status_code=204) + + +@app.post("/api/v1/chats/{chat_id}/attachments") +async def upload(request: Request, chat_id: str): + user = await actor(request) + cid = parse_uuid(chat_id) + await run_io(service(request).get_chat, actor_id=user.id, chat_id=cid) + names = request.query_params.getlist("filename") + if len(names) != 1: + raise invalid() + name = images.filename(names[0]) + declared = ( + request.headers.get("content-type", "") + .partition(";")[0] + .strip() + .lower() + ) + if declared not in {"image/png", "image/jpeg"}: + raise DomainError( + 415, "unsupported_media_type", "PNG or JPEG required" + ) + length = request.headers.get("content-length") + if length and (not length.isdecimal() or len(length) > 12): + raise invalid() + if length and int(length) > images.MAX_BYTES: + raise DomainError(413, "payload_too_large", "Byte limit exceeded") + try: + with fail_after(20): + async with app.state.upload_slots: + with tempfile.SpooledTemporaryFile( + max_size=1024 * 1024, mode="w+b" + ) as stream: + size = 0 + digest = hashlib.sha256() + async for chunk in request.stream(): + size += len(chunk) + if size > images.MAX_BYTES: + raise DomainError( + 413, "payload_too_large", "Byte limit exceeded" + ) + digest.update(chunk) + stream.write(chunk) + await run_io( + images.verify, stream=stream, declared=declared + ) + result = await run_io( + app.state.attachments.upload, + chat_id=cid, + owner_id=user.id, + filename=name, + content_type=declared, + size=size, + sha256=digest.hexdigest(), + stream=stream, + ) + return response(result, status=202) + except ClientDisconnect: + raise invalid() from None + except TimeoutError: + raise DomainError( + 503, "unavailable", "Upload deadline exceeded" + ) from None + + +@app.get("/api/v1/attachments/{attachment_id}") +async def attachment_metadata(request: Request, attachment_id: str): + user = await actor(request) + return response( + await run_io( + app.state.attachments.metadata, + identity=parse_uuid(attachment_id), + actor_id=user.id, + ) + ) + + +@app.get("/api/v1/attachments/{attachment_id}/content") +async def attachment_content(request: Request, attachment_id: str): + user = await actor(request) + variants = request.query_params.getlist("variant") + if len(variants) > 1: + raise invalid() + row, upstream = await run_io( + app.state.attachments.content, + identity=parse_uuid(attachment_id), + actor_id=user.id, + variant=variants[0] if variants else "original", + ) + + def chunks(): + try: + while data := upstream.read(65536): + yield data + finally: + upstream.close() + upstream.release_conn() + + return StreamingResponse( + chunks(), + media_type=row["content_type"], + headers={ + "Content-Length": str(row["size_bytes"]), + "Content-Disposition": "inline; filename*=UTF-8''" + + quote(row["filename"], safe=""), + }, + ) diff --git a/src/attachments.py b/src/attachments.py new file mode 100644 index 0000000..9bd841d --- /dev/null +++ b/src/attachments.py @@ -0,0 +1,144 @@ +from uuid import uuid4 + +from src.errors import DomainError, not_found +from src.pipeline import enqueue, fault + + +def dto(row, variants=()): + return { + k: row[k] + for k in [ + "id", + "chat_id", + "owner_id", + "filename", + "content_type", + "size_bytes", + "sha256", + "created_at", + "updated_at", + ] + } | { + "status": row["state"], + "variants": [ + { + k: v[k] + for k in [ + "name", + "content_type", + "size_bytes", + "sha256", + "width", + "height", + ] + } + for v in variants + if v["name"] != "original" + ], + "error_code": row["error_code"] if row["state"] == "failed" else None, + } + + +class Attachments: + def __init__(self, *, database, store, instance): + self.database, self.store, self.instance = database, store, instance + + def upload( + self, + *, + chat_id, + owner_id, + filename, + content_type, + size, + sha256, + stream, + ): + identity, job_id = uuid4(), uuid4() + key = f"objects/staging/{identity}/original" + with self.database.connection() as conn: + conn.execute( + "INSERT INTO upload_reservations(id,object_key) VALUES(%s,%s)", + (identity, key), + ) + self.store.put( + key=key, + stream=stream, + size=size, + content_type=content_type, + sha256=sha256, + ) + fault(self.database, chat_id, "api_after_staging") + with self.database.connection() as conn, conn.transaction(): + reservation = conn.execute( + "SELECT * FROM upload_reservations WHERE id=%s AND expires_at>clock_timestamp() FOR UPDATE", + (identity,), + ).fetchone() + if reservation is None: + raise DomainError( + 503, "unavailable", "Upload reservation expired" + ) + row = conn.execute( + "INSERT INTO attachments(id,chat_id,owner_id,filename,content_type,size_bytes,sha256,object_key,state,uploader_instance,expires_at) " + "VALUES(%s,%s,%s,%s,%s,%s,%s,%s,'queued',%s,clock_timestamp()) RETURNING *", + ( + identity, + chat_id, + owner_id, + filename, + content_type, + size, + sha256, + key, + self.instance, + ), + ).fetchone() + conn.execute( + "INSERT INTO jobs(id,attachment_id,pipeline_version,source_key,state) VALUES(%s,%s,1,%s,'queued')", + (job_id, identity, key), + ) + enqueue(conn, job_id) + conn.execute( + "DELETE FROM upload_reservations WHERE id=%s", (identity,) + ) + fault(self.database, chat_id, "api_after_commit") + # Captured committed snapshot remains queued even if worker already finished. + return dto(row) + + def row(self, *, identity, actor_id): + with self.database.connection() as conn: + row = conn.execute( + "SELECT a.* FROM attachments a JOIN members m ON m.chat_id=a.chat_id AND m.user_id=%s WHERE a.id=%s", + (actor_id, identity), + ).fetchone() + if row is None: + raise not_found() + return row + + def metadata(self, *, identity, actor_id): + row = self.row(identity=identity, actor_id=actor_id) + variants = [] + if row["state"] == "ready": + with self.database.connection() as conn: + variants = conn.execute( + "SELECT * FROM attachment_variants WHERE attachment_id=%s AND pipeline_version=%s ORDER BY name", + (identity, row["published_version"]), + ).fetchall() + return dto(row, variants) + + def content(self, *, identity, actor_id, variant): + row = self.row(identity=identity, actor_id=actor_id) + if row["state"] != "ready": + raise DomainError(409, "conflict", "Attachment is not ready") + with self.database.connection() as conn: + data = conn.execute( + "SELECT * FROM attachment_variants WHERE attachment_id=%s AND pipeline_version=%s AND name=%s", + (identity, row["published_version"], variant), + ).fetchone() + if data is None: + raise not_found() + if self.store.head(key=data["object_key"]) is None: + raise DomainError(503, "unavailable", "Variant unavailable") + return {**data, "filename": row["filename"]}, self.store.get( + key=data["object_key"] + ) diff --git a/src/cache.py b/src/cache.py new file mode 100644 index 0000000..9ccfee4 --- /dev/null +++ b/src/cache.py @@ -0,0 +1,68 @@ +import json +import threading +import time +from datetime import datetime +from uuid import UUID + +import redis +from redis.backoff import NoBackoff +from redis.retry import Retry + +from src.domain import User, timestamp +from src.identity import redis_tls + + +class UserCache: + def __init__(self, *, url: str): + self.client = redis.Redis.from_url( + url, + socket_connect_timeout=0.15, + socket_timeout=0.15, + max_connections=16, + retry=Retry(NoBackoff(), 0), + decode_responses=True, + **redis_tls(), + ) + self.disabled_until = 0.0 + self.lock = threading.Lock() + + def close(self): + self.client.close() + + def _command(self, function, *args, **kwargs): + if time.monotonic() < self.disabled_until: + return None + try: + return function(*args, **kwargs) + except redis.RedisError, OSError: + with self.lock: + self.disabled_until = time.monotonic() + 5 + return None + + def get(self, *, user_id: UUID) -> User | None: + raw = self._command(self.client.get, "user:" + str(user_id)) + if raw is None: + return None + try: + row = json.loads(raw) + if UUID(row["id"]) != user_id: + return None + return User( + user_id, + row["username"], + row["display_name"], + datetime.fromisoformat(row["created_at"]), + ) + except ValueError, TypeError, KeyError: + return None + + def put(self, *, user: User): + raw = json.dumps( + { + "id": str(user.id), + "username": user.username, + "display_name": user.display_name, + "created_at": timestamp(user.created_at), + } + ) + self._command(self.client.set, "user:" + str(user.id), raw, ex=30) diff --git a/src/cursor.py b/src/cursor.py new file mode 100644 index 0000000..9d9c3c9 --- /dev/null +++ b/src/cursor.py @@ -0,0 +1,64 @@ +import base64 +import binascii +import json +import re +from datetime import datetime +from uuid import UUID + +from src.domain import Key, timestamp +from src.errors import invalid + + +def parse_uuid(value: str) -> UUID: + if not isinstance(value, str) or not re.fullmatch( + r"[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}", value + ): + raise invalid() + return UUID(value) + + +def encode_cursor(*, scope: str, key: Key) -> str: + payload = { + "v": 1, + "scope": scope, + "at": timestamp(key[0]), + "id": str(key[1]), + } + return ( + base64.urlsafe_b64encode( + json.dumps(payload, separators=(",", ":")).encode() + ) + .decode() + .rstrip("=") + ) + + +def decode_cursor(*, value: str | None, scope: str) -> Key | None: + if value is None: + return None + try: + if ( + not value + or len(value) > 2048 + or not re.fullmatch(r"[A-Za-z0-9_-]+", value) + ): + raise ValueError + data = json.loads( + base64.b64decode( + value + "=" * (-len(value) % 4), altchars=b"-_", validate=True + ) + ) + if ( + not isinstance(data, dict) + or type(data.get("v")) is not int + or data["v"] != 1 + or data.get("scope") != scope + or not isinstance(data.get("at"), str) + ): + raise ValueError + at = datetime.fromisoformat(data["at"]) + if at.tzinfo is None or timestamp(at) != data["at"]: + raise ValueError + return at, parse_uuid(data["id"]) + except ValueError, TypeError, KeyError, binascii.Error, RecursionError: + raise invalid() from None diff --git a/src/database.py b/src/database.py new file mode 100644 index 0000000..91c86af --- /dev/null +++ b/src/database.py @@ -0,0 +1,82 @@ +import time +from contextlib import contextmanager + +import psycopg +from psycopg.rows import dict_row +from psycopg_pool import ConnectionPool, PoolTimeout + +from src import identity, telemetry +from src.errors import DomainError + + +class DeadlineConnection(psycopg.Connection): + """Клиентский срок действует и при замороженном PostgreSQL.""" + + def wait(self, gen, interval=0.1, timeout=None): + deadline = getattr(self, "request_deadline", None) + remaining = ( + max(0.001, deadline - time.monotonic()) if deadline else 3.0 + ) + bound = min(remaining, timeout) if timeout is not None else remaining + try: + return super().wait(gen, interval=interval, timeout=bound) + except psycopg.OperationalError: + self.close() + raise + + +class Database: + def __init__(self, *, url: str, size: int): + self.pool = ConnectionPool( + (lambda: identity.secret("DATABASE_URL")) + if identity.enabled() + else url, + connection_class=DeadlineConnection, + kwargs={ + "autocommit": True, + "row_factory": dict_row, + "connect_timeout": 2, + "options": ( + "-c statement_timeout=2500 -c lock_timeout=1000 " + "-c idle_in_transaction_session_timeout=6000" + ), + }, + min_size=1, + max_size=size, + timeout=1, + max_lifetime=30, + max_idle=15, + open=False, + ) + telemetry.register_pool(self.pool) + + def open(self): + self.pool.open(wait=True, timeout=10) + + def close(self): + self.pool.close(timeout=2) + + @contextmanager + def connection(self): + identity.ensure() + try: + with ( + telemetry.span( + "db.postgresql", + attributes={"db.system.name": "postgresql"}, + ), + self.pool.connection(timeout=1) as conn, + ): + conn.request_deadline = time.monotonic() + 4 + try: + yield conn + finally: + conn.request_deadline = None + except psycopg.OperationalError, psycopg.InterfaceError, PoolTimeout: + raise DomainError( + 503, "unavailable", "Database unavailable" + ) from None + + def ping(self): + with self.connection() as conn: + conn.execute("SELECT 1").fetchone() diff --git a/src/domain.py b/src/domain.py new file mode 100644 index 0000000..e595a2e --- /dev/null +++ b/src/domain.py @@ -0,0 +1,45 @@ +from dataclasses import dataclass +from datetime import UTC, datetime +from uuid import UUID + + +def utcnow() -> datetime: + return datetime.now(UTC) + + +def timestamp(value: datetime) -> str: + return value.isoformat(timespec="microseconds").replace("+00:00", "Z") + + +@dataclass(frozen=True, slots=True) +class User: + id: UUID + username: str + display_name: str + created_at: datetime + + +@dataclass(frozen=True, slots=True) +class Chat: + id: UUID + title: str + member_ids: tuple[UUID, ...] + created_at: datetime + + +@dataclass(frozen=True, slots=True) +class Message: + id: UUID + chat_id: UUID + sender_id: UUID + text: str + created_at: datetime + attachment_ids: tuple[UUID, ...] = () + + +type Record = User | Chat | Message +type Key = tuple[datetime, UUID] + + +def order_key(record: Record) -> Key: + return record.created_at, record.id diff --git a/src/errors.py b/src/errors.py new file mode 100644 index 0000000..693b2cc --- /dev/null +++ b/src/errors.py @@ -0,0 +1,16 @@ +class DomainError(Exception): + def __init__( + self, status: int, code: str, message: str, headers=None + ) -> None: + self.status = status + self.code = code + self.message = message + self.headers = headers or {} + + +def invalid() -> DomainError: + return DomainError(400, "invalid_request", "Invalid request") + + +def not_found() -> DomainError: + return DomainError(404, "not_found", "Resource not found") diff --git a/src/identity.py b/src/identity.py new file mode 100644 index 0000000..9301583 --- /dev/null +++ b/src/identity.py @@ -0,0 +1,65 @@ +"""Read only the current, bounded lease written by this service's agent.""" + +import json +import os +import ssl +import time +from pathlib import Path + +from src.errors import DomainError + +IDENTITY = Path("/run/identity") + + +def enabled(): + return os.getenv("IDENTITY_ENABLED") == "1" + + +def values(): + try: + lease = json.loads((IDENTITY / "secrets.json").read_text()) + if time.time() >= lease["valid_until"]: + raise ValueError("expired") + return lease["values"] + except OSError, ValueError, KeyError, TypeError: + raise DomainError( + 503, "unavailable", "Service identity unavailable" + ) from None + + +def ensure(): + if enabled(): + values() + + +def secret(name): + try: + value = values()[name] + if not isinstance(value, str) or not value: + raise ValueError("invalid") + return value + except KeyError, ValueError: + raise DomainError( + 503, "unavailable", "Service identity unavailable" + ) from None + + +def tls_context(): + context = ssl.create_default_context(cafile="/trust/ca.pem") + context.minimum_version = ssl.TLSVersion.TLSv1_3 + # Resolve the generation once so key/certificate always form a pair. + current = (IDENTITY / "current").resolve(strict=True) + context.load_cert_chain(current / "cert.pem", current / "key.pem") + return context + + +def redis_tls(): + if not enabled(): + return {} + return { + "ssl_ca_certs": "/trust/ca.pem", + "ssl_certfile": "/run/identity/current/cert.pem", + "ssl_keyfile": "/run/identity/current/key.pem", + "ssl_cert_reqs": "required", + "ssl_check_hostname": True, + } diff --git a/src/identity_init.py b/src/identity_init.py new file mode 100644 index 0000000..07903ea --- /dev/null +++ b/src/identity_init.py @@ -0,0 +1,41 @@ +"""Explicit one-shot volume ownership and bootstrap leaf installation.""" + +import json +import os +import shutil +from pathlib import Path + + +def main(): + owners = json.loads(os.environ["IDENTITY_OWNERS"]) + for role, uid in owners.items(): + directory = Path("/identity") / role + directory.mkdir(parents=True, exist_ok=True) + if not (directory / "current").exists(): + initial = directory / "bootstrap" + initial.mkdir(mode=0o700, exist_ok=True) + for name in ["cert.pem", "key.pem", "bundle.pem"]: + shutil.copyfile( + Path("/bootstrap") / role / name, initial / name + ) + (initial / name).chmod(0o600) + (directory / "current").symlink_to("bootstrap") + directory.chmod(0o700) + for item in [directory, *directory.rglob("*")]: + if not item.is_symlink(): + os.chown(item, uid, uid) + for name, uid in [("openbao", 1000), ("broker", 999)]: + directory = Path("/data") / name + directory.mkdir(parents=True, exist_ok=True) + os.chown(directory, uid, uid) + directory.chmod(0o700) + if name == "openbao": + for child in ["storage", "audit"]: + p = directory / child + p.mkdir(mode=0o700, exist_ok=True) + os.chown(p, uid, uid) + print("Bootstrap leaf material and persistent volume ownership prepared") + + +if __name__ == "__main__": + main() diff --git a/src/images.py b/src/images.py new file mode 100644 index 0000000..bf7f57b --- /dev/null +++ b/src/images.py @@ -0,0 +1,77 @@ +import struct +import threading +import unicodedata +import zlib + +from PIL import Image, UnidentifiedImageError + +from src.errors import DomainError, invalid + +MAX_BYTES = 10 * 1024 * 1024 +MAX_PIXELS = 40_000_000 +Image.MAX_IMAGE_PIXELS = MAX_PIXELS +DECODE_SLOT = threading.BoundedSemaphore(1) + + +def filename(value): + if ( + not value + or not 1 <= len(value) <= 255 + or not value.strip() + or any( + c in "/\\" or unicodedata.category(c) in {"Cc", "Cs"} + for c in value + ) + ): + raise invalid() + return value + + +def verify(stream, *, declared): + if declared not in {"image/png", "image/jpeg"}: + raise DomainError( + 415, "unsupported_media_type", "PNG or JPEG required" + ) + with DECODE_SLOT: + try: + stream.seek(0) + with Image.open(stream) as image: + actual = {"PNG": "image/png", "JPEG": "image/jpeg"}.get( + image.format + ) + if actual != declared: + raise DomainError( + 415, "unsupported_media_type", "Image type mismatch" + ) + if image.width * image.height > MAX_PIXELS: + raise DomainError( + 413, "payload_too_large", "Pixel limit exceeded" + ) + image.verify() + # JPEG verify alone does not decode entropy data. + stream.seek(0) + with Image.open(stream) as image: + image.load() + except Image.DecompressionBombError: + raise DomainError( + 413, "payload_too_large", "Pixel limit exceeded" + ) from None + except ( + UnidentifiedImageError, + OSError, + ValueError, + SyntaxError, + struct.error, + zlib.error, + EOFError, + ): + raise DomainError( + 415, "unsupported_media_type", "Invalid image" + ) from None + except MemoryError: + raise DomainError( + 503, "unavailable", "Image memory budget exceeded" + ) from None + finally: + stream.seek(0) + return declared diff --git a/src/logging_config.py b/src/logging_config.py new file mode 100644 index 0000000..e89db63 --- /dev/null +++ b/src/logging_config.py @@ -0,0 +1,17 @@ +import json +import logging +from datetime import UTC, datetime + + +class JsonFormatter(logging.Formatter): + def format(self, record: logging.LogRecord) -> str: + message = record.getMessage() + try: + event = json.loads(message) + if not isinstance(event, dict): + event = {"event": message} + except ValueError: + event = {"event": message} + event["timestamp"] = datetime.now(UTC).isoformat() + event["level"] = record.levelname.lower() + return json.dumps(event, ensure_ascii=False) diff --git a/src/migrate.py b/src/migrate.py new file mode 100644 index 0000000..30363ba --- /dev/null +++ b/src/migrate.py @@ -0,0 +1,51 @@ +import hashlib +import json +from pathlib import Path + +import psycopg + +from src.settings import secret + + +def main(): + with psycopg.connect( + secret("DATABASE_URL"), autocommit=True, connect_timeout=3 + ) as conn: + conn.execute("SELECT pg_advisory_lock(2301002)") + try: + conn.execute( + "CREATE TABLE IF NOT EXISTS schema_migrations " + "(name text PRIMARY KEY, checksum text NOT NULL, " + "applied_at timestamptz NOT NULL DEFAULT now())" + ) + for path in sorted(Path("migrations").glob("*.sql")): + content = path.read_bytes() + checksum = hashlib.sha256(content).hexdigest() + row = conn.execute( + "SELECT checksum FROM schema_migrations WHERE name=%s", + (path.name,), + ).fetchone() + if row: + if row[0] != checksum: + raise RuntimeError( + "Applied migration checksum mismatch" + ) + continue + with conn.transaction(): + conn.execute(content.decode()) + conn.execute( + "INSERT INTO schema_migrations(name,checksum) " + "VALUES(%s,%s)", + (path.name, checksum), + ) + print( + json.dumps( + {"event": "migration_applied", "name": path.name} + ) + ) + finally: + conn.execute("SELECT pg_advisory_unlock(2301002)") + + +if __name__ == "__main__": + main() diff --git a/src/object_store.py b/src/object_store.py new file mode 100644 index 0000000..2187686 --- /dev/null +++ b/src/object_store.py @@ -0,0 +1,102 @@ +from contextlib import contextmanager + +import urllib3 +from minio import Minio +from minio.credentials import Credentials, Provider +from minio.error import S3Error + +from src import identity, secure_http, telemetry +from src.errors import DomainError +from src.settings import secret + +BUCKET = "messenger" + + +class CurrentCredentials(Provider): + def retrieve(self): + return Credentials(secret("S3_ACCESS_KEY"), secret("S3_SECRET_KEY")) + + +class ObjectStore: + def __init__(self): + self.http = ( + secure_http.pool if identity.enabled() else urllib3.PoolManager + )( + maxsize=32, + block=True, + timeout=urllib3.Timeout(connect=1, read=3), + retries=urllib3.Retry(total=0), + ) + self.client = Minio( + "s3:9443" if identity.enabled() else "s3:9000", + credentials=CurrentCredentials(), + secure=identity.enabled(), + region="us-east-1", + http_client=self.http, + ) + + @contextmanager + def operation(self, name="request"): + try: + with telemetry.span("s3." + name, attributes={"operation": name}): + yield + except S3Error, urllib3.exceptions.HTTPError, OSError: + raise DomainError( + 503, "unavailable", "Object store unavailable" + ) from None + + def ping(self): + with self.operation("head_bucket"): + if identity.enabled(): + result = self.http.request( + "GET", "https://s3:9443/minio/health/ready" + ) + if result.status != 200: + raise DomainError( + 503, "unavailable", "Object store unavailable" + ) + return + if not self.client.bucket_exists(BUCKET): + raise DomainError( + 503, "unavailable", "Object store unavailable" + ) + + def put(self, *, key, stream, size, content_type, sha256): + stream.seek(0) + with self.operation("put"): + self.client.put_object( + BUCKET, + key, + stream, + length=size, + content_type=content_type, + metadata={"sha256": sha256}, + part_size=10 * 1024 * 1024, + num_parallel_uploads=1, + ) + + def head(self, *, key): + with self.operation("head"): + try: + return self.client.stat_object(BUCKET, key) + except S3Error as exc: + if exc.code in {"NoSuchKey", "NoSuchObject"}: + return None + raise + + def get(self, *, key): + with self.operation("get"): + return self.client.get_object(BUCKET, key) + + def delete(self, *, key): + with self.operation("delete"): + self.client.remove_object(BUCKET, key) + + def objects(self): + with self.operation("list"): + yield from self.client.list_objects( + BUCKET, prefix="objects/", recursive=True + ) + + def close(self): + self.http.clear() diff --git a/src/observer.py b/src/observer.py new file mode 100644 index 0000000..48e1baa --- /dev/null +++ b/src/observer.py @@ -0,0 +1,96 @@ +"""Bounded DB polling; pending tasks missing the deadline count as bad SLIs.""" + +import time +from uuid import uuid4 + +from src import telemetry +from src.pipeline import database + + +def poll(db, epoch): + with db.connection() as conn, conn.transaction(): + # Evaluate unfinished jobs at their deadline, not after completion. + # Exclude decided IDs before LIMIT to avoid starving newer jobs. + conn.execute( + "INSERT INTO job_slo_observations(job_id,outcome) " + "SELECT j.id,CASE WHEN e.committed_at<=j.created_at+interval '10 seconds' " + "THEN 'good' ELSE 'bad' END FROM jobs j " + "LEFT JOIN effect_publications e ON e.job_id=j.id " + "WHERE NOT EXISTS(SELECT 1 FROM job_slo_observations o WHERE o.job_id=j.id) " + "AND j.state<>'obsolete' AND (e.committed_at IS NOT NULL " + "OR j.state='failed' OR j.created_at<=clock_timestamp()-interval '10 seconds') " + "ORDER BY j.created_at LIMIT 128 ON CONFLICT DO NOTHING" + ) + queue = conn.execute( + "SELECT count(*) FILTER(WHERE state='queued') depth," + "COALESCE(max(EXTRACT(epoch FROM clock_timestamp()-created_at)) " + "FILTER(WHERE state IN ('queued','processing')),0) oldest FROM jobs" + ).fetchone() + decisions = conn.execute( + "SELECT outcome,count(*) n FROM job_slo_observations GROUP BY outcome" + ).fetchall() + completed = conn.execute( + "SELECT event,count(*) n FROM pipeline_events " + "WHERE event IN ('effect_committed','failed') GROUP BY event" + ).fetchall() + ready = conn.execute( + "SELECT o.job_id,EXTRACT(epoch FROM e.committed_at-j.created_at) seconds " + "FROM job_slo_observations o JOIN effect_publications e ON e.job_id=o.job_id " + "JOIN jobs j ON j.id=o.job_id WHERE o.histogram_epoch IS DISTINCT FROM %s::uuid " + "ORDER BY e.committed_at LIMIT 128 FOR UPDATE OF o SKIP LOCKED", + (epoch,), + ).fetchall() + for row in ready: + conn.execute( + "UPDATE job_slo_observations SET histogram_epoch=%s WHERE job_id=%s", + (epoch, row["job_id"]), + ) + values = { + "queue_depth": queue["depth"], + "oldest_job_age": float(queue["oldest"]), + "slo_good": 0, + "slo_bad": 0, + "completed_ready": 0, + "completed_failed": 0, + } + values.update({"slo_" + row["outcome"]: row["n"] for row in decisions}) + values.update( + { + "completed_" + + ( + "ready" if row["event"] == "effect_committed" else "failed" + ): row["n"] + for row in completed + } + ) + telemetry.observe(values) + for row in ready: + telemetry.duration( + "time_to_ready", + float(row["seconds"]), + {"job_type": "attachment.process.v1", "outcome": "ready"}, + ) + + +def main(): + epoch = str(uuid4()) + telemetry.configure("messenger-observer", instance=epoch) + db = database() + try: + while True: + try: + poll(db, epoch) + except Exception: + telemetry.log( + "observer.unavailable", + error=True, + error_code="database_unavailable", + ) + time.sleep(2) + finally: + db.close() + telemetry.stop() + + +if __name__ == "__main__": + main() diff --git a/src/operator.py b/src/operator.py new file mode 100644 index 0000000..b2c5cdf --- /dev/null +++ b/src/operator.py @@ -0,0 +1,123 @@ +"""Explicit local operator actions. There is deliberately no HTTP replay endpoint.""" + +import argparse +import json +from uuid import UUID, uuid4 + +from src.object_store import ObjectStore +from src.pipeline import database, enqueue, event + + +def change(db, store, *, job_id, operator, reason, version=None): + if ( + not operator.strip() + or not reason.strip() + or len(operator) > 100 + or len(reason) > 500 + ): + raise ValueError("Operator and reason are required") + with db.connection() as conn, conn.transaction(): + job = conn.execute( + "SELECT * FROM jobs WHERE id=%s FOR UPDATE", (job_id,) + ).fetchone() + if not job: + raise ValueError("Unknown job") + attachment = conn.execute( + "SELECT * FROM attachments WHERE id=%s FOR UPDATE", + (job["attachment_id"],), + ).fetchone() + if job["pipeline_version"] != attachment["pipeline_version"]: + raise ValueError("Superseded job cannot be replayed") + source = ( + job["source_key"] + if attachment["published_version"] is None + else attachment["object_key"] + ) + if store.head(key=source) is None: + raise ValueError("Source expired or missing; replay refused") + if version is None: + if job["state"] != "failed": + raise ValueError("Only failed jobs can be replayed") + conn.execute( + "UPDATE jobs SET state='queued',attempt=0,cycle=cycle+1,fence=fence+1,error_code=NULL,next_at=clock_timestamp(),lease_owner=NULL,lease_until=NULL,updated_at=clock_timestamp() WHERE id=%s", + (job_id,), + ) + action = "replay" + target = job_id + else: + if ( + version not in {1, 2} + or version <= attachment["pipeline_version"] + ): + raise ValueError("Supported version must increase (1 or 2)") + conn.execute( + "UPDATE jobs SET state='obsolete',fence=fence+1,lease_owner=NULL,lease_until=NULL WHERE id=%s", + (job_id,), + ) + target = uuid4() + conn.execute( + "INSERT INTO jobs(id,attachment_id,pipeline_version,source_key,state) VALUES(%s,%s,%s,%s,'queued')", + (target, attachment["id"], version, source), + ) + conn.execute( + "UPDATE attachments SET pipeline_version=%s WHERE id=%s", + (version, attachment["id"]), + ) + action = "new_version" + conn.execute( + "UPDATE attachments SET state='queued',error_code=NULL,updated_at=clock_timestamp() WHERE id=%s", + (attachment["id"],), + ) + conn.execute( + "INSERT INTO pipeline_audit(job_id,action,operator,reason) VALUES(%s,%s,%s,%s)", + (target, action, operator, reason), + ) + event(conn, target, action, {"previous_job": str(job_id)}) + enqueue(conn, target) + return str(target) + + +def main(): + p = argparse.ArgumentParser() + p.add_argument("action", choices=["failed", "replay", "version"]) + p.add_argument("--job-id", type=UUID) + p.add_argument("--operator") + p.add_argument("--reason") + p.add_argument("--version", type=int) + a = p.parse_args() + db, store = database(), ObjectStore() + try: + if a.action == "failed": + with db.connection() as conn: + rows = conn.execute( + "SELECT id,attachment_id,pipeline_version,attempt,cycle,error_code,updated_at FROM jobs WHERE state='failed' ORDER BY updated_at,id" + ).fetchall() + print(json.dumps(rows, default=str)) + else: + if not all([a.job_id, a.operator, a.reason]): + p.error("job-id/operator/reason required") + if a.action == "version" and a.version is None: + p.error("version required") + print( + json.dumps( + { + "job_id": change( + db, + store, + job_id=a.job_id, + operator=a.operator, + reason=a.reason, + version=a.version + if a.action == "version" + else None, + ) + } + ) + ) + finally: + db.close() + store.close() + + +if __name__ == "__main__": + main() diff --git a/src/password.py b/src/password.py new file mode 100644 index 0000000..bce8bd2 --- /dev/null +++ b/src/password.py @@ -0,0 +1,36 @@ +import threading + +from argon2 import PasswordHasher +from argon2.exceptions import InvalidHashError, VerificationError +from argon2.low_level import Type + +from src.errors import DomainError + + +class Passwords: + def __init__(self): + self.hasher = PasswordHasher( + time_cost=3, memory_cost=65536, parallelism=4, type=Type.ID + ) + self.slots = threading.BoundedSemaphore(2) + self.dummy = self.hasher.hash("Synthetic-dummy-password-not-for-login") + + def _run(self, function, *args): + if not self.slots.acquire(timeout=5): + raise DomainError(503, "unavailable", "Authentication busy") + try: + return function(*args) + finally: + self.slots.release() + + def hash(self, *, password: str) -> str: + return self._run(self.hasher.hash, password) + + def verify(self, *, password: str, encoded: str | None) -> bool: + try: + return ( + self._run(self.hasher.verify, encoded or self.dummy, password) + and encoded is not None + ) + except VerificationError, InvalidHashError: + return False diff --git a/src/pipeline.py b/src/pipeline.py new file mode 100644 index 0000000..186f24c --- /dev/null +++ b/src/pipeline.py @@ -0,0 +1,291 @@ +"""Durable job state is authoritative; stream entries are wake-up notifications.""" + +import json +import os +import random +import re +import time +from datetime import UTC, datetime +from uuid import UUID + +import redis +from psycopg.types.json import Jsonb + +from src import telemetry +from src.database import Database +from src.identity import redis_tls +from src.settings import integer, secret + +STREAM = "attachments" +GROUP = "image-workers" + + +def database(): + db = Database(url=secret("DATABASE_URL"), size=4) + db.open() + return db + + +def broker(): + return redis.Redis.from_url( + secret("BROKER_URL"), + decode_responses=True, + socket_connect_timeout=1, + socket_timeout=3, + max_connections=8, + **redis_tls(), + ) + + +def envelope(row): + return dict( + schema_version=1, + job_id=str(row["id"]), + type="attachment.process.v1", + attachment_id=str(row["attachment_id"]), + pipeline_version=row["pipeline_version"], + attempt=row["attempt"] + 1, + created_at=datetime.now(UTC).isoformat().replace("+00:00", "Z"), + ) + + +def validate_job(data): + required = { + "schema_version", + "job_id", + "type", + "attachment_id", + "pipeline_version", + "attempt", + "created_at", + } + if ( + not isinstance(data, dict) + or not required <= data.keys() + or data.keys() - required - {"traceparent", "tracestate"} + ): + raise ValueError("Invalid job envelope") + if ( + type(data["schema_version"]) is not int + or data["schema_version"] != 1 + or data["type"] != "attachment.process.v1" + ): + raise ValueError("Invalid job type") + for k in ["job_id", "attachment_id"]: + if not isinstance(data[k], str): + raise ValueError("Invalid job UUID") + UUID(data[k]) + for k in ["pipeline_version", "attempt"]: + if type(data[k]) is not int or data[k] < 1: + raise ValueError("Invalid job number") + timestamp = data["created_at"] + if not isinstance(timestamp, str) or not re.fullmatch( + r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})", + timestamp, + ): + raise ValueError("Invalid job timestamp") + datetime.fromisoformat(timestamp.replace("Z", "+00:00")) + if "traceparent" in data: + if not isinstance(data["traceparent"], str) or not re.fullmatch( + r"00-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}", data["traceparent"] + ): + raise ValueError("Invalid trace context") + if "tracestate" in data and ( + not isinstance(data["tracestate"], str) + or len(data["tracestate"]) > 512 + ): + raise ValueError("Invalid trace context") + return data + + +def event(conn, job_id, name, detail=None): + conn.execute( + "INSERT INTO pipeline_events(job_id,event,detail) VALUES(%s,%s,%s)", + (job_id, name, Jsonb(detail or {})), + ) + + +def enqueue(conn, job_id): + row = conn.execute("SELECT * FROM jobs WHERE id=%s", (job_id,)).fetchone() + context = telemetry.carrier() + if not context and row.get("traceparent"): + context = {"traceparent": row["traceparent"]} + if row.get("tracestate"): + context["tracestate"] = row["tracestate"] + if context: + conn.execute( + "UPDATE jobs SET traceparent=%s,tracestate=%s WHERE id=%s", + ( + context.get("traceparent", ""), + context.get("tracestate", ""), + job_id, + ), + ) + conn.execute( + "INSERT INTO outbox(job_id,payload,due_at) VALUES(%s,%s,%s)", + (job_id, Jsonb(envelope(row) | context), row["next_at"]), + ) + + +def fault(db, target, phase): + if os.getenv("PIPELINE_FAULTS") != "1": + return + with db.connection() as conn, conn.transaction(): + row = conn.execute( + "SELECT * FROM pipeline_faults WHERE target=%s AND phase=%s AND remaining>0 ORDER BY id FOR UPDATE SKIP LOCKED LIMIT 1", + (target, phase), + ).fetchone() + if row is None: + return + conn.execute( + "UPDATE pipeline_faults SET remaining=remaining-1,hit_at=clock_timestamp() WHERE id=%s", + (row["id"],), + ) + action = row["action"] + if action == "crash": + os._exit(89) + if action == "permanent": + raise PermanentFailure("invalid_image") + if action == "transient": + raise RuntimeError("injected_transient") + if action == "hang": + time.sleep(120) + if action == "wait": + end = time.monotonic() + 60 + while time.monotonic() < end: + with db.connection() as conn: + released = conn.execute( + "SELECT released_at FROM pipeline_faults WHERE id=%s", + (row["id"],), + ).fetchone() + if released and released["released_at"]: + return + time.sleep(0.05) + raise RuntimeError("fault_wait_timeout") + + +class PermanentFailure(Exception): + pass + + +def retry(conn, row, error, *, permanent=False): + maximum = integer("JOB_MAX_ATTEMPTS", 5, 1, 20) + failed = permanent or row["attempt"] >= maximum + delay = random.uniform(0.25, min(30, 2 ** row["attempt"])) + state = "failed" if failed else "queued" + code = error if permanent else ("retry_exhausted" if failed else error) + conn.execute( + "UPDATE jobs SET state=%s,fence=fence+1,lease_owner=NULL,lease_until=NULL,error_code=%s,next_at=clock_timestamp()+%s*interval '1 second',updated_at=clock_timestamp() WHERE id=%s", + (state, code, delay, row["id"]), + ) + conn.execute( + "UPDATE attachments SET state=%s,error_code=%s,updated_at=clock_timestamp() WHERE id=%s AND pipeline_version=%s", + ( + state, + code if failed else None, + row["attachment_id"], + row["pipeline_version"], + ), + ) + event( + conn, + row["id"], + "failed" if failed else "retry", + {"attempt": row["attempt"], "code": code, "backoff_seconds": delay}, + ) + if not failed: + enqueue(conn, row["id"]) + + +def watchdog(db): + with db.connection() as conn, conn.transaction(): + rows = conn.execute( + "SELECT * FROM jobs WHERE state='processing' AND lease_untilclock_timestamp()-interval '15 seconds')) FOR UPDATE OF j SKIP LOCKED LIMIT 16" + ).fetchall() + for row in rows: + enqueue(conn, row["id"]) + + +def relay_once(db, queue): + watchdog(db) + with db.connection() as conn, conn.transaction(): + row = conn.execute( + "SELECT * FROM outbox WHERE published_at IS NULL AND due_at<=clock_timestamp() ORDER BY id FOR UPDATE SKIP LOCKED LIMIT 1" + ).fetchone() + if not row: + return False + validate_job(row["payload"]) + with telemetry.span( + "attachments publish", + kind=telemetry.SpanKind.PRODUCER, + parent=row["payload"], + attributes={ + "job.id": str(row["job_id"]), + "messaging.system": "valkey", + "messaging.destination.name": STREAM, + }, + ): + # WAITAOF must use the SAME connection as XADD (not two pooled calls). + with queue.client() as dedicated: + entry = dedicated.xadd( + STREAM, + { + "job": json.dumps( + row["payload"] | telemetry.carrier(), + separators=(",", ":"), + ) + }, + ) + confirmation = dedicated.execute_command("WAITAOF", 1, 0, 2000) + if int(confirmation[0]) < 1: + raise RuntimeError( + "Broker durability confirmation timed out" + ) + telemetry.log("job.published", job_id=str(row["job_id"])) + fault(db, row["job_id"], "relay_after_publish") + conn.execute( + "UPDATE outbox SET published_at=clock_timestamp() WHERE id=%s", + (row["id"],), + ) + event( + conn, + row["job_id"], + "published", + {"entry": entry, "outbox": row["id"]}, + ) + return True + + +def relay(): + telemetry.configure("messenger-relay") + db, queue = database(), broker() + try: + while True: + try: + if not relay_once(db, queue): + time.sleep(0.2) + except Exception: + print( + json.dumps( + { + "event": "relay_retry", + "code": "dependency_unavailable", + } + ), + flush=True, + ) + time.sleep(1) + finally: + queue.close() + db.close() + telemetry.stop() + + +if __name__ == "__main__": + relay() diff --git a/src/reconcile.py b/src/reconcile.py new file mode 100644 index 0000000..e48d77b --- /dev/null +++ b/src/reconcile.py @@ -0,0 +1,122 @@ +"""Retention cleanup; default is dry-run. Active intent always protects bytes.""" + +import argparse +import json +import time + +from src.object_store import ObjectStore +from src.pipeline import database +from src.settings import integer + + +def reconcile(db, store, *, apply=False, grace=None): + grace = ( + grace + if grace is not None + else integer("STAGING_RETENTION_SECONDS", 86400, 300, 604800) + ) + if grace < 300: + raise ValueError("Retention must be at least 300 seconds") + actions = [] + for obj in store.objects(): + # Recheck each candidate in a bounded transaction, including late PUT age. + with db.connection() as conn, conn.transaction(): + now = conn.execute("SELECT clock_timestamp() now").fetchone()[ + "now" + ] + if (now - obj.last_modified).total_seconds() < grace: + continue + reservation = conn.execute( + "SELECT * FROM upload_reservations WHERE object_key=%s FOR UPDATE", + (obj.object_name,), + ).fetchone() + if reservation and reservation["expires_at"] > now: + continue + jobs = conn.execute( + "SELECT * FROM jobs WHERE source_key=%s OR %s LIKE 'objects/' || attachment_id::text || '/v' || pipeline_version::text || '/%%' FOR UPDATE", + (obj.object_name, obj.object_name), + ).fetchall() + if any(j["state"] in {"queued", "processing"} for j in jobs): + continue + current = conn.execute( + "SELECT v.* FROM attachment_variants v JOIN attachments a ON a.id=v.attachment_id AND a.published_version=v.pipeline_version WHERE v.object_key=%s", + (obj.object_name,), + ).fetchone() + if current: + continue + if any( + j["state"] == "failed" + and (now - j["updated_at"]).total_seconds() < grace + for j in jobs + ): + continue + head = store.head(key=obj.object_name) + if ( + head is None + or (now - head.last_modified).total_seconds() < grace + ): + continue + action = { + "action": "delete_expired_object", + "key": obj.object_name, + "applied": apply, + } + if apply: + # Taking the reservation lock fences an expired API before deletion. + if reservation: + conn.execute( + "DELETE FROM upload_reservations WHERE id=%s", + (reservation["id"],), + ) + store.delete(key=obj.object_name) + for job in jobs: + if ( + job["state"] == "failed" + and job["source_key"] == obj.object_name + ): + conn.execute( + "UPDATE jobs SET error_code='source_expired' WHERE id=%s", + (job["id"],), + ) + conn.execute( + "UPDATE attachments SET error_code='source_expired' WHERE id=%s AND pipeline_version=%s AND state='failed'", + (job["attachment_id"], job["pipeline_version"]), + ) + actions.append(action) + return {"apply": apply, "retention_seconds": grace, "actions": actions} + + +def main(): + p = argparse.ArgumentParser() + p.add_argument("--apply", action="store_true") + p.add_argument("--loop", action="store_true") + a = p.parse_args() + db, store = database(), ObjectStore() + try: + while True: + try: + print( + json.dumps(reconcile(db, store, apply=a.apply)), flush=True + ) + except Exception: + if not a.loop: + raise + print( + json.dumps( + { + "event": "cleanup_retry", + "code": "dependency_unavailable", + } + ), + flush=True, + ) + if not a.loop: + break + time.sleep(60) + finally: + db.close() + store.close() + + +if __name__ == "__main__": + main() diff --git a/src/repository.py b/src/repository.py new file mode 100644 index 0000000..3f5d213 --- /dev/null +++ b/src/repository.py @@ -0,0 +1,319 @@ +import hashlib +import json +from uuid import UUID + +from psycopg.errors import ForeignKeyViolation, UniqueViolation + +from src.cache import UserCache +from src.database import Database +from src.domain import Chat, Key, Message, User +from src.errors import DomainError, invalid, not_found + +MESSAGE_COLUMNS = ( + "m.*, ARRAY(SELECT attachment_id FROM message_attachments ma " + "WHERE ma.message_id=m.id ORDER BY ma.position) attachment_ids" +) + +USER_COLUMNS = "id, username, display_name, created_at" + + +def user_dto(row) -> User: + return User( + row["id"], row["username"], row["display_name"], row["created_at"] + ) + + +def chat_dto(row) -> Chat: + return Chat( + row["id"], row["title"], tuple(row["member_ids"]), row["created_at"] + ) + + +def message_dto(row) -> Message: + return Message( + row["id"], + row["chat_id"], + row["sender_id"], + row["text"], + row["created_at"], + tuple(row.get("attachment_ids", ())), + ) + + +class PostgresRepository: + def __init__(self, *, database: Database, cache: UserCache): + self.database = database + self.cache = cache + + def limit_login(self, *, username: str): + # One transaction serializes both buckets across every API replica. + with self.database.connection() as conn, conn.transaction(): + wait = conn.execute( + "SELECT login_wait(%s) wait", + (hashlib.sha256(username.encode()).hexdigest(),), + ).fetchone()["wait"] + if wait: + raise DomainError( + 429, + "rate_limited", + "Too many login attempts", + headers={"Retry-After": str(wait)}, + ) + + def rehash_password(self, *, user_id, previous, current): + with self.database.connection() as conn: + conn.execute( + "UPDATE users SET password_hash=%s " + "WHERE id=%s AND password_hash=%s", + (current, user_id, previous), + ) + + def add_user(self, *, user: User, password_hash: str) -> User: + try: + with self.database.connection() as conn: + conn.execute( + "INSERT INTO users(id,username,display_name," + "password_hash,created_at) VALUES(%s,%s,%s,%s,%s)", + ( + user.id, + user.username, + user.display_name, + password_hash, + user.created_at, + ), + ) + except UniqueViolation: + raise DomainError( + 409, "conflict", "Username already exists" + ) from None + return user + + def get_user(self, *, user_id: UUID) -> User | None: + cached = self.cache.get(user_id=user_id) + if cached is not None: + return cached + with self.database.connection() as conn: + row = conn.execute( + "SELECT " + USER_COLUMNS + " FROM users WHERE id=%s", + (user_id,), + ).fetchone() + if row is None: + return None + user = user_dto(row) + self.cache.put(user=user) + return user + + def credentials(self, *, username: str): + with self.database.connection() as conn: + row = conn.execute( + "SELECT " + + USER_COLUMNS + + ", password_hash FROM users WHERE username=%s", + (username,), + ).fetchone() + if row is None: + return None, None + return user_dto(row), row["password_hash"] + + def username_exists(self, *, username: str) -> bool: + with self.database.connection() as conn: + return ( + conn.execute( + "SELECT 1 FROM users WHERE username=%s", (username,) + ).fetchone() + is not None + ) + + def add_session( + self, *, digest: bytes, user_id: UUID, created_at, expires_at + ): + with self.database.connection() as conn: + conn.execute( + "INSERT INTO sessions(token_digest,user_id,created_at," + "expires_at) VALUES(%s,%s,%s,%s)", + (digest, user_id, created_at, expires_at), + ) + + def session_user(self, *, digest: bytes) -> UUID | None: + with self.database.connection() as conn: + row = conn.execute( + "SELECT user_id FROM sessions WHERE token_digest=%s " + "AND expires_at>clock_timestamp()", + (digest,), + ).fetchone() + return row["user_id"] if row else None + + def delete_session(self, *, digest: bytes): + with self.database.connection() as conn: + conn.execute( + "DELETE FROM sessions WHERE token_digest=%s", (digest,) + ) + + def add_chat(self, *, chat: Chat, actor_id: UUID) -> Chat: + members = chat.member_ids + if actor_id not in members or len(set(members)) != len(members): + raise invalid() + try: + with self.database.connection() as conn, conn.transaction(): + conn.execute( + "INSERT INTO chats(id,title,created_at) VALUES(%s,%s,%s)", + (chat.id, chat.title, chat.created_at), + ) + with conn.cursor() as cursor: + cursor.executemany( + "INSERT INTO members(chat_id,user_id,position) " + "VALUES(%s,%s,%s)", + [ + (chat.id, user_id, position) + for position, user_id in enumerate(members) + ], + ) + except ForeignKeyViolation: + raise invalid() from None + return chat + + def get_chat(self, *, chat_id: UUID, actor_id: UUID) -> Chat: + with self.database.connection() as conn: + row = conn.execute( + "SELECT c.id,c.title,c.created_at," + "array_agg(m.user_id ORDER BY m.position) member_ids " + "FROM chats c JOIN members m ON m.chat_id=c.id " + "WHERE c.id=%s AND EXISTS(SELECT 1 FROM members own " + "WHERE own.chat_id=c.id AND own.user_id=%s) GROUP BY c.id", + (chat_id, actor_id), + ).fetchone() + if row is None: + raise not_found() + return chat_dto(row) + + def add_message( + self, *, message: Message, idempotency_key: str + ) -> Message: + # Область включает пользователя, метод и нормализованный путь чата. + scope = f"{message.sender_id}:POST:{message.chat_id}:{idempotency_key}" + lock = int.from_bytes( + hashlib.sha256(scope.encode()).digest()[:8], "big", signed=True + ) + fingerprint = hashlib.sha256( + json.dumps( + { + "text": message.text, + "attachment_ids": [str(x) for x in message.attachment_ids], + }, + ensure_ascii=False, + sort_keys=True, + separators=(",", ":"), + ).encode() + ).digest() + try: + with self.database.connection() as conn, conn.transaction(): + conn.execute("SELECT pg_advisory_xact_lock(%s)", (lock,)) + prior = conn.execute( + "SELECT i.body_hash,i.message_id," + "i.expires_at>clock_timestamp() active " + "FROM idempotency i WHERE user_id=%s AND chat_id=%s " + "AND key=%s FOR UPDATE", + (message.sender_id, message.chat_id, idempotency_key), + ).fetchone() + if prior and prior["active"]: + if bytes(prior["body_hash"]) != fingerprint: + raise DomainError(409, "conflict", "Key already used") + row = conn.execute( + "SELECT " + + MESSAGE_COLUMNS + + " FROM messages m WHERE m.id=%s", + (prior["message_id"],), + ).fetchone() + return message_dto(row) + if message.attachment_ids: + rows = conn.execute( + "SELECT id,state FROM attachments WHERE chat_id=%s " + "AND id=ANY(%s) FOR SHARE", + (message.chat_id, list(message.attachment_ids)), + ).fetchall() + if len(rows) != len(message.attachment_ids): + raise not_found() + if any(row["state"] == "failed" for row in rows): + raise DomainError( + 409, "conflict", "Attachment is not ready" + ) + conn.execute( + "INSERT INTO messages(id,chat_id,sender_id," + "text,created_at) " + "VALUES(%s,%s,%s,%s,%s)", + ( + message.id, + message.chat_id, + message.sender_id, + message.text, + message.created_at, + ), + ) + if message.attachment_ids: + with conn.cursor() as cursor: + cursor.executemany( + "INSERT INTO message_attachments(" + "message_id,chat_id," + "attachment_id,position) " + "VALUES(%s,%s,%s,%s)", + [ + (message.id, message.chat_id, aid, i) + for i, aid in enumerate(message.attachment_ids) + ], + ) + conn.execute( + "INSERT INTO idempotency(user_id,chat_id,key,body_hash," + "message_id,expires_at) VALUES(%s,%s,%s,%s,%s," + "clock_timestamp()+interval '24 hours') " + "ON CONFLICT(user_id,chat_id,key) DO UPDATE SET " + "body_hash=excluded.body_hash,message_id=excluded.message_id," + "expires_at=excluded.expires_at", + ( + message.sender_id, + message.chat_id, + idempotency_key, + fingerprint, + message.id, + ), + ) + except ForeignKeyViolation: + raise not_found() from None + return message + + def list_chats( + self, *, actor_id: UUID, after: Key | None, limit: int + ) -> list[Chat]: + condition = "AND (c.created_at,c.id)>(%s,%s)" if after else "" + parameters = ( + [actor_id, *after, limit + 1] if after else [actor_id, limit + 1] + ) + with self.database.connection() as conn: + rows = conn.execute( + "SELECT c.id,c.title,c.created_at,ARRAY(SELECT user_id " + "FROM members WHERE chat_id=c.id " + "ORDER BY position) member_ids " + "FROM chats c JOIN members own ON own.chat_id=c.id " + "WHERE own.user_id=%s " + + condition + + " ORDER BY c.created_at,c.id LIMIT %s", + parameters, + ).fetchall() + return [chat_dto(row) for row in rows] + + def list_messages( + self, *, chat_id: UUID, actor_id: UUID, after: Key | None, limit: int + ) -> list[Message]: + condition = "AND (m.created_at,m.id)>(%s,%s)" if after else "" + parameters = ( + [chat_id, *after, limit + 1] if after else [chat_id, limit + 1] + ) + with self.database.connection() as conn: + rows = conn.execute( + "SELECT " + + MESSAGE_COLUMNS + + " FROM messages m WHERE m.chat_id=%s " + + condition + + " ORDER BY m.created_at,m.id LIMIT %s", + parameters, + ).fetchall() + return [message_dto(row) for row in rows] diff --git a/src/runtime.py b/src/runtime.py new file mode 100644 index 0000000..adfb3b7 --- /dev/null +++ b/src/runtime.py @@ -0,0 +1,66 @@ +"""Supervise one application process and its narrowly scoped identity agent.""" + +import json +import os +import signal +import subprocess +import sys +import time +from pathlib import Path + + +def main(): + role = os.environ["SERVICE_ROLE"] + agent = subprocess.Popen( + ["/usr/local/bin/tls-gateway", "/etc/tls/" + role + ".json"] + ) + child = None + + def stop(number, _): + if child is not None and child.poll() is None: + child.send_signal(number) + if agent.poll() is None: + agent.send_signal(signal.SIGTERM) + + signal.signal(signal.SIGTERM, stop) + signal.signal(signal.SIGINT, stop) + try: + deadline = time.monotonic() + 90 + while time.monotonic() < deadline: + if agent.poll() is not None: + raise RuntimeError("Identity agent stopped") + try: + data = json.loads(Path("/run/identity/agent.json").read_text()) + if data["refreshed_at"] > time.time() - 60: + break + except OSError, ValueError, KeyError: + pass + time.sleep(0.2) + else: + raise RuntimeError("Identity startup deadline") + child = subprocess.Popen( + [sys.executable, "-m", sys.argv[1], *sys.argv[2:]] + ) + while child.poll() is None: + if agent.poll() is not None: + child.terminate() + break + time.sleep(0.2) + try: + status = child.wait(timeout=28) + except subprocess.TimeoutExpired: + child.kill() + status = child.wait() + raise SystemExit(status) + finally: + if agent.poll() is None: + agent.terminate() + try: + agent.wait(timeout=3) + except subprocess.TimeoutExpired: + agent.kill() + agent.wait() + + +if __name__ == "__main__": + main() diff --git a/src/schemas.py b/src/schemas.py new file mode 100644 index 0000000..744618c --- /dev/null +++ b/src/schemas.py @@ -0,0 +1,65 @@ +import re +from typing import Annotated +from uuid import UUID + +from pydantic import ( + BaseModel, + BeforeValidator, + ConfigDict, + Field, + StrictStr, + ValidationInfo, + field_validator, + model_validator, +) + +from src.cursor import parse_uuid + +UuidIn = Annotated[UUID, BeforeValidator(parse_uuid)] + + +class Input(BaseModel): + model_config = ConfigDict(extra="forbid") + + @field_validator("*", mode="after") + @classmethod + def nonblank(cls, value: object, info: ValidationInfo) -> object: + if isinstance(value, str) and ( + (not value.strip() and info.field_name != "text") + or any(0xD800 <= ord(c) <= 0xDFFF for c in value) + ): + raise ValueError("Invalid text") + return value + + +class CreateUser(Input): + username: StrictStr + display_name: StrictStr = Field(min_length=1, max_length=100) + password: StrictStr = Field(min_length=12, max_length=128) + + @field_validator("username") + @classmethod + def username_format(cls, value: str) -> str: + if not re.fullmatch(r"[a-z0-9_]{3,32}", value): + raise ValueError("Invalid username") + return value + + +class CreateChat(Input): + title: StrictStr = Field(min_length=1, max_length=100) + member_ids: list[UuidIn] = Field(min_length=1, max_length=100, strict=True) + + +class CreateMessage(Input): + text: StrictStr = Field(max_length=4000) + attachment_ids: list[UuidIn] = Field( + default_factory=list, max_length=10, strict=True + ) + + @model_validator(mode="after") + def content(self): + if len(set(self.attachment_ids)) != len(self.attachment_ids): + raise ValueError("Duplicate attachment") + if not self.text.strip() and not self.attachment_ids: + raise ValueError("Empty message") + return self diff --git a/src/secure_http.py b/src/secure_http.py new file mode 100644 index 0000000..528b3bd --- /dev/null +++ b/src/secure_http.py @@ -0,0 +1,26 @@ +"""Reload trust and the current client leaf for every network connection.""" + +import urllib3 +from urllib3.connection import HTTPSConnection +from urllib3.connectionpool import HTTPSConnectionPool + +from src import identity + + +class CurrentConnection(HTTPSConnection): + def connect(self): + self.ssl_context = identity.tls_context() + self.cert_reqs = "CERT_REQUIRED" + return super().connect() + + +class CurrentPool(HTTPSConnectionPool): + ConnectionCls = CurrentConnection + + +def pool(**kwargs): + manager = urllib3.PoolManager(**kwargs) + # Copy before changing: PoolManager otherwise shares the class mapping. + manager.pool_classes_by_scheme = dict(manager.pool_classes_by_scheme) + manager.pool_classes_by_scheme["https"] = CurrentPool + return manager diff --git a/src/security_probe.py b/src/security_probe.py new file mode 100644 index 0000000..6bd6725 --- /dev/null +++ b/src/security_probe.py @@ -0,0 +1,328 @@ +"""Operator-only in-network negative tests. Outputs no credentials.""" + +import io +import json +import socket +import ssl +import urllib.error +import urllib.request +from functools import partial +from pathlib import Path +from uuid import uuid4 + +import psycopg +import redis +import urllib3 +from minio import Minio +from minio.credentials import StaticProvider +from minio.error import S3Error +from psycopg.errors import InsufficientPrivilege + + +def context(role=None, *, foreign=False, wrong_ca=False): + ctx = ssl.create_default_context( + cafile="/probe-fixtures/foreign-ca.pem" + if wrong_ca + else "/trust/ca.pem" + ) + ctx.minimum_version = ssl.TLSVersion.TLSv1_3 + if role: + directory = ( + Path("/probe-fixtures/foreign") + if foreign + else Path("/identities") / role / "current" + ) + ctx.load_cert_chain(directory / "cert.pem", directory / "key.pem") + return ctx + + +def exchange( + host, + port, + role, + request, + *, + address=None, + foreign=False, + wrong_ca=False, + hostname=None, +): + with socket.create_connection((address or host, port), timeout=4) as raw: + with context(role, foreign=foreign, wrong_ca=wrong_ca).wrap_socket( + raw, server_hostname=hostname or host + ) as conn: + conn.sendall(request) + result = conn.recv(8192) + assert result, "Empty response is not proof of authorization" + return result + + +def denied(action): + try: + action() + except ssl.SSLError: + return True + raise AssertionError("TLS identity unexpectedly accepted") + + +def values(role): + return json.loads( + (Path("/identities") / role / "secrets.json").read_text() + )["values"] + + +def main(): + report = {"complete": False, "tls": [], "bypass": [], "database": {}} + request = ( + b"GET /health/live HTTP/1.1\r\nHost: api\r\nConnection: close\r\n\r\n" + ) + addresses = sorted( + { + x[4][0] + for x in socket.getaddrinfo( + "api", 8443, type=socket.SOCK_STREAM, family=socket.AF_INET + ) + } + ) + assert len(addresses) >= 2, "Both API replicas must be running" + endpoints = [ + ("api", 8443, "lb", "worker", request, ip) for ip in addresses + ] + body = b"{}" + otlp = ( + b"POST /v1/traces HTTP/1.1\r\nHost: otel\r\n" + b"Content-Type: application/json\r\nContent-Length: 2\r\n" + b"Connection: close\r\n\r\n" + body + ) + endpoints += [ + ("otel", 4438, "api", "lb", otlp, None), + ("broker", 6380, "worker", "api", b"*1\r\n$4\r\nPING\r\n", None), + ] + for host, port, good, wrong, payload, address in endpoints: + response = exchange(host, port, good, payload, address=address) + assert b" 200 " in response or response.startswith(b"-NOAUTH"), ( + host, + response[:80], + ) + result = { + "host": host, + "port": port, + "address": address, + "authorized": True, + } + for case, role, foreign in [ + ("no_certificate", None, False), + ("foreign_ca", good, True), + ("trusted_wrong_identity", wrong, False), + ]: + result[case + "_denied"] = denied( + partial( + exchange, + host, + port, + role, + payload, + address=address, + foreign=foreign, + ) + ) + report["tls"].append(result) + report["tls_server_ca_denied"] = denied( + lambda: exchange("api", 8443, "lb", request, wrong_ca=True) + ) + report["tls_server_hostname_denied"] = denied( + lambda: exchange( + "api", 8443, "lb", request, hostname="unexpected.invalid" + ) + ) + for host, port in [ + ("api", 8080), + ("postgres", 5432), + ("broker", 6379), + ("cache", 6379), + ("s3", 9000), + ("otel", 4318), + ("otel", 8889), + ("prometheus", 9090), + ("loki", 3100), + ("tempo", 3200), + ("grafana", 3000), + ("lb", 8404), + ]: + try: + with socket.create_connection((host, port), timeout=2): + raise AssertionError("Plaintext boundary bypass: " + host) + except ConnectionRefusedError: + report["bypass"].append( + {"host": host, "port": port, "closed": True} + ) + worker = values("worker") + with psycopg.connect( + worker["DATABASE_URL"].replace( + "/run/identity/", "/identities/worker/" + ), + connect_timeout=3, + autocommit=True, + ) as connection: + assert connection.execute("SELECT 1").fetchone()[0] == 1 + for key, query in [ + ( + "user_passwords_denied", + "SELECT password_hash FROM users LIMIT 1", + ), + ( + "session_hashes_denied", + "SELECT token_digest FROM sessions LIMIT 1", + ), + ("create_role_denied", "CREATE ROLE unauthorized_probe LOGIN"), + ]: + try: + connection.execute(query) + except InsufficientPrivilege: + report["database"][key] = True + else: + raise AssertionError( + "Worker SQL privilege was excessive: " + key + ) + url = worker["BROKER_URL"] + queue = redis.Redis.from_url( + url, + ssl_ca_certs="/trust/ca.pem", + ssl_certfile="/identities/worker/current/cert.pem", + ssl_keyfile="/identities/worker/current/key.pem", + ssl_cert_reqs="required", + ssl_check_hostname=True, + socket_timeout=3, + socket_connect_timeout=3, + ) + try: + assert queue.ping() + try: + queue.config_get("*") + except redis.exceptions.NoPermissionError: + report["broker_admin_denied"] = True + else: + raise AssertionError( + "Worker received broker administration privileges" + ) + finally: + queue.close() + + # Real service certificate authentication against persistent OpenBao. + def bao(method, path, payload=None, token=None): + headers = {"Content-Type": "application/json"} + if token: + headers["X-Vault-Token"] = token + request = urllib.request.Request( + "https://openbao:8200/v1/" + path, + data=json.dumps(payload).encode() if payload is not None else None, + method=method, + headers=headers, + ) + try: + with urllib.request.urlopen( + request, context=context("worker"), timeout=4 + ) as response: + return response.status, json.load( + response + ) if response.length != 0 else {} + except urllib.error.HTTPError as error: + return error.code, {} + + status, login = bao("POST", "auth/cert/login", {}) + assert status == 200 + token = login["auth"]["client_token"] + assert set(login["auth"]["policies"]) == {"messenger-worker"} + report["openbao"] = { + "service_policies": login["auth"]["policies"], + "token_ttl_seconds": login["auth"]["lease_duration"], + } + assert bao("GET", "secret/data/worker", token=token)[0] == 200 + for key, method, path, payload in [ + ("foreign_secret_denied", "GET", "secret/data/api", None), + ( + "policy_write_denied", + "PUT", + "sys/policies/acl/messenger-worker", + {"policy": 'path "*" { capabilities=["sudo"] }'}, + ), + ( + "foreign_pki_role_denied", + "POST", + "pki/issue/lb", + {"common_name": "lb"}, + ), + ]: + assert bao(method, path, payload, token)[0] == 403, key + report["openbao"][key] = True + clients = {} + pools = [] + for role in ["api", "worker", "reconciler"]: + credentials = values(role) + pool = urllib3.PoolManager( + ssl_context=context(role), + timeout=urllib3.Timeout(connect=2, read=4), + retries=False, + ) + pools.append(pool) + clients[role] = Minio( + "s3:9443", + credentials=StaticProvider( + credentials["S3_ACCESS_KEY"], credentials["S3_SECRET_KEY"] + ), + secure=True, + http_client=pool, + region="us-east-1", + ) + prefix = uuid4().hex + staging = "objects/staging/probe-" + prefix + derived = "objects/probe-" + prefix + "/v1/original" + + def put(role, key): + clients[role].put_object( + "messenger", key, io.BytesIO(b"Synthetic IAM probe"), 19 + ) + + def s3_denied(action): + try: + action() + except S3Error as error: + assert error.code == "AccessDenied", error.code + return True + raise AssertionError("S3 operation unexpectedly allowed") + + try: + put("api", staging) + received = clients["worker"].get_object("messenger", staging) + try: + assert received.read() == b"Synthetic IAM probe" + finally: + received.close() + received.release_conn() + put("worker", derived) + report["s3"] = { + "api_staging_write": True, + "worker_source_read": True, + "worker_derived_write": True, + "api_derived_write_denied": s3_denied(lambda: put("api", derived)), + "worker_staging_write_denied": s3_denied( + lambda: put("worker", staging) + ), + "worker_other_bucket_denied": s3_denied( + lambda: clients["worker"].list_buckets() + ), + "worker_delete_denied": s3_denied( + lambda: clients["worker"].remove_object("messenger", derived) + ), + } + finally: + for key in [staging, derived]: + clients["reconciler"].remove_object("messenger", key) + for pool in pools: + pool.clear() + report["complete"] = True + print(json.dumps(report)) + + +if __name__ == "__main__": + main() diff --git a/src/service.py b/src/service.py new file mode 100644 index 0000000..6e5bd0e --- /dev/null +++ b/src/service.py @@ -0,0 +1,199 @@ +import base64 +import hashlib +import re +import secrets +import threading +from datetime import timedelta +from uuid import UUID, uuid4 + +from src.cursor import decode_cursor, encode_cursor +from src.domain import Chat, Message, Record, User, order_key, utcnow +from src.errors import DomainError, invalid, not_found +from src.password import Passwords +from src.repository import PostgresRepository + + +def page(*, rows: list[Record], limit: int, scope: str) -> dict: + items = rows[:limit] + cursor = ( + encode_cursor(scope=scope, key=order_key(items[-1])) + if len(rows) > limit + else None + ) + return {"items": items, "next_cursor": cursor} + + +def unauthorized(*, basic=False): + challenge = ( + 'Basic realm="messenger", charset="UTF-8"' + if basic + else 'Bearer realm="messenger"' + ) + return DomainError( + 401, + "unauthorized", + "Authentication required", + {"WWW-Authenticate": challenge}, + ) + + +def bearer(value): + if not value: + raise unauthorized() + scheme, _, token = value.partition(" ") + if scheme.lower() != "bearer" or not re.fullmatch( + r"[A-Za-z0-9_-]{32,256}", token + ): + raise unauthorized() + return token + + +def token_digest(value): + return hashlib.sha256(value.encode()).digest() + + +class MessengerService: + def __init__( + self, + *, + repository: PostgresRepository, + passwords: Passwords, + session_ttl: int, + ) -> None: + self.repository = repository + self.passwords = passwords + self.session_ttl = session_ttl + self.registration_locks = [threading.Lock() for _ in range(64)] + + def identify(self, *, value: str | None) -> User: + token = bearer(value) + user_id = self.repository.session_user(digest=token_digest(token)) + user = self.repository.get_user(user_id=user_id) if user_id else None + if user is None: + raise unauthorized() + return user + + def register( + self, *, username: str, display_name: str, password: str + ) -> User: + # Bound lock memory and avoid running Argon2 for every local duplicate. + # Different replicas still race safely through PostgreSQL UNIQUE. + stripe = hashlib.sha256(username.encode()).digest()[0] % 64 + lock = self.registration_locks[stripe] + if not lock.acquire(timeout=8): + raise DomainError(503, "unavailable", "Registration busy") + try: + if self.repository.username_exists(username=username): + raise DomainError(409, "conflict", "Username already exists") + encoded = self.passwords.hash(password=password) + return self.repository.add_user( + user=User(uuid4(), username, display_name, utcnow()), + password_hash=encoded, + ) + finally: + lock.release() + + def login(self, *, authorization: str | None): + try: + scheme, _, encoded = (authorization or "").partition(" ") + if scheme.lower() != "basic": + raise ValueError + plain = base64.b64decode(encoded, validate=True).decode("utf-8") + username, separator, password = plain.partition(":") + if ( + not separator + or not re.fullmatch(r"[a-z0-9_]{3,32}", username) + or not 12 <= len(password) <= 128 + or not password.strip() + ): + raise ValueError + except ValueError, UnicodeError: + raise unauthorized(basic=True) from None + self.repository.limit_login(username=username) + user, password_hash = self.repository.credentials(username=username) + if not self.passwords.verify(password=password, encoded=password_hash): + raise unauthorized(basic=True) + if self.passwords.hasher.check_needs_rehash(password_hash): + self.repository.rehash_password( + user_id=user.id, + previous=password_hash, + current=self.passwords.hash(password=password), + ) + now = utcnow() + expires = now + timedelta(seconds=self.session_ttl) + token = secrets.token_urlsafe(32) + self.repository.add_session( + digest=token_digest(token), + user_id=user.id, + created_at=now, + expires_at=expires, + ) + return { + "token": token, + "token_type": "Bearer", + "expires_at": expires, + "user": user, + } + + def logout(self, *, authorization: str | None): + self.identify(value=authorization) + self.repository.delete_session( + digest=token_digest(bearer(authorization)) + ) + + def create_chat( + self, *, actor_id: UUID, title: str, member_ids: list[UUID] + ) -> Chat: + return self.repository.add_chat( + chat=Chat(uuid4(), title, tuple(member_ids), utcnow()), + actor_id=actor_id, + ) + + def get_chat(self, *, actor_id: UUID, chat_id: UUID) -> Chat: + return self.repository.get_chat(actor_id=actor_id, chat_id=chat_id) + + def send( + self, + *, + actor_id: UUID, + chat_id: UUID, + text: str, + idempotency_key: str | None, + attachment_ids: list[UUID], + ) -> Message: + if not idempotency_key or not re.fullmatch( + r"[A-Za-z0-9._:-]{1,128}", idempotency_key + ): + raise invalid() + return self.repository.add_message( + message=Message( + uuid4(), + chat_id, + actor_id, + text, + utcnow(), + tuple(attachment_ids), + ), + idempotency_key=idempotency_key, + ) + + def chats(self, *, actor_id: UUID, limit: int, cursor: str | None) -> dict: + scope = f"chats:{actor_id}" + after = decode_cursor(value=cursor, scope=scope) + rows = self.repository.list_chats( + actor_id=actor_id, after=after, limit=limit + ) + return page(rows=rows, limit=limit, scope=scope) + + def history( + self, *, actor_id: UUID, chat: Chat, limit: int, cursor: str | None + ) -> dict: + if actor_id not in chat.member_ids: + raise not_found() + chat_id = chat.id + scope = f"messages:{chat_id}" + after = decode_cursor(value=cursor, scope=scope) + rows = self.repository.list_messages( + actor_id=actor_id, chat_id=chat_id, after=after, limit=limit + ) + return page(rows=rows, limit=limit, scope=scope) diff --git a/src/settings.py b/src/settings.py new file mode 100644 index 0000000..9aa9f0b --- /dev/null +++ b/src/settings.py @@ -0,0 +1,41 @@ +import os +from dataclasses import dataclass, field +from pathlib import Path + + +def secret(name: str) -> str: + from src import identity + + if identity.enabled(): + return identity.secret(name) + file = os.environ.get(name + "_FILE") + if file: + return Path(file).read_text().strip() + value = os.environ.get(name) + if not value: + raise ValueError("Missing required secret setting: " + name) + return value + + +def integer(name: str, default: int, low: int, high: int) -> int: + value = int(os.environ.get(name, str(default))) + if not low <= value <= high: + raise ValueError("Invalid setting: " + name) + return value + + +@dataclass(frozen=True) +class Settings: + database_url: str = field(repr=False) + cache_url: str = field(repr=False) + session_ttl: int = 3600 + pool_size: int = 10 + + @classmethod + def load(cls): + return cls( + secret("DATABASE_URL"), + secret("CACHE_URL"), + integer("SESSION_TTL_SECONDS", 3600, 1, 86400), + integer("DB_POOL_SIZE", 10, 1, 32), + ) diff --git a/src/telemetry.py b/src/telemetry.py new file mode 100644 index 0000000..76a9749 --- /dev/null +++ b/src/telemetry.py @@ -0,0 +1,441 @@ +"""Explicit OTLP signals; no HTTP bodies, credentials, SQL or raw URLs.""" + +import json +import os +import re +import threading +import time +import weakref +from contextlib import contextmanager +from pathlib import Path +from types import SimpleNamespace +from uuid import uuid4 + +import psutil +from opentelemetry import trace +from opentelemetry._logs import SeverityNumber +from opentelemetry.exporter.otlp.proto.http._log_exporter import ( + OTLPLogExporter, +) +from opentelemetry.exporter.otlp.proto.http.metric_exporter import ( + OTLPMetricExporter, +) +from opentelemetry.exporter.otlp.proto.http.trace_exporter import ( + OTLPSpanExporter, +) +from opentelemetry.metrics import Observation +from opentelemetry.sdk._logs import LoggerProvider +from opentelemetry.sdk._logs.export import BatchLogRecordProcessor +from opentelemetry.sdk.metrics import Histogram, MeterProvider +from opentelemetry.sdk.metrics.export import PeriodicExportingMetricReader +from opentelemetry.sdk.metrics.view import ( + ExplicitBucketHistogramAggregation, + View, +) +from opentelemetry.sdk.resources import Resource +from opentelemetry.sdk.trace import TracerProvider +from opentelemetry.sdk.trace.export import BatchSpanProcessor +from opentelemetry.sdk.trace.sampling import ParentBased, TraceIdRatioBased +from opentelemetry.trace import SpanKind, Status, StatusCode +from opentelemetry.trace.propagation.tracecontext import ( + TraceContextTextMapPropagator, +) + +_state = None +_lock = threading.Lock() +_pools = weakref.WeakSet() +_instruments = {} +_observer = {} +_propagator = TraceContextTextMapPropagator() +BUCKETS = ( + 0.005, + 0.01, + 0.025, + 0.05, + 0.1, + 0.25, + 0.5, + 1, + 2.5, + 5, + 10, + 20, + 60, + 120, +) +LOG_FIELDS = { + "request_id", + "job_id", + "attachment_id", + "method", + "route", + "status", + "duration_seconds", + "attempt", + "version", + "fence", + "outcome", + "error_code", + "operation", + "cycle", +} +TRACE_FIELDS = { + "request_id", + "job.id", + "attachment.id", + "pipeline.version", + "job.attempt", + "db.system.name", + "operation", + "messaging.system", + "messaging.destination.name", + "http.route", + "http.request.method", + "http.response.status_code", + "error.type", +} + + +def enabled(): + return os.getenv("OTEL_ENABLED", "0") == "1" + + +def register_pool(pool): + _pools.add(pool) + + +def observe(values): + _observer.update(values) + + +def _pool_stat(key): + stats = [p.get_stats() for p in list(_pools)] + if key == "used": + return sum( + max(0, s.get("pool_size", 0) - s.get("pool_available", 0)) + for s in stats + ) + return sum(s.get("requests_waiting", 0) for s in stats) + + +def configure(service, *, instance=None, with_metrics=True): + global _state + if not enabled(): + return + with _lock: + if _state is not None: + return + instance = instance or uuid4().hex + resource = Resource.create( + { + "service.name": service, + "service.version": os.getenv("APP_VERSION", "development"), + "service.instance.id": instance, + "deployment.environment.name": "lab", + } + ) + endpoint = os.getenv( + "OTEL_EXPORTER_OTLP_ENDPOINT", "http://otel:4318" + ).rstrip("/") + options = {"timeout": 0.75} + # Certificate options are also honored by the exporters in the TLS lab. + mp = None + if with_metrics: + reader = PeriodicExportingMetricReader( + OTLPMetricExporter( + endpoint=endpoint + "/v1/metrics", **options + ), + export_interval_millis=2000, + export_timeout_millis=1000, + ) + mp = MeterProvider( + resource=resource, + metric_readers=[reader], + views=[ + View( + instrument_type=Histogram, + aggregation=ExplicitBucketHistogramAggregation( + BUCKETS + ), + ) + ], + ) + meter = mp.get_meter("messenger", "1.0") + for name in ["http_requests", "job_attempts"]: + _instruments[name] = meter.create_counter("messenger_" + name) + _instruments["worker_busy"] = meter.create_up_down_counter( + "messenger_worker_busy" + ) + for name in ["http_duration", "job_duration", "time_to_ready"]: + _instruments[name] = meter.create_histogram( + "messenger_" + name, unit="s" + ) + for key in ["used", "waiting"]: + meter.create_observable_gauge( + "messenger_db_pool_" + key, + callbacks=[lambda _, k=key: [Observation(_pool_stat(k))]], + ) + process = psutil.Process() + meter.create_observable_counter( + "messenger_process_cpu", + unit="s", + callbacks=[ + lambda _: [Observation(sum(process.cpu_times()[:2]))] + ], + ) + meter.create_observable_gauge( + "messenger_process_memory", + unit="By", + callbacks=[lambda _: [Observation(process.memory_info().rss)]], + ) + + def container_memory(_): + p = Path("/sys/fs/cgroup/memory.current") + return [Observation(int(p.read_text()))] if p.exists() else [] + + meter.create_observable_gauge( + "messenger_container_memory", + unit="By", + callbacks=[container_memory], + ) + if service == "messenger-worker": + meter.create_observable_gauge( + "messenger_worker_capacity", + callbacks=[ + lambda _: [ + Observation( + int(os.getenv("WORKER_CONCURRENCY", "2")) + ) + ] + ], + ) + if service == "messenger-observer": + for key in ["queue_depth", "oldest_job_age"]: + meter.create_observable_gauge( + "messenger_" + key, + unit="s" if key.endswith("age") else "", + callbacks=[ + lambda _, k=key: [ + Observation( + _observer.get(k, 0), + {"queue": "attachments"}, + ) + ] + ], + ) + for name, prefix in [ + ("slo_decisions", "slo_"), + ("jobs_completed", "completed_"), + ]: + meter.create_observable_counter( + "messenger_" + name, + callbacks=[ + lambda _, p=prefix: [ + Observation( + _observer.get(p + outcome, 0), + { + "outcome": outcome, + "job_type": "attachment.process.v1", + }, + ) + for outcome in ( + ["good", "bad"] + if p == "slo_" + else ["ready", "failed"] + ) + ] + ], + ) + tp = TracerProvider( + resource=resource, + sampler=ParentBased( + TraceIdRatioBased(float(os.getenv("OTEL_TRACE_RATIO", "1"))) + ), + ) + tp.add_span_processor( + BatchSpanProcessor( + OTLPSpanExporter(endpoint=endpoint + "/v1/traces", **options), + max_queue_size=512, + max_export_batch_size=64, + schedule_delay_millis=200, + export_timeout_millis=1000, + ) + ) + lp = LoggerProvider(resource=resource) + lp.add_log_record_processor( + BatchLogRecordProcessor( + OTLPLogExporter(endpoint=endpoint + "/v1/logs", **options), + max_queue_size=512, + max_export_batch_size=64, + schedule_delay_millis=200, + export_timeout_millis=1000, + ) + ) + _state = SimpleNamespace( + service=service, + instance=instance, + traces=tp, + metrics=mp, + logs=lp, + tracer=tp.get_tracer("messenger", "1.0"), + logger=lp.get_logger("messenger", "1.0"), + ) + + +def stop(): + if _state is None: + return + for provider in [_state.traces, _state.logs, _state.metrics]: + if provider is not None: + provider.force_flush(timeout_millis=1000) + provider.shutdown() + + +def count(name, value=1, attributes=None): + instrument = _instruments.get(name) + if instrument is not None: + instrument.add(value, attributes or {}) + + +def duration(name, seconds, attributes=None): + instrument = _instruments.get(name) + if instrument is not None: + instrument.record(max(0, seconds), attributes or {}) + + +def carrier(): + result = {} + _propagator.inject(result) + if len(result.get("tracestate", "")) > 512: + result.pop("tracestate", None) + return result + + +@contextmanager +def span(name, *, kind=SpanKind.INTERNAL, parent=None, attributes=None): + tracer = ( + _state.tracer if _state is not None else trace.get_tracer("messenger") + ) + attrs = {k: v for k, v in (attributes or {}).items() if k in TRACE_FIELDS} + context = _propagator.extract(parent) if parent is not None else None + with tracer.start_as_current_span( + name, + kind=kind, + context=context, + attributes=attrs, + record_exception=False, + set_status_on_exception=False, + ) as current: + try: + yield current + except BaseException as exc: + current.set_attribute("error.type", type(exc).__name__) + current.set_status(Status(StatusCode.ERROR, "operation failed")) + raise + + +def log(event, *, error=False, **fields): + event = ( + event + if re.fullmatch(r"[a-z][a-z0-9_.-]{0,79}", event) + else "application.event" + ) + attrs = { + k: v[:256] if isinstance(v, str) else v + for k, v in fields.items() + if k in LOG_FIELDS and isinstance(v, (str, int, float, bool)) + } + current = trace.get_current_span().get_span_context() + record = { + "event": event, + "timestamp": time.time(), + "severity": "ERROR" if error else "INFO", + "service.name": _state.service if _state else "messenger", + **attrs, + } + if current.is_valid: + record.update( + trace_id=f"{current.trace_id:032x}", + span_id=f"{current.span_id:016x}", + ) + print(json.dumps(record, ensure_ascii=False), flush=True) + if _state is not None: + _state.logger.emit( + body=event, + attributes=attrs, + severity_text=record["severity"], + severity_number=SeverityNumber.ERROR + if error + else SeverityNumber.INFO, + ) + + +class TelemetryMiddleware: + def __init__(self, app): + self.app = app + + async def __call__(self, scope, receive, send): + if scope["type"] != "http": + return await self.app(scope, receive, send) + # Health polling does not enter business SLIs or spans. + if scope.get("path", "").startswith("/health/"): + return await self.app(scope, receive, send) + headers = { + k.decode("latin1"): v.decode("latin1") + for k, v in scope.get("headers", []) + if k.lower() in {b"traceparent", b"tracestate"} + } + status = 500 + started = time.monotonic() + + async def measured_send(message): + nonlocal status + if message["type"] == "http.response.start": + status = message["status"] + await send(message) + + with span("HTTP", kind=SpanKind.SERVER, parent=headers) as current: + try: + await self.app(scope, receive, measured_send) + finally: + route = getattr(scope.get("route"), "path", "unmatched") + method = scope.get("method", "UNKNOWN") + if method not in { + "GET", + "POST", + "PUT", + "PATCH", + "DELETE", + "HEAD", + "OPTIONS", + }: + method = "OTHER" + current.update_name(method + " " + route) + current.set_attributes( + { + "http.route": route, + "http.request.method": method, + "http.response.status_code": status, + } + ) + if status >= 500: + current.set_status( + Status(StatusCode.ERROR, "HTTP server error") + ) + elapsed = time.monotonic() - started + labels = { + "route": route, + "method": method, + "status_class": str(status // 100) + "xx", + } + count("http_requests", attributes=labels) + duration("http_duration", elapsed, labels) + log( + "http.request", + request_id=scope.get("state", {}).get("request_id", ""), + method=method, + route=route, + status=status, + duration_seconds=round(elapsed, 6), + error=status >= 500, + ) diff --git a/src/worker.py b/src/worker.py new file mode 100644 index 0000000..b316a6d --- /dev/null +++ b/src/worker.py @@ -0,0 +1,547 @@ +"""Two bounded consumers; every decode runs in a killable isolated process.""" + +import hashlib +import io +import json +import multiprocessing +import resource +import threading +import time +from pathlib import Path +from uuid import uuid4 + +import redis +from PIL import Image, ImageOps, UnidentifiedImageError + +from src import telemetry +from src.images import MAX_BYTES, MAX_PIXELS +from src.object_store import ObjectStore +from src.pipeline import ( + GROUP, + STREAM, + PermanentFailure, + broker, + database, + event, + fault, + retry, + validate_job, +) +from src.settings import integer + + +def sizes(width, height, bound): + longest = max(width, height) + return ( + (width, height) + if longest <= bound + else ( + max(1, width * bound // longest), + max(1, height * bound // longest), + ) + ) + + +def make_variants(raw, row): + if ( + len(raw) != row["size_bytes"] + or hashlib.sha256(raw).hexdigest() != row["sha256"] + ): + raise PermanentFailure("source_checksum_mismatch") + try: + with Image.open(io.BytesIO(raw)) as source: + if source.width * source.height > MAX_PIXELS: + raise PermanentFailure("pixel_limit") + if source.format not in {"PNG", "JPEG"}: + raise PermanentFailure("invalid_image") + source.load() + oriented = ImageOps.exif_transpose(source) + rgba = oriented.convert("RGBA") + rgb = Image.new("RGB", rgba.size, "white") + rgb.paste(rgba, mask=rgba.getchannel("A")) + rgb.info.clear() + yield "original", raw, row["content_type"], source.size + thumbnail = rgb.resize( + sizes(*rgb.size, 256), Image.Resampling.LANCZOS + ) + crop = ImageOps.fit( + rgb, (128, 128), Image.Resampling.LANCZOS, centering=(0.5, 0.5) + ) + optimized = rgb.resize( + sizes(*rgb.size, 1280), Image.Resampling.LANCZOS + ) + for name, image, fmt, mime, options in [ + ( + "thumbnail", + thumbnail, + "JPEG", + "image/jpeg", + {"quality": 85, "subsampling": 0}, + ), + ( + "crop", + crop, + "JPEG", + "image/jpeg", + {"quality": 85, "subsampling": 0}, + ), + ( + "optimized", + optimized, + "WEBP", + "image/webp", + { + "quality": 82 if row["pipeline_version"] == 1 else 76, + "method": 4, + }, + ), + ]: + output = io.BytesIO() + image.info.clear() + image.save(output, format=fmt, **options) + yield name, output.getvalue(), mime, image.size + except ( + UnidentifiedImageError, + OSError, + ValueError, + Image.DecompressionBombError, + ) as exc: + raise PermanentFailure("invalid_image") from exc + + +def process(job_id, fence, sender, trace_context=None): + telemetry.configure("messenger-worker", with_metrics=False) + try: + with telemetry.span( + "attachment.process", + parent=trace_context, + attributes={"job.id": job_id}, + ): + telemetry.log("job.processing", job_id=job_id, fence=fence) + process_body(job_id, fence, sender) + finally: + telemetry.stop() + + +def process_body(job_id, fence, sender): + db = store = None + started = time.monotonic() + cpu = time.process_time() + try: + resource.setrlimit(resource.RLIMIT_AS, (768 * 1024**2, 768 * 1024**2)) + db, store = database(), ObjectStore() + with db.connection() as conn: + row = conn.execute( + "SELECT j.*,a.size_bytes,a.sha256,a.content_type FROM jobs j JOIN attachments a ON a.id=j.attachment_id WHERE j.id=%s AND j.fence=%s", + (job_id, fence), + ).fetchone() + if not row: + sender.send({"result": "stale"}) + return + # Record limits before fault hooks: a slow external inspector must not + # consume the child timeout while attempting to observe the limit. + cgroup = Path("/sys/fs/cgroup") + limits = { + name: (cgroup / name).read_text().strip() + if (cgroup / name).exists() + else "unavailable" + for name in ["memory.max", "cpu.max"] + } + limits["address_space_bytes"] = list( + resource.getrlimit(resource.RLIMIT_AS) + ) + with db.connection() as conn: + event(conn, job_id, "worker_resource_limits", limits) + fault(db, job_id, "before_effect") + upstream = store.get(key=row["source_key"]) + try: + raw = upstream.read(MAX_BYTES + 1) + finally: + upstream.close() + upstream.release_conn() + results = [] + for name, data, mime, (width, height) in make_variants(raw, row): + key = f"objects/{row['attachment_id']}/v{row['pipeline_version']}/{name}" + digest = hashlib.sha256(data).hexdigest() + store.put( + key=key, + stream=io.BytesIO(data), + size=len(data), + content_type=mime, + sha256=digest, + ) + results.append((name, key, mime, len(data), digest, width, height)) + fault(db, job_id, "after_effect") + with db.connection() as conn, conn.transaction(): + current = conn.execute( + "SELECT * FROM jobs WHERE id=%s FOR UPDATE", (job_id,) + ).fetchone() + allowed = conn.execute( + "SELECT pipeline_version FROM attachments WHERE id=%s FOR UPDATE", + (row["attachment_id"],), + ).fetchone() + valid_lease = conn.execute( + "SELECT %s::timestamptz>clock_timestamp() live", + (current["lease_until"],), + ).fetchone()["live"] + if ( + current["state"] != "processing" + or current["fence"] != fence + or not valid_lease + or allowed["pipeline_version"] != row["pipeline_version"] + ): + event( + conn, + job_id, + "stale_completion_rejected", + {"fence": fence, "version": row["pipeline_version"]}, + ) + sender.send({"result": "stale"}) + return + for result in results: + conn.execute( + "INSERT INTO attachment_variants(attachment_id,pipeline_version,name,object_key,content_type,size_bytes,sha256,width,height) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s) ON CONFLICT(attachment_id,pipeline_version,name) DO NOTHING", + (row["attachment_id"], row["pipeline_version"], *result), + ) + conn.execute( + "INSERT INTO effect_publications(attachment_id,pipeline_version,job_id,fence) VALUES(%s,%s,%s,%s)", + (row["attachment_id"], row["pipeline_version"], job_id, fence), + ) + conn.execute( + "UPDATE attachments SET state='ready',object_key=%s,published_version=pipeline_version,error_code=NULL,updated_at=clock_timestamp() WHERE id=%s", + (results[0][1], row["attachment_id"]), + ) + conn.execute( + "UPDATE jobs SET state='ready',error_code=NULL,lease_owner=NULL,lease_until=NULL,updated_at=clock_timestamp() WHERE id=%s", + (job_id,), + ) + event( + conn, + job_id, + "effect_committed", + { + "fence": fence, + "version": row["pipeline_version"], + "variants": 4, + }, + ) + fault(db, job_id, "after_commit") + # Cleanup is independently retryable; it cannot undo the committed effect. + if row["source_key"].startswith("objects/staging/"): + try: + store.delete(key=row["source_key"]) + except Exception: + pass + telemetry.log( + "job.ready", job_id=job_id, version=row["pipeline_version"] + ) + sender.send( + { + "result": "ready", + "seconds": time.monotonic() - started, + "cpu_seconds": time.process_time() - cpu, + "rss_peak_mib": resource.getrusage( + resource.RUSAGE_SELF + ).ru_maxrss + / 1024, + } + ) + except PermanentFailure as exc: + telemetry.log( + "job.processing_failed", + job_id=job_id, + error=True, + error_code=str(exc), + ) + telemetry.trace.get_current_span().set_status( + telemetry.Status( + telemetry.StatusCode.ERROR, "permanent processing error" + ) + ) + sender.send({"result": "permanent", "code": str(exc)}) + except MemoryError: + telemetry.log( + "job.processing_failed", + job_id=job_id, + error=True, + error_code="memory_limit", + ) + telemetry.trace.get_current_span().set_status( + telemetry.Status(telemetry.StatusCode.ERROR, "memory limit") + ) + sender.send({"result": "permanent", "code": "memory_limit"}) + except Exception: + telemetry.log( + "job.processing_failed", + job_id=job_id, + error=True, + error_code="processing_unavailable", + ) + telemetry.trace.get_current_span().set_status( + telemetry.Status( + telemetry.StatusCode.ERROR, "transient processing error" + ) + ) + sender.send({"result": "transient", "code": "processing_unavailable"}) + finally: + if store: + store.close() + if db: + db.close() + sender.close() + + +def claim(db, data, consumer): + with db.connection() as conn, conn.transaction(): + row = conn.execute( + "SELECT * FROM jobs WHERE id=%s FOR UPDATE", (data["job_id"],) + ).fetchone() + if ( + not row + or str(row["attachment_id"]) != data["attachment_id"] + or row["pipeline_version"] != data["pipeline_version"] + ): + return "obsolete", None + if row["state"] in {"ready", "failed", "obsolete"}: + return row["state"], row + if data["attempt"] < row["attempt"] or ( + row["state"] == "queued" and data["attempt"] <= row["attempt"] + ): + return "obsolete", row + if row["state"] == "processing": + return "busy", row + if data["attempt"] != row["attempt"] + 1: + return "obsolete", row + due = conn.execute( + "SELECT %s::timestamptz<=clock_timestamp() due", (row["next_at"],) + ).fetchone()["due"] + if not due: + return "busy", row + lease = integer("JOB_LEASE_SECONDS", 23, 3, 120) + updated = conn.execute( + "UPDATE jobs SET state='processing',attempt=attempt+1,fence=fence+1,lease_owner=%s,lease_until=clock_timestamp()+%s*interval '1 second',updated_at=clock_timestamp() WHERE id=%s RETURNING *", + (consumer, lease, row["id"]), + ).fetchone() + conn.execute( + "UPDATE attachments SET state='processing',updated_at=clock_timestamp() WHERE id=%s AND pipeline_version=%s", + (row["attachment_id"], row["pipeline_version"]), + ) + event( + conn, + row["id"], + "claimed", + { + "attempt": updated["attempt"], + "fence": updated["fence"], + "version": updated["pipeline_version"], + }, + ) + return "claimed", updated + + +def ready_effect(db, store, row): + with db.connection() as conn: + variants = conn.execute( + "SELECT * FROM attachment_variants WHERE attachment_id=%s AND pipeline_version=%s", + (row["attachment_id"], row["pipeline_version"]), + ).fetchall() + if len(variants) != 4: + return False + for variant in variants: + head = store.head(key=variant["object_key"]) + if ( + head is None + or head.size != variant["size_bytes"] + or head.metadata.get("x-amz-meta-sha256") != variant["sha256"] + ): + return False + return True + + +def consume(slot): + db, queue, store = database(), broker(), ObjectStore() + consumer = str(uuid4()) + f"-{slot}" + context = multiprocessing.get_context("spawn") + cursor = "0-0" + timeout = integer("JOB_TIMEOUT_SECONDS", 20, 2, 117) + lease = integer("JOB_LEASE_SECONDS", 23, 3, 120) + if lease <= timeout: + raise ValueError("Lease must exceed child timeout") + try: + while True: + try: + try: + queue.xgroup_create(STREAM, GROUP, id="0", mkstream=True) + except redis.ResponseError as exc: + if "BUSYGROUP" not in str(exc): + raise + reclaimed = queue.xautoclaim( + STREAM, + GROUP, + consumer, + # Do not steal an entry from a consumer inside its live budget. + min_idle_time=lease * 1000, + start_id=cursor, + count=1, + ) + cursor, messages = reclaimed[0], reclaimed[1] + if not messages: + batch = queue.xreadgroup( + GROUP, consumer, {STREAM: ">"}, count=1, block=500 + ) + messages = batch[0][1] if batch else [] + for entry, fields in messages: + try: + data = validate_job( + json.loads(fields.get("job", "null")) + ) + except ValueError, TypeError, KeyError: + # Malformed notifications cannot become jobs; preserve diagnostic count. + with db.connection() as conn: + event(conn, None, "invalid_envelope") + queue.xack(STREAM, GROUP, entry) + queue.xdel(STREAM, entry) + continue + with telemetry.span( + "attachments consume", + kind=telemetry.SpanKind.CONSUMER, + parent=data, + attributes={ + "job.id": data["job_id"], + "messaging.system": "valkey", + "messaging.destination.name": STREAM, + }, + ): + state, row = claim(db, data, consumer) + if state == "busy": + continue + if state == "ready" and not ready_effect( + db, store, row + ): + with db.connection() as conn: + event(conn, row["id"], "ready_effect_missing") + continue + if state in {"ready", "obsolete", "failed"}: + with db.connection() as conn: + event( + conn, + data["job_id"], + "duplicate_decision", + {"state": state, "entry": entry}, + ) + if state == "claimed": + attempt_started = time.monotonic() + receiver, sender = context.Pipe(duplex=False) + child = context.Process( + target=process, + args=( + str(row["id"]), + row["fence"], + sender, + telemetry.carrier(), + ), + ) + child.start() + telemetry.count("worker_busy", 1) + sender.close() + child.join(timeout) + if child.is_alive(): + child.kill() + child.join(2) + result = { + "result": "transient", + "code": "worker_timeout", + } + else: + try: + result = ( + receiver.recv() + if receiver.poll() + else { + "result": "transient", + "code": "worker_crashed", + } + ) + except EOFError: + result = { + "result": "transient", + "code": "worker_crashed", + } + telemetry.count("worker_busy", -1) + labels = { + "job_type": "attachment.process.v1", + "outcome": result["result"], + } + telemetry.count("job_attempts", attributes=labels) + telemetry.duration( + "job_duration", + time.monotonic() - attempt_started, + labels, + ) + telemetry.log( + "job.attempt_finished", + job_id=str(row["id"]), + attempt=row["attempt"], + version=row["pipeline_version"], + outcome=result["result"], + error_code=result.get("code", ""), + ) + receiver.close() + child.close() + with db.connection() as conn, conn.transaction(): + current = conn.execute( + "SELECT * FROM jobs WHERE id=%s FOR UPDATE", + (row["id"],), + ).fetchone() + event( + conn, row["id"], "child_finished", result + ) + if ( + current["state"] == "processing" + and current["fence"] == row["fence"] + ): + retry( + conn, + current, + result.get( + "code", "processing_failed" + ), + permanent=result["result"] + == "permanent", + ) + # Commit result or a retry/terminal decision precedes ack. + queue.xack(STREAM, GROUP, entry) + queue.xdel(STREAM, entry) + except Exception: + print( + json.dumps( + { + "event": "worker_retry", + "code": "dependency_unavailable", + } + ), + flush=True, + ) + time.sleep(0.5) + finally: + queue.close() + store.close() + db.close() + + +def main(): + telemetry.configure("messenger-worker") + count = integer("WORKER_CONCURRENCY", 2, 1, 4) + threads = [ + threading.Thread(target=consume, args=(i,), daemon=False) + for i in range(count) + ] + for thread in threads: + thread.start() + for thread in threads: + thread.join() + telemetry.stop() + + +if __name__ == "__main__": + main() diff --git a/student-tests/conftest.py b/student-tests/conftest.py new file mode 100644 index 0000000..b5db8d3 --- /dev/null +++ b/student-tests/conftest.py @@ -0,0 +1,125 @@ +import json +import os +import ssl +from pathlib import Path +from uuid import uuid4 + +import httpx +import pytest +from jsonschema import Draft202012Validator, FormatChecker + +CONTRACT = json.loads( + (Path(__file__).parents[1] / "contracts/openapi.json").read_text() +) +BASE_URL = os.environ.get("BASE_URL", "https://localhost:8443") +TLS_CONTEXT = ssl.create_default_context( + cafile=os.getenv( + "CA_FILE", str(Path(__file__).parents[1] / "trust/ca.pem") + ) +) +PASSWORD = "Synthetic-Password-🌍-123" +TOKENS = {} + + +def check(result: httpx.Response, status: int, schema: str) -> dict: + assert result.status_code == status, result.text + assert result.headers["x-request-id"] + assert result.headers["x-instance-id"] + assert result.headers["content-type"].startswith("application/json") + payload = result.json() + spec = {"$ref": f"#/components/schemas/{schema}", **CONTRACT} + Draft202012Validator(spec, format_checker=FormatChecker()).validate( + payload + ) + if schema == "Error": + assert payload["error"]["request_id"] == result.headers["x-request-id"] + assert ( + payload["error"]["code"] + == { + 400: "invalid_request", + 401: "unauthorized", + 404: "not_found", + 409: "conflict", + 413: "payload_too_large", + 415: "unsupported_media_type", + 429: "rate_limited", + 500: "internal_error", + 503: "unavailable", + }[status] + ) + return payload + + +def register(client: httpx.Client, **overrides) -> dict: + data = { + "username": "u_" + uuid4().hex[:24], + "display_name": "Алиса 🌍", + "password": PASSWORD, + } + data.update(overrides) + user = check(client.post("/api/v1/users", json=data), 201, "User") + session = check( + client.post( + "/api/v1/auth/sessions", + auth=httpx.BasicAuth(data["username"], data["password"]), + ), + 201, + "Session", + ) + TOKENS[user["id"]] = session["token"] + return user + + +@pytest.fixture +def client(): + with httpx.Client( + base_url=BASE_URL, timeout=15, trust_env=False, verify=TLS_CONTEXT + ) as client: + yield client + + +@pytest.fixture +def actors(client): + return register(client), register(client), register(client) + + +@pytest.fixture +def chat(client, actors): + alice, bob, _ = actors + return check( + client.post( + "/api/v1/chats", + headers=headers(alice), + json={"title": "Учёба 🌍", "member_ids": [alice["id"], bob["id"]]}, + ), + 201, + "Chat", + ) + + +def headers(actor: dict) -> dict: + return { + "Authorization": "Bearer " + TOKENS[actor["id"]], + "Idempotency-Key": uuid4().hex, + } + + +def history(client, actor, chat_id, limit=7): + found, cursor = [], None + while True: + params = {"limit": limit} + if cursor: + params["cursor"] = cursor + page = check( + client.get( + f"/api/v1/chats/{chat_id}/messages", + headers=headers(actor), + params=params, + ), + 200, + "MessagePage", + ) + found.extend(page["items"]) + cursor = page["next_cursor"] + if cursor is None: + return found diff --git a/student-tests/test_api.py b/student-tests/test_api.py new file mode 100644 index 0000000..fb58655 --- /dev/null +++ b/student-tests/test_api.py @@ -0,0 +1,420 @@ +import base64 +import json +import threading +from concurrent.futures import ThreadPoolExecutor +from uuid import UUID, uuid4 + +import httpx +import pytest +from conftest import ( + BASE_URL, + PASSWORD, + TLS_CONTEXT, + check, + headers, + history, + register, +) + + +@pytest.mark.parametrize("path", ["/health/live", "/health/ready"]) +def test_health(client, path): + assert check(client.get(path), 200, "Health") == {"status": "ok"} + + +@pytest.mark.parametrize( + "value", [None, "not-a-uuid", str(uuid4()), uuid4().hex] +) +def test_identification(client, value): + check( + client.get( + "/api/v1/users/me", headers={"X-User-Id": value} if value else {} + ), + 401, + "Error", + ) + + +def test_identity(client, actors): + assert ( + check( + client.get("/api/v1/users/me", headers=headers(actors[0])), + 200, + "User", + ) + == actors[0] + ) + + +@pytest.mark.parametrize( + "data", + [ + {}, + [], + None, + {"username": "ABC", "display_name": "A"}, + {"username": "abc\n", "display_name": "A"}, + {"username": 123, "display_name": "A"}, + {"username": "abc", "display_name": " "}, + {"username": "abc", "display_name": "x" * 101}, + {"username": "abc", "display_name": "A", "extra": True}, + {"username": "abc", "display_name": "\ud800"}, + ], +) +def test_invalid_user(client, data): + if isinstance(data, dict): + data = {"password": PASSWORD, **data} + check(client.post("/api/v1/users", content=json.dumps(data)), 400, "Error") + + +@pytest.mark.parametrize( + "raw", [b"{", b"NaN", b'{"username":"abc", "display_name":NaN}', b"\xff"] +) +def test_malformed_json(client, raw): + check(client.post("/api/v1/users", content=raw), 400, "Error") + + +def test_auth_before_json(client): + check(client.post("/api/v1/chats", content=b"{"), 401, "Error") + + +def test_duplicate_username(client, actors): + check( + client.post( + "/api/v1/users", + json={ + "username": actors[0]["username"], + "display_name": "B", + "password": PASSWORD, + }, + ), + 409, + "Error", + ) + + +def test_unicode_codepoints(client, actors, chat): + user = register(client, display_name="🌍" * 100) + assert user["display_name"] == "🌍" * 100 + text = "🌍" * 4000 + result = check( + client.post( + f"/api/v1/chats/{chat['id']}/messages", + headers=headers(actors[0]), + json={"text": text}, + ), + 201, + "Message", + ) + assert result["text"] == text + assert result["sender_id"] == actors[0]["id"] + + +@pytest.mark.parametrize( + "method,suffix,body", + [ + ("GET", "", None), + ("GET", "/messages", None), + ("POST", "/messages", {"text": "hello"}), + ], +) +def test_acl(client, actors, chat, method, suffix, body): + outsider = headers(actors[2]) + actual = check( + client.request( + method, + f"/api/v1/chats/{chat['id']}{suffix}", + headers=outsider, + json=body, + ), + 404, + "Error", + ) + missing = check( + client.request( + method, + f"/api/v1/chats/{uuid4()}{suffix}", + headers=outsider, + json=body, + ), + 404, + "Error", + ) + assert actual["error"]["message"] == missing["error"]["message"] + + +@pytest.mark.parametrize("value", ["", " \t\n", 42, True, None, "a" * 4001]) +def test_bad_message(client, actors, chat, value): + check( + client.post( + f"/api/v1/chats/{chat['id']}/messages", + headers=headers(actors[0]), + json={"text": value}, + ), + 400, + "Error", + ) + + +def test_sender_not_client_controlled(client, actors, chat): + check( + client.post( + f"/api/v1/chats/{chat['id']}/messages", + headers=headers(actors[0]), + json={"text": "Hi", "sender_id": actors[1]["id"]}, + ), + 400, + "Error", + ) + + +@pytest.mark.parametrize( + "case", + [ + "duplicate", + "unknown", + "no_caller", + "empty", + "wrong_type", + "bad_uuid", + "too_many", + "blank_title", + ], +) +def test_invalid_chat(client, actors, case): + a, b, _ = actors + members = { + "duplicate": [a["id"], a["id"]], + "unknown": [a["id"], str(uuid4())], + "no_caller": [b["id"]], + "empty": [], + "wrong_type": a["id"], + "bad_uuid": ["broken"], + "too_many": [str(uuid4()) for _ in range(101)], + "blank_title": [a["id"]], + }[case] + check( + client.post( + "/api/v1/chats", + headers=headers(a), + json={ + "title": " " if case == "blank_title" else "Title", + "member_ids": members, + }, + ), + 400, + "Error", + ) + + +@pytest.mark.parametrize( + "limit", ["0", "101", "-1", "1.5", "true", "1e1", "", "12"] +) +def test_bad_limit(client, actors, chat, limit): + check( + client.get( + f"/api/v1/chats/{chat['id']}/messages", + headers=headers(actors[0]), + params={"limit": limit}, + ), + 400, + "Error", + ) + + +@pytest.mark.parametrize( + "cursor", ["", "broken", "W10", "e30", "*", "x" * 2049] +) +def test_bad_cursor(client, actors, chat, cursor): + check( + client.get( + f"/api/v1/chats/{chat['id']}/messages", + headers=headers(actors[0]), + params={"cursor": cursor}, + ), + 400, + "Error", + ) + + +def test_pagination(client, actors, chat): + a, b, outsider = actors + sent = [] + path = f"/api/v1/chats/{chat['id']}/messages" + for i in range(23): + sent.append( + check( + client.post( + path, + headers=headers(a if i % 2 else b), + json={"text": f"Msg {i}"}, + ), + 201, + "Message", + ) + ) + got = history(client, a, chat["id"]) + assert got == sorted( + sent, key=lambda m: (m["created_at"], UUID(m["id"]).int) + ) + first = check( + client.get(path, headers=headers(a), params={"limit": 1}), + 200, + "MessagePage", + ) + second = check( + client.get( + path, + headers=headers(b), + params={"limit": 22, "cursor": first["next_cursor"]}, + ), + 200, + "MessagePage", + ) + assert second["items"] == got[1:] + assert second["next_cursor"] is None + chats = check( + client.get("/api/v1/chats", headers=headers(outsider)), 200, "ChatPage" + ) + assert chats["items"] == [] + other = check( + client.post( + "/api/v1/chats", + headers=headers(a), + json={"title": "Other", "member_ids": [a["id"]]}, + ), + 201, + "Chat", + ) + check( + client.get( + f"/api/v1/chats/{other['id']}/messages", + headers=headers(a), + params={"cursor": first["next_cursor"]}, + ), + 400, + "Error", + ) + # Валидный base64/JSON с неверным типом ключа тоже даёт 400. + data = json.loads( + base64.urlsafe_b64decode( + first["next_cursor"] + "=" * (-len(first["next_cursor"]) % 4) + ) + ) + data["at"] = 17 + forged = ( + base64.urlsafe_b64encode(json.dumps(data).encode()) + .decode() + .rstrip("=") + ) + check( + client.get(path, headers=headers(a), params={"cursor": forged}), + 400, + "Error", + ) + + +def test_chat_pagination_scope(client, actors): + a, b, _ = actors + created = [] + for i in range(4): + created.append( + check( + client.post( + "/api/v1/chats", + headers=headers(a), + json={"title": str(i), "member_ids": [a["id"], b["id"]]}, + ), + 201, + "Chat", + ) + ) + page = check( + client.get("/api/v1/chats", headers=headers(a), params={"limit": 2}), + 200, + "ChatPage", + ) + assert page["items"] == created[:2] + last = check( + client.get( + "/api/v1/chats", + headers=headers(a), + params={"limit": 2, "cursor": page["next_cursor"]}, + ), + 200, + "ChatPage", + ) + assert last["items"] == created[2:] + assert last["next_cursor"] is None + check( + client.get( + "/api/v1/chats", + headers=headers(b), + params={"cursor": page["next_cursor"]}, + ), + 400, + "Error", + ) + + +def test_concurrent_messages(client, actors, chat): + barrier = threading.Barrier(10) + a = actors[0] + path = f"/api/v1/chats/{chat['id']}/messages" + + def worker(i): + with httpx.Client( + base_url=BASE_URL, timeout=15, trust_env=False, verify=TLS_CONTEXT + ) as conn: + barrier.wait(timeout=15) + return [ + check( + conn.post( + path, headers=headers(a), json={"text": f"{i}:{j}"} + ), + 201, + "Message", + )["id"] + for j in range(10) + ] + + with ThreadPoolExecutor(max_workers=10) as pool: + ids = [item for batch in pool.map(worker, range(10)) for item in batch] + rows = history(client, a, chat["id"]) + assert len(rows) == len(ids) == len(set(ids)) == 100 + assert set(ids) == {row["id"] for row in rows} + assert len({row["text"] for row in rows}) == 100 + + +def test_registration_race(client): + username = "race_" + uuid4().hex[:20] + barrier = threading.Barrier(10) + + def worker(_): + with httpx.Client( + base_url=BASE_URL, timeout=15, trust_env=False, verify=TLS_CONTEXT + ) as conn: + barrier.wait(timeout=15) + result = conn.post( + "/api/v1/users", + json={ + "username": username, + "display_name": "Test", + "password": PASSWORD, + }, + ) + check( + result, + result.status_code, + "User" if result.status_code == 201 else "Error", + ) + return result.status_code + + with ThreadPoolExecutor(max_workers=10) as pool: + statuses = list(pool.map(worker, range(10))) + assert statuses.count(201) == 1 + assert statuses.count(409) == 9 + + +def test_unknown_path(client): + check(client.get("/does-not-exist"), 404, "Error") diff --git a/student-tests/test_attachments.py b/student-tests/test_attachments.py new file mode 100644 index 0000000..6aacd2e --- /dev/null +++ b/student-tests/test_attachments.py @@ -0,0 +1,277 @@ +import hashlib +import io +import time +from pathlib import Path +from uuid import uuid4 + +import pytest +from conftest import check, headers +from PIL import Image + +PNG = (Path(__file__).parents[1] / "tests/fixtures/sample.png").read_bytes() + + +def upload( + client, actor, chat, *, data=PNG, filename="Фото 🌍.png", mime="image/png" +): + return client.post( + f"/api/v1/chats/{chat['id']}/attachments", + headers={**headers(actor), "Content-Type": mime}, + params={"filename": filename}, + content=data, + ) + + +def wait_ready(client, actor, attachment): + end = time.monotonic() + 60 + while time.monotonic() < end: + row = check( + client.get( + f"/api/v1/attachments/{attachment['id']}", + headers=headers(actor), + ), + 200, + "Attachment", + ) + if row["status"] == "ready": + return row + assert row["status"] != "failed", row + time.sleep(0.2) + raise TimeoutError("Pipeline readiness") + + +def test_attachment_roundtrip_acl_and_message(client, actors, chat): + attachment = check(upload(client, actors[0], chat), 202, "Attachment") + assert attachment["status"] == "queued" and attachment["variants"] == [] + attachment = wait_ready(client, actors[0], attachment) + assert attachment["sha256"] == hashlib.sha256(PNG).hexdigest() + assert attachment["size_bytes"] == len(PNG) + path = f"/api/v1/attachments/{attachment['id']}" + assert ( + check(client.get(path, headers=headers(actors[1])), 200, "Attachment") + == attachment + ) + downloaded = client.get(path + "/content", headers=headers(actors[1])) + assert downloaded.status_code == 200 and downloaded.content == PNG + assert downloaded.headers["Content-Type"] == "image/png" + assert not downloaded.history + for suffix in ["", "/content"]: + check( + client.get(path + suffix, headers=headers(actors[2])), 404, "Error" + ) + check(client.get(path + suffix), 401, "Error") + thumb = client.get( + path + "/content", + headers=headers(actors[1]), + params={"variant": "thumbnail"}, + ) + assert thumb.status_code == 200 + with Image.open(io.BytesIO(thumb.content)) as image: + assert image.format == "JPEG" and image.size == (256, 160) + sent = check( + client.post( + f"/api/v1/chats/{chat['id']}/messages", + headers=headers(actors[1]), + json={"text": "", "attachment_ids": [attachment["id"]]}, + ), + 201, + "Message", + ) + assert sent["attachment_ids"] == [attachment["id"]] + assert sent["sender_id"] == actors[1]["id"] + + +@pytest.mark.parametrize( + "name", + [ + "../x.png", + "x/y.png", + "x\\y.png", + "x\x00.png", + "x\x7f.png", + "x\n.png", + "a" * 256, + "", + ], +) +def test_filename_guard(client, actors, chat, name): + check(upload(client, actors[0], chat, filename=name), 400, "Error") + + +@pytest.mark.parametrize( + "data,mime,status", + [ + (b"not an image", "image/png", 415), + (PNG, "image/jpeg", 415), + (PNG, "application/octet-stream", 415), + (PNG[:25], "image/png", 415), + (b"", "image/png", 415), + (b"x" * (10 * 1024 * 1024 + 1), "image/png", 413), + ], +) +def test_image_guards(client, actors, chat, data, mime, status): + r = upload(client, actors[0], chat, data=data, mime=mime) + check(r, status, "Error") + + +def test_jpeg_original_unchanged(client, actors, chat): + stream = io.BytesIO() + Image.new("RGB", (320, 200), (30, 60, 90)).save(stream, format="JPEG") + jpeg = stream.getvalue() + attachment = check( + upload( + client, + actors[0], + chat, + data=jpeg, + filename="camera.jpg", + mime="image/jpeg", + ), + 202, + "Attachment", + ) + attachment = wait_ready(client, actors[0], attachment) + r = client.get( + f"/api/v1/attachments/{attachment['id']}/content", + headers=headers(actors[1]), + ) + assert r.content == jpeg + + +def test_cross_chat_link_and_unknown(client, actors, chat): + a = check(upload(client, actors[0], chat), 202, "Attachment") + other = check( + client.post( + "/api/v1/chats", + headers=headers(actors[0]), + json={"title": "Other", "member_ids": [actors[0]["id"]]}, + ), + 201, + "Chat", + ) + for identity in [a["id"], str(uuid4())]: + check( + client.post( + f"/api/v1/chats/{other['id']}/messages", + headers=headers(actors[0]), + json={"text": "", "attachment_ids": [identity]}, + ), + 404, + "Error", + ) + check( + client.post( + f"/api/v1/chats/{chat['id']}/messages", + headers=headers(actors[0]), + json={"text": "", "attachment_ids": [a["id"], a["id"]]}, + ), + 400, + "Error", + ) + + +def test_default_attachments_are_semantically_equal(client, actors, chat): + h = headers(actors[0]) + path = f"/api/v1/chats/{chat['id']}/messages" + first = check( + client.post(path, headers=h, json={"text": "Semantic default"}), + 201, + "Message", + ) + second = check( + client.post( + path, + headers=h, + json={"attachment_ids": [], "text": "Semantic default"}, + ), + 201, + "Message", + ) + assert first == second and first["attachment_ids"] == [] + + +def test_pixel_limit_before_decode(client, actors, chat): + # Compressible synthetic image stays below10MiB but exceeds40M pixels. + stream = io.BytesIO() + Image.new("1", (8000, 5001)).save(stream, format="PNG") + assert len(stream.getvalue()) < 10 * 1024 * 1024 + r = upload(client, actors[0], chat, data=stream.getvalue()) + assert r.status_code == 413 + + +def test_chunked_body_limit_without_content_length(client, actors, chat): + r = client.post( + f"/api/v1/chats/{chat['id']}/attachments", + headers={**headers(actors[0]), "Content-Type": "image/png"}, + params={"filename": "chunked.png"}, + content=iter([b"x" * (10 * 1024 * 1024 + 1)]), + ) + assert r.request.headers.get("content-length") is None + assert r.status_code == 413 + assert r.json()["error"]["code"] == "payload_too_large" + assert r.json()["error"]["request_id"] == r.headers["x-request-id"] + + +@pytest.mark.parametrize("size", [(1, 17), (320, 200), (1600, 900)]) +def test_variant_geometry_and_alpha(client, actors, chat, size): + stream = io.BytesIO() + Image.new("RGBA", size, (0, 0, 0, 0)).save(stream, format="PNG") + a = check( + upload(client, actors[0], chat, data=stream.getvalue()), + 202, + "Attachment", + ) + a = wait_ready(client, actors[0], a) + for v in a["variants"]: + r = client.get( + f"/api/v1/attachments/{a['id']}/content", + headers=headers(actors[1]), + params={"variant": v["name"]}, + ) + assert len(r.content) == v["size_bytes"] + assert hashlib.sha256(r.content).hexdigest() == v["sha256"] + with Image.open(io.BytesIO(r.content)) as image: + assert image.size == (v["width"], v["height"]) + assert not image.getexif() + assert min(image.convert("RGB").getpixel((0, 0))) >= 250 + if v["name"] == "crop": + assert image.size == (128, 128) + else: + bound = 256 if v["name"] == "thumbnail" else 1280 + assert max(image.size) <= bound + assert image.width <= size[0] and image.height <= size[1] + + +def test_exif_orientation_applied_but_original_preserved(client, actors, chat): + stream = io.BytesIO() + exif = Image.Exif() + exif[274] = 6 + exif[270] = "Synthetic metadata must be removed" + Image.new("RGB", (320, 200), "red").save(stream, format="JPEG", exif=exif) + raw = stream.getvalue() + a = check( + upload( + client, + actors[0], + chat, + data=raw, + mime="image/jpeg", + filename="exif.jpg", + ), + 202, + "Attachment", + ) + a = wait_ready(client, actors[0], a) + r = client.get( + f"/api/v1/attachments/{a['id']}/content", headers=headers(actors[1]) + ) + assert r.content == raw + v = next(v for v in a["variants"] if v["name"] == "thumbnail") + assert (v["width"], v["height"]) == (160, 256) + r = client.get( + f"/api/v1/attachments/{a['id']}/content", + headers=headers(actors[1]), + params={"variant": "thumbnail"}, + ) + with Image.open(io.BytesIO(r.content)) as image: + assert image.size == (160, 256) and not image.getexif() diff --git a/student-tests/test_contract_edges.py b/student-tests/test_contract_edges.py new file mode 100644 index 0000000..81d39ed --- /dev/null +++ b/student-tests/test_contract_edges.py @@ -0,0 +1,26 @@ +import json +from uuid import uuid4 + +import pytest +from conftest import check, headers + + +@pytest.mark.parametrize("encoding", ["utf-16", "utf-32"]) +def test_only_utf8_json(client, encoding): + payload = {"username": "u_" + uuid4().hex[:20], "display_name": "UTF"} + payload["password"] = "Synthetic-encoding-test-123" + result = client.post( + "/api/v1/users", + content=json.dumps(payload).encode(encoding), + headers={"Content-Type": "application/json"}, + ) + check(result, 400, "Error") + + +def test_leading_zero_limit(client, actors, chat): + result = client.get( + "/api/v1/chats/" + chat["id"] + "/messages", + headers=headers(actors[0]), + params={"limit": "0001"}, + ) + check(result, 200, "MessagePage") diff --git a/student-tests/test_history_acl.py b/student-tests/test_history_acl.py new file mode 100644 index 0000000..61bd461 --- /dev/null +++ b/student-tests/test_history_acl.py @@ -0,0 +1,23 @@ +from conftest import check, headers + + +def test_history_acl_precedes_query_validation(client, actors, chat): + path = f"/api/v1/chats/{chat['id']}/messages" + check( + client.get( + path, + headers=headers(actors[2]), + params={"limit": 0, "cursor": "broken"}, + ), + 404, + "Error", + ) + check( + client.get( + path, + headers=headers(actors[0]), + params={"limit": 0, "cursor": "broken"}, + ), + 400, + "Error", + ) diff --git a/student-tests/test_idempotency.py b/student-tests/test_idempotency.py new file mode 100644 index 0000000..f5282db --- /dev/null +++ b/student-tests/test_idempotency.py @@ -0,0 +1,77 @@ +from concurrent.futures import ThreadPoolExecutor +from uuid import uuid4 + +import httpx +import pytest +from conftest import BASE_URL, TLS_CONTEXT, check, headers, history + + +@pytest.mark.parametrize("key", [None, "", "a b", "x" * 129, "a/b"]) +def test_key_required_and_valid(client, actors, chat, key): + h = headers(actors[0]) + h.pop("Idempotency-Key") + if key is not None: + h["Idempotency-Key"] = key + check( + client.post( + f"/api/v1/chats/{chat['id']}/messages", + headers=h, + json={"text": "Key"}, + ), + 400, + "Error", + ) + + +def test_parallel_replay_across_instances(client, actors, chat): + h = headers(actors[0]) + path = f"/api/v1/chats/{chat['id']}/messages" + + def send(_): + with httpx.Client( + base_url=BASE_URL, trust_env=False, timeout=15, verify=TLS_CONTEXT + ) as c: + r = c.post(path, headers=h, json={"text": "Один результат 🌍"}) + return check(r, 201, "Message"), r.headers["x-instance-id"] + + with ThreadPoolExecutor(max_workers=10) as pool: + results = list(pool.map(send, range(30))) + assert len({r[0]["id"] for r in results}) == 1 + assert len({r[1] for r in results}) >= 2 + assert history(client, actors[0], chat["id"]) == [results[0][0]] + check( + client.post(path, headers=h, json={"text": "Другой текст"}), + 409, + "Error", + ) + # Другой пользователь может независимо использовать тот же ключ. + other = headers(actors[1]) + other["Idempotency-Key"] = h["Idempotency-Key"] + second = check( + client.post(path, headers=other, json={"text": "Боб"}), 201, "Message" + ) + assert second["id"] != results[0][0]["id"] + + +def test_replay_rechecks_acl(client, actors, chat): + h = headers(actors[0]) + path = f"/api/v1/chats/{chat['id']}/messages" + check( + client.post(path, headers=h, json={"text": "Existing"}), 201, "Message" + ) + outsider = headers(actors[2]) + outsider["Idempotency-Key"] = h["Idempotency-Key"] + check( + client.post(path, headers=outsider, json={"text": "Existing"}), + 404, + "Error", + ) + check( + client.post( + path, + headers={"Idempotency-Key": uuid4().hex}, + json={"text": "Existing"}, + ), + 401, + "Error", + ) diff --git a/student-tests/test_sessions.py b/student-tests/test_sessions.py new file mode 100644 index 0000000..78a5ce4 --- /dev/null +++ b/student-tests/test_sessions.py @@ -0,0 +1,114 @@ +from uuid import uuid4 + +import httpx +import pytest +from conftest import PASSWORD, TOKENS, check, headers, register + + +@pytest.mark.parametrize( + "password", ["", "x" * 11, "x" * 129, " " * 12, 42, True, None] +) +def test_password_validation(client, password): + check( + client.post( + "/api/v1/users", + json={ + "username": "pwd_" + uuid4().hex[:20], + "display_name": "Test", + "password": password, + }, + ), + 400, + "Error", + ) + + +def test_full_utf8_password(client): + password = "🌍" * 127 + ":" + user = register(client, password=password) + assert ( + check( + client.get("/api/v1/users/me", headers=headers(user)), 200, "User" + ) + == user + ) + + +@pytest.mark.parametrize( + "authorization", [None, "Basic broken", "Bearer unknown", "Basic /w=="] +) +def test_bad_basic(client, authorization): + result = client.post( + "/api/v1/auth/sessions", + headers={"Authorization": authorization} if authorization else {}, + ) + check(result, 401, "Error") + assert ( + result.headers["www-authenticate"] + == 'Basic realm="messenger", charset="UTF-8"' + ) + + +def test_wrong_password_and_unknown_user(client): + user = register(client) + for username in [user["username"], "missing_" + uuid4().hex[:20]]: + result = client.post( + "/api/v1/auth/sessions", + auth=httpx.BasicAuth(username, PASSWORD + "wrong"), + ) + data = check(result, 401, "Error") + assert data["error"]["message"] == "Authentication required" + + +def test_logout_is_not_revived_by_cache(client): + user = register(client) + auth = headers(user) + check(client.get("/api/v1/users/me", headers=auth), 200, "User") + result = client.delete("/api/v1/auth/sessions/current", headers=auth) + assert result.status_code == 204 and result.content == b"" + assert result.headers["x-request-id"] + check(client.get("/api/v1/users/me", headers=auth), 401, "Error") + check( + client.delete("/api/v1/auth/sessions/current", headers=auth), + 401, + "Error", + ) + + +def test_only_current_session_revoked(client): + user = register(client) + another = check( + client.post( + "/api/v1/auth/sessions", + auth=httpx.BasicAuth(user["username"], PASSWORD), + ), + 201, + "Session", + ) + assert another["token"] != TOKENS[user["id"]] + assert len(another["token"]) >= 32 + assert ( + client.delete( + "/api/v1/auth/sessions/current", headers=headers(user) + ).status_code + == 204 + ) + result = client.get( + "/api/v1/users/me", + headers={"Authorization": "Bearer " + another["token"]}, + ) + assert check(result, 200, "User") == user + + +def test_bearer_source_and_ignored_user_header(client, actors): + alice, bob, _ = actors + auth = {**headers(alice), "X-User-Id": bob["id"]} + assert ( + check(client.get("/api/v1/users/me", headers=auth), 200, "User")["id"] + == alice["id"] + ) + result = client.get( + "/api/v1/users/me", auth=httpx.BasicAuth(alice["username"], PASSWORD) + ) + check(result, 401, "Error") + assert result.headers["www-authenticate"] == 'Bearer realm="messenger"' diff --git a/student-unit/test_job_envelope.py b/student-unit/test_job_envelope.py new file mode 100644 index 0000000..895dfb5 --- /dev/null +++ b/student-unit/test_job_envelope.py @@ -0,0 +1,119 @@ +import copy +from datetime import UTC, datetime +from uuid import uuid4 + +import pytest +from jsonschema import Draft202012Validator, FormatChecker + +from src.pipeline import validate_job + + +def example(): + return dict( + schema_version=1, + job_id=str(uuid4()), + type="attachment.process.v1", + attachment_id=str(uuid4()), + pipeline_version=1, + attempt=1, + created_at=datetime.now(UTC).isoformat(), + ) + + +def test_schema_and_runtime_agree_on_valid_job(): + import json + from pathlib import Path + + schema = json.loads(Path("contracts/jobs.schema.json").read_text()) + for version in [1, 2]: + data = example() + data["pipeline_version"] = version + data.update( + traceparent="00-" + "a" * 32 + "-" + "b" * 16 + "-01", + tracestate="vendor=opaque", + ) + Draft202012Validator(schema, format_checker=FormatChecker()).validate( + data + ) + assert validate_job(data) == data + + +@pytest.mark.parametrize( + "field,value", + [ + ("schema_version", True), + ("schema_version", 2), + ("type", "other"), + ("job_id", 123), + ("job_id", "broken"), + ("attachment_id", None), + ("pipeline_version", 0), + ("pipeline_version", True), + ("attempt", 0), + ("attempt", 1.0), + ("created_at", "2026-01-01"), + ("created_at", "2026-01-01T12:00:00"), + ("created_at", None), + ("traceparent", "not-w3c"), + ("tracestate", "x" * 513), + ("url", "http://invalid.example"), + ("bytes", "secret-contents"), + ("filename", "../../bad"), + ], +) +def test_invalid_notification_is_rejected(field, value): + data = copy.deepcopy(example()) + data[field] = value + with pytest.raises((ValueError, TypeError)): + validate_job(data) + + +def test_worker_rejects_oversized_pixels_before_decode(): + import hashlib + import io + + from PIL import Image + + from src.pipeline import PermanentFailure + from src.worker import make_variants + + stream = io.BytesIO() + Image.new("1", (8000, 5001)).save(stream, format="PNG") + raw = stream.getvalue() + row = dict( + size_bytes=len(raw), + sha256=hashlib.sha256(raw).hexdigest(), + content_type="image/png", + pipeline_version=1, + ) + with ( + pytest.warns(Image.DecompressionBombWarning), + pytest.raises(PermanentFailure, match="pixel_limit"), + ): + list(make_variants(raw, row)) + + +def test_worker_rejects_changed_source_checksum(): + from src.pipeline import PermanentFailure + from src.worker import make_variants + + with pytest.raises(PermanentFailure, match="source_checksum_mismatch"): + list(make_variants(b"changed", dict(size_bytes=7, sha256="0" * 64))) + + +def test_worker_rejects_invalid_image_as_permanent(): + import hashlib + + from src.pipeline import PermanentFailure + from src.worker import make_variants + + raw = b"not an image" + with pytest.raises(PermanentFailure, match="invalid_image"): + list( + make_variants( + raw, + dict( + size_bytes=len(raw), sha256=hashlib.sha256(raw).hexdigest() + ), + ) + ) diff --git a/student-unit/test_security.py b/student-unit/test_security.py new file mode 100644 index 0000000..d01aeaf --- /dev/null +++ b/student-unit/test_security.py @@ -0,0 +1,60 @@ +import json +import time + +import pytest + +from src import identity +from src.errors import DomainError + + +def test_expired_or_missing_scoped_snapshot_fails_closed( + tmp_path, monkeypatch +): + monkeypatch.setattr(identity, "IDENTITY", tmp_path) + monkeypatch.setenv("IDENTITY_ENABLED", "1") + with pytest.raises(DomainError) as denied: + identity.ensure() + assert denied.value.status == 503 + snapshot = tmp_path / "secrets.json" + snapshot.write_text( + json.dumps( + { + "valid_until": time.time() + 30, + "values": {"DATABASE_URL": "synthetic"}, + } + ) + ) + assert identity.secret("DATABASE_URL") == "synthetic" + with pytest.raises(DomainError): + identity.secret("FOREIGN_ADMIN_SECRET") + snapshot.write_text( + json.dumps( + { + "valid_until": time.time() - 1, + "values": {"DATABASE_URL": "synthetic"}, + } + ) + ) + with pytest.raises(DomainError): + identity.secret("DATABASE_URL") + + +def test_bootstrap_repairs_config_without_changing_credentials( + tmp_path, monkeypatch +): + from scripts import bootstrap_security as bootstrap + + monkeypatch.setattr(bootstrap, "OPERATOR", tmp_path / "operator") + monkeypatch.setattr(bootstrap, "SECRET", tmp_path / "secrets") + monkeypatch.setattr(bootstrap, "TRUST", tmp_path / "trust") + bootstrap.generate() + private = bootstrap.OPERATOR / "service-secrets.json" + original = private.read_bytes() + config = bootstrap.SECRET / "broker.conf" + expected = config.read_bytes() + config.unlink() + bootstrap.generate() + assert private.read_bytes() == original + assert config.read_bytes() == expected + assert bootstrap.OPERATOR.stat().st_mode & 0o777 == 0o700 + assert private.stat().st_mode & 0o777 == 0o600 diff --git a/student-unit/test_telemetry.py b/student-unit/test_telemetry.py new file mode 100644 index 0000000..a5055ec --- /dev/null +++ b/student-unit/test_telemetry.py @@ -0,0 +1,147 @@ +import asyncio +import json +from types import SimpleNamespace + +import pytest +from opentelemetry.sdk.trace import TracerProvider +from opentelemetry.sdk.trace.export import SimpleSpanProcessor +from opentelemetry.sdk.trace.export.in_memory_span_exporter import ( + InMemorySpanExporter, +) + +from src import telemetry + + +@pytest.fixture +def signals(monkeypatch): + exporter = InMemorySpanExporter() + provider = TracerProvider() + provider.add_span_processor(SimpleSpanProcessor(exporter)) + logs = [] + monkeypatch.setattr( + telemetry, + "_state", + SimpleNamespace( + tracer=provider.get_tracer("synthetic-test"), + service="messenger-api", + logger=SimpleNamespace(emit=lambda **record: logs.append(record)), + ), + ) + yield exporter, logs + provider.shutdown() + + +def test_trace_context_survives_separate_publish_and_consume(signals): + exporter, _ = signals + with telemetry.span("upload") as upload: + accepted_context = telemetry.carrier() + with telemetry.span( + "publish", kind=telemetry.SpanKind.PRODUCER, parent=accepted_context + ) as publish: + notification = telemetry.carrier() + with telemetry.span( + "consume", kind=telemetry.SpanKind.CONSUMER, parent=notification + ) as consume: + with telemetry.span("s3.put"): + pass + spans = {s.name: s for s in exporter.get_finished_spans()} + assert len({s.context.trace_id for s in spans.values()}) == 1 + assert spans["publish"].parent.span_id == upload.get_span_context().span_id + assert ( + spans["consume"].parent.span_id == publish.get_span_context().span_id + ) + assert spans["s3.put"].parent.span_id == consume.get_span_context().span_id + + +def test_secret_in_exception_and_unapproved_fields_is_not_exported( + signals, capsys +): + exporter, logs = signals + sensitive = "SyntheticSensitiveValueForPrivacyProbe" + with pytest.raises(ValueError): + with telemetry.span( + "db.operation", attributes={"db.query.text": sensitive} + ): + telemetry.log( + "request.failed", + request_id="safe-request", + password=sensitive, + Authorization=sensitive, + body=sensitive, + ) + raise ValueError(sensitive) + exported = exporter.get_finished_spans()[0] + assert exported.events == () + assert sensitive not in str(exported.attributes) + assert sensitive not in exported.status.description + assert sensitive not in json.dumps(logs, default=str) + assert sensitive not in capsys.readouterr().out + + +def test_http_metrics_use_route_template_and_bounded_method( + signals, monkeypatch, capsys +): + exporter, logs = signals + counts = [] + monkeypatch.setattr( + telemetry, "count", lambda name, **kw: counts.append((name, kw)) + ) + sensitive = "SyntheticPrivateFilenameAndToken" + + async def application(scope, receive, send): + scope["route"] = SimpleNamespace( + path="/api/v1/chats/{chat_id}/messages" + ) + await send({"type": "http.response.start", "status": 201}) + await send({"type": "http.response.body", "body": sensitive.encode()}) + + async def send(_): + pass + + scope = { + "type": "http", + "path": "/api/v1/chats/" + sensitive + "/messages", + "query_string": sensitive.encode(), + "method": "CUSTOM_UNBOUNDED_METHOD", + "headers": [(b"authorization", sensitive.encode())], + "state": {"request_id": "safe-request"}, + } + asyncio.run(telemetry.TelemetryMiddleware(application)(scope, None, send)) + assert ( + counts[0][1]["attributes"]["route"] + == "/api/v1/chats/{chat_id}/messages" + ) + assert counts[0][1]["attributes"]["method"] == "OTHER" + assert sensitive not in json.dumps(logs, default=str) + assert sensitive not in str(exporter.get_finished_spans()[0].attributes) + assert sensitive not in capsys.readouterr().out + + +def test_large_tracestate_cannot_break_durable_job_contract(signals): + from datetime import UTC, datetime + from uuid import uuid4 + + from src.pipeline import validate_job + + trace_id = uuid4().hex + incoming = { + "traceparent": "00-" + trace_id + "-" + uuid4().hex[:16] + "-01", + "tracestate": ",".join( + "vendor" + str(i) + "=" + "x" * 200 for i in range(3) + ), + } + with telemetry.span("upload", parent=incoming): + retained = telemetry.carrier() + message = { + "schema_version": 1, + "job_id": str(uuid4()), + "type": "attachment.process.v1", + "attachment_id": str(uuid4()), + "pipeline_version": 1, + "attempt": 1, + "created_at": datetime.now(UTC).isoformat(), + **retained, + } + assert validate_job(message) == message + assert retained["traceparent"].split("-")[1] == trace_id + assert "tracestate" not in retained diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..14b9e6e --- /dev/null +++ b/uv.lock @@ -0,0 +1,1564 @@ +version = 1 +revision = 5 +requires-python = "==3.14.*" + +[[package]] +name = "annotated-doc" +version = "0.0.5" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/5a/8e/38aa427ed5402449e226975b649c5dc73ccadfefeb95e6aecb8f8ea4b6b6/annotated_doc-0.0.5.tar.gz", hash = "sha256:c7e58ce09192557605d8bbd92836d7e1d520ac9580096042c0bfd197efacf1bb", size = 10758, upload-time = "2026-07-28T13:50:58.129Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3e/30/e900b21425a860e195f32e37657aa1f7c7f2b1bfb26f03ca209b90933c06/annotated_doc-0.0.5-py3-none-any.whl", hash = "sha256:117bac03a25ede5df5440e855b32d556049ca169ead221505badf432fed4b101", size = 5302, upload-time = "2026-07-28T13:50:57.239Z" }, +] + +[[package]] +name = "annotated-types" +version = "0.8.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/5f/56/a8120250d128bed162cd73c76d45f6ef9991f3e068f62a8ee060afa3104a/annotated_types-0.8.0.tar.gz", hash = "sha256:13b2beaad985e05e2d6407ee4c4f35590b11f8d693a258a561055cac8f64cab7", size = 15893, upload-time = "2026-07-23T20:16:13.995Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/99/91/8acff4f5e50511b911bbccb72b8628a49c68ce14148cd9f6431094859a90/annotated_types-0.8.0-py3-none-any.whl", hash = "sha256:f072f4d804ea359e4eaf198b1af7a8b0943881a87f31bb764f8bf219bb9419e0", size = 13427, upload-time = "2026-07-23T20:16:12.938Z" }, +] + +[[package]] +name = "anyio" +version = "4.16.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "idna" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a1/98/7e457a3b014976887a050561955c0b76e1e7e2d6e27b78ecef2ef80518f2/anyio-4.16.0.tar.gz", hash = "sha256:59bb03251907983d1603d27c3087ddb1e93299ea2163adcdba37899a4fb12ffb", size = 310971, upload-time = "2026-11-01T11:20:07.282Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a9/16/7757fb84c819accc7d7e9af5291b261e4abb8627ee040f99e7d35ef2457a/anyio-4.16.0-py3-none-any.whl", hash = "sha256:c66ae634e0b8228396b801741beb3294326d4b6102f7bba4041c0dfb58c29026", size = 134521, upload-time = "2026-11-01T11:20:05.59Z" }, +] + +[[package]] +name = "argon2-cffi" +version = "25.1.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "argon2-cffi-bindings" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/0e/89/ce5af8a7d472a67cc819d5d998aa8c82c5d860608c4db9f46f1162d7dab9/argon2_cffi-25.1.0.tar.gz", hash = "sha256:694ae5cc8a42f4c4e2bf2ca0e64e51e23a040c6a517a85074683d3959e1346c1", size = 45706, upload-time = "2025-06-03T06:55:32.073Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4f/d3/a8b22fa575b297cd6e3e3b0155c7e25db170edf1c74783d6a31a2490b8d9/argon2_cffi-25.1.0-py3-none-any.whl", hash = "sha256:fdc8b074db390fccb6eb4a3604ae7231f219aa669a2652e0f20e16ba513d5741", size = 14657, upload-time = "2025-06-03T06:55:30.804Z" }, +] + +[[package]] +name = "argon2-cffi-bindings" +version = "26.1.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "cffi" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/0b/43/bb8b6e8708d49a5ab36781333af092d9f483b198a2710d01281204640055/argon2_cffi_bindings-26.1.0.tar.gz", hash = "sha256:63505c71542a44b68b1e38060450fb006404170da375feb31af153e7f9c6205d", size = 1790807, upload-time = "2026-08-20T07:44:22.492Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e7/d2/0ae991f1b2181e5be49007c574710a800ad36c2978683addb3e67c474e55/argon2_cffi_bindings-26.1.0-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:21ca0396fe5ec995dd54431c32698189666f9224810acfa752e50d2bd94d9df2", size = 25521, upload-time = "2026-08-20T07:32:43.019Z" }, + { url = "https://files.pythonhosted.org/packages/7e/e4/ad91d8297638aa2258aad4501c306aca99480dfe76ccd638173fa3702db9/argon2_cffi_bindings-26.1.0-cp310-abi3-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:78de2d65e0b9ea7ce9d1b1c3e87297b2d7305a02c266ee2a2d6910daddd7ee69", size = 27177, upload-time = "2026-08-20T07:32:44.158Z" }, + { url = "https://files.pythonhosted.org/packages/6f/86/5363df11b86d02cf3662208e7406496327649cc90eb365bf6f4e8a54a41f/argon2_cffi_bindings-26.1.0-cp310-abi3-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:27f1821903e2ceadcb88ec2b45ef190897b7682449c772f4d9b53e42c520cf29", size = 26597, upload-time = "2026-08-20T07:32:45.172Z" }, + { url = "https://files.pythonhosted.org/packages/f4/b5/a14dcc592652347dad23ee93b278a4da5d2a25c9ed3ebd10d68eea823a4f/argon2_cffi_bindings-26.1.0-cp310-abi3-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:d88e5f7e60f28ae0b0cc6b2f16c43e87cd642a196a86f85e0d8bb6fe016fc16d", size = 27403, upload-time = "2026-08-20T07:32:46.13Z" }, + { url = "https://files.pythonhosted.org/packages/b3/81/b4a20d4902af7f796390bf9245ff83c5217dfa7367efa1d14986956c482b/argon2_cffi_bindings-26.1.0-cp310-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:34b7d9c24a4165a2c61cc8ae11d44d48c9ce2830fb536cb7914e11fdd9962728", size = 27132, upload-time = "2026-08-20T07:32:47.13Z" }, + { url = "https://files.pythonhosted.org/packages/7e/1b/c8de358af07b1c490e0fcb863ef98e46ddb486e45567aca5a60bd68d9daa/argon2_cffi_bindings-26.1.0-cp310-abi3-musllinux_1_2_riscv64.whl", hash = "sha256:224865cbbcb7a2bd1356741dff12b0134df726b6d44bb7b500df8e303cbd9e81", size = 27588, upload-time = "2026-08-20T07:32:48.087Z" }, + { url = "https://files.pythonhosted.org/packages/48/2f/7ee62a6e79f9309f9d9982d301b22a00010adb580c05c8109b94d7b33de0/argon2_cffi_bindings-26.1.0-cp310-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:ffff613aaa9ce6236766e2fc6dc560bb5abde7a2e2416e3db1f9ae395a2b4dd4", size = 26785, upload-time = "2026-08-20T07:32:48.977Z" }, + { url = "https://files.pythonhosted.org/packages/e9/10/960d0ee93d4897741bcaf4799c697dae2d81499f66fd1ed042a7dd54c1f4/argon2_cffi_bindings-26.1.0-cp310-abi3-win32.whl", hash = "sha256:a86c069c91a747a2c4e5c51473590aeb48172fff9b2130d23729a42d98665ecb", size = 23898, upload-time = "2026-08-20T07:32:50.114Z" }, + { url = "https://files.pythonhosted.org/packages/6d/3a/0cc14a05810e6add9bce5e87693334baa2222de5f647fa31781885b6573f/argon2_cffi_bindings-26.1.0-cp310-abi3-win_amd64.whl", hash = "sha256:2c36ff87b5dfaa477d0bd51e9d7f6abdae7c8955d2983c97419085d842154b3e", size = 25730, upload-time = "2026-08-20T07:32:51.091Z" }, + { url = "https://files.pythonhosted.org/packages/4e/db/d83cf2af140547f0b9cdaece05b2dc2dcbf991be4667331d073eff771435/argon2_cffi_bindings-26.1.0-cp310-abi3-win_arm64.whl", hash = "sha256:f9c4420a7a864fe1b86ce35befc95b8e39fb852493b81cf798671ddc265de638", size = 24478, upload-time = "2026-08-20T07:32:52.111Z" }, + { url = "https://files.pythonhosted.org/packages/76/38/de696045960f5b846d428c0fb6c130ed3da87aac2af209b05c193815404c/argon2_cffi_bindings-26.1.0-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:db0fcd827ca61622a01b220aadfbece01939acf53888f2cb98cd93e9b1e2c97e", size = 15449, upload-time = "2026-08-20T07:32:54.075Z" }, + { url = "https://files.pythonhosted.org/packages/91/0a/c25af768f6b75a5a71e31207f87c540656b2808c015260444a22763221ad/argon2_cffi_bindings-26.1.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:28524438cd3e723f25412f63d4fd516ff5bae9ae5aa56acbe2a1404398a0cf31", size = 25683, upload-time = "2026-08-20T07:32:55.05Z" }, + { url = "https://files.pythonhosted.org/packages/a8/7e/be212c751ab0bcea7f646615f933bf262e8e50b3f7bef32f861d0a2d066b/argon2_cffi_bindings-26.1.0-cp314-cp314t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ac82fc756a446b6ccd7139ce70efa9d8bbe541e7ad579a12dcb52764b7175c5f", size = 27311, upload-time = "2026-08-20T07:32:56.166Z" }, + { url = "https://files.pythonhosted.org/packages/a6/ee/f84b28e4afd13d3cac36c1d8fa8c239d2dc2c51cd978d02ee5d5ad98d9bb/argon2_cffi_bindings-26.1.0-cp314-cp314t-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6a4e68eed961a8de6928d1c17ff3dc2a547e0e923c17f8f1cd79fb7bc9502f98", size = 26771, upload-time = "2026-08-20T07:32:57.206Z" }, + { url = "https://files.pythonhosted.org/packages/21/c3/95c07a023691ecd529da9cb6a8f0779e13ebc1bdfaa86d145fdc1c6e7e79/argon2_cffi_bindings-26.1.0-cp314-cp314t-manylinux_2_34_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:151dfaad9de753f4af2a7854e707e4784f2acc434340ade64239c5b104b2d605", size = 27568, upload-time = "2026-08-20T07:32:58.361Z" }, + { url = "https://files.pythonhosted.org/packages/e6/31/3a18e31406d8694b4d6a31573c3e572fff6bed318bb744453eb653766d22/argon2_cffi_bindings-26.1.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:061a6919145bbf282ebf1f9c59d3135d4833c25313c8595c0d68cf7712ddfce2", size = 27280, upload-time = "2026-08-20T07:32:59.343Z" }, + { url = "https://files.pythonhosted.org/packages/0b/39/d4be4577e178b2397aa5b5575c8a309bf0da2afe05fe0c72c8f398662d63/argon2_cffi_bindings-26.1.0-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:62ff20cd130c956c7c9144d5fe35228f98b51c579b2439e988b27ef93e16c02a", size = 27776, upload-time = "2026-08-20T07:33:00.325Z" }, + { url = "https://files.pythonhosted.org/packages/71/47/78f4dd96f7411339f723b96fe24039c1bd5835102b8a5ba71ac4ec712ac7/argon2_cffi_bindings-26.1.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:19423e5d7ac1cc354baab59eaabf18db2ec04ef6593b5abe5a34f323c4a8f87a", size = 26932, upload-time = "2026-08-20T07:33:01.272Z" }, + { url = "https://files.pythonhosted.org/packages/3b/cd/96bfd37434cc0a848a9066c291d84b28846c4c9ea289ed9866b1164d622b/argon2_cffi_bindings-26.1.0-cp314-cp314t-win32.whl", hash = "sha256:4f84cdd868978d7b7350a566c254042d44216d9e37f241f3a6d3b1dfebeede35", size = 24878, upload-time = "2026-08-20T07:33:02.189Z" }, + { url = "https://files.pythonhosted.org/packages/f1/42/d8b6810abd9b1bd2f47ebbccf460da59c9f32e94888bea4f7b137d998797/argon2_cffi_bindings-26.1.0-cp314-cp314t-win_amd64.whl", hash = "sha256:2b741888c93147444fdfc851abd81cc207f37f7f7da42062a00deb3888e57da8", size = 26656, upload-time = "2026-08-20T07:33:03.222Z" }, + { url = "https://files.pythonhosted.org/packages/a9/d1/095d95eaf2ed1d9f77268cf3291bde148c6cd56121f8db2c74c1ba618a0e/argon2_cffi_bindings-26.1.0-cp314-cp314t-win_arm64.whl", hash = "sha256:6ab674f668d5962a3a4136ae0812519b0f1586874263723a32181d60d64137e1", size = 25378, upload-time = "2026-08-20T07:33:04.332Z" }, +] + +[[package]] +name = "attrs" +version = "26.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/9a/8e/82a0fe20a541c03148528be8cac2408564a6c9a0cc7e9171802bc1d26985/attrs-26.1.0.tar.gz", hash = "sha256:d03ceb89cb322a8fd706d4fb91940737b6642aa36998fe130a9bc96c985eff32", size = 952055, upload-time = "2026-03-19T14:22:25.026Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/64/b4/17d4b0b2a2dc85a6df63d1157e028ed19f90d4cd97c36717afef2bc2f395/attrs-26.1.0-py3-none-any.whl", hash = "sha256:c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309", size = 67548, upload-time = "2026-03-19T14:22:23.645Z" }, +] + +[[package]] +name = "boolean-py" +version = "5.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/c4/cf/85379f13b76f3a69bca86b60237978af17d6aa0bc5998978c3b8cf05abb2/boolean_py-5.0.tar.gz", hash = "sha256:60cbc4bad079753721d32649545505362c754e121570ada4658b852a3a318d95", size = 37047, upload-time = "2025-04-03T10:39:49.734Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e5/ca/78d423b324b8d77900030fa59c4aa9054261ef0925631cd2501dd015b7b7/boolean_py-5.0-py3-none-any.whl", hash = "sha256:ef28a70bd43115208441b53a045d1549e2f0ec6e3d08a9d142cbc41c1938e8d9", size = 26577, upload-time = "2025-04-03T10:39:48.449Z" }, +] + +[[package]] +name = "cachecontrol" +version = "0.15.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "msgpack" }, + { name = "requests" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/f6/03/825d9b1cb14c5ca1ce4dec89fbb87ef87bdd5d45eb5bd96a463aa1ead457/cachecontrol-0.15.0.tar.gz", hash = "sha256:52157b539eb64d85c8c793660e86cf05cf95fad7b98c8ef6846e4a0ddffdb193", size = 31535, upload-time = "2026-11-16T20:48:41.99Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8d/4b/fb590767eef526df867d79f1ebfaf737ce85365a752fa1f4cc428497da7d/cachecontrol-0.15.0-py3-none-any.whl", hash = "sha256:10b7ab4387355ad9361d5b89bc0f6758e48099017be173241c4e0f20d9e1dad2", size = 22333, upload-time = "2026-11-16T20:48:40.674Z" }, +] + +[package.optional-dependencies] +filecache = [ + { name = "filelock" }, +] + +[[package]] +name = "certifi" +version = "2026.10.23" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/fd/11/b524cbd9bbdaca58608e4cf4053fd463417549e1959fa8d3aa18319f9555/certifi-2026.10.23.tar.gz", hash = "sha256:a9895e6e2758b371e0545e321a3a8fd1fcfd9829ada8824a936dfb16aaaf36cd", size = 136225, upload-time = "2026-10-23T11:36:16.478Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/32/d1/a3652fe2c19134d0d15922177821d863cbd7e842d53a21bbe7e8e3a1b5ac/certifi-2026.10.23-py3-none-any.whl", hash = "sha256:e9b54de76e530bb6cf0ccd036787103acb58fd42ba930ea8bf948ddbaa2f61d1", size = 135082, upload-time = "2026-10-23T11:36:14.763Z" }, +] + +[[package]] +name = "cffi" +version = "2.1.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pycparser", marker = "implementation_name != 'PyPy'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9e/ef/008a1939e372c06329a3fce4279c02f328488f3526744906eeec3da7ad5f/cffi-2.1.1.tar.gz", hash = "sha256:dd31f52ea1086513bb9df30f8fcee9b8918323ae067a3d5b78bc826a000712be", size = 530807, upload-time = "2026-08-03T21:21:18.939Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d3/7b/d6bbf82b8b96e7391438898c42f5bd96dd02030fd5b64937d248220003e2/cffi-2.1.1-cp314-cp314-ios_13_0_arm64_iphoneos.whl", hash = "sha256:7dbb61fe3a7699468030f71bbe5f8a0e326a151daa91beb11a6fc1f980c55e1c", size = 194064, upload-time = "2026-08-03T21:20:17.148Z" }, + { url = "https://files.pythonhosted.org/packages/94/e6/bcc91b283be94735e268487a054004f0aa19947b6348fa367db53230abc8/cffi-2.1.1-cp314-cp314-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:f24fb43132a4c6b4cb4eb029492919b2db645be6808d738f244fd146c03c32cb", size = 196720, upload-time = "2026-08-03T21:20:18.268Z" }, + { url = "https://files.pythonhosted.org/packages/d9/99/c4b0c17cacdc9c3b8f280026286a9826d6a208c0f047591a3c3ce99b91fd/cffi-2.1.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:d28630f5854ab07ab1fd4aba756de52326c82e6be15d414b12793f1975048b54", size = 184964, upload-time = "2026-08-03T21:20:19.708Z" }, + { url = "https://files.pythonhosted.org/packages/b3/a9/9db617d05d7367c1ad0ab00b3aa6e6f9281edd689b4ee9ea0e5a84e89c97/cffi-2.1.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:661c298b4821edebead0c91edd2b00374d67ad7c5a1f7a91d4442633b79d6a72", size = 184962, upload-time = "2026-08-03T21:20:20.833Z" }, + { url = "https://files.pythonhosted.org/packages/67/b8/b42132ca113dc567d37684437b46ca1dafc885902b02a110a02d5b511857/cffi-2.1.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:58acb8ab8e295e6c5ea12f888cbb13cf21511ef2a3303a23f4325c29d17fe5c1", size = 222328, upload-time = "2026-08-03T21:20:22.118Z" }, + { url = "https://files.pythonhosted.org/packages/80/10/c5c0cbf0a657aecf59ef511409734230bf556f05a0d6c9eed7aa5c0a0166/cffi-2.1.1-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:456a61fa52d579ebf9df2e9552ead5129855dbaff6c1e5a9b1bc408809bdc062", size = 209985, upload-time = "2026-08-03T21:20:23.401Z" }, + { url = "https://files.pythonhosted.org/packages/d5/6c/bfa0b87b03b9238148beca990292843c9396ba069b54496596594173de7b/cffi-2.1.1-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:a4f00aa42f75d6e4595e8866e748cc1705adc0cddfeb2ca86d0d03993d63ba03", size = 208530, upload-time = "2026-08-03T21:20:24.628Z" }, + { url = "https://files.pythonhosted.org/packages/e9/02/4e7d553a7ac4b4238b38b3c1b80d486e9d4436f8d2acbf87a0997fe3f402/cffi-2.1.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:b0431303acaea1089ad4b3e9ce4e6518193def1118d4073ca848635ee4ea2e96", size = 221525, upload-time = "2026-08-03T21:20:25.758Z" }, + { url = "https://files.pythonhosted.org/packages/82/1d/a4aaf9babd75acb4d5f223bff71533bee748dd770a382619a798960ee9ba/cffi-2.1.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:64faea20f4e2613363a1a9b9c7dd73058f3ecd00133a511e72ad7c511658f527", size = 225053, upload-time = "2026-08-03T21:20:26.985Z" }, + { url = "https://files.pythonhosted.org/packages/81/10/5dc0e7bdd18e22107054288283380fc97a06ae3f1656a106908d666a3c88/cffi-2.1.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5c58fe613dc5e5336357eff555824a314d8e43282600435c8d1cb6a7a2fedd13", size = 223213, upload-time = "2026-08-03T21:20:28.277Z" }, + { url = "https://files.pythonhosted.org/packages/0b/e9/d0061c364cde06ee43168a0d076ac1da512cbc380d44767b844ba34fe2b6/cffi-2.1.1-cp314-cp314-win32.whl", hash = "sha256:1a18a57b58cfb21fc28d72e876acf10eaed67a1ed96226f92af4df681d571c4c", size = 177682, upload-time = "2026-08-03T21:20:44.288Z" }, + { url = "https://files.pythonhosted.org/packages/a7/06/1c3e01e3ba14c39f6d10bfbac52753b7e22259e38088e5cfe1d704918690/cffi-2.1.1-cp314-cp314-win_amd64.whl", hash = "sha256:3222ba5d678f80a030e6afbcc33dc1ae5cb45facabb61cee2c7016b8432fde48", size = 187949, upload-time = "2026-08-03T21:20:45.623Z" }, + { url = "https://files.pythonhosted.org/packages/87/5b/da4e39efe18eeb89cf580ea9cfc66b6a7c3eadb808fc0cc1d3a295cb5a5d/cffi-2.1.1-cp314-cp314-win_arm64.whl", hash = "sha256:ab36d55f9ed2d067327667c2fea18dda018eb628dd6347aa01dda6cf1f5d3836", size = 182947, upload-time = "2026-08-03T21:20:46.955Z" }, + { url = "https://files.pythonhosted.org/packages/23/59/40338bf421c5accea1d45158170c87006ef1cd371b05c077e76476949728/cffi-2.1.1-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:7750c6449dff7864bb9bb27ddfb0267756189201a3afc911d82b3caacd70dfc3", size = 188504, upload-time = "2026-08-03T21:20:29.495Z" }, + { url = "https://files.pythonhosted.org/packages/7d/47/5ecf1023850036e674c77ec4de86182d309ae344e39e7cba984b7df5d647/cffi-2.1.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:0beceaabe56af686895136a2de78db54ecd8e4046b236b8fd6d6cb61389e9bf2", size = 188259, upload-time = "2026-08-03T21:20:31.291Z" }, + { url = "https://files.pythonhosted.org/packages/2a/9c/92934c3bea9f785b23eba304538c0b4d37a2a96d2431eb3a1bc87a11aa19/cffi-2.1.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:49cbc70e6542d4ccccb936558d1064a8012541e78f821f955cff24e357776c94", size = 223864, upload-time = "2026-08-03T21:20:32.571Z" }, + { url = "https://files.pythonhosted.org/packages/4d/45/ba4c93527bc38616a8bd36488acb69a2212d60486794f0c1f318949bbb76/cffi-2.1.1-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:e2d65b31f36619cda3999b78b2aa9632e76b78448e7a56fc4240824200e7c4fc", size = 211538, upload-time = "2026-08-03T21:20:33.808Z" }, + { url = "https://files.pythonhosted.org/packages/80/e9/b6ef565e452acb932fb0cb5443f44a78efbd1233e566f02b5a83855e9115/cffi-2.1.1-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.whl", hash = "sha256:28907ab9bfb6aa13184cfc17c6b8e1023c5ab6fd7076d8c20a35e59fe04f8f29", size = 210688, upload-time = "2026-08-03T21:20:34.974Z" }, + { url = "https://files.pythonhosted.org/packages/9a/95/eff5f0cee78d2eabc7eebffec40d3fc1876b5f3c95582e018bb4b99601f2/cffi-2.1.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:51b31d1c98274844cfd7838ce00bfc27c7423a4dc00fc0772fc3331c2cc90676", size = 223803, upload-time = "2026-08-03T21:20:36.564Z" }, + { url = "https://files.pythonhosted.org/packages/fa/01/579d39fb8bef00a335a23d83757b44feb24cd6345a2c451b64cb67b9c362/cffi-2.1.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:5e7cecbaadb83884793e05828cee59b210b24583b9c7425d0ba6a754fe22eb4e", size = 226763, upload-time = "2026-08-03T21:20:37.816Z" }, + { url = "https://files.pythonhosted.org/packages/8d/b0/0b44f47c60b01b57b6e2bbd92343f13a85a1d93bc46ccf6e47e244acd99c/cffi-2.1.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:25792eac27877609e7bb06d42ff88278a6624fff2ba9bbb523c09616b117e80f", size = 225688, upload-time = "2026-08-03T21:20:38.959Z" }, + { url = "https://files.pythonhosted.org/packages/eb/d2/3b7176cb570a1d3e27faf67b72f591af508036e0d8b2be2ef9af9e8c84bb/cffi-2.1.1-cp314-cp314t-win32.whl", hash = "sha256:8ef53b2de9bcb9197d31854256575d59dbac0cba72ac627bb291ef5eceb74be4", size = 182868, upload-time = "2026-08-03T21:20:40.388Z" }, + { url = "https://files.pythonhosted.org/packages/56/78/31f00c1bcd97c9bbf55f1bfdf5bc809a5de8887473e90bb9960dca825e80/cffi-2.1.1-cp314-cp314t-win_amd64.whl", hash = "sha256:616f097f2fe415bc92a247f02e11f634e1f9e9a83d327e3c915c15089c87869e", size = 194104, upload-time = "2026-08-03T21:20:41.725Z" }, + { url = "https://files.pythonhosted.org/packages/7b/1b/58496f2ed0a35de575250c02a43ab3cc2c04d494a88fed31c1cabc0fd176/cffi-2.1.1-cp314-cp314t-win_arm64.whl", hash = "sha256:ad2c86c495b899d862ea0f4b42891b8713a3bd45dd4105c7fd51c2a72f39f3a5", size = 186402, upload-time = "2026-08-03T21:20:43.042Z" }, +] + +[[package]] +name = "charset-normalizer" +version = "3.5.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/33/1c/f41d4e74c28ab327ff3acd36053f7ea506c55872d7a90b0fa71aa3ab0c89/charset_normalizer-3.5.2.tar.gz", hash = "sha256:39de2a259fc954455c57274dc94c79d5842774e1247a016aff30bc0efed0f4ef", size = 172659, upload-time = "2026-09-30T04:39:23.398Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/58/ca/7aa91362a2f77ac8e9e28a9b902a74f7d0e11a851ef0d27a74308da8cd90/charset_normalizer-3.5.2-cp314-cp314-android_24_arm64_v8a.whl", hash = "sha256:1afb975bd5d68d5ce9f6b6d44fdf2f7e34b895a35e95708a7a91b20a3b51d187", size = 226010, upload-time = "2026-09-30T04:36:27.669Z" }, + { url = "https://files.pythonhosted.org/packages/a8/cf/ac8878d0322cf88a1aad4c7b147db32ca0bd806eb0060957b2e31486dbe6/charset_normalizer-3.5.2-cp314-cp314-android_24_x86_64.whl", hash = "sha256:bbbfc8e28816f19d7c0f1816664980c0a9875d01b27cdf8eedddb639d9e108ad", size = 239266, upload-time = "2026-09-30T04:36:29.434Z" }, + { url = "https://files.pythonhosted.org/packages/c9/6d/9a08d7e0b29b7208e2c6c01dc56c8e0520e7c7beadbbfb024b58fd69c8a5/charset_normalizer-3.5.2-cp314-cp314-ios_13_0_arm64_iphoneos.whl", hash = "sha256:7967d08cf06dee78443b874f98c98036f624f3a4e73e11f9f64f5be4d25393cf", size = 206783, upload-time = "2026-09-30T04:36:30.872Z" }, + { url = "https://files.pythonhosted.org/packages/82/44/b0aa350280e6ff5a5492d17cf10460dd39d5ee848f872f7ba2df10607f60/charset_normalizer-3.5.2-cp314-cp314-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:4c2b5031f63e331e3839b40aed2dd6f191e9c07edbde303e7876846ea1946995", size = 210449, upload-time = "2026-09-30T04:36:32.625Z" }, + { url = "https://files.pythonhosted.org/packages/7c/8a/40db9aa9f5907bb0e6f8b6d64064bf8852fb33d4b813ff9414911df7647c/charset_normalizer-3.5.2-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:fcff63213e8e6e47770541a4607175404f47cbb3ebea7b6058cc82d524a0e424", size = 367815, upload-time = "2026-09-30T04:36:34.197Z" }, + { url = "https://files.pythonhosted.org/packages/7f/72/9c5e7707b57c8ddfa9ddf7b0b1d009d7fbab9e9e887d5b721060f37e307d/charset_normalizer-3.5.2-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8d86d6fc60743dc916eb79e2eb1ec4818e21e427731543af40a3021851174a13", size = 247095, upload-time = "2026-09-30T04:36:35.803Z" }, + { url = "https://files.pythonhosted.org/packages/83/09/71e453691e927de4ddf792770cfaab3f49d494e222f66ea5e404bbd5e39c/charset_normalizer-3.5.2-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:7a881931aa470808df94a8c380eed2bbbc76cd9dc622310f99665658c821eb6d", size = 233942, upload-time = "2026-09-30T04:36:37.407Z" }, + { url = "https://files.pythonhosted.org/packages/9f/86/85c84e4da8b27dd409577d9437926ff581c5f9d3c66038dc68c1a526de51/charset_normalizer-3.5.2-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:8024d00c3faf3fc0c16e07a69f4405e8eac7cc0ab15f65fe6cf43827c4cf72b4", size = 273762, upload-time = "2026-09-30T04:36:38.904Z" }, + { url = "https://files.pythonhosted.org/packages/92/08/564955a4b5f2ccb410ab480bbe8c6a18063ff27f2d35458731c4a5335df9/charset_normalizer-3.5.2-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:4d48f2d08b9de5864e2c8744d4461b862fb149a18274abc8b698c45975573438", size = 269514, upload-time = "2026-09-30T04:36:40.469Z" }, + { url = "https://files.pythonhosted.org/packages/18/24/bad3ac4271589df29cf5ce2f5ae490518a5739358052bd0d61209e6fea54/charset_normalizer-3.5.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:34276fd796040bf0993ab33a369aa572e6979c7aab225a88893667ad8eac8f7a", size = 255056, upload-time = "2026-09-30T04:36:42.02Z" }, + { url = "https://files.pythonhosted.org/packages/d6/3e/350d89ad49916b86554d6f5f2d03ec1152148f87e5ff735106c6a03b1a36/charset_normalizer-3.5.2-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:0521c5665880b33d603717defa76c094048900010897909952397feb3039da56", size = 251311, upload-time = "2026-09-30T04:36:43.577Z" }, + { url = "https://files.pythonhosted.org/packages/56/5b/4970a2d154df502e133402906dd04e3ae7cada7b3011283c88d0479a2585/charset_normalizer-3.5.2-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:eff0ac9dbe711a4aee69bf04a83896aa9b85f19641264053a9f6d48573abb7dd", size = 250190, upload-time = "2026-09-30T04:36:45.185Z" }, + { url = "https://files.pythonhosted.org/packages/88/8c/f1a91bddc8fb47c2889e29ea7ea49a194eb0d9868675d786806519c00d76/charset_normalizer-3.5.2-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:1503bccbeb36d5527790c3930327704c39af22de3112f1b1666a9f3ce15ee204", size = 237098, upload-time = "2026-09-30T04:36:46.689Z" }, + { url = "https://files.pythonhosted.org/packages/24/0e/bb5dace3cc7e79068425386a6589c19b5a2ab5fefc2a46abea6919683332/charset_normalizer-3.5.2-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:52aa6992700996af31f375de0c6bacd402b0097fe40b53c426b9f51a90ebabc7", size = 274228, upload-time = "2026-09-30T04:36:48.31Z" }, + { url = "https://files.pythonhosted.org/packages/9d/79/b849ad523017ea9f5a45581bbebed91439e0cf42fd2860a6f64e358eb5a6/charset_normalizer-3.5.2-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:e09a3942ecbdee5cce73ea9d42da82b81b72ac1bf031ce069b93b5adf4eac8cd", size = 252401, upload-time = "2026-09-30T04:36:50.091Z" }, + { url = "https://files.pythonhosted.org/packages/89/8c/75469d690cf47200bce8f6cad7655724fc23148e147abfc5ce78b5f65863/charset_normalizer-3.5.2-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:c7c9ab723cde841fefb34efbad91e87f00a674b1fe1cd0784fde742bf2c154dc", size = 271846, upload-time = "2026-09-30T04:36:51.719Z" }, + { url = "https://files.pythonhosted.org/packages/26/cd/6d52d3c7437cdcf2e310ce9f28f282e733d4ef60ed19105d1819c356255f/charset_normalizer-3.5.2-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:ddc7dacc8ece3a182e7f15cb862d1fd616b46d076cb1ae9dd232b2c38b655874", size = 258151, upload-time = "2026-09-30T04:36:53.234Z" }, + { url = "https://files.pythonhosted.org/packages/f7/4c/070b38bdb5f49a70199fce923ec0726a49536a63ab262abbfcaaf351110b/charset_normalizer-3.5.2-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:ee43c17b173d46a3212baa6ead3ae258eeabdae48c263a01ccf0218c366dd655", size = 143570, upload-time = "2026-09-30T04:36:54.816Z" }, + { url = "https://files.pythonhosted.org/packages/81/84/9ebfc8ed6c8c4fcd8e726ff6bf220cc8deb3966e31dce9be8dd8aa017e64/charset_normalizer-3.5.2-cp314-cp314-win32.whl", hash = "sha256:4f87960d57feabfb618e4e0af6e7371645fa26a277860739d6e5d6e0012c92f0", size = 186412, upload-time = "2026-09-30T04:36:56.643Z" }, + { url = "https://files.pythonhosted.org/packages/d1/78/5ed86f743d4bc350db307e7636419a0a5ee1d91806d30c7f667bd5c80dae/charset_normalizer-3.5.2-cp314-cp314-win_amd64.whl", hash = "sha256:e4e81e09c1578b8df602e3db08b0b3ea0a6947ad612f52bf8dc5ea8d47691f0c", size = 210965, upload-time = "2026-09-30T04:36:58.205Z" }, + { url = "https://files.pythonhosted.org/packages/53/94/a3a7698e9b1a395e1eb99ccd9a324be9347973bff4e72db2a06496d7cd27/charset_normalizer-3.5.2-cp314-cp314-win_arm64.whl", hash = "sha256:80d02b6f04e92601a081dd97b23d3128033098bff5d35d392ddcc0476ea11253", size = 200406, upload-time = "2026-09-30T04:36:59.764Z" }, + { url = "https://files.pythonhosted.org/packages/c1/48/c5dd00d5ef7791f02666de250a5bb6071e29b7e133cf4b835800b6d3bc27/charset_normalizer-3.5.2-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:dca9ab98072a5a54ebacebdc45f53e645336b320c667410b061be1ca588ae709", size = 396871, upload-time = "2026-09-30T04:37:01.543Z" }, + { url = "https://files.pythonhosted.org/packages/12/c8/8379554b42e8368161d898476686947a0fdbd3e8865170d7909dcabfdee8/charset_normalizer-3.5.2-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f0aa869112ef88429ae17820d99c3dd9504c9e9c671d3c246f3d7442cb051084", size = 249711, upload-time = "2026-09-30T04:37:03.111Z" }, + { url = "https://files.pythonhosted.org/packages/4a/eb/2ddb1035d17320caa9f41682935123a9a250277b261c3efc86b2d2a21343/charset_normalizer-3.5.2-cp314-cp314t-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:c0afc6800ba57ccc350374c5bd6150419915d95ce93cdbab2d783d75eaf30ecb", size = 231146, upload-time = "2026-09-30T04:37:04.721Z" }, + { url = "https://files.pythonhosted.org/packages/4a/24/2ecb4bde104322cd7859d6594fcfa74649f8d90b3221c9feecbef149875b/charset_normalizer-3.5.2-cp314-cp314t-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:7dcd882da75ef9adf94903b1e3b9419e8aa8fb4c7396822b834b9ef7fb96954f", size = 271552, upload-time = "2026-09-30T04:37:06.295Z" }, + { url = "https://files.pythonhosted.org/packages/3f/98/9d5f6ebc3aee9fef5d30b4aff11fb2ab7a1222b4064f8ef2c7c87cde217a/charset_normalizer-3.5.2-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:2e06a3a98f916dd41d27f3105e02e7a40181c98c94b9158733d03a6f80506c09", size = 269810, upload-time = "2026-09-30T04:37:07.905Z" }, + { url = "https://files.pythonhosted.org/packages/09/e1/a3b06a10461b1b7628853c934c644e03bc28e42767116afb52f19a56519b/charset_normalizer-3.5.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6bd128f206a7752ae1f2ab6c61bf8a24ba28913a10df8b14c2637b973ff97a80", size = 259845, upload-time = "2026-09-30T04:37:09.554Z" }, + { url = "https://files.pythonhosted.org/packages/fd/d3/6f561f74a296cf27d61775a1dc665ad13f3bff6a798810ca05907f37a7c4/charset_normalizer-3.5.2-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:c8f3d67aeaf55f017982b73683f0e7342ba2f6635a78f69ce89ebb26aa411e5c", size = 252825, upload-time = "2026-09-30T04:37:11.274Z" }, + { url = "https://files.pythonhosted.org/packages/26/9f/69e13ca3b18f43e0eafcd34c04a45b732ae22a43b54a5fc9e119103356eb/charset_normalizer-3.5.2-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:fe9753dfee015c570d73df76f899f18444d41388bffcde097deba51c4fadbb9f", size = 252659, upload-time = "2026-09-30T04:37:12.941Z" }, + { url = "https://files.pythonhosted.org/packages/73/a9/ace29806a0dae18939919c76ba526472d83214afa101105fabff2cf30625/charset_normalizer-3.5.2-cp314-cp314t-musllinux_1_2_armv7l.whl", hash = "sha256:92888bb3187c5ba50500b00b3b310c9f2c651709d28036077680cb5255450a03", size = 238819, upload-time = "2026-09-30T04:37:14.659Z" }, + { url = "https://files.pythonhosted.org/packages/f8/c1/6116d52a2e3311ec80f21f5fb5e17b27405f10b9608af8f6e69516841a1b/charset_normalizer-3.5.2-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:d008d90a7f2471519aef0c90dfbe73b3e6e4d5e66ac48e19154c17e89e98b604", size = 272973, upload-time = "2026-09-30T04:37:16.346Z" }, + { url = "https://files.pythonhosted.org/packages/19/aa/9955c7e93bba10a9c7e8f7a5031b7ced66f3a1883a55c00712b8d5850ff3/charset_normalizer-3.5.2-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:31f3930700408d211f13378ccbe1c40845d8da54bd0681fac3a9b5aae81c7aa8", size = 253692, upload-time = "2026-09-30T04:37:18.212Z" }, + { url = "https://files.pythonhosted.org/packages/bb/33/2a6ae7fdc1b10cb581cef91addd8cdfc5f40d50abb5702309369d5834579/charset_normalizer-3.5.2-cp314-cp314t-musllinux_1_2_s390x.whl", hash = "sha256:2a925889534b3748302dae5dead07cc13480de1dac3aea80a941b729b471ef93", size = 268757, upload-time = "2026-09-30T04:37:19.877Z" }, + { url = "https://files.pythonhosted.org/packages/a2/22/80992720a0282cd39bba1db35868e6b9c22f41281160143a836544bc1d8a/charset_normalizer-3.5.2-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:f5ec61164adcec446f8969a3358ec3f9b26bbda3b9213e5586d219afa8df2915", size = 262220, upload-time = "2026-09-30T04:37:21.583Z" }, + { url = "https://files.pythonhosted.org/packages/92/9f/181fd07e1bffea1d95cd80c84ac537354f50699c22cfc4d3c02b6fc16208/charset_normalizer-3.5.2-cp314-cp314t-win32.whl", hash = "sha256:598a11a2c7ebaa5334bf698bf29568c9c390abac6a154d8170fedecd1cea38c5", size = 197797, upload-time = "2026-09-30T04:37:23.235Z" }, + { url = "https://files.pythonhosted.org/packages/49/1c/25d8415ec1c4f2f41f1680435e4c87cfb378ff2f677d950946f2a45d0632/charset_normalizer-3.5.2-cp314-cp314t-win_amd64.whl", hash = "sha256:7fdde2c9fd9e3eca40631e024664cf2584272cc8f96308cbe5fdfc930f51d8bc", size = 222765, upload-time = "2026-09-30T04:37:24.891Z" }, + { url = "https://files.pythonhosted.org/packages/3e/b4/46b48f013dadfc0d0d33b375438e31bdf5a989dc68389c6bf627054d4df9/charset_normalizer-3.5.2-cp314-cp314t-win_arm64.whl", hash = "sha256:d1befeed746d247c81127bb14de9dc3d30edb6e5976d34f83f86ed262b1d9105", size = 210985, upload-time = "2026-09-30T04:37:26.634Z" }, + { url = "https://files.pythonhosted.org/packages/8c/ab/176fbfd5b64939c55d652366aa5b9ef1d767af207a3aa6ebeb0d226c484d/charset_normalizer-3.5.2-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:4275811936e2f06feff5e598fb42a1b7ae852da8e39605211892b56b81a34efd", size = 331815, upload-time = "2026-09-30T04:38:26.216Z" }, + { url = "https://files.pythonhosted.org/packages/7e/84/371eac6b30bdbcbf2d632a1a01809103459216fcaae61b8b8d922c1bfb8a/charset_normalizer-3.5.2-cp37-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:1c50fe28bbc2ced33386f298650d91218076c05420e6cbd790b913adc41659e7", size = 253276, upload-time = "2026-09-30T04:38:28.032Z" }, + { url = "https://files.pythonhosted.org/packages/43/6f/c4fbae58febff71709c51bc7e18fdfa55341dc382704740f9f0cbf03817b/charset_normalizer-3.5.2-cp37-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:d19fbd981a488e22cd04883659ca6b08f50b5974f9fd7c95655ef6a043e5893f", size = 241239, upload-time = "2026-09-30T04:38:29.732Z" }, + { url = "https://files.pythonhosted.org/packages/61/71/458c3f42164a07d0c5210798e9e704b39e540a6793b05aba67f3a35243a9/charset_normalizer-3.5.2-cp37-abi3-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:0fed1d06615f022ee3b13caf5e8b180cfea32bb2c5aded8a9d44277afc040f93", size = 231121, upload-time = "2026-09-30T04:38:31.462Z" }, + { url = "https://files.pythonhosted.org/packages/09/54/ab9e89367076f6331bb6c65c4bf14a5361fa5191cb6561bf534f18504e1b/charset_normalizer-3.5.2-cp37-abi3-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:838dcc90063569a0448120554591a1d6c4a4ffe11babf048908793154ab86ade", size = 260350, upload-time = "2026-09-30T04:38:33.239Z" }, + { url = "https://files.pythonhosted.org/packages/7c/c1/061431ecc688d9d76602502cb57cc01e691e682c18f1beb45f9673b5bbd2/charset_normalizer-3.5.2-cp37-abi3-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:2ce45c6627b22c47e390bc91a41c3d13032192e699fa0bea96e9671b373d69b0", size = 255430, upload-time = "2026-09-30T04:38:34.865Z" }, + { url = "https://files.pythonhosted.org/packages/8d/1f/20c8949f0676f7ab811abdeb7f4d7f1cbc6e61ff20bef08b44edeb092bc8/charset_normalizer-3.5.2-cp37-abi3-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:0774bf9bf620249fee3e0b8b9fd3065de213be30f3aa94ce2494b3b638949e26", size = 250612, upload-time = "2026-09-30T04:38:36.649Z" }, + { url = "https://files.pythonhosted.org/packages/2b/9e/46f2fa4c431fc98c4ae76a8cb5bdca54e0341e3cfc3fcfd8e82740250818/charset_normalizer-3.5.2-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:1db38f4c5496827c1a501846d64d14c3b80c7e6714e406cd7dc36a9899fa1011", size = 242083, upload-time = "2026-09-30T04:38:38.26Z" }, + { url = "https://files.pythonhosted.org/packages/bd/39/559be29a0c0f086e0bba6922babd38916cc5e0b58ced4de13ee01ea05508/charset_normalizer-3.5.2-cp37-abi3-musllinux_1_2_armv7l.whl", hash = "sha256:304d8e4d493af723536393eee0c689eb7813f4a474c8b479dee63f1fdd98f621", size = 232738, upload-time = "2026-09-30T04:38:39.81Z" }, + { url = "https://files.pythonhosted.org/packages/ff/6c/387b0e4f756a282831c1d9fc6aeb6c51ca4507ca202767c8de15ce9b12e2/charset_normalizer-3.5.2-cp37-abi3-musllinux_1_2_ppc64le.whl", hash = "sha256:9b7f416ff0978e2f2249330527f0ad6fa02f4932e6199692d3b52da2048c19e4", size = 260703, upload-time = "2026-09-30T04:38:41.346Z" }, + { url = "https://files.pythonhosted.org/packages/96/92/1fdf015f09ef449f50d3ac4b67c90887c9c318b727daa95cc4f866e6521d/charset_normalizer-3.5.2-cp37-abi3-musllinux_1_2_riscv64.whl", hash = "sha256:01077390b03f7988f11d700a2194e69b119741a86b1a638b1db88891e3eced8e", size = 247622, upload-time = "2026-09-30T04:38:42.937Z" }, + { url = "https://files.pythonhosted.org/packages/dc/3c/8e7b8a5671ad5d433669fb2a76f1a0164df2d9b1718b0206bc2a16d840cc/charset_normalizer-3.5.2-cp37-abi3-musllinux_1_2_s390x.whl", hash = "sha256:7e841fb9010836c992c9f12fcbd43a831de93a5f726fc1ccd8ca1d0268c5014c", size = 257500, upload-time = "2026-09-30T04:38:44.604Z" }, + { url = "https://files.pythonhosted.org/packages/b4/f0/45b579df5cabc1d5d53ea1cc35e8437d3ca768c0acccc7041517cb6fbb32/charset_normalizer-3.5.2-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:9cae88599c7219005d879f98e5ed53341e9a122af585e1091200358a3003d2a0", size = 255100, upload-time = "2026-09-30T04:38:46.289Z" }, + { url = "https://files.pythonhosted.org/packages/31/68/fdec18a343f5fb3f310588dd478b09ac4799e0b187dbade3a8cd776f03ef/charset_normalizer-3.5.2-cp37-abi3-win32.whl", hash = "sha256:01b0c0d2262a9e28e8484a278c7e1b5d650e3ac8cf2683d2967e25899f208bdf", size = 174499, upload-time = "2026-09-30T04:38:47.999Z" }, + { url = "https://files.pythonhosted.org/packages/9d/8a/b618149cc5207943a0242068d7a27897f56a62947b5a039085f2a22029f8/charset_normalizer-3.5.2-cp37-abi3-win_amd64.whl", hash = "sha256:9f56f72050826f63dcee7a7f55b0a77168cb3bfc553fd405e7f8f9ece75a4036", size = 200092, upload-time = "2026-09-30T04:38:49.707Z" }, + { url = "https://files.pythonhosted.org/packages/03/cf/4c66866fa9e2b1c78e3c911516d1de497a677b7ac60f1eceda74ce777ca3/charset_normalizer-3.5.2-cp37-abi3-win_arm64.whl", hash = "sha256:40ab6bffa02ae10a0581e6c198be7d2d8ca5c2a0c64e4ed3465d766df457573e", size = 294363, upload-time = "2026-09-30T04:38:51.312Z" }, + { url = "https://files.pythonhosted.org/packages/fc/ad/d07d7862a62ffa6d79d68074d14823243dd235a77c45262acbf6adeb28bf/charset_normalizer-3.5.2-py3-none-any.whl", hash = "sha256:b6b751274acb69d77b3323d6b7dbaa3c7fdfc1eb829b7eb61d262f32e1af9685", size = 68872, upload-time = "2026-09-30T04:39:21.828Z" }, +] + +[[package]] +name = "click" +version = "8.5.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/45/37/edbf1b0707709013c0cf2e8317e03d97ed29bf4cac709fe328904ae92a38/click-8.5.1.tar.gz", hash = "sha256:9bbfada76703fd1d784b83eea012e3e8c6a001a876543ef104fa56aaaeb072b4", size = 399151, upload-time = "2026-11-06T17:37:01.021Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/31/7d/164b7ffc8624fe9efb4221bf9af485d5c1e41b9ae118045d2b6dc5457d8b/click-8.5.1-py3-none-any.whl", hash = "sha256:8bb5376d2006950386f8c6427613334a2acadc5f559cb80e638d00b4df957e37", size = 126163, upload-time = "2026-11-06T17:36:59.287Z" }, +] + +[[package]] +name = "colorama" +version = "0.4.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, +] + +[[package]] +name = "contourpy" +version = "1.4.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "numpy" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/83/5a/a55177dd22553a277388e8a1b3220e92de91bacb28356cdc73caa240121d/contourpy-1.4.0.tar.gz", hash = "sha256:20156f5a1ac4f8ce02656e39a61e82164a3d359796dc8026f75b062783d500e1", size = 13323726, upload-time = "2026-09-11T19:05:05.808Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/75/b0/b548628c8dddf6e5e0a981b7fa8e4c008024df09c7d17c6a9e271edfa0b3/contourpy-1.4.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:a3e67bc1a6a4618a1dac7c3053a9ffece5ddfa2046b2670b342cf430bb0b87d1", size = 297354, upload-time = "2026-09-11T19:03:35.017Z" }, + { url = "https://files.pythonhosted.org/packages/04/5a/513484208742f65af2648c519f0b7ab034616e183c4403538024c136a1ab/contourpy-1.4.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:072a702e2e178f4fcf96f04775d0c059e4c917925abf0d3208ebb6865df3c23d", size = 283729, upload-time = "2026-09-11T19:03:36.818Z" }, + { url = "https://files.pythonhosted.org/packages/35/da/5a6562febc994b2c4bf9d01e57a50458ef8a2051bb3e7b35a00333e0fc26/contourpy-1.4.0-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:404dbcd9233513dfd1323b66ea593fef90e899f658f6b8a9ed8e93bd0ca669db", size = 357819, upload-time = "2026-09-11T19:03:39.058Z" }, + { url = "https://files.pythonhosted.org/packages/6d/99/7b358ce888aaa426f755daa096c99c59d17c352037344e836f20e5d3b957/contourpy-1.4.0-cp314-cp314-manylinux_2_26_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:61624f6722480aa7e168fd746164e7bfdf48f8ccb6542f1613741200dc37e2b1", size = 407795, upload-time = "2026-09-11T19:03:41.293Z" }, + { url = "https://files.pythonhosted.org/packages/be/02/34d7548adf08c60967435d79d7a90882eacc84f5093435287974c7e99943/contourpy-1.4.0-cp314-cp314-manylinux_2_26_s390x.manylinux_2_28_s390x.whl", hash = "sha256:2e741a39dfc96babe1722561e81351aeec104526c57dbe91c167c1db606c2d55", size = 408552, upload-time = "2026-09-11T19:03:42.728Z" }, + { url = "https://files.pythonhosted.org/packages/cf/8c/9677dad226e5aaac5b823d5b09d881ebc32ff1648af417597649841e516c/contourpy-1.4.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e439ab450c93455feb0218532ded3e946ec7a9b5f459069f122cfa44b89229f6", size = 384850, upload-time = "2026-09-11T19:03:44.402Z" }, + { url = "https://files.pythonhosted.org/packages/08/f5/e3fbeaa489c223629fbb434737cb3de4ecaca9cae4825e77b92490f640f8/contourpy-1.4.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:417be048f7e122cefbe2a34c51a1f2b0410f8eb35796f794d45475ddb7872d9d", size = 1357601, upload-time = "2026-09-11T19:03:46.746Z" }, + { url = "https://files.pythonhosted.org/packages/88/be/55fec293d342c222ed58a5d4056df4362e192af2e59527a3d5d822de8828/contourpy-1.4.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:43d80072a32299bf945de0a6dd4e034ea0162e832261de2e07a274a5adbba9c9", size = 1427340, upload-time = "2026-09-11T19:03:48.745Z" }, + { url = "https://files.pythonhosted.org/packages/86/40/0faabf453edf59b0e3633381d7ca72c3414fb9b72b5cbb08b06ed792d3e5/contourpy-1.4.0-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:fa1b787362a3856e63dd2b89449f6c384d55ee1beb8f94f4bcc871b40f02462c", size = 118355, upload-time = "2026-09-11T19:03:50.047Z" }, + { url = "https://files.pythonhosted.org/packages/38/0c/7ea75aa3559ae8a6805015e15a19c92b6480752ecc92526361e5776e88c5/contourpy-1.4.0-cp314-cp314-win32.whl", hash = "sha256:738c44fa71735a617f36da58e32810512407d283d5d1bb5b1cecb00d7eeba7cf", size = 356977, upload-time = "2026-09-11T19:04:11.401Z" }, + { url = "https://files.pythonhosted.org/packages/15/41/3df8cc14bb572c8b447f9dfbc876703f0f2f2896058285b5c87a1d4a638d/contourpy-1.4.0-cp314-cp314-win_amd64.whl", hash = "sha256:181bea01bc742734ae672fa00c717d855dd35e1f029536406538c52e7b0cd73d", size = 240101, upload-time = "2026-09-11T19:04:12.772Z" }, + { url = "https://files.pythonhosted.org/packages/66/01/ee6830a5aa4565662a345172f6f35eeeed625d20f1c9d4ecd35318fe4ade/contourpy-1.4.0-cp314-cp314-win_arm64.whl", hash = "sha256:64039341e2d8804f1a13bda8c69083eab935167bbd7e856cf096241f17d5bd45", size = 576359, upload-time = "2026-09-11T19:04:14.983Z" }, + { url = "https://files.pythonhosted.org/packages/51/af/49ee9c9cf012699e505c1b63c531cc99f19df50f205173092c4d541e3ec7/contourpy-1.4.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:ef47fef9a912c77e3d84b014f701e5a9340f25703e9ed3bcebe37f91fb69dc49", size = 313601, upload-time = "2026-09-11T19:03:51.452Z" }, + { url = "https://files.pythonhosted.org/packages/ad/59/ce411ab2be0f805038626d8f4ca9ce563487ff51ff6c363e7512271564ed/contourpy-1.4.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:96019f059bcb3774acc0104be3360a57b36d33eaaa2e1d7f77c800ca8e07618b", size = 302812, upload-time = "2026-09-11T19:03:53.022Z" }, + { url = "https://files.pythonhosted.org/packages/95/b0/390915f9af14c1e2d3b2a9ad99d85b98df4352346a51e368cbb825f813c3/contourpy-1.4.0-cp314-cp314t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ddf5a2596d716fd3793434844caf31abc7a40b1e8718431420c89858268fb909", size = 348996, upload-time = "2026-09-11T19:03:54.594Z" }, + { url = "https://files.pythonhosted.org/packages/c7/85/e0952576d54322f3e9983b1e049a7a31f42ce82c5c29d01821e6dd3780d7/contourpy-1.4.0-cp314-cp314t-manylinux_2_26_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:dd59df9e2fb0aff8bd7fd1adb9f349b7c835245a9d0f18c2f2deeb537190f2b1", size = 400272, upload-time = "2026-09-11T19:03:56.822Z" }, + { url = "https://files.pythonhosted.org/packages/d6/7d/f13543a5e1598e4a4ad01d9d5e2d65f9c09c37660616429913d606c5977d/contourpy-1.4.0-cp314-cp314t-manylinux_2_26_s390x.manylinux_2_28_s390x.whl", hash = "sha256:b7794ea07cab575633daad8d6e963b662053391022294d3aacc1d9ba9ef54114", size = 412895, upload-time = "2026-09-11T19:03:58.487Z" }, + { url = "https://files.pythonhosted.org/packages/c5/a8/6e5eaff53507dfd2dfc428240eecda32453067277d4b3e7ca71210b2d611/contourpy-1.4.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a1c8a74744fa746eeaa12f0f9ed7f8b4add9d8f1b14d95e3b5e133675eac888f", size = 377060, upload-time = "2026-09-11T19:04:00.122Z" }, + { url = "https://files.pythonhosted.org/packages/16/a3/d00e44d35511b3cead5bd794ee672d4eecf30d9de4ceac57a49d6204064f/contourpy-1.4.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:107ec46f7aa1664266d69b1181aadc953d58d39f7d8d648fa5b795d4a060b0de", size = 1345688, upload-time = "2026-09-11T19:04:02.705Z" }, + { url = "https://files.pythonhosted.org/packages/1e/01/1e533b0cae32c8edd63fe40435ec3b29345dab87321afcd28722d7f957d1/contourpy-1.4.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:5a4c89c7f38a0d7a94356d74e3391073c4325c4d47ad2fd065c3fe7dbae16c0c", size = 1416140, upload-time = "2026-09-11T19:04:04.77Z" }, + { url = "https://files.pythonhosted.org/packages/6d/0c/4ee66759f00d6a5d6909782f14f441d639fa18a4a43142e334351efc47f8/contourpy-1.4.0-cp314-cp314t-win32.whl", hash = "sha256:912c6afaa106e2f74ba22b30416b77ef7eb94e3bdc5a4df51ab147845dba9b6d", size = 371982, upload-time = "2026-09-11T19:04:06.233Z" }, + { url = "https://files.pythonhosted.org/packages/e6/ac/b3e5324138c3e3741f526663f4f265f4f69dfdf26415a39428940864a5f6/contourpy-1.4.0-cp314-cp314t-win_amd64.whl", hash = "sha256:ef9440f6f8506246269a82734f5ff9e2e4c5e775b3996fc883cc491c5257eca6", size = 262907, upload-time = "2026-09-11T19:04:07.882Z" }, + { url = "https://files.pythonhosted.org/packages/19/37/c9aa45e47819dc15a38fc5c81a2fb987fde55e9d3b991fbde514e3b6b5f5/contourpy-1.4.0-cp314-cp314t-win_arm64.whl", hash = "sha256:fc9feef8f1f001c5b87decadc67c4a5d1eebb62ca39c4763d1237ff62cf2b707", size = 587071, upload-time = "2026-09-11T19:04:09.898Z" }, +] + +[[package]] +name = "cryptography" +version = "50.0.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "cffi", marker = "platform_python_implementation != 'PyPy'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/9d/af/182eb91b0df3fe75c4d9f26fe70684569566745f6ba7e5c9c73a862c5252/cryptography-50.0.2.tar.gz", hash = "sha256:7b46165bb56eb4704e2eaaf86f3c940d19154535d9b0ca7d6d590b04060e00d5", size = 880623, upload-time = "2026-09-30T15:30:04.884Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e5/56/d194340cc4a57535e82e1bee9e89667ac4b7c13b5d3f59686deae3094dd5/cryptography-50.0.2-cp311-abi3-macosx_11_0_arm64.whl", hash = "sha256:fa8f5efb344d6908a1ce62f4a24e2e5780f825d6f53f5f50ec5ffacac72936cb", size = 3914904, upload-time = "2026-09-30T14:43:44.339Z" }, + { url = "https://files.pythonhosted.org/packages/d9/69/c9bd862c3bf43d6399c433caf002df16e2dffd4be49bdf515cda38038711/cryptography-50.0.2-cp311-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:79def8d059362e7831389ed3be0ecdf58a89386e1271e35dd9f5af84e81bffd0", size = 4731146, upload-time = "2026-09-30T14:43:47.113Z" }, + { url = "https://files.pythonhosted.org/packages/21/69/64cef1f702bf6657e0cc186ed1a2891d50d29fb41586b254e1c07adea261/cryptography-50.0.2-cp311-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:630ebfea3bf689d075f82316324ff7433dc447fe6bc1bfc76524b74b4a9567d2", size = 4719841, upload-time = "2026-09-30T14:43:49.01Z" }, + { url = "https://files.pythonhosted.org/packages/38/6b/61a3f8d8c5e1e49a6cddccafc4015cc1c0021360ab0acb4080e7a423644a/cryptography-50.0.2-cp311-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:f9f6143a8c75945eb960d9eb98905a441394abfa24afaae239d514ffb2586480", size = 4738340, upload-time = "2026-09-30T14:43:50.932Z" }, + { url = "https://files.pythonhosted.org/packages/7b/2e/7212ca32fd43dc91f2f41db20160b268098874b4c9a0e7be94d6835f5b2e/cryptography-50.0.2-cp311-abi3-manylinux_2_28_ppc64le.whl", hash = "sha256:a582ab2ae1d34f67112cadc86702774c9ea4374df6bca6afe672817203c99134", size = 5367029, upload-time = "2026-09-30T14:43:52.911Z" }, + { url = "https://files.pythonhosted.org/packages/1a/f1/b474e930c4d910328780e3940da76f5aa5cbc48ce1fc14e44d239d9ea9db/cryptography-50.0.2-cp311-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:4061c0079120205fb760c58acab6443e217307dcf05e3702cf970e0689972856", size = 4753050, upload-time = "2026-09-30T14:43:55.272Z" }, + { url = "https://files.pythonhosted.org/packages/7c/52/9af10e80ac16b0fcc2123f9cbd5e7afbd0fd5075bb7a607c592258a39cda/cryptography-50.0.2-cp311-abi3-manylinux_2_31_armv7l.whl", hash = "sha256:ac9ed99d81760c62fe89d5f0815cdfa1ba9a35141cf30f1c2d044f04b4803d2e", size = 4376724, upload-time = "2026-09-30T14:43:57.24Z" }, + { url = "https://files.pythonhosted.org/packages/71/37/6202e488cc1eb625ea110c292c6bda92823176e023f427d8d5660ce8d632/cryptography-50.0.2-cp311-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:87e9ce85beb6b328ba370cc6e6aea483c92617b4c95b1d33a49297eb662bfb04", size = 4737859, upload-time = "2026-09-30T14:43:59.541Z" }, + { url = "https://files.pythonhosted.org/packages/8f/30/e86d7d518489b0ae2497091a35287abcb1a2ce4037837a34afbe9b1d6964/cryptography-50.0.2-cp311-abi3-manylinux_2_34_ppc64le.whl", hash = "sha256:f265528741e048bce55c3463ed721fb0aa45a5888d8add8cfeccb3035451bbdc", size = 5324103, upload-time = "2026-09-30T14:44:01.901Z" }, + { url = "https://files.pythonhosted.org/packages/d3/69/2c833a049475e0a3444e94c7d0aca0aa51d166374a449b09e92ac98138de/cryptography-50.0.2-cp311-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:9dab55f57c74c3cad24c323bacbbd04be4705ba6eb0d92e920b1fc4837ed5079", size = 4752576, upload-time = "2026-09-30T14:44:04.545Z" }, + { url = "https://files.pythonhosted.org/packages/6c/5d/906970b83bbfc1f5bbfb677a143c181f2801f23b6a7204a3b47c42c97e65/cryptography-50.0.2-cp311-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:25784ce8b9621c90c643efb9e1e2162ab3b0224cae446ad5e70e7fcb1ce18b51", size = 4870819, upload-time = "2026-09-30T14:44:06.884Z" }, + { url = "https://files.pythonhosted.org/packages/68/e3/f2298d3bb55e0c4a91841ec4d01b3f020ba8c5fbf15ccdcc6dcf03f97025/cryptography-50.0.2-cp311-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:85d0d9a31b9098e98534226d5686b47264b95e62ce459dc2e62fdfc809f9fe93", size = 5030152, upload-time = "2026-09-30T14:44:09.443Z" }, + { url = "https://files.pythonhosted.org/packages/9a/4f/adfc442765721292fff86d314ce385d3249d22db42295c0dd057727b60f3/cryptography-50.0.2-cp311-abi3-win_amd64.whl", hash = "sha256:7afa5a6602a9f29af1f3a2965f831bae7c9d5d597b7cbb716d41ab3b7d89879c", size = 3824692, upload-time = "2026-09-30T14:44:11.671Z" }, + { url = "https://files.pythonhosted.org/packages/ce/cb/52eb3770c0d0be2702a98c6e96065ddc0a2877cf0845aa9c23397c142cd4/cryptography-50.0.2-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:f785f6161f202ab04d8ca194158968798e480ca058943907972da5f12e2881e8", size = 3892731, upload-time = "2026-09-30T14:44:13.485Z" }, + { url = "https://files.pythonhosted.org/packages/19/8e/aa1fc533d4546b127b45de8aa024eb5933d23eff9debfe25931e56861095/cryptography-50.0.2-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:0ecbc5652bdb6fc9eaf89a7d196e20941adfe812f43bc4ca05d9150496821047", size = 4710431, upload-time = "2026-09-30T14:44:15.427Z" }, + { url = "https://files.pythonhosted.org/packages/6a/64/72bc3f75176e7e406b748a3e3830432b8c51297b38368713df04dc04898a/cryptography-50.0.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:ab50ee449bf968271e820086f10a33d101dd060370abc10bcd22279be2656539", size = 4694824, upload-time = "2026-09-30T14:44:17.69Z" }, + { url = "https://files.pythonhosted.org/packages/4e/c6/62c77550edfa5ca3f14bf44a1e6739b9fa09d6e998a11d97ed8213bccc98/cryptography-50.0.2-cp314-cp314t-manylinux_2_28_aarch64.whl", hash = "sha256:a9f7355e6fab51f6c369b86fb7571cffa05edee2c2121e0380a37fb9ac1cd5c1", size = 4716967, upload-time = "2026-09-30T14:44:19.661Z" }, + { url = "https://files.pythonhosted.org/packages/f4/37/cce70f150c432914460157a6ecc161752e053aa5ec0ef3b3f7dc6e31039a/cryptography-50.0.2-cp314-cp314t-manylinux_2_28_ppc64le.whl", hash = "sha256:94e5e9f108ee10471288214d3d233fbfbb492840a8457eb85178d643ddeb32c7", size = 5328676, upload-time = "2026-09-30T14:44:21.744Z" }, + { url = "https://files.pythonhosted.org/packages/aa/9a/6f2f0304d634ceafdeaf23e84537336664ac419b5d07611675c2ad3f6b7a/cryptography-50.0.2-cp314-cp314t-manylinux_2_28_x86_64.whl", hash = "sha256:241449bf940a5d27309bd317e6f9a2af6932113818bb2b8f5c59ddc7ef16da18", size = 4727698, upload-time = "2026-09-30T14:44:24.178Z" }, + { url = "https://files.pythonhosted.org/packages/1d/de/66bcf9244d118663b2e1aaded8990f4640e3d7b7411870a5765f252074d2/cryptography-50.0.2-cp314-cp314t-manylinux_2_31_armv7l.whl", hash = "sha256:d8947001be83df1394050758ce0e745dd74fb134eef0a4b5124208dfc3a68c37", size = 4354821, upload-time = "2026-09-30T14:44:26.263Z" }, + { url = "https://files.pythonhosted.org/packages/bd/e6/db28a28c7b6c676addce89136de3d8db49ea825a8c863472e36e42ead4ad/cryptography-50.0.2-cp314-cp314t-manylinux_2_34_aarch64.whl", hash = "sha256:4a20ce1e5cb4284a86692fdcba7cb8754185c6b2e5c56fcef3751cf451d3cdc2", size = 4716748, upload-time = "2026-09-30T14:44:28.447Z" }, + { url = "https://files.pythonhosted.org/packages/30/96/01546c7f69ea0e2ab790a2e4f0934a4052fb9b388147fbf83c2fd72f1e57/cryptography-50.0.2-cp314-cp314t-manylinux_2_34_ppc64le.whl", hash = "sha256:84f964e537f916e2cc85199e5a88742e964939b575ac8598b3f9d6cc416cdaf1", size = 5285085, upload-time = "2026-09-30T14:44:30.704Z" }, + { url = "https://files.pythonhosted.org/packages/6c/01/03263395f74d50b071e9e66daace3f8bef80493e5d410726f2ba8554736b/cryptography-50.0.2-cp314-cp314t-manylinux_2_34_x86_64.whl", hash = "sha256:828d49b0ff5a0e3975865571c5d91dbbdd0d38d8289b249a163e9425413a5e05", size = 4727268, upload-time = "2026-09-30T14:44:32.92Z" }, + { url = "https://files.pythonhosted.org/packages/eb/94/2bfe8f29ec0cc9c0d99359c4161adf32858e4934b72c6d100d2ac0bbe962/cryptography-50.0.2-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:deb9fde5c60e437ee4821bc9bc39ff31b42135c27e1dc61ef0a629389c1de62e", size = 4849503, upload-time = "2026-09-30T14:44:34.969Z" }, + { url = "https://files.pythonhosted.org/packages/54/44/e80651ecbf0e42b62e2bb5f5768916e07eea72e1297338956a61df361f88/cryptography-50.0.2-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:8c71ba2cd31fc93748c38e1b613200ff1c2665cbfd5341fe3a61cfde35a1430e", size = 5004057, upload-time = "2026-09-30T14:44:37.064Z" }, + { url = "https://files.pythonhosted.org/packages/f8/cc/1d33befb3cd7ea7e77d2d73f43f2066471da1b21f24a6156efcaabf6d2e8/cryptography-50.0.2-cp314-cp314t-win_amd64.whl", hash = "sha256:78198641e5be9521beea5aa782bb551a58068d10e6eb04c9c680c1b69f2e7d45", size = 3795868, upload-time = "2026-09-30T14:44:39.71Z" }, + { url = "https://files.pythonhosted.org/packages/2d/49/93f6a6e7a87c9aa68d44d3e1cdb5fe8f60c90d5d2f46acae9a56892816b8/cryptography-50.0.2-cp315-abi3.abi3t-macosx_11_0_arm64.whl", hash = "sha256:edc3342adf8f697fc5f59c887a304356f147b397809440ed64e2fa6af2f50f37", size = 4133708, upload-time = "2026-09-30T14:44:41.807Z" }, + { url = "https://files.pythonhosted.org/packages/8c/75/32ac2a56243d778805c16ca6a32b8f74fb757df7e28d7ecb560afafb59cf/cryptography-50.0.2-cp315-abi3.abi3t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:d370b8d1dfcdf7130178137f6fbee6140774a1acc6cacefc4b42643ec11d0a3a", size = 4956267, upload-time = "2026-09-30T14:44:43.693Z" }, + { url = "https://files.pythonhosted.org/packages/aa/a4/2c8d734e43d97f0842ee9f1b7b4bfb3d0cf5e19edebf43c2afe6675c2320/cryptography-50.0.2-cp315-abi3.abi3t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:f2f9bd7f90c64fe89253f0a2c05e3c4856072660429ce8831b4235bf29403a67", size = 4966465, upload-time = "2026-09-30T14:44:45.769Z" }, + { url = "https://files.pythonhosted.org/packages/c2/58/ee288c829a6f41f6235ae9dd33d82fd19b45442b65b4c8a3da36963d9f7a/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_28_aarch64.whl", hash = "sha256:e275096ea1e60cc595cda2836fd4a6c725d1125108b868be17f53684d164e2cc", size = 4959356, upload-time = "2026-09-30T14:44:48.211Z" }, + { url = "https://files.pythonhosted.org/packages/92/20/9ded6d51ddd9897f6b6e81fb9ebea7951d7cc5d6c890b0ed8abf77a51a80/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_28_ppc64le.whl", hash = "sha256:b13478603dcd0a2479ff8e87e2c19a7d525734686fe3c49542472293a204212d", size = 5548822, upload-time = "2026-09-30T14:44:50.86Z" }, + { url = "https://files.pythonhosted.org/packages/02/a8/8df951850d6b31d2a00218f19e2b3f999523437ed7a819df7fa427942fca/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_28_x86_64.whl", hash = "sha256:58a0c478eeca76fe5e07993c5a0703def34a6dc6a0cda4f5564639b33112ffe7", size = 5001199, upload-time = "2026-09-30T14:44:53.379Z" }, + { url = "https://files.pythonhosted.org/packages/8b/f9/36b3022218ce75b7cdf068fb95f809f9bd0d820e4955ef43b90c255cc7ac/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_31_armv7l.whl", hash = "sha256:d38cdff612d06fa6a32840d5e1b1f7a27cee4a349aa9085d94a67789d6bfd408", size = 4629333, upload-time = "2026-09-30T14:44:55.635Z" }, + { url = "https://files.pythonhosted.org/packages/8c/72/20f99a219f6af47cdd1cbd978c243b92d71496e168a746138af44ded4f29/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_34_aarch64.whl", hash = "sha256:fdd28f912fccfec1846a94e2e1e8f9b0012f557f0c46fe4f3eb0d7a87afcf90b", size = 4958822, upload-time = "2026-09-30T14:44:59.639Z" }, + { url = "https://files.pythonhosted.org/packages/f2/20/196f112617fb08eb4d608a2a6c422373d46f9cc2857f38fc0667033c0899/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_34_ppc64le.whl", hash = "sha256:cbc8738fd8526d80f35cb3a40d41f41a2e7030bb3b18b09a6778ef63d291c2fd", size = 5506351, upload-time = "2026-09-30T14:45:02.267Z" }, + { url = "https://files.pythonhosted.org/packages/24/95/83378121ef3eaaaf71d4b781577ff794acb39b9e1b87a3f156898c8497ed/cryptography-50.0.2-cp315-abi3.abi3t-manylinux_2_34_x86_64.whl", hash = "sha256:e105ab60406787da31fccc883fc0f733af1efd78f0136a4599692c4083a73d0c", size = 5000859, upload-time = "2026-09-30T14:45:05.009Z" }, + { url = "https://files.pythonhosted.org/packages/22/f7/70fd7ae4d1dbfa7ba29b02e1b9068771519a86027756510b700ce81086a8/cryptography-50.0.2-cp315-abi3.abi3t-musllinux_1_2_aarch64.whl", hash = "sha256:6f8700550aa1474a91e5dc07049c46f98b423b5b1ddd0483e0b51362eeeaf5be", size = 5092151, upload-time = "2026-09-30T15:29:15.932Z" }, + { url = "https://files.pythonhosted.org/packages/d4/be/688367b74de86984bd58d8efacfc7c9e68b89a6a22ced0fb4f38db50254a/cryptography-50.0.2-cp315-abi3.abi3t-musllinux_1_2_x86_64.whl", hash = "sha256:c71be1cbfa5cd9a41ee452acf1eccd82b2c05950358b106ec8ceb83411d1a020", size = 5286120, upload-time = "2026-09-30T15:29:18.309Z" }, + { url = "https://files.pythonhosted.org/packages/39/d1/55f8a3f2ef5d1529e16835ef10cf0fe3d559ce237b46dddc440c0bba3649/cryptography-50.0.2-cp315-abi3.abi3t-win_amd64.whl", hash = "sha256:c423ab384a46c4dff7217b2ea5ba2e11cffdeab6441acd04cf65a369caf0366c", size = 4111557, upload-time = "2026-09-30T15:29:20.155Z" }, + { url = "https://files.pythonhosted.org/packages/23/ad/ac987755d00e1e64273760228d2635ae38dae2be83e3c6e0d3289d91dec3/cryptography-50.0.2-cp39-abi3-macosx_11_0_arm64.whl", hash = "sha256:0ec5f09541743261e66e291b4a0cbf0fb2997aeaab6d9e9c740b9dba1b58d1c2", size = 3943588, upload-time = "2026-09-30T15:29:22.265Z" }, + { url = "https://files.pythonhosted.org/packages/d5/8d/6d585339bedf85d45044c85d8412dac53f2bb6f918e8b7777efba1787844/cryptography-50.0.2-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:c5e67125c7dca78d199ec4e116aa93dbb83494808ecbb8211a2cb09b1bf41dbd", size = 4756166, upload-time = "2026-09-30T15:29:24.58Z" }, + { url = "https://files.pythonhosted.org/packages/bf/f1/1c1f6874e8550cfddd4b688ceb38cefb6ed15ceed224d56f133f3d88c214/cryptography-50.0.2-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:ee247f5c245c9a2fe7c8e2214e295918838e44e00a45a6718451e4004219e767", size = 4749145, upload-time = "2026-09-30T15:29:26.807Z" }, + { url = "https://files.pythonhosted.org/packages/c1/63/61b15dc1a8de03fe0adbe3fd7608b3ad5c73bf50993bbcb1faaa930afe33/cryptography-50.0.2-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:dfe9763530994147d9af1def057a5b9658b00e8f8fe8743d144d1e0911c2e454", size = 4763638, upload-time = "2026-09-30T15:29:28.588Z" }, + { url = "https://files.pythonhosted.org/packages/fc/35/b345bdfa40c9126df1a9d33236aa98418367931b8725f84fc3ae2b98dc59/cryptography-50.0.2-cp39-abi3-manylinux_2_28_ppc64le.whl", hash = "sha256:58ddb5a8e3179d12f19e4ea34d2d32e9d63a4baa142c875c1eb59f41b7243acd", size = 5382217, upload-time = "2026-09-30T15:29:30.589Z" }, + { url = "https://files.pythonhosted.org/packages/4f/87/ef344a9e616871f2519c22d6afcda79ddd5d35e9592d95eb6e677608d055/cryptography-50.0.2-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:f21e8a22c8605750c7af886bab299a363721264061b4ac0a30efb73cfd58efc5", size = 4781387, upload-time = "2026-09-30T15:29:32.605Z" }, + { url = "https://files.pythonhosted.org/packages/90/5b/f2fdb13cd0b96f6f932c8627bb292a45f11c64d21620a8e120aee9a3b848/cryptography-50.0.2-cp39-abi3-manylinux_2_31_armv7l.whl", hash = "sha256:9c8402a82ea0dc4ceeab793db05f0fafa8ca139ca34fcde5df0f596103c74107", size = 4403790, upload-time = "2026-09-30T15:29:34.374Z" }, + { url = "https://files.pythonhosted.org/packages/bc/ce/7e4f662b1e3c393513569e402cfc85ac7da0bd3d5435e122a3140219eb2d/cryptography-50.0.2-cp39-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:0ddc924c04591c2811ca024d62ecad4f7f6f08af8939c211438f48a16bd23602", size = 4764319, upload-time = "2026-09-30T15:29:36.149Z" }, + { url = "https://files.pythonhosted.org/packages/3c/3f/86ff33ce34cc0de6847fb96e035a1a760d81652e38643f617c02ad32ef7a/cryptography-50.0.2-cp39-abi3-manylinux_2_34_ppc64le.whl", hash = "sha256:a6557e5f38e065ca9fbdaf7cfc7435ecb1d113aa81a022d1b51921ee7432e227", size = 5338560, upload-time = "2026-09-30T15:29:39.053Z" }, + { url = "https://files.pythonhosted.org/packages/40/cf/6b5c8e2fd9202d98988ab7cb5cc5c991704c4ad55f492ff408e4969f83f1/cryptography-50.0.2-cp39-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:1981f1db4630889b9ef7803fadef12b056f428cb6b85c27ba57b774793b6093c", size = 4780973, upload-time = "2026-09-30T15:29:41.251Z" }, + { url = "https://files.pythonhosted.org/packages/10/bf/8d6ebc7dded797bd0f0160d52188021211f011a2b164ef0ae1dac4587465/cryptography-50.0.2-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:7a8701d6b584d76e909e3d305b7d126b41439876a5aaf76cddc67fc230eafa2e", size = 4897738, upload-time = "2026-09-30T15:29:43.106Z" }, + { url = "https://files.pythonhosted.org/packages/d4/aa/f3f6e0de7e6253b8baa8b2d8fb9d50924fa75cee3d4624bd4bc1208ee923/cryptography-50.0.2-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:ce47f66801c20ec6c6632453bb5960fe38939e9306970b48b3a5a26de7745d94", size = 5058280, upload-time = "2026-09-30T15:29:44.827Z" }, + { url = "https://files.pythonhosted.org/packages/f6/b6/a1faf3a27ae9405fb34b1713cc73b2d8a26b04d5c561578fa2e6ef3e5bb9/cryptography-50.0.2-cp39-abi3-win_amd64.whl", hash = "sha256:4e81d95e5bafc2d6e34e4bed780e53e4d5b9a2f928573428aa4d35fbec1eb0de", size = 3854095, upload-time = "2026-09-30T15:29:46.782Z" }, +] + +[[package]] +name = "cycler" +version = "0.12.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a9/95/a3dbbb5028f35eafb79008e7522a75244477d2838f38cbb722248dabc2a8/cycler-0.12.1.tar.gz", hash = "sha256:88bb128f02ba341da8ef447245a9e138fae777f6a23943da4540077d3601eb1c", size = 7615, upload-time = "2023-10-07T05:32:18.335Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e7/05/c19819d5e3d95294a6f5947fb9b9629efb316b96de511b418c53d245aae6/cycler-0.12.1-py3-none-any.whl", hash = "sha256:85cef7cff222d8644161529808465972e51340599459b8ac3ccbac5a854e0d30", size = 8321, upload-time = "2023-10-07T05:32:16.783Z" }, +] + +[[package]] +name = "cyclonedx-python-lib" +version = "11.12.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "license-expression" }, + { name = "packageurl-python" }, + { name = "py-serializable" }, + { name = "sortedcontainers" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/17/40/6509e6cfd7f2f3255501690f46375fdd224949e21fd1e96f4f4c8a9041b1/cyclonedx_python_lib-11.12.0.tar.gz", hash = "sha256:16767c4039de90c04e9f03348f8f0ed4b8ff842eaa7eefcad3a95685f970dacf", size = 1445378, upload-time = "2026-08-13T07:52:18.675Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cf/f0/b2cb999244f2f4194df63ecff6939228178fa63a33be809c412684ca8db7/cyclonedx_python_lib-11.12.0-py3-none-any.whl", hash = "sha256:0e807521a921a5c3cb8ce1153f8a61d29eedfe76a46aac2796b7c6b573391a54", size = 529453, upload-time = "2026-08-13T07:52:16.836Z" }, +] + +[[package]] +name = "defusedxml" +version = "0.7.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/0f/d5/c66da9b79e5bdb124974bfe172b4daf3c984ebd9c2a06e2b8a4dc7331c72/defusedxml-0.7.1.tar.gz", hash = "sha256:1bb3032db185915b62d7c6209c5a8792be6a32ab2fedacc84e01b52c51aa3e69", size = 75520, upload-time = "2021-03-08T10:59:26.269Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/07/6c/aa3f2f849e01cb6a001cd8554a88d4c77c5c1a31c95bdf1cf9301e6d9ef4/defusedxml-0.7.1-py2.py3-none-any.whl", hash = "sha256:a352e7e428770286cc899e2542b6cdaedb2b4953ff269a210103ec58f6198a61", size = 25604, upload-time = "2021-03-08T10:59:24.45Z" }, +] + +[[package]] +name = "fastapi" +version = "0.143.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "annotated-doc" }, + { name = "opentelemetry-api" }, + { name = "pydantic" }, + { name = "starlette" }, + { name = "typing-extensions" }, + { name = "typing-inspection" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/38/d5/b0aeb0b303650ac87b0411de4aaf3f901b06042dcc3fb00f30b97b7ff585/fastapi-0.143.3.tar.gz", hash = "sha256:b9ab567ee57afb4454004ce04c889f8f0160ac47946b99795887cd6e88484848", size = 469834, upload-time = "2026-10-16T14:14:13.31Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2c/1a/03d246befcf307219bb2161c97d8c5d314f84125bf7dd245730a28589828/fastapi-0.143.3-py3-none-any.whl", hash = "sha256:75e8bd68e2f52f77d29b2879749c257d64de2d85282d25270caf2bfccce5efe5", size = 144849, upload-time = "2026-10-16T14:14:11.763Z" }, +] + +[[package]] +name = "filelock" +version = "4.2.12" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/52/aa/8ccff8da9a27e089727fcffd3c5b61708383217e47eb1e1b8af37b1dd166/filelock-4.2.12.tar.gz", hash = "sha256:7e7da24d3ac39268b0f156e56870001de44886318f092f9d851e692f7114d6dd", size = 680837, upload-time = "2026-11-18T01:20:03.951Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8a/c9/eb6b6528c7edb958d4c24ac47a8b94113d9de36e4cfc6eecd599b1a4f349/filelock-4.2.12-py3-none-any.whl", hash = "sha256:21decfec02f116ed4c954433cdb31f28c3b346b784543177b6d7059da2702ee9", size = 222442, upload-time = "2026-11-18T01:20:02.439Z" }, +] + +[[package]] +name = "fonttools" +version = "4.68.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/0c/b5/672312ae80ce8b8eb9779c56052a24c8f36652aa7293a1a420553bcf03e5/fonttools-4.68.0.tar.gz", hash = "sha256:73294e233070f71e2b3653b6bd8564af676d57f26d075761fb06d1ab2e4a7a5d", size = 3848583, upload-time = "2026-10-27T16:30:26.451Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1a/70/ee6655887166a111d0c4d7ca61f03c90b141cdc6f70c85138fd0b8bfa2e3/fonttools-4.68.0-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:b2ee7b9c1a5e1d637073c39b0978956febad7e862a1269719f527934c65535a4", size = 3145377, upload-time = "2026-10-27T16:29:03.757Z" }, + { url = "https://files.pythonhosted.org/packages/d6/37/66e7ab417660cb2c65889eb5ad8d80cc5a7cb2c09dd1becdbe6d56bac4fe/fonttools-4.68.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:9d80813ae74b969ef2166a3040b591826e80ecd879bdeab7f13f4e8eaf08b345", size = 2634889, upload-time = "2026-10-27T16:29:05.651Z" }, + { url = "https://files.pythonhosted.org/packages/0c/ad/da985167af1988b82112cf133e826cf075cecb28d120778589265cb3125d/fonttools-4.68.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a6837def5de49772b82683dadd836df214def04b307cb98d0e7723d49e7e15bb", size = 5420416, upload-time = "2026-10-27T16:29:07.502Z" }, + { url = "https://files.pythonhosted.org/packages/b7/67/e9f2eb2aed41d4ed251a3c6f66e104685f0a03d8ded7ed87f1f0fc63898c/fonttools-4.68.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:cbb63b26d33acc3eb61f544c22a0cadbe01682fc064b266bb0e33fa66cea853f", size = 5363969, upload-time = "2026-10-27T16:29:10.172Z" }, + { url = "https://files.pythonhosted.org/packages/e6/06/c4510ac6b43b374b1b707b99fdd0ba1d4059d2fb516584a412c0396fedef/fonttools-4.68.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:81ea963d4390bb9e79f91a905310d91ac7ff7675d8e1c0cfc0f1712521c41a43", size = 5362373, upload-time = "2026-10-27T16:29:12.298Z" }, + { url = "https://files.pythonhosted.org/packages/e0/ef/ea0bf283a30a88a84a47078ff39f7bdefa0346a8bd7737439fd33084031f/fonttools-4.68.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:3b9b87645bcdbfc3f30240e2758a37bbef4fdd0f708683b2bfceb60975d63e59", size = 5495553, upload-time = "2026-10-27T16:29:14.614Z" }, + { url = "https://files.pythonhosted.org/packages/95/c0/d493f8c8974859e57920ce193ffbe277423da7eebccbb9241bc31e1b5f1d/fonttools-4.68.0-cp314-cp314-win32.whl", hash = "sha256:39913c1f576af86c69519dc351302332561ee62b39fed04dcfa8019d9c2d129f", size = 2484057, upload-time = "2026-10-27T16:29:16.45Z" }, + { url = "https://files.pythonhosted.org/packages/96/41/c9ca629ffe1b883c1422540a8a11a4ea09616366ab585ab4ee9833f2cd75/fonttools-4.68.0-cp314-cp314-win_amd64.whl", hash = "sha256:1782f2cf952eb262c4126b1f57b5f0e027e71bf2b632350a033dec526f448428", size = 2536130, upload-time = "2026-10-27T16:29:18.399Z" }, + { url = "https://files.pythonhosted.org/packages/17/40/f6264c988076393db3e0b00d6d0ea2a53ce40d445e8a196be241d16d362c/fonttools-4.68.0-cp314-cp314-win_arm64.whl", hash = "sha256:f0b39924698a85bee107184a3c2ee9ae27248144977160534f7d558831db50cf", size = 2508386, upload-time = "2026-10-27T16:29:20.318Z" }, + { url = "https://files.pythonhosted.org/packages/c5/d8/a4d710362f3f23aecc16015eeed1d602187189af7f63a63546233ad2fa73/fonttools-4.68.0-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:956230858b7a7bb9f5e0971ae07dc64b6155307304acd8c62aedca30e6aae874", size = 3219047, upload-time = "2026-10-27T16:29:22.337Z" }, + { url = "https://files.pythonhosted.org/packages/4d/4d/0d516a1d3d34e84c56237ba1d8dfed8575c350b0e8d39aa30b518d089daf/fonttools-4.68.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:b637d82a488116da2869afbddccfd93ca14e3c47b404c8ec5a9bad9d4381b08c", size = 2668060, upload-time = "2026-10-27T16:29:24.536Z" }, + { url = "https://files.pythonhosted.org/packages/4d/40/56893c685cb1ee7d7ee30d0ac94adf92020787cf5a8e15c2e4e6944f0bec/fonttools-4.68.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:419bf78474adaa6fb320a06822f4f941b19345d598a9de379d6e2f0e4d819df6", size = 5593080, upload-time = "2026-10-27T16:29:26.51Z" }, + { url = "https://files.pythonhosted.org/packages/41/b6/bc0bbad6f1aef22519c4e731c6dc8655e92c6f7204277ec36502ea7e76cd/fonttools-4.68.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:fe80d05dd85e6ac58d0cd4fa10ddb96252a6f1046ee0fd00cd1d48f0c25921ac", size = 5399669, upload-time = "2026-10-27T16:29:28.969Z" }, + { url = "https://files.pythonhosted.org/packages/c1/b4/4404a91dc699dd430732d366996cef6d8c8f61c758b5e544a76903db580a/fonttools-4.68.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:cea1969b9bfe230cb3fd66f1c66da5a63a9a917d9cd25a0839524d3d1a88b40e", size = 5460446, upload-time = "2026-10-27T16:29:31.15Z" }, + { url = "https://files.pythonhosted.org/packages/56/09/66876a0d1a01f7c16eb9f7c8ebcf064ebbd6b249f837691cb5a35780316a/fonttools-4.68.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:fde43b9785c7f105aa563b6b5481edabea4ab6be7d9ef14ff4d76225950923e8", size = 5495792, upload-time = "2026-10-27T16:29:33.455Z" }, + { url = "https://files.pythonhosted.org/packages/15/7d/1d702dc628e6f5b0d63be906025afc5e5b487cee48128943bb0a71d2bcb3/fonttools-4.68.0-cp314-cp314t-win32.whl", hash = "sha256:a325e6d7f96f20b3004658c5ed17ccfce5b66277b43ccd883035c61be6945275", size = 2517805, upload-time = "2026-10-27T16:29:36.929Z" }, + { url = "https://files.pythonhosted.org/packages/f3/42/8fa0741e08ae16be66a0d2e6d67f918fa0f2961bad70ccef84f9af0767cc/fonttools-4.68.0-cp314-cp314t-win_amd64.whl", hash = "sha256:e80ac66627a01698675ce6e98d90ea9817d1e06644129ec8b0093f66ff1cbeac", size = 2567666, upload-time = "2026-10-27T16:29:40.081Z" }, + { url = "https://files.pythonhosted.org/packages/13/2f/b73cf496570e8d2c66a6099f825505283ef8e944bd588e0b63036d6b2412/fonttools-4.68.0-cp314-cp314t-win_arm64.whl", hash = "sha256:83bd3d558c15f4e1d87b8f3fcfb337c2bce63c7e5c05212abc8fdcf15e216c54", size = 2532338, upload-time = "2026-10-27T16:29:42.073Z" }, + { url = "https://files.pythonhosted.org/packages/35/74/4ea331ecc65ba05a58b1e4e8ccd604c8a15565f876dfbf93fc2a2ea2e22b/fonttools-4.68.0-py3-none-any.whl", hash = "sha256:d76f8fdcb6936f5e1045a0c9dd721a4bf11112e60d1e243bfa1d39f06a8b3104", size = 1248357, upload-time = "2026-10-27T16:30:24.389Z" }, +] + +[[package]] +name = "googleapis-common-protos" +version = "1.76.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "protobuf" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/62/b6/bc095b23a3e0d978e75c8c18cabe4c11f791837410670e4486f0d539bfba/googleapis_common_protos-1.76.0.tar.gz", hash = "sha256:71db0e44a1d4c2dd024ebad44ca67129cc1e2892e4861df466764749d5ef8642", size = 156250, upload-time = "2026-10-22T23:43:36.263Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/05/6d/78dc67a9e779e594b49bf62604034d3a6aa428a55afc729cafda4b7333e1/googleapis_common_protos-1.76.0-py3-none-any.whl", hash = "sha256:59e13344a9f3651aa201a03e2bee815a3bf43a4baf1f9ff8a9b62a840ce25fac", size = 307707, upload-time = "2026-10-22T23:43:10.445Z" }, +] + +[[package]] +name = "h11" +version = "0.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" }, +] + +[[package]] +name = "httpcore" +version = "1.0.9" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "certifi" }, + { name = "h11" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/06/94/82699a10bca87a5556c9c59b5963f2d039dbd239f25bc2a63907a05a14cb/httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8", size = 85484, upload-time = "2025-04-24T22:06:22.219Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", size = 78784, upload-time = "2025-04-24T22:06:20.566Z" }, +] + +[[package]] +name = "httpx" +version = "0.28.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "certifi" }, + { name = "httpcore" }, + { name = "idna" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b1/df/48c586a5fe32a0f01324ee087459e112ebb7224f646c0b5023f5e79e9956/httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc", size = 141406, upload-time = "2024-12-06T15:37:23.222Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517, upload-time = "2024-12-06T15:37:21.509Z" }, +] + +[[package]] +name = "idna" +version = "3.20" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f5/08/8eea9d4b8302028f3abb2c0813953f7aec26d33b7a8960ed760e65ff29fa/idna-3.20.tar.gz", hash = "sha256:a7db850025b95ded1eae8a46181a1a6c56c92c96f0e2b005d9ff8dc0210cab44", size = 216463, upload-time = "2026-09-17T14:11:04.752Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/58/a2/bb081bab032533a855d44de1d56f8e8426114ff1ba5d1f07a438a0a654f8/idna-3.20-py3-none-any.whl", hash = "sha256:ab7ae7122974553370f0bdb919e1a960b2cd1bc1ef0276416d896db81c14582c", size = 69583, upload-time = "2026-09-17T14:11:03.168Z" }, +] + +[[package]] +name = "iniconfig" +version = "2.3.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/01/e1/2069291243c926a2ff1cd706c7f3eeb9b62144bf60f77c9fb9ff2fb26bd3/iniconfig-2.3.1.tar.gz", hash = "sha256:67f4b9c50da0dedf52af349e7749a80a9057a5031199791b906c3bb3ae878960", size = 21209, upload-time = "2026-10-06T22:48:38.076Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/56/43/4ca9e49d27a1fcf6bece6f6aec0ea46bb9112489b93d4b688fb415457bdb/iniconfig-2.3.1-py3-none-any.whl", hash = "sha256:9121e2c1fdb355232495be3194c8dfe87ccc2d5dee45947b78e68f499790d7a7", size = 7552, upload-time = "2026-10-06T22:48:36.959Z" }, +] + +[[package]] +name = "jsonschema" +version = "4.26.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "attrs" }, + { name = "jsonschema-specifications" }, + { name = "referencing" }, + { name = "rpds-py" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b3/fc/e067678238fa451312d4c62bf6e6cf5ec56375422aee02f9cb5f909b3047/jsonschema-4.26.0.tar.gz", hash = "sha256:0c26707e2efad8aa1bfc5b7ce170f3fccc2e4918ff85989ba9ffa9facb2be326", size = 366583, upload-time = "2026-01-07T13:41:07.246Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/69/90/f63fb5873511e014207a475e2bb4e8b2e570d655b00ac19a9a0ca0a385ee/jsonschema-4.26.0-py3-none-any.whl", hash = "sha256:d489f15263b8d200f8387e64b4c3a75f06629559fb73deb8fdfb525f2dab50ce", size = 90630, upload-time = "2026-01-07T13:41:05.306Z" }, +] + +[[package]] +name = "jsonschema-path" +version = "0.3.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pathable" }, + { name = "pyyaml" }, + { name = "referencing" }, + { name = "requests" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/6e/45/41ebc679c2a4fced6a722f624c18d658dee42612b83ea24c1caf7c0eb3a8/jsonschema_path-0.3.4.tar.gz", hash = "sha256:8365356039f16cc65fddffafda5f58766e34bebab7d6d105616ab52bc4297001", size = 11159, upload-time = "2025-01-24T14:33:16.547Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cb/58/3485da8cb93d2f393bce453adeef16896751f14ba3e2024bc21dc9597646/jsonschema_path-0.3.4-py3-none-any.whl", hash = "sha256:f502191fdc2b22050f9a81c9237be9d27145b9001c55842bece5e94e382e52f8", size = 14810, upload-time = "2025-01-24T14:33:14.652Z" }, +] + +[[package]] +name = "jsonschema-specifications" +version = "2025.9.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "referencing" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/19/74/a633ee74eb36c44aa6d1095e7cc5569bebf04342ee146178e2d36600708b/jsonschema_specifications-2025.9.1.tar.gz", hash = "sha256:b540987f239e745613c7a9176f3edb72b832a4ac465cf02712288397832b5e8d", size = 32855, upload-time = "2025-09-08T01:34:59.186Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/41/45/1a4ed80516f02155c51f51e8cedb3c1902296743db0bbc66608a0db2814f/jsonschema_specifications-2025.9.1-py3-none-any.whl", hash = "sha256:98802fee3a11ee76ecaca44429fda8a41bff98b00a0f2838151b113f210cc6fe", size = 18437, upload-time = "2025-09-08T01:34:57.871Z" }, +] + +[[package]] +name = "kiwisolver" +version = "1.5.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ba/07/bd78e6a8fae171ea041ef5bba3ed21a003522fa088834b069b1909981f30/kiwisolver-1.5.1.tar.gz", hash = "sha256:f1303ef2eec81262a4b708c3e858afe58d7c75ad91c1c05266eda7673369859a", size = 104395, upload-time = "2026-08-28T10:28:27.153Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/dd/87/2d5dfad0daf17dcc18d98c48ed2332fc3f051cf599e60be6182a30dd4cf1/kiwisolver-1.5.1-cp314-cp314-ios_13_0_arm64_iphoneos.whl", hash = "sha256:0324cd2567259b7a095f6cf18a52b0ffc6f3de9e69528ff1bc0e7a37bd43ff1a", size = 62337, upload-time = "2026-08-28T10:26:18.778Z" }, + { url = "https://files.pythonhosted.org/packages/08/c8/83e1624f15d6262b470dbcc80b09979fd4d5b2ea3ddfc6b6e3327e235726/kiwisolver-1.5.1-cp314-cp314-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:74ea337e0ec3f6f342a36a4f1b5cd94dd9affddcd28ba9aae2905af932ee8c6b", size = 64513, upload-time = "2026-08-28T10:26:19.909Z" }, + { url = "https://files.pythonhosted.org/packages/c9/2d/827ec30eb07f528c08d8459ffb318ae91a56d793ee8acbea8b491f0ff906/kiwisolver-1.5.1-cp314-cp314-ios_13_0_x86_64_iphonesimulator.whl", hash = "sha256:ee9df1f0d77b9c6e94f4ac0fec533fbddd5ea3a327807f18d7b069ae019ded80", size = 66287, upload-time = "2026-08-28T10:26:21.078Z" }, + { url = "https://files.pythonhosted.org/packages/53/11/5c43a562529dad8def4b81e5e1877c612a7e0298105a5939b3b409d2079c/kiwisolver-1.5.1-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:fc271a6f0a2126958f4090e5507b9da5848927dae331f8f763bd4aa642b3d2cd", size = 123940, upload-time = "2026-08-28T10:26:22.475Z" }, + { url = "https://files.pythonhosted.org/packages/64/db/9bd6c505c95128c258a55236bfbb3a7a3fb6023f863316b6d7d9f3c69052/kiwisolver-1.5.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:9b3092d8992a1d69b7a59c3e39f35e1b9be327a17f68a7c35fc17329e337d6f2", size = 66493, upload-time = "2026-08-28T10:26:23.743Z" }, + { url = "https://files.pythonhosted.org/packages/e1/f4/b3007a3ed5c9be73f81161140684cf7d9bdb9c4b632f5f484d2a1c713fb9/kiwisolver-1.5.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:c2306e8bb53601979fcb3fa09cc65e031876d9ae01eff2fcbcd7a84ef94d5bc1", size = 64720, upload-time = "2026-08-28T10:26:24.95Z" }, + { url = "https://files.pythonhosted.org/packages/a1/13/08188f0cafa3a800403e4ff62b9aad4e7a17f9c4c7e080dc8f18c64794cf/kiwisolver-1.5.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:18a0cfb124546a4c2e6087c5f3029c7f44b37c85b142e0ced71f73a7599ac208", size = 1475867, upload-time = "2026-08-28T10:26:26.393Z" }, + { url = "https://files.pythonhosted.org/packages/8a/3e/053bdc3c9abdb8f2606225eda398adca25c0c91ab90add8222a69db65ee0/kiwisolver-1.5.1-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:34ec467940442c9943016fb2d4c81d1ba84351eeca2f1a78f8bc87f1ba0d414c", size = 1282865, upload-time = "2026-08-28T10:26:28.118Z" }, + { url = "https://files.pythonhosted.org/packages/5e/64/a44c341b36b610588cc2f1e89b3cae072a3119aa8be578e90987cd640751/kiwisolver-1.5.1-cp314-cp314-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:a83ee7107df13abe42a54a6654670eef9bb39425cf2e27f65e0007465e1286ab", size = 1300865, upload-time = "2026-08-28T10:26:30.125Z" }, + { url = "https://files.pythonhosted.org/packages/60/5e/7e7d716dca38c714478b741257a5b4a321d9932b8d851551a136dcaf3984/kiwisolver-1.5.1-cp314-cp314-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:bebb89489b279b2f5661bbbb2abcc87bcd4a46607bb4a5c966f04f1db6b8df9a", size = 1348071, upload-time = "2026-08-28T10:26:31.829Z" }, + { url = "https://files.pythonhosted.org/packages/10/1a/2b98fdda8bf45b7be317e48ed12393d44334394d315c74b81f4a14c0e31b/kiwisolver-1.5.1-cp314-cp314-manylinux_2_39_riscv64.whl", hash = "sha256:509735237ae0d849e8a843551d423d2500d2e0a9ac1611a145658b29c0fb9f85", size = 992191, upload-time = "2026-08-28T10:26:33.544Z" }, + { url = "https://files.pythonhosted.org/packages/b6/55/d893f5ede0e50f9e3fcf01f6015f42ec7d9cd221e26772701fe4a98745f9/kiwisolver-1.5.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:824c3d763a05ea9e9003610145186b0e9848c7584a5575c79bac5a8e7cd80bad", size = 2233854, upload-time = "2026-08-28T10:26:35.282Z" }, + { url = "https://files.pythonhosted.org/packages/b1/82/f85f6279555a6ee1639fef7bfe83adb037a03e11a6fc9eaa54b8d0380339/kiwisolver-1.5.1-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:1fff05e239575b1481b6ed1a782f6fad616efbf1f0b1f44e6e85c4dfe426e483", size = 2330621, upload-time = "2026-08-28T10:26:36.9Z" }, + { url = "https://files.pythonhosted.org/packages/56/31/e11aea078f66fc2fffcc179d38ca90d9da97652a241b64519169742ba46a/kiwisolver-1.5.1-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:0627b9bceb9c3cdcf12b8a18655eedfed2692b038df27423383c120d0b7dc2d6", size = 1982848, upload-time = "2026-08-28T10:26:39.01Z" }, + { url = "https://files.pythonhosted.org/packages/af/ea/2956b63bf5140ca46aa2c2818e6aa03e2d5754dd2fa41db1c6b28922940c/kiwisolver-1.5.1-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:8a708a47ade1fe19e8371d5da076bac0dd4b0a5a7985ad6c637f7f7e361b6baa", size = 2494850, upload-time = "2026-08-28T10:26:40.837Z" }, + { url = "https://files.pythonhosted.org/packages/11/d1/3829542258d8b3fc0898d221e7ef0e2c83eca0d348709bb8dbe54f3d4005/kiwisolver-1.5.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:007a5553dfc4f4e8d184f588a0200e2cd4b63a59cc8796df3c39909e679dc7a0", size = 2298067, upload-time = "2026-08-28T10:26:42.803Z" }, + { url = "https://files.pythonhosted.org/packages/4e/0e/49522e1ab5788cbaf63a26fbd3b851f9028616828c961b8a31b35cb96df8/kiwisolver-1.5.1-cp314-cp314-win_amd64.whl", hash = "sha256:f4167e87b397f273dc2356fcf1eaf50a6bac51e6105f45103ef7129c8efb0255", size = 72282, upload-time = "2026-08-28T10:26:44.268Z" }, + { url = "https://files.pythonhosted.org/packages/f5/b6/22e7ca5315d363e6f81c9f37c9472e12e7b298731e77c0428e6a911a2c39/kiwisolver-1.5.1-cp314-cp314-win_arm64.whl", hash = "sha256:5c490db2168a508088f59140dd392556a54b8bd1048fc6383c8baff13c359673", size = 69855, upload-time = "2026-08-28T10:26:45.725Z" }, + { url = "https://files.pythonhosted.org/packages/30/8c/03a9cfbe871964c8758a816eb03ac96c806da2795a9a7cd9bf9648bfb594/kiwisolver-1.5.1-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:4d4ca09bf13cff792b1884f64b98ee6c2467930d632233be25c56b442d99f10e", size = 126289, upload-time = "2026-08-28T10:26:47.023Z" }, + { url = "https://files.pythonhosted.org/packages/f2/e3/14ce3041ca79dff9c9d884ca00c7bf32374e76028a865a9ecd99b4f5a517/kiwisolver-1.5.1-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:44b8faef94f1857e77fa0238f3390ff1ac51d2ea20a487e2e452a59fd2b5f5ca", size = 67709, upload-time = "2026-08-28T10:26:48.268Z" }, + { url = "https://files.pythonhosted.org/packages/af/c4/45030471a66ec8ef042e9f96ffe1d522c9ab12da180186a0898966fc1385/kiwisolver-1.5.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:2ae70bc59790d2af72a3f76f24b272403e135070340281108b447cb77ea70819", size = 65909, upload-time = "2026-08-28T10:26:49.523Z" }, + { url = "https://files.pythonhosted.org/packages/42/73/17dce073a6ae259bb32cf9d686c4079d2e538868bc45967462bf33df914a/kiwisolver-1.5.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:43844c1a7ad6d723d5b5b4c4fc7f5bd399c40e288120d16257c7c9e8765c6e85", size = 1584907, upload-time = "2026-08-28T10:26:50.933Z" }, + { url = "https://files.pythonhosted.org/packages/8c/84/ae3c75909f507283cbfcc7e916c7e822579ef962020b97e6882b27b4478f/kiwisolver-1.5.1-cp314-cp314t-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:22d5e5aaad6be121f2515765e3b1c444352cb8eb4c86510801db8f2e50757316", size = 1392474, upload-time = "2026-08-28T10:26:52.638Z" }, + { url = "https://files.pythonhosted.org/packages/34/31/8bcc83caad5bce8fa4577152389848bf6bc110e51e573a2b4e7c2aa34c89/kiwisolver-1.5.1-cp314-cp314t-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:3fa5855898f6d3d01b72ccd48a2d65cbdee301251603fefe34e2025bddba219c", size = 1405246, upload-time = "2026-08-28T10:26:54.248Z" }, + { url = "https://files.pythonhosted.org/packages/55/72/220345537d790cf4ae54f8acfff4b5cc2468e0702a384d651cf7a771c63e/kiwisolver-1.5.1-cp314-cp314t-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:d66a64dd5dec136040ec2ae94aa026a912ee60fdd45bc28d3db30037fd809e88", size = 1456099, upload-time = "2026-08-28T10:26:56.042Z" }, + { url = "https://files.pythonhosted.org/packages/cd/10/3725fd2398f66d18c34b4e0f81a8d03764cd4f4f089f58a527f0b4428086/kiwisolver-1.5.1-cp314-cp314t-manylinux_2_39_riscv64.whl", hash = "sha256:9e51c119992ea8820706871c30a4642ec76de20ae82f9b50b9a45517d8e9f810", size = 1073695, upload-time = "2026-08-28T10:26:57.658Z" }, + { url = "https://files.pythonhosted.org/packages/86/cb/28d6e09e66b93e4588b2e6b7d84d020ccefea09e2f4de788510a07efeab7/kiwisolver-1.5.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:70ed9a45c7484d2b30cdacf60d220f494a1763b9fec1ad03285c6553fa0889f2", size = 2335355, upload-time = "2026-08-28T10:26:59.202Z" }, + { url = "https://files.pythonhosted.org/packages/6a/b3/a0f31d5e4e40af7dc97c36b8a74fdd3a36cf3c8bbd098da9a23466ff6a94/kiwisolver-1.5.1-cp314-cp314t-musllinux_1_2_ppc64le.whl", hash = "sha256:98b208a7cc42c803445ef551d6753cc42a5ea13e9cab1ee66cd8b9cb70195330", size = 2426524, upload-time = "2026-08-28T10:27:01.181Z" }, + { url = "https://files.pythonhosted.org/packages/2f/c9/728f63bd58c72cafdc79fc306abeeac7391bec03b757a48dadeb30906521/kiwisolver-1.5.1-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:c6834b92dd2428e2dd85ef3d85f723d3c12f20aaf43a2ddd4f944ca25d833408", size = 2063430, upload-time = "2026-08-28T10:27:03.06Z" }, + { url = "https://files.pythonhosted.org/packages/84/df/ce188b96f92f9a2c958231da140768918cba53c9713dc887b82f85462118/kiwisolver-1.5.1-cp314-cp314t-musllinux_1_2_s390x.whl", hash = "sha256:5d142e352eb13facc7dd047489aebdff6ba78576c239f1ea04931979caaf0567", size = 2597513, upload-time = "2026-08-28T10:27:05.072Z" }, + { url = "https://files.pythonhosted.org/packages/69/d6/76947c8203768968382e5bd74d9cc95654746703a61ea53015f2c74a2e06/kiwisolver-1.5.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:f9b1c4900736e489a812c529100de4b8fb617d4db075e931e213c57424b83d9b", size = 2394488, upload-time = "2026-08-28T10:27:07.423Z" }, + { url = "https://files.pythonhosted.org/packages/e4/d4/14b21e4eb203c4d15425e8b6a2c625a320b4a1f2f7557eead63ffc30ffb7/kiwisolver-1.5.1-cp314-cp314t-win_amd64.whl", hash = "sha256:5978c3340f16a35c30f8ab2fa7bcf559973c55f1a5ef6970e1f621acf3c4db13", size = 75404, upload-time = "2026-08-28T10:27:08.892Z" }, + { url = "https://files.pythonhosted.org/packages/cb/f5/53157899fc7f45f76421b77b99eb1639dd0f83f26ff9d76300c96bb4a3b0/kiwisolver-1.5.1-cp314-cp314t-win_arm64.whl", hash = "sha256:ca307d6c259e5c98d3cb9ade55342b47a6839762caf2536f3d7b46ee660cc82e", size = 72946, upload-time = "2026-08-28T10:27:10.944Z" }, +] + +[[package]] +name = "lazy-object-proxy" +version = "1.13.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d4/8e/f26b09778fcb26261fdeb4cc2b011975292316529bff9b541a5a02acb976/lazy_object_proxy-1.13.0.tar.gz", hash = "sha256:ce34046cb021d69c72d05ddb83821ecfd4d2d0a5d43a93c5cd01c9e34779cf14", size = 45649, upload-time = "2026-10-17T16:38:01.975Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d0/0b/410ea9a56ad59421d8969535099560f0bad7162d483869e1c07ff5880f35/lazy_object_proxy-1.13.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:62612150e2b67d1cb26c2201d020773e9bab9c596d783d55ada42885a695f749", size = 26856, upload-time = "2026-10-17T16:37:48.864Z" }, + { url = "https://files.pythonhosted.org/packages/8c/97/79ab37585905cf6841134806e73ace576d61a87c4eee333be4622161b23f/lazy_object_proxy-1.13.0-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:ad7630266b5775463f2a1806165c1d9dff07780cf1bba3c53f311e1d026e8921", size = 70985, upload-time = "2026-10-20T01:05:49.274Z" }, + { url = "https://files.pythonhosted.org/packages/18/2e/66bbb45f20aab9e81139e2bf9fea1a29850b5af769cbf7f181221ce062dc/lazy_object_proxy-1.13.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:73f05b09e37b0eb0ca7d6e80e2b0689c49bedac8c5d69667c1ebb9f02a4ed5c7", size = 70984, upload-time = "2026-10-20T01:05:50.548Z" }, + { url = "https://files.pythonhosted.org/packages/74/e0/63dc39750c7b266e9e25022962eba32ba80e4f17fdcd674fc4ad4143fd90/lazy_object_proxy-1.13.0-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:91a725d3c64dfe13d365cf78c469c2a8f95884859379aeca89cb8d2ed291649a", size = 65689, upload-time = "2026-10-20T01:05:51.765Z" }, + { url = "https://files.pythonhosted.org/packages/e7/6c/b94a8779eec1331477557ca3ea4742860d59dc9bcd4dcf21bcef3cd8c4f2/lazy_object_proxy-1.13.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:e28a75d33378141927c08f3eb291cc98d0a22776670ae330f8347f898cd3b175", size = 69492, upload-time = "2026-10-20T01:05:53.116Z" }, + { url = "https://files.pythonhosted.org/packages/60/99/6c3ff4a32f15e807ffb868c47de136ebd4be31e7320af42b699dc43a7495/lazy_object_proxy-1.13.0-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:a785fe44b61fcbffc0e264fe6b735a909e0b5ef922f0e976e281bbe8477fb47a", size = 65019, upload-time = "2026-10-20T01:05:54.462Z" }, + { url = "https://files.pythonhosted.org/packages/c4/1a/447ff40629a11f879f194e839d59e5a026dd26f4d0eb8672de858644be85/lazy_object_proxy-1.13.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:e321425f76451885c93083ecec0850b64de0f83bb94c113e930e8a0a630e45ab", size = 70334, upload-time = "2026-10-20T01:05:55.619Z" }, + { url = "https://files.pythonhosted.org/packages/70/52/2ca84fb914b17d4b02193cbf8b6ba9344b36459944a19711d3da1d14b03d/lazy_object_proxy-1.13.0-cp314-cp314-win_amd64.whl", hash = "sha256:0e52094b7fff1f26f4e227b88be3f350817078e4bb79b4c80846fca0d15efae4", size = 26122, upload-time = "2026-10-17T16:37:53.02Z" }, + { url = "https://files.pythonhosted.org/packages/84/c7/ebbeb84639e84fbf6f07a48373f76fe048d23fbcfd4557509b48f35d284d/lazy_object_proxy-1.13.0-cp314-cp314-win_arm64.whl", hash = "sha256:b2dd1c37d64cf9f3f4a2072971639408989b0803a3b7f05e75c1fe28d1a93c1f", size = 24746, upload-time = "2026-10-17T16:37:53.954Z" }, + { url = "https://files.pythonhosted.org/packages/38/ac/8ff35cc4d1316e056144edfb816dbff9b5db9ccd7e98c69f6b602c11bc29/lazy_object_proxy-1.13.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:348370676ea6d9ed08f9b74545c37e5be4cf009c45b9d50c6aff476fb7fcc7ec", size = 27524, upload-time = "2026-10-17T16:37:49.825Z" }, + { url = "https://files.pythonhosted.org/packages/14/c5/8afe34ead41fdd48a207c4535192a4e931c56c791d5f0a57c0abd4558c1c/lazy_object_proxy-1.13.0-cp314-cp314t-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:dee2fb3326cd81384d2b752c3f6888d7ed9eba2cdbf0583097b5168b8bb4a703", size = 80523, upload-time = "2026-10-20T01:05:57.129Z" }, + { url = "https://files.pythonhosted.org/packages/38/fd/0e68a385daaf141b1b1d943b132b8a9887bd53abb88886dab286cca9b62e/lazy_object_proxy-1.13.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2b4c446cbc8e411b116c9ee9b475cb664b8bc5c3d912bcbf1bab5c785fc69a02", size = 82823, upload-time = "2026-10-20T01:05:58.56Z" }, + { url = "https://files.pythonhosted.org/packages/91/ce/648e09f90dc59cb6007d9093c2cc17d72e2d93c06553828037126205ea7c/lazy_object_proxy-1.13.0-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:1e671e0e9f2793759f382a69a3853c8742474bc011865ed3595187340ac5956d", size = 74655, upload-time = "2026-10-20T01:05:59.717Z" }, + { url = "https://files.pythonhosted.org/packages/10/4d/811442390862dbf85e00520ecb0cb58c7dbdf824dc563ad933729f9e20f3/lazy_object_proxy-1.13.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:a0155084a5dc8ce3e1a3d6e3f2fb4d84d5fc09e66ed84dc0e5f8a2697d421ea0", size = 80848, upload-time = "2026-10-20T01:06:00.884Z" }, + { url = "https://files.pythonhosted.org/packages/24/4e/c30ea3678b50a7ed7774760fbde917106cbb860edb88cc31a17a8385b3d4/lazy_object_proxy-1.13.0-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:2d07e0bde2738922a7117fccc1a82514aefbc9c07ee8ff0bb84a1c606dbb5ac8", size = 74127, upload-time = "2026-10-20T01:06:01.949Z" }, + { url = "https://files.pythonhosted.org/packages/19/d0/862f0f96b031dab7faa036679e2076bbd6a18ea06e34fb1400fca65b03f0/lazy_object_proxy-1.13.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:da9f1b8780678af93c4ddba46826166c53a25d8d71133fc818542bf7b481e033", size = 79497, upload-time = "2026-10-20T01:06:03.122Z" }, + { url = "https://files.pythonhosted.org/packages/d5/50/20454483d8f95a11710b951518f86aaaaaae9195982fe27c12eeed130660/lazy_object_proxy-1.13.0-cp314-cp314t-win_amd64.whl", hash = "sha256:f21b4711e6744d46a4672497ca2db390cbdb03241d9b1654bbf38dbbc4db2a5e", size = 26670, upload-time = "2026-10-17T16:37:50.977Z" }, + { url = "https://files.pythonhosted.org/packages/4a/df/c1ff843fd9c4978d9a50ef2bceda3897d71645d4127ec1413aa15204cb64/lazy_object_proxy-1.13.0-cp314-cp314t-win_arm64.whl", hash = "sha256:de295ae25e5c1fd712088547f251c4b2976d2f60df28057b6c416e771a99842b", size = 25297, upload-time = "2026-10-17T16:37:52.088Z" }, +] + +[[package]] +name = "license-expression" +version = "30.4.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "boolean-py" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/40/71/d89bb0e71b1415453980fd32315f2a037aad9f7f70f695c7cec7035feb13/license_expression-30.4.4.tar.gz", hash = "sha256:73448f0aacd8d0808895bdc4b2c8e01a8d67646e4188f887375398c761f340fd", size = 186402, upload-time = "2025-07-22T11:13:32.17Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/af/40/791891d4c0c4dab4c5e187c17261cedc26285fd41541577f900470a45a4d/license_expression-30.4.4-py3-none-any.whl", hash = "sha256:421788fdcadb41f049d2dc934ce666626265aeccefddd25e162a26f23bcbf8a4", size = 120615, upload-time = "2025-07-22T11:13:31.217Z" }, +] + +[[package]] +name = "markdown-it-py" +version = "4.3.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "mdurl" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/16/fc/cee2c45553c9a9bf77d8b0c391560c556d7ed756b1f0bb35eb5d48db09ea/markdown_it_py-4.3.0.tar.gz", hash = "sha256:91a58fa5b72c71a40cf7177250fd767480d7a2bb3ac426ccfb76fb90305fdaaa", size = 242701, upload-time = "2026-11-10T16:18:30.467Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c9/31/5f0ac2f1a1c67423c995c731a11cd4ad05d081a2be969d74f868bdb9cc70/markdown_it_py-4.3.0-py3-none-any.whl", hash = "sha256:7aa1511a46c39138de78d9eba92ce47e63124d8003fc98b3a351909e04239efa", size = 96951, upload-time = "2026-11-10T16:18:28.975Z" }, +] + +[[package]] +name = "matplotlib" +version = "3.11.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "contourpy" }, + { name = "cycler" }, + { name = "fonttools" }, + { name = "kiwisolver" }, + { name = "numpy" }, + { name = "packaging" }, + { name = "pillow" }, + { name = "pyparsing" }, + { name = "python-dateutil" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/e7/c8/9aa712a0afb882649424dd8de8ad9aa6235e796e84c6052e8f6dc1598d0d/matplotlib-3.11.2.tar.gz", hash = "sha256:cec596316640f2b394b8f0daa0ea61a8eae82d017b620b9f202befb972a59ea4", size = 32660610, upload-time = "2026-09-11T19:05:31.214Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/54/b4/4facdb700bc236e4c676495ca3798d8134ab8668cbfe0f6b2e9ebf962a38/matplotlib-3.11.2-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:c9721f81275499da1feeb36a2cf8192ea086283b3bd16b7dc4c9d7aedb7396d6", size = 9478976, upload-time = "2026-09-11T19:04:00.12Z" }, + { url = "https://files.pythonhosted.org/packages/4c/a0/bba05f0a25bfeb0475c2f2a87958b31103aa6b7a5386017afb1a96212825/matplotlib-3.11.2-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:1a3040b209f3968b4e84161df7b174f07a9fad33b0f2d7e48ea3bbd3075e2863", size = 9307932, upload-time = "2026-09-11T19:04:02.976Z" }, + { url = "https://files.pythonhosted.org/packages/d4/42/81d5cba4bb39b41b0998efc880e129f2d7cdb94256ca49678fdcd9c21be5/matplotlib-3.11.2-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:bf3fe71fbfb8ec0e310e0bc8537c3405a01f38f25f9394ed2135e6202fed542b", size = 10674370, upload-time = "2026-09-11T19:04:06.912Z" }, + { url = "https://files.pythonhosted.org/packages/29/5e/52f56f93d5b20815ee0ae352f7a38eff25580edb180b4fa7df87cfeba68f/matplotlib-3.11.2-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8c8255de28f986d935a64c9ca71c0ec2d2f41d355691f5ea684725dc91413f71", size = 10954597, upload-time = "2026-09-11T19:04:09.948Z" }, + { url = "https://files.pythonhosted.org/packages/6e/ae/f8918a1b564db49c53cd603eb3c8748c5767e4ce0fb2cf1d7c38653e4c5d/matplotlib-3.11.2-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:a8756cc73d9af9a7fe0deb54ea2e75ef73b01d9e575877e72acad5458e660943", size = 10812583, upload-time = "2026-09-11T19:04:12.887Z" }, + { url = "https://files.pythonhosted.org/packages/ea/61/4315ef0d63937fe56f451887b4a0be3b8e8b22cf1d92a8d157caac54570d/matplotlib-3.11.2-cp314-cp314-win_amd64.whl", hash = "sha256:ecea603dd2fbf8242fd31a305a8b12a4ece2de28096870c65fdd0d1e35b8d9a6", size = 9505972, upload-time = "2026-09-11T19:04:15.788Z" }, + { url = "https://files.pythonhosted.org/packages/d5/00/02398b0a1a62ef73d9af0a957fe1773363eec9a6ca7e433c72ae2790fbce/matplotlib-3.11.2-cp314-cp314-win_arm64.whl", hash = "sha256:01dc8eaaab5a9fce9ff615eca82345728f289e4715b186ee10c6d85272fc26bb", size = 9184534, upload-time = "2026-09-11T19:04:18.691Z" }, + { url = "https://files.pythonhosted.org/packages/ec/c5/1e6ca10baa7e04f113c37856aadb4adc3dbb1c55fc7da6dc830bba1292d7/matplotlib-3.11.2-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:79a258f58253dfa025af80a9e9bb228d75fced007f0e93ae7423fefbde81a74d", size = 9526415, upload-time = "2026-09-11T19:04:21.39Z" }, + { url = "https://files.pythonhosted.org/packages/e0/93/7561727af07ccc84747953c6a33eee3981cc436d04f465032e707ca0e429/matplotlib-3.11.2-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c0b83f044ce10a98027b105b3931548719a6e8c7ef986b4362651e0b5367c8dc", size = 9361064, upload-time = "2026-09-11T19:04:24.107Z" }, + { url = "https://files.pythonhosted.org/packages/c1/40/ce270ef2a6794d94a409fe28b8dabedffc07c07f9e5dbb89e0f605bd157d/matplotlib-3.11.2-cp314-cp314t-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e43b188f0a5b75447bcc197728258166aa64365770ed1caa36595a5e1ca4bbba", size = 10684626, upload-time = "2026-09-11T19:04:27.201Z" }, + { url = "https://files.pythonhosted.org/packages/45/46/396e0307dbf1c1f2d0a3654caa6dbc780dd5379f5f11257369cf8d21d9fe/matplotlib-3.11.2-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d3304eb5a59442a8867f6920d484591c0fa09ffc29e9260be2feec3351e25869", size = 10960602, upload-time = "2026-09-11T19:04:30.254Z" }, + { url = "https://files.pythonhosted.org/packages/1c/97/4defb84695477340aa88b27c9482cc1ca4de11f36f66b6c8c0ddd685def1/matplotlib-3.11.2-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:02329432ae5c6af87cf208ee575b701d698bdf0b1a3bb28cc6d53c36e967e575", size = 10822603, upload-time = "2026-09-11T19:04:32.964Z" }, + { url = "https://files.pythonhosted.org/packages/7d/e7/eab54551c1ec6b72dcd678a078b6c6da8d4c85ec1ff0016e81fe52866304/matplotlib-3.11.2-cp314-cp314t-win_amd64.whl", hash = "sha256:f2ac30cf5eb5dff1b584627ae0b0e1186551a4f69ae3c75073911da497a29170", size = 9551206, upload-time = "2026-09-11T19:04:35.811Z" }, + { url = "https://files.pythonhosted.org/packages/4e/0e/04698032cb4d8fb1e30d8ffec5ded20f6f582b03c8c58b2385c95245f158/matplotlib-3.11.2-cp314-cp314t-win_arm64.whl", hash = "sha256:cf41ecd1b0c0b6f7177ed965a54c2afbe888715c7cf6054dc12d53bc1494002c", size = 9234977, upload-time = "2026-09-11T19:04:38.972Z" }, +] + +[[package]] +name = "mdurl" +version = "0.1.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba", size = 8729, upload-time = "2022-08-14T12:40:10.846Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b3/38/89ba8ad64ae25be8de66a6d463314cf1eb366222074cfda9ee839c56a4b4/mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", size = 9979, upload-time = "2022-08-14T12:40:09.779Z" }, +] + +[[package]] +name = "minio" +version = "7.2.20" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "argon2-cffi" }, + { name = "certifi" }, + { name = "pycryptodome" }, + { name = "typing-extensions" }, + { name = "urllib3" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/40/df/6dfc6540f96a74125a11653cce717603fd5b7d0001a8e847b3e54e72d238/minio-7.2.20.tar.gz", hash = "sha256:95898b7a023fbbfde375985aa77e2cd6a0762268db79cf886f002a9ea8e68598", size = 136113, upload-time = "2025-11-27T00:37:15.569Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3e/9a/b697530a882588a84db616580f2ba5d1d515c815e11c30d219145afeec87/minio-7.2.20-py3-none-any.whl", hash = "sha256:eb33dd2fb80e04c3726a76b13241c6be3c4c46f8d81e1d58e757786f6501897e", size = 93751, upload-time = "2025-11-27T00:37:13.993Z" }, +] + +[[package]] +name = "msgpack" +version = "1.2.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/cc/52/1ec7ead2c7528bf3d1db73e886fa4df10f9e6f0eb7854a448b7090cfcef7/msgpack-1.2.4.tar.gz", hash = "sha256:475c44e12f2a5de766a8448783f149c9b33f3f49b88953c6cd739a77d93c732c", size = 197764, upload-time = "2026-10-26T17:55:48.593Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/86/34/747f9ea2b428088201c73fcb3a885cebcbedcd71def0f1f3c36896294b27/msgpack-1.2.4-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:895e9369185df4a874768849405c30cba7990caceb3fcb1692ebe62bb050f55e", size = 92449, upload-time = "2026-10-26T17:54:37.503Z" }, + { url = "https://files.pythonhosted.org/packages/83/7e/52d208cb1561f869762c17be0e2c004e4d34f2842d239a450492d6246d62/msgpack-1.2.4-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:c97f5f17407e1761f23f1944be33cbf1d5ce67017db32544dcd5e16e0b1b4a3b", size = 91202, upload-time = "2026-10-26T17:54:38.797Z" }, + { url = "https://files.pythonhosted.org/packages/2e/58/5516cabb60da83506024015c669622a0277979aef51eb611308cebaf4cc9/msgpack-1.2.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2444a4e04f924630d059ae6eae8f91fdfcd28ed9fd17b21bacf4e74550a091f7", size = 455185, upload-time = "2026-10-26T17:54:40.213Z" }, + { url = "https://files.pythonhosted.org/packages/39/8f/bf975b5d2111e4954a0f8567fc6b60bab22c8766dd4fa509af1334c91a4f/msgpack-1.2.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:5d65b791ce4283e02b6267742ad540899155e1b32887b9cbdda47f38f5a076b5", size = 465078, upload-time = "2026-10-26T17:54:41.971Z" }, + { url = "https://files.pythonhosted.org/packages/32/2f/c74baeafc53d1c1fadfbeb774444d0e6354778d12b40b827e437a7a35856/msgpack-1.2.4-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:5e4c67dbac05dce90a3fa1d845137617383c415e6b319062baac9734540706ae", size = 420144, upload-time = "2026-10-26T17:54:44.994Z" }, + { url = "https://files.pythonhosted.org/packages/b0/f2/bdf2ce9e284821397dc5549101824c7607ee6ba6e0635390d168a77ac49c/msgpack-1.2.4-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:781e856db4f2cb398e4992e2a74305295d3ebf694eec26fa0f4bc766eb9fa0a0", size = 446479, upload-time = "2026-10-26T17:54:46.484Z" }, + { url = "https://files.pythonhosted.org/packages/76/8d/b4572d24bb75d98bcbbd031a934a3a1d03494ea88a100cd51ab16c4c7d57/msgpack-1.2.4-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:cfc1cc237792f9a5664002b66acb961027d4184528ec9d10e0e42330f7972383", size = 418780, upload-time = "2026-10-26T17:54:48.04Z" }, + { url = "https://files.pythonhosted.org/packages/55/8e/4493bef4422730cfd3420b84094652fabd27ef8aadc8b443a8995b524d08/msgpack-1.2.4-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:f60de6ae13d4d2a12a483f15c5e47cb6fa2731aa32d92fb31178e2017d6574a8", size = 462009, upload-time = "2026-10-26T17:54:49.433Z" }, + { url = "https://files.pythonhosted.org/packages/41/29/efdc3d1d09e4e0e45955b0aad559b4c1f5d908767c9fb1021990c52182a5/msgpack-1.2.4-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:06a0657a4110d563255006b7cb7147432f67827144e429c2cdb1c967548d1817", size = 53714, upload-time = "2026-10-26T17:54:50.753Z" }, + { url = "https://files.pythonhosted.org/packages/df/0b/08794c65e0a752acf20aa44e193e61dfb552b48fe6c27ba6023c146f9e77/msgpack-1.2.4-cp314-cp314-win32.whl", hash = "sha256:727a65b35db9f5ef516fc0229c4b05cab983092b1ae274a8a769b2d517fb0499", size = 70726, upload-time = "2026-10-26T17:54:52.397Z" }, + { url = "https://files.pythonhosted.org/packages/b5/da/e2cc63ec61e7ac05595b391cba01c10cb4657f4e517da1512e4a75d2d12e/msgpack-1.2.4-cp314-cp314-win_amd64.whl", hash = "sha256:80f5d4fda1ba373d95933f98e6c1d18247feffac839fda3930bdd85e6561bb5f", size = 78346, upload-time = "2026-10-26T17:54:54.662Z" }, + { url = "https://files.pythonhosted.org/packages/93/e4/1b0eb49887009dc2c530171d659cf2aa37202b5f79c0b784e63777554b37/msgpack-1.2.4-cp314-cp314-win_arm64.whl", hash = "sha256:e5f67f0286f2ba2c6dbb4998404ed880112ca204ceda729cf239879cd89d3acf", size = 74152, upload-time = "2026-10-26T17:54:55.915Z" }, + { url = "https://files.pythonhosted.org/packages/d0/4a/6defc8fd0270c4ba675e6625f4f76ce936fd0c48733395fd7ba912cd423e/msgpack-1.2.4-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:45506bfb902cde24a0d33fb0581f58497ddb2682686dd1f6aa07e7b769df7ca4", size = 94083, upload-time = "2026-10-26T17:54:57.108Z" }, + { url = "https://files.pythonhosted.org/packages/c8/e8/59f7e076739048864710a4de3403ae1c1b43ed5077b796cd9e8cbce9b3f6/msgpack-1.2.4-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:dc9dc681958e69f46b9f37def3e7fd6cc5dcfaa5943fb00bfe9c223a1a1052f6", size = 95037, upload-time = "2026-10-26T17:54:58.489Z" }, + { url = "https://files.pythonhosted.org/packages/2c/dd/dbae250b23b831cd0571eb664089f80de3249a39e98c6ef55f9a0efe928d/msgpack-1.2.4-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:0bef691e2a95119cc6bf3ded29325dbd89c4b6f8ff233070431948ed70902421", size = 472722, upload-time = "2026-10-26T17:54:59.924Z" }, + { url = "https://files.pythonhosted.org/packages/a9/e2/383ece1c1b27c1ed322055fce8ab8972bc6d529ede881592065ce0c461bf/msgpack-1.2.4-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:55e6106d2d085af42b2de72efeb38ed255241a24b32295ca889707c1d679c442", size = 468726, upload-time = "2026-10-26T17:55:01.492Z" }, + { url = "https://files.pythonhosted.org/packages/37/2f/5410a8815ae74a824ac87543c612e40cb6674851b70a6ad858bb32813203/msgpack-1.2.4-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:996dfc4774c240c8e6adf1166ae102141cfbed33c8856fde821bd6c0bd35ee41", size = 420488, upload-time = "2026-10-26T17:55:02.848Z" }, + { url = "https://files.pythonhosted.org/packages/39/8e/16fdf02b4f91dff9c1480433c1bf80756c2fedc0b74fc6a231f02dfed007/msgpack-1.2.4-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:efa1357fb0c7201e833de28638be371ee127476f7ccff9e7a94211b0afc33ddf", size = 455541, upload-time = "2026-10-26T17:55:04.564Z" }, + { url = "https://files.pythonhosted.org/packages/c4/76/2454ef54d780a167667552d02e7bc977a3d419943bcbdf6a96a4da6786ad/msgpack-1.2.4-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:b9270b63409e70c8c6deb5faedc81fc27c6bd0196b38084a8773f68286abf034", size = 419514, upload-time = "2026-10-26T17:55:06.257Z" }, + { url = "https://files.pythonhosted.org/packages/ac/8b/2af9bf378def33c24875f250421b0d0b1b06f72a1c2c3f964749fc4cdee1/msgpack-1.2.4-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:2b597bb01aff61d65e305c2cf2589c93c86609929d42d575bfc359f3c54ea8e1", size = 461910, upload-time = "2026-10-26T17:55:08.05Z" }, + { url = "https://files.pythonhosted.org/packages/0e/46/a133ac6c4cef4d3939383c00cc19baa16ee85fd70af0c5990e7a9ca8767f/msgpack-1.2.4-cp314-cp314t-win32.whl", hash = "sha256:ad5bc540cbc34db236f8535721a9a872d12a9d88d1322470f1fc7c5e9dadfdb2", size = 76441, upload-time = "2026-10-26T17:55:09.711Z" }, + { url = "https://files.pythonhosted.org/packages/d4/f5/8d22ec454c188f1795107a3fd9f68ada485076ebf394a4aaaa5fbb6093e7/msgpack-1.2.4-cp314-cp314t-win_amd64.whl", hash = "sha256:287e52c2ebaa94f8eca045628374859f51584e77bc07086e6835a9bb2204c774", size = 84321, upload-time = "2026-10-26T17:55:10.947Z" }, + { url = "https://files.pythonhosted.org/packages/41/52/1390514aee47d14ca3fe6ea0cf236fddc55021867ace30daf8761deba36f/msgpack-1.2.4-cp314-cp314t-win_arm64.whl", hash = "sha256:f3f19fe5decd348b35b003ae5f32d3fa90877413a0183da676f748a3a7ab9270", size = 78589, upload-time = "2026-10-26T17:55:12.425Z" }, +] + +[[package]] +name = "mtusi-messenger-lab7" +version = "1.0.0" +source = { virtual = "." } +dependencies = [ + { name = "argon2-cffi" }, + { name = "cryptography" }, + { name = "fastapi" }, + { name = "minio" }, + { name = "opentelemetry-api" }, + { name = "opentelemetry-exporter-otlp-proto-http" }, + { name = "opentelemetry-sdk" }, + { name = "pillow" }, + { name = "psutil" }, + { name = "psycopg", extra = ["binary", "pool"] }, + { name = "pydantic" }, + { name = "redis" }, + { name = "uvicorn" }, +] + +[package.dev-dependencies] +dev = [ + { name = "httpx" }, + { name = "matplotlib" }, + { name = "openapi-spec-validator" }, + { name = "pip-audit" }, + { name = "psutil" }, + { name = "pytest" }, + { name = "pyyaml" }, + { name = "ruff" }, +] + +[package.metadata] +requires-dist = [ + { name = "argon2-cffi", specifier = ">=25,<26" }, + { name = "cryptography", specifier = "==50.0.2" }, + { name = "fastapi", specifier = "==0.143.3" }, + { name = "minio", specifier = "==7.2.20" }, + { name = "opentelemetry-api", specifier = "==1.45.2" }, + { name = "opentelemetry-exporter-otlp-proto-http", specifier = "==1.45.2" }, + { name = "opentelemetry-sdk", specifier = "==1.45.2" }, + { name = "pillow", specifier = "==13.0.0" }, + { name = "psutil", specifier = "==7.1.3" }, + { name = "psycopg", extras = ["binary", "pool"], specifier = "==3.3.6" }, + { name = "pydantic", specifier = "==2.14.1" }, + { name = "redis", specifier = "==8.1.0" }, + { name = "uvicorn", specifier = "==0.54.0" }, +] + +[package.metadata.requires-dev] +dev = [ + { name = "httpx", specifier = ">=0.28,<1" }, + { name = "matplotlib", specifier = ">=3.10,<4" }, + { name = "openapi-spec-validator", specifier = "==0.7.2" }, + { name = "pip-audit", specifier = "==2.10.1" }, + { name = "psutil", specifier = ">=7,<8" }, + { name = "pytest", specifier = ">=8,<10" }, + { name = "pyyaml", specifier = "==6.0.3" }, + { name = "ruff", specifier = ">=0.14,<1" }, +] + +[[package]] +name = "numpy" +version = "2.5.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/95/b0/c7453d0b6e2073c3264468b106ee1563750cecc910965e67357e3698c83e/numpy-2.5.4.tar.gz", hash = "sha256:9a94cf751c9ad8ebaa835bcd3d40dacf8534ad086b88c38029b65123c7999d2a", size = 20866315, upload-time = "2026-10-10T20:05:31.422Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/99/ba/005cb5edd580d2f84d7ca3206b92dc17d4388e56e6f87ffe8f2762f83139/numpy-2.5.4-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:c668b2f0d651605b58892644b0e302c7157f7159544227758c896982ef384b18", size = 17005499, upload-time = "2026-10-10T20:03:37.961Z" }, + { url = "https://files.pythonhosted.org/packages/f3/49/fee7587c33ee35f7977f9051d7f2023d4e7246d62710c80f20c2361ea232/numpy-2.5.4-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:ffa6ce09a1c6a08e9667dd9c97aa0b14184e8d18f2a14b78b2a2328c9147f076", size = 12019666, upload-time = "2026-10-10T20:03:40.606Z" }, + { url = "https://files.pythonhosted.org/packages/d5/b2/c6ce165acffceb15a82c07b9cc77d391f86b3f379ba62911908ae5d34b91/numpy-2.5.4-cp314-cp314-macosx_14_0_arm64.whl", hash = "sha256:956555e0603a4d38019ae6925711cb9dc43195c076a928accf7ea5d50bddfe53", size = 5455617, upload-time = "2026-10-10T20:03:43.138Z" }, + { url = "https://files.pythonhosted.org/packages/77/7f/dd85ce260a669a89be06842cf355d7353a33e6cfbc590fb8ebb947d88dc9/numpy-2.5.4-cp314-cp314-macosx_14_0_x86_64.whl", hash = "sha256:2c2c4afffdeb7920e445028dd71eb932cac3e704792e964bc2a232426d4f1255", size = 6791932, upload-time = "2026-10-10T20:03:44.874Z" }, + { url = "https://files.pythonhosted.org/packages/63/d6/34b0a2b0741386a63025a65a2c09caaaaaad6d0ca95b66cd65c30dd7fcb5/numpy-2.5.4-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4054173604cd8658796053f1f3bc0befb68ec1c0762c57fdad61e199256a8617", size = 15710899, upload-time = "2026-10-10T20:03:46.839Z" }, + { url = "https://files.pythonhosted.org/packages/16/d5/928078d2b28f26829b138b4a6c3980045022fb409f570657a224ae60ef4e/numpy-2.5.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d549420b8858885cea8838a727842249218b9c1da24dd517e25c9c7a948310a3", size = 16721710, upload-time = "2026-10-10T20:03:49.489Z" }, + { url = "https://files.pythonhosted.org/packages/f9/cf/673fd1b8f4cd78eb6320e87ec4c90ac19c095644259e3749853a405c70f4/numpy-2.5.4-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:823874a507a84af050493b622affde94b6f7c3a0dc22cb2801381bc03b871c00", size = 17066182, upload-time = "2026-10-10T20:03:52.25Z" }, + { url = "https://files.pythonhosted.org/packages/f3/92/a77b5061b1b3e2643928c37976d79ee173e1b171ed158b7a3c61056b41bc/numpy-2.5.4-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:4e263278bfb5ee6409db8aedbc4cc32973b1b82bc1e8d3c668551d04d83a7e37", size = 18480315, upload-time = "2026-10-10T20:03:55.39Z" }, + { url = "https://files.pythonhosted.org/packages/bb/1d/1486ef3d3fb2279fd93c4c43c1bbbf1ca389a19816696684409f71babaab/numpy-2.5.4-cp314-cp314-win32.whl", hash = "sha256:cfd73180400042a7c532d30c5e287bdd03c59ff9ee1b4c0316af0539e29dfe23", size = 6185739, upload-time = "2026-10-10T20:03:58.186Z" }, + { url = "https://files.pythonhosted.org/packages/52/9a/e1e512ebc948d5b9dd33b08736760f0ebbed2848fd4eda1f553088a6dcee/numpy-2.5.4-cp314-cp314-win_amd64.whl", hash = "sha256:2ca144f15135b6212a5c47b1e2aeca6e412f102f95a2d5d88d8aec77eb255de3", size = 12703552, upload-time = "2026-10-10T20:04:00.28Z" }, + { url = "https://files.pythonhosted.org/packages/2c/05/de709a982d7bbcd688a3fad71f002e9ff80c2db39e03ee726609b610f1d1/numpy-2.5.4-cp314-cp314-win_arm64.whl", hash = "sha256:468397ba3c64427474706e5c9123fe266395496714dc684294eac75cd4930d1e", size = 10803901, upload-time = "2026-10-10T20:04:02.659Z" }, + { url = "https://files.pythonhosted.org/packages/13/34/083570ada3bb2a30fbe5d77c8c6fef9141144a15d33e6f793a67e9749ab8/numpy-2.5.4-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:1ef3aa6d7e29bb13677323114280b05acc57607fa2300e66432d665d5418a162", size = 12138695, upload-time = "2026-10-10T20:04:05.012Z" }, + { url = "https://files.pythonhosted.org/packages/94/06/1f9c24db48eef0c2d1207e3b11fffb0478e39dfd8c1e1be7476936885eed/numpy-2.5.4-cp314-cp314t-macosx_14_0_arm64.whl", hash = "sha256:98b053943e5a0474ec0da309d2cb9d3f18ea57f8a2067c2ab7b5f763d1068380", size = 5574615, upload-time = "2026-10-10T20:04:07.316Z" }, + { url = "https://files.pythonhosted.org/packages/da/0f/593fba2e1560e949123bc7d2fc48b5893d56e58cd4bd5a273d2fbf60b220/numpy-2.5.4-cp314-cp314t-macosx_14_0_x86_64.whl", hash = "sha256:b64a85f40e154983960a4167d4c1d57a50c7f109b3d3264a3a984154e90a8454", size = 6889383, upload-time = "2026-10-10T20:04:09.918Z" }, + { url = "https://files.pythonhosted.org/packages/eb/9f/b799dfdce4e05e80ed4bc815c71ff343a11533b2c0ffc221cae8538cda63/numpy-2.5.4-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:a813ed7719bf45463c51779e6a98d0385fe905e48447526938a4b8337333d551", size = 15753763, upload-time = "2026-10-10T20:04:12.278Z" }, + { url = "https://files.pythonhosted.org/packages/34/88/16c5f12f86f5ad2817c4d103205131fc6c8acb3d1878af05a1a4f23ec859/numpy-2.5.4-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c9b80cdf5cedba0e90d93fa5f9a333c4d65bd545cd669b71bb97ce2b703c9d73", size = 16757212, upload-time = "2026-10-10T20:04:14.799Z" }, + { url = "https://files.pythonhosted.org/packages/ff/4f/a1fe40e18a898e6a5089f4f0d891f0a493eb0574d5b34458f0fbe5aa3e5c/numpy-2.5.4-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:2199ed071f460487c8db2c0e5c0b564494190edb4772fe80f9aad88b2604def5", size = 17116471, upload-time = "2026-10-10T20:04:17.58Z" }, + { url = "https://files.pythonhosted.org/packages/aa/46/e923a11c78e65c1722e7aaad817c06bd591324174b9d28ce5d31eee4d432/numpy-2.5.4-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:64f9c9878c1938476365e11ccfb6b770f3b9e5f045ccddc514235041e6959365", size = 18524063, upload-time = "2026-10-10T20:04:20.365Z" }, + { url = "https://files.pythonhosted.org/packages/5a/fa/84ab064514440c1f64a1b21088f2c82756defdd05e07c75ab233899565b2/numpy-2.5.4-cp314-cp314t-win32.whl", hash = "sha256:64d1c8ac28a4077cf987e0a71a7a0ef7e2df70722f07f0baa42dbb7eb6938647", size = 6340926, upload-time = "2026-10-10T20:04:22.865Z" }, + { url = "https://files.pythonhosted.org/packages/7e/7e/6cd886876f435b10685db9b9f7eeb70356f99e052116f4e5f11c5792c714/numpy-2.5.4-cp314-cp314t-win_amd64.whl", hash = "sha256:067374eb538c34c745436365cf7b0112595c1d326f21ce4ff340f61230239fbb", size = 12901584, upload-time = "2026-10-10T20:04:24.99Z" }, + { url = "https://files.pythonhosted.org/packages/38/1b/3c1684f6a06f7307f2335fca6e486cb162847fb97e91d65f8eb5cabad213/numpy-2.5.4-cp314-cp314t-win_arm64.whl", hash = "sha256:e94aef2c639da4a960ad0db8e06471208d8589974953d78b61d345b4eb99e394", size = 10891152, upload-time = "2026-10-10T20:04:27.52Z" }, +] + +[[package]] +name = "openapi-schema-validator" +version = "0.6.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "jsonschema" }, + { name = "jsonschema-specifications" }, + { name = "rfc3339-validator" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/8b/f3/5507ad3325169347cd8ced61c232ff3df70e2b250c49f0fe140edb4973c6/openapi_schema_validator-0.6.3.tar.gz", hash = "sha256:f37bace4fc2a5d96692f4f8b31dc0f8d7400fd04f3a937798eaf880d425de6ee", size = 11550, upload-time = "2025-01-10T18:08:22.268Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/21/c6/ad0fba32775ae749016829dace42ed80f4407b171da41313d1a3a5f102e4/openapi_schema_validator-0.6.3-py3-none-any.whl", hash = "sha256:f3b9870f4e556b5a62a1c39da72a6b4b16f3ad9c73dc80084b1b11e74ba148a3", size = 8755, upload-time = "2025-01-10T18:08:19.758Z" }, +] + +[[package]] +name = "openapi-spec-validator" +version = "0.7.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "jsonschema" }, + { name = "jsonschema-path" }, + { name = "lazy-object-proxy" }, + { name = "openapi-schema-validator" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/82/af/fe2d7618d6eae6fb3a82766a44ed87cd8d6d82b4564ed1c7cfb0f6378e91/openapi_spec_validator-0.7.2.tar.gz", hash = "sha256:cc029309b5c5dbc7859df0372d55e9d1ff43e96d678b9ba087f7c56fc586f734", size = 36855, upload-time = "2025-06-07T14:48:56.299Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/27/dd/b3fd642260cb17532f66cc1e8250f3507d1e580483e209dc1e9d13bd980d/openapi_spec_validator-0.7.2-py3-none-any.whl", hash = "sha256:4bbdc0894ec85f1d1bea1d6d9c8b2c3c8d7ccaa13577ef40da9c006c9fd0eb60", size = 39713, upload-time = "2025-06-07T14:48:54.077Z" }, +] + +[[package]] +name = "opentelemetry-api" +version = "1.45.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/19/14/cf3a6b6448849656e1e5f4e2101f3988dc6789724050096aba1bc5ccf592/opentelemetry_api-1.45.2.tar.gz", hash = "sha256:d7b0008e21e5fd61cbe7a7f34ca3b6905a78ab677d9bc395e299359c75cda6b4", size = 73277, upload-time = "2026-10-29T17:29:37.888Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a9/2d/610db864d7513158cebb8f36cc88e67e73bd6c7aa1905ef18d89e1281c81/opentelemetry_api-1.45.2-py3-none-any.whl", hash = "sha256:2cbd737377e710ee740d261c94e93fa0f08e6d037c18f17513cc0a2d94479a34", size = 60335, upload-time = "2026-10-29T17:29:06.955Z" }, +] + +[[package]] +name = "opentelemetry-exporter-http-transport" +version = "0.66b2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "opentelemetry-api" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a6/e6/dbeb3e217418071656232a4028c791060d219f218cef1249b664049d12c0/opentelemetry_exporter_http_transport-0.66b2.tar.gz", hash = "sha256:66d6ed810a515432c8891da9a834464332fd70badeca45bdeeae81b4280c903b", size = 11693, upload-time = "2026-10-29T17:29:39.444Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a1/b2/c622a101f31c0e6670b82f4264c4e77c161bce415bc6fc158fda0b82e218/opentelemetry_exporter_http_transport-0.66b2-py3-none-any.whl", hash = "sha256:fd5f5b490c099acda1cd7b909d5e8981436bf18cc8c6098d302d114c271720e9", size = 12154, upload-time = "2026-10-29T17:29:10.244Z" }, +] + +[package.optional-dependencies] +requests = [ + { name = "requests" }, +] + +[[package]] +name = "opentelemetry-exporter-otlp-common" +version = "0.66b2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "opentelemetry-sdk" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/5a/3c/3f2cc8c42bde2620e65024d71e2eb025f7bd0821bb363b52bcc5a3260dbd/opentelemetry_exporter_otlp_common-0.66b2.tar.gz", hash = "sha256:06f5a9b88638e310efa1f1d206cdf6b75393e112aba4e174a963416192bd1028", size = 14325, upload-time = "2026-10-29T17:29:41.701Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a8/47/b3049e30b339c82e3c7ec1fc692185a5d5a3ba65a94c570bb39b2c0b8424/opentelemetry_exporter_otlp_common-0.66b2-py3-none-any.whl", hash = "sha256:ace86efb75489f925f1ef809856ae5f0c7db534e4afdc624530222228b1236a5", size = 12385, upload-time = "2026-10-29T17:29:13.667Z" }, +] + +[[package]] +name = "opentelemetry-exporter-otlp-proto-common" +version = "1.45.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "opentelemetry-proto" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/69/58/239c98b36d9ea317098769957043c251703636a26189c884fba46c1dad84/opentelemetry_exporter_otlp_proto_common-1.45.2.tar.gz", hash = "sha256:f1f2806f3f28ce7938033823e50934fcd91595a39de38e69a28a51e19f40fc6d", size = 18873, upload-time = "2026-10-29T17:29:44.496Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e6/d6/0f30d38120a949aef70528f845bf539f80df62abb4b8e62fdf69c2b6df5a/opentelemetry_exporter_otlp_proto_common-1.45.2-py3-none-any.whl", hash = "sha256:af483b24217028892f017096731b794b196b785025d2e6808874720fd0b05a80", size = 15392, upload-time = "2026-10-29T17:29:17.913Z" }, +] + +[[package]] +name = "opentelemetry-exporter-otlp-proto-http" +version = "1.45.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "googleapis-common-protos" }, + { name = "opentelemetry-api" }, + { name = "opentelemetry-exporter-http-transport", extra = ["requests"] }, + { name = "opentelemetry-exporter-otlp-common" }, + { name = "opentelemetry-exporter-otlp-proto-common" }, + { name = "opentelemetry-proto" }, + { name = "opentelemetry-sdk" }, + { name = "requests" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/db/07/b7b01ecb69d02f540e679a9e36f7413d081f225bbbed4469d212ada10bb7/opentelemetry_exporter_otlp_proto_http-1.45.2.tar.gz", hash = "sha256:5984a3fb46bc4628e4e2b85d4a6e72637e03962aae6cf372791137768a4ad939", size = 28843, upload-time = "2026-10-29T17:29:46.15Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/32/65/f64d7d2450217e2989714e1dee15e19bf79a77a313387abac0cac77bc10e/opentelemetry_exporter_otlp_proto_http-1.45.2-py3-none-any.whl", hash = "sha256:6e4d025138829d0ee57946930c2ccad6491ad4d92a958e9c7eea69278fe60cfc", size = 22180, upload-time = "2026-10-29T17:29:20.154Z" }, +] + +[[package]] +name = "opentelemetry-proto" +version = "1.45.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "protobuf" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/24/9c/1aa4ce60e9bc72af20dc49c92cc0566825092d92b3d6a277439fb5fb7c01/opentelemetry_proto-1.45.2.tar.gz", hash = "sha256:bd8d23cf770605b0af9b7be2071d26a464fea289d35429abfd2a66226114ad64", size = 46486, upload-time = "2026-10-29T17:29:53.007Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7e/0d/a0b8f2b9efe2ec1abdf639d3696db9b1563ebeb11d91aac08ba7341e9122/opentelemetry_proto-1.45.2-py3-none-any.whl", hash = "sha256:03a7ca1b43f89fd5b965d5975902bb2515c0c86e2428b456836e9a6149c6235a", size = 72484, upload-time = "2026-10-29T17:29:31.403Z" }, +] + +[[package]] +name = "opentelemetry-sdk" +version = "1.45.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "opentelemetry-api" }, + { name = "opentelemetry-semantic-conventions" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/7b/1a/74a21d4d6969fb8b432ac397e66112a8167a6deb267ea4559dbaf2fe91ef/opentelemetry_sdk-1.45.2.tar.gz", hash = "sha256:7eec4de13dd21ff3a1670dcb0e02079e692736f94d733dfdce5af461d884248d", size = 221705, upload-time = "2026-10-29T17:29:54.685Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9f/a5/9a3b793ef48245f2336a16beb2324c2397dbb3f987cd68942f77cca06156/opentelemetry_sdk-1.45.2-py3-none-any.whl", hash = "sha256:ff974ea70ee4f1d51e2ec152db37c2b626c7bf82bb3f7d86114fd8704e7199c6", size = 141756, upload-time = "2026-10-29T17:29:33.722Z" }, +] + +[[package]] +name = "opentelemetry-semantic-conventions" +version = "0.66b2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "opentelemetry-api" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/37/3f/50f95972b50e8e353f5b9342034c9cd17730f1956f009ce6a3fbbd89f9ce/opentelemetry_semantic_conventions-0.66b2.tar.gz", hash = "sha256:7da5f1a5dc4383eb66711d4d3d3e71824d9403ac1559fea021cc103c1a4c4976", size = 150246, upload-time = "2026-10-29T17:29:55.682Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/67/bd/6bf33ed31521c565931c037e9e81bac47c1acb000e850c6e24220e2a0c00/opentelemetry_semantic_conventions-0.66b2-py3-none-any.whl", hash = "sha256:4cbe61e5f9275d57ab31708446e7938ef4291ebbe6a7fca6f7a629c5acae87d8", size = 206280, upload-time = "2026-10-29T17:29:35.062Z" }, +] + +[[package]] +name = "packageurl-python" +version = "0.17.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f5/d6/3b5a4e3cfaef7a53869a26ceb034d1ff5e5c27c814ce77260a96d50ab7bb/packageurl_python-0.17.6.tar.gz", hash = "sha256:1252ce3a102372ca6f86eb968e16f9014c4ba511c5c37d95a7f023e2ca6e5c25", size = 50618, upload-time = "2025-11-24T15:20:17.998Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b1/2f/c7277b7615a93f51b5fbc1eacfc1b75e8103370e786fd8ce2abf6e5c04ab/packageurl_python-0.17.6-py3-none-any.whl", hash = "sha256:31a85c2717bc41dd818f3c62908685ff9eebcb68588213745b14a6ee9e7df7c9", size = 36776, upload-time = "2025-11-24T15:20:16.962Z" }, +] + +[[package]] +name = "packaging" +version = "26.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7d/fa/3944b40b07da9ce895c0e6303a5ab7d53da063554f534556b134a54d6093/packaging-26.3.tar.gz", hash = "sha256:94edc256424af38762eb31306eed28beb9f0efc50a8837492c9d6fd6004aed79", size = 313412, upload-time = "2026-08-04T18:15:28.737Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/63/34/ba1c580383c9eada3711951fef0795c80b829a078d72188184bcab9dd527/packaging-26.3-py3-none-any.whl", hash = "sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c", size = 129956, upload-time = "2026-08-04T18:15:27.159Z" }, +] + +[[package]] +name = "pathable" +version = "0.4.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/67/93/8f2c2075b180c12c1e9f6a09d1a985bc2036906b13dff1d8917e395f2048/pathable-0.4.4.tar.gz", hash = "sha256:6905a3cd17804edfac7875b5f6c9142a218c7caef78693c2dbbbfbac186d88b2", size = 8124, upload-time = "2025-01-10T18:43:13.247Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7d/eb/b6260b31b1a96386c0a880edebe26f89669098acea8e0318bff6adb378fd/pathable-0.4.4-py3-none-any.whl", hash = "sha256:5ae9e94793b6ef5a4cbe0a7ce9dbbefc1eec38df253763fd0aeeacf2762dbbc2", size = 9592, upload-time = "2025-01-10T18:43:11.88Z" }, +] + +[[package]] +name = "pillow" +version = "13.0.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ce/a4/9cc30690a394a8305e8be4c9036aa16d0dfddadd09079860b582f562496d/pillow-13.0.0.tar.gz", hash = "sha256:cdcd1ba258178f7356d74170c9a81ba4eab6a5d55748bc402a5a2a6fe6be3510", size = 47058631, upload-time = "2026-10-16T22:18:09.718Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8e/45/fbad9c7f5e2f1745c373a434d46072bc84eddfefaa28b852425ac957fda6/pillow-13.0.0-cp314-cp314-ios_13_0_arm64_iphoneos.whl", hash = "sha256:44629d4498c9cb6b2051806155f22141df0d8a929c56134b166655232dfb2f8c", size = 4190721, upload-time = "2026-10-16T22:16:27.524Z" }, + { url = "https://files.pythonhosted.org/packages/a2/bf/2074902a259a90692c5dbf132885d21671644cbbd3f690047516243a55db/pillow-13.0.0-cp314-cp314-ios_13_0_arm64_iphonesimulator.whl", hash = "sha256:bf97ba1b5542050e9b0c74e632323b6d8136cc99d64e193abebee22fe6013c76", size = 4290236, upload-time = "2026-10-16T22:16:29.562Z" }, + { url = "https://files.pythonhosted.org/packages/ff/a5/3d1bb93b8ea38d15d21356c1b8e9f50971ac592aaa248f7fb71739094c0e/pillow-13.0.0-cp314-cp314-ios_13_0_x86_64_iphonesimulator.whl", hash = "sha256:aa694c49787040943570d61c9b8fc01271bd2a2cfdd55f0d896f8aecdce1a981", size = 3723093, upload-time = "2026-10-16T22:16:31.249Z" }, + { url = "https://files.pythonhosted.org/packages/84/a1/be060135d85187b25fa8b2573786c0e45c62ae27527fff5257675eb97f4a/pillow-13.0.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:49c12af515073e9bf511e4ef736743bf70d531a643668722279314b937742ba4", size = 5572253, upload-time = "2026-10-16T22:16:33.103Z" }, + { url = "https://files.pythonhosted.org/packages/b5/f4/0bf6f1ac9ba7ee2ffe9914aeb410a1035a0c1a3c42f122388d7fc950bc4b/pillow-13.0.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:d9b0a2bee3f3e03e9f29057aedb807dbf1e1d96ee1b9d0f422d9db6c8583271d", size = 4852269, upload-time = "2026-10-16T22:16:35.102Z" }, + { url = "https://files.pythonhosted.org/packages/83/16/b603274617b3e6728da3a0133d4fba1ea8d7fbe0c4ea5fef9cbffa398b8b/pillow-13.0.0-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5933fcea5a5ba64c686f55c886a115cbfd92f2900460784a1e79909fdbafd7b6", size = 6516058, upload-time = "2026-10-16T22:16:37.228Z" }, + { url = "https://files.pythonhosted.org/packages/1d/f2/1371707ce438ba9a43f9d24089828494ec6f9396e28cd7903aa704dd6306/pillow-13.0.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:e91c2b1cbeae768c98752e67e717e283d68dae45717b41f2d91eaee648e37b7d", size = 7142574, upload-time = "2026-10-16T22:16:39.172Z" }, + { url = "https://files.pythonhosted.org/packages/b9/a9/62cf68587f910bc87c5951bcb6e9430c7643a65076adf5f18b4bf350e2bd/pillow-13.0.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7f6299e494e46253d40c34653cac369412f44ca53b5f85d848d3f95b1ed0546c", size = 6614295, upload-time = "2026-10-16T22:16:41.117Z" }, + { url = "https://files.pythonhosted.org/packages/6c/c9/9e9b48178649730299be0bafbf5f810a5b6977538f5a92d47e4ba5f5d608/pillow-13.0.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:f9bd7d260d986f3553518c5d723544346fa48031f8aef3265d786aeb59845bc0", size = 7224841, upload-time = "2026-10-16T22:16:43.118Z" }, + { url = "https://files.pythonhosted.org/packages/8f/48/c44e91384b1b6c072a714a63d00608acc16a6a968735e478e4be4384e5ac/pillow-13.0.0-cp314-cp314-win32.whl", hash = "sha256:2e31c4e68cffd7b1f116127626813b82fcba19edf6b940a7b0c266d6484d0055", size = 6508694, upload-time = "2026-10-16T22:16:45.883Z" }, + { url = "https://files.pythonhosted.org/packages/50/e2/7ad17747517e4c813dca78257d6bb593466f8231baf1384bc98d92745edb/pillow-13.0.0-cp314-cp314-win_amd64.whl", hash = "sha256:f7cbb7a64e7ec664775195e4f81923bc8a93d9451b963f844e59118f63147a7a", size = 7281830, upload-time = "2026-10-16T22:16:47.725Z" }, + { url = "https://files.pythonhosted.org/packages/41/9f/e5b51f2ce8ef4563215334035403ce61a244f93a2e65c24a940131618f87/pillow-13.0.0-cp314-cp314-win_arm64.whl", hash = "sha256:a6aaa7871aebca081eb5c45f83e845bbd9712ae99fa9286dbfdcee835e63f4b4", size = 2695468, upload-time = "2026-10-16T22:16:49.515Z" }, + { url = "https://files.pythonhosted.org/packages/97/73/a53502f731f6c84805a4ce87a8881e86d07a65aee64728b900d112dc703e/pillow-13.0.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:7b999816b5850a35ada08443e6e03945f1f6488144a83afe2d37b240a552aafa", size = 5578196, upload-time = "2026-10-16T22:16:51.291Z" }, + { url = "https://files.pythonhosted.org/packages/21/50/7e949959a56b5559c78ef172b70fc6025706acb289f3f648a15329e4fa6f/pillow-13.0.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:67871a13cf47275201553b536c025da777f997fa562a19eb798af4ad4b97c18f", size = 4857276, upload-time = "2026-10-16T22:16:53.399Z" }, + { url = "https://files.pythonhosted.org/packages/c9/52/43ded0ac08e77e39d17bd6d894162572201b5e8fdc4a022b14c55a1960a4/pillow-13.0.0-cp314-cp314t-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:e8ca8f69b7c77fa96dad99f8638c1fc4f1c0bed4acaa1baf7a3c31bdb80a0ab1", size = 6607008, upload-time = "2026-10-16T22:16:55.525Z" }, + { url = "https://files.pythonhosted.org/packages/0d/2e/4a57ed216d5bf877387cba4d44c02aa87abe51ad2e06404aa6b597c4da39/pillow-13.0.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6bce6a29c3898191f4c9998e4d4e8f69790caeabde46e54da4bc235ce5bde683", size = 7224281, upload-time = "2026-10-16T22:16:57.738Z" }, + { url = "https://files.pythonhosted.org/packages/5c/3d/2929b248e135752d63aaeabf53f6de797e905b7b6263f9c1e2adade20aba/pillow-13.0.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:816752a5ef76a80484c8c441c85593b7ea9304f6231fc5776ad1fbff7e773058", size = 6695600, upload-time = "2026-10-16T22:16:59.842Z" }, + { url = "https://files.pythonhosted.org/packages/bc/33/fb0da992cf084ed1ee6ee05e96b6191e35c351eb707ca2df874feb24ce47/pillow-13.0.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:5bdb38ba220b61b4ec31dd1046dea6b016d3c6850a23f43ed8b58332b2fc668e", size = 7300589, upload-time = "2026-10-16T22:17:01.686Z" }, + { url = "https://files.pythonhosted.org/packages/bb/af/c30dd9ef6a3dce84ecb1b2393cac629047a32e66279056c6cb46c3ffd65c/pillow-13.0.0-cp314-cp314t-win32.whl", hash = "sha256:06903aac074d00c988e77a1fc435286dc498506d4ca8d6f69df9babddf4ecc15", size = 6517204, upload-time = "2026-10-16T22:17:03.722Z" }, + { url = "https://files.pythonhosted.org/packages/85/d5/ef3a8ae7609c8ab26570abf18194882534b480d245a9148b895a2262c004/pillow-13.0.0-cp314-cp314t-win_amd64.whl", hash = "sha256:9a635068d9793c7f0d929f39f18b58f1bd86c236e8e7b64167b86af9232ebca0", size = 7286695, upload-time = "2026-10-16T22:17:05.543Z" }, + { url = "https://files.pythonhosted.org/packages/84/3c/0861db0c69a03689ebe3e7599d35668a414deb5aaafd8255215e4e62e3d3/pillow-13.0.0-cp314-cp314t-win_arm64.whl", hash = "sha256:0d1a9cf7bc6917538b20f8d06b9ab2147e542f68849e96fc58eb66bdf6acc692", size = 2698098, upload-time = "2026-10-16T22:17:07.674Z" }, +] + +[[package]] +name = "pip" +version = "26.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/53/c7/f8d9e2e0e7c1ed8a22a10eeb3b5bf7860bc07d8446c7a978a882c5c8214b/pip-26.3.tar.gz", hash = "sha256:6c36ae7da8695be67e3cd9f7d87919667ced53f57ce2ede75d89b5912ed2bc4c", size = 1934348, upload-time = "2026-11-02T20:34:27.738Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/07/25/ee8c38ae72d66b844ce8eb9711ba905dba21ca1a8a0c960057c41cd23337/pip-26.3-py3-none-any.whl", hash = "sha256:f3b60b20ffaadd4415ed7957212a38ac63fa4c5fa375bd0f4a797777940fad13", size = 1950951, upload-time = "2026-11-02T20:34:25.728Z" }, +] + +[[package]] +name = "pip-api" +version = "0.0.35" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pip" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/fc/08/47dfc28aa16ef0dbc38dd7c6e4fe24d124c3ed3a722a4a3e5021584a588c/pip_api-0.0.35.tar.gz", hash = "sha256:14dea05d7b3b68f4c7582213e3ae8932bbba8e1f754bf06b95263d5fa6ab4363", size = 123884, upload-time = "2026-09-08T19:35:12.876Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1d/2e/d424c5b5877be862dd9a2c8b7e9ddb13382bb25e132e6dd50cc09c0a7dde/pip_api-0.0.35-py3-none-any.whl", hash = "sha256:66990d0da25378555cbb538db79384bab92d4617c6350dfd7a2126ba2a3a9894", size = 123943, upload-time = "2026-09-08T19:35:11.537Z" }, +] + +[[package]] +name = "pip-audit" +version = "2.10.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "cachecontrol", extra = ["filecache"] }, + { name = "cyclonedx-python-lib" }, + { name = "packaging" }, + { name = "pip-api" }, + { name = "pip-requirements-parser" }, + { name = "platformdirs" }, + { name = "requests" }, + { name = "rich" }, + { name = "tomli" }, + { name = "tomli-w" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/66/a4/f21d5f0a0edabcbce31560b73c7c5a6f72ae87af4236fd1069c8f59a353d/pip_audit-2.10.1.tar.gz", hash = "sha256:1eb4565d19ebe5d48996f4b770b4d2b32887e12cb12cfa637f1a064011b55ffc", size = 54275, upload-time = "2026-06-10T22:17:01.744Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a3/a7/b0c504148114047bd1bc9d97447453c6850ca176bb2f3c0038835994e8b7/pip_audit-2.10.1-py3-none-any.whl", hash = "sha256:99ef3f600a317c1945f1e89e227ef26e1c2d618429b8bd3fa6f4f7c440c4611a", size = 62023, upload-time = "2026-06-10T22:17:00.309Z" }, +] + +[[package]] +name = "pip-requirements-parser" +version = "32.0.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "packaging" }, + { name = "pyparsing" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/5e/2a/63b574101850e7f7b306ddbdb02cb294380d37948140eecd468fae392b54/pip-requirements-parser-32.0.1.tar.gz", hash = "sha256:b4fa3a7a0be38243123cf9d1f3518da10c51bdb165a2b2985566247f9155a7d3", size = 209359, upload-time = "2022-12-21T15:25:22.732Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/54/d0/d04f1d1e064ac901439699ee097f58688caadea42498ec9c4b4ad2ef84ab/pip_requirements_parser-32.0.1-py3-none-any.whl", hash = "sha256:4659bc2a667783e7a15d190f6fccf8b2486685b6dba4c19c3876314769c57526", size = 35648, upload-time = "2022-12-21T15:25:21.046Z" }, +] + +[[package]] +name = "platformdirs" +version = "4.14.8" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/71/18/0b0d99f5bf164f04a7a9534c3dbdbe4d5fd2b382667685ad40c192c4d3d1/platformdirs-4.14.8.tar.gz", hash = "sha256:96893d686e84e9e6f358a9ea41a8de544df66dbf2ba6cda250e7dc73acf85b9b", size = 87203, upload-time = "2026-11-20T08:14:52.63Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/5b/be/373cc7341f53bfd3acba3e5db62433fd960a45fcf73ad64a5f4d27e74910/platformdirs-4.14.8-py3-none-any.whl", hash = "sha256:1e34af590de4d978631b751eb2202f2fee4497537a17c1720b12fcf57b331392", size = 94267, upload-time = "2026-11-20T08:14:51.306Z" }, +] + +[[package]] +name = "pluggy" +version = "1.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/bf/db/7fc19e6f2dc92a966727031389fc2e08b558f0f25eb7403c1119ad4713cd/pluggy-1.7.0.tar.gz", hash = "sha256:d1eaa46ebb595891b860ab086b4d09c8588af65ebd4361b8e8f4bb8920b90ba8", size = 123304, upload-time = "2026-10-15T09:50:58.343Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/40/9e/2b38731e0fc536806f16490e1a12d7f0dc2a1235aa8cc07bcc75416a7daa/pluggy-1.7.0-py3-none-any.whl", hash = "sha256:7dd7b0d8832ba3cb632c306926ded123429211b83641b35dc5c41ad2d34f9bec", size = 27082, upload-time = "2026-10-15T09:50:56.808Z" }, +] + +[[package]] +name = "protobuf" +version = "7.36.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d9/89/5b8517baa72f84a67b8a307ba953c91057af618bf40bf676f3c03551f8f0/protobuf-7.36.2.tar.gz", hash = "sha256:497d0463ff3316681da6c0b9e8d06cb465d61abce00b613ab42226175644d1bb", size = 512737, upload-time = "2026-09-17T20:07:59.326Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/32/72/98342feb672507c8f3a69e34b4fa8961f608edba5c1a48a6f47156d92cb5/protobuf-7.36.2-cp310-abi3-macosx_10_9_universal2.whl", hash = "sha256:cbc70b17ee27e28894c7fee8bb04be1abead49e936bc70eb60052531eee2079e", size = 456039, upload-time = "2026-09-17T20:07:51.542Z" }, + { url = "https://files.pythonhosted.org/packages/b6/ea/91fdf7c2b8bbd49cde056f00a9df6773532987e1c00fe2830b895af95c7e/protobuf-7.36.2-cp310-abi3-manylinux2014_aarch64.whl", hash = "sha256:e11e1f0180583a2af89db6a2ecd9e8dc40aa6d2988ca175bfd0e6d12ea72d74e", size = 344219, upload-time = "2026-09-17T20:07:52.914Z" }, + { url = "https://files.pythonhosted.org/packages/17/ab/5fd5f8ece73fad885c5a09aa849b32d70472f954ba3a92d3bb5974ea953b/protobuf-7.36.2-cp310-abi3-manylinux2014_s390x.whl", hash = "sha256:f4fee11ec330d238b34a05c9b675f693c20415d1c5bd7d5320cc2f8a798eb9cf", size = 357223, upload-time = "2026-09-17T20:07:53.985Z" }, + { url = "https://files.pythonhosted.org/packages/db/f3/3996583dd2906297a637af12114deddf7658af6e683fedb83be061983fb5/protobuf-7.36.2-cp310-abi3-manylinux2014_x86_64.whl", hash = "sha256:89f23aa53c24553a2416fd4fd1ec06f74fa42b14b546d8883128813f775bbfd2", size = 343223, upload-time = "2026-09-17T20:07:54.931Z" }, + { url = "https://files.pythonhosted.org/packages/fc/1b/dcc64f358fcb51811b58ae40b3d28f820725f116d86487cc20bd4b130701/protobuf-7.36.2-cp310-abi3-win32.whl", hash = "sha256:912c1221170e16c08d1f086762f563dd61ff83c18b5fa6652952dfaded66f728", size = 442998, upload-time = "2026-09-17T20:07:55.826Z" }, + { url = "https://files.pythonhosted.org/packages/8a/55/b77bda4e5e5f5971fb51b07663694690e9afdb9402136c16a522bd621cad/protobuf-7.36.2-cp310-abi3-win_amd64.whl", hash = "sha256:a300819d441e078a5608c0d3c709796bb548136058fda017ae51d425b44fd353", size = 456514, upload-time = "2026-09-17T20:07:57.188Z" }, + { url = "https://files.pythonhosted.org/packages/e4/04/d52c7016b04b6c5108f26691f9d33ec82a9b65d041f1a9c771137693d618/protobuf-7.36.2-py3-none-any.whl", hash = "sha256:bdb3a345d48db958e6ce1f18e508beb0cc981d64f24088427549c866cd039f1e", size = 179806, upload-time = "2026-09-17T20:07:58.211Z" }, +] + +[[package]] +name = "psutil" +version = "7.1.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e1/88/bdd0a41e5857d5d703287598cbf08dad90aed56774ea52ae071bae9071b6/psutil-7.1.3.tar.gz", hash = "sha256:6c86281738d77335af7aec228328e944b30930899ea760ecf33a4dba66be5e74", size = 489059, upload-time = "2025-11-02T12:25:54.619Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2e/bb/6670bded3e3236eb4287c7bcdc167e9fae6e1e9286e437f7111caed2f909/psutil-7.1.3-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:b403da1df4d6d43973dc004d19cee3b848e998ae3154cc8097d139b77156c353", size = 239843, upload-time = "2025-11-02T12:26:11.968Z" }, + { url = "https://files.pythonhosted.org/packages/b8/66/853d50e75a38c9a7370ddbeefabdd3d3116b9c31ef94dc92c6729bc36bec/psutil-7.1.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:ad81425efc5e75da3f39b3e636293360ad8d0b49bed7df824c79764fb4ba9b8b", size = 240369, upload-time = "2025-11-02T12:26:14.358Z" }, + { url = "https://files.pythonhosted.org/packages/41/bd/313aba97cb5bfb26916dc29cf0646cbe4dd6a89ca69e8c6edce654876d39/psutil-7.1.3-cp314-cp314t-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:8f33a3702e167783a9213db10ad29650ebf383946e91bc77f28a5eb083496bc9", size = 288210, upload-time = "2025-11-02T12:26:16.699Z" }, + { url = "https://files.pythonhosted.org/packages/c2/fa/76e3c06e760927a0cfb5705eb38164254de34e9bd86db656d4dbaa228b04/psutil-7.1.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:fac9cd332c67f4422504297889da5ab7e05fd11e3c4392140f7370f4208ded1f", size = 291182, upload-time = "2025-11-02T12:26:18.848Z" }, + { url = "https://files.pythonhosted.org/packages/0f/1d/5774a91607035ee5078b8fd747686ebec28a962f178712de100d00b78a32/psutil-7.1.3-cp314-cp314t-win_amd64.whl", hash = "sha256:3792983e23b69843aea49c8f5b8f115572c5ab64c153bada5270086a2123c7e7", size = 250466, upload-time = "2025-11-02T12:26:21.183Z" }, + { url = "https://files.pythonhosted.org/packages/00/ca/e426584bacb43a5cb1ac91fae1937f478cd8fbe5e4ff96574e698a2c77cd/psutil-7.1.3-cp314-cp314t-win_arm64.whl", hash = "sha256:31d77fcedb7529f27bb3a0472bea9334349f9a04160e8e6e5020f22c59893264", size = 245756, upload-time = "2025-11-02T12:26:23.148Z" }, + { url = "https://files.pythonhosted.org/packages/ef/94/46b9154a800253e7ecff5aaacdf8ebf43db99de4a2dfa18575b02548654e/psutil-7.1.3-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:2bdbcd0e58ca14996a42adf3621a6244f1bb2e2e528886959c72cf1e326677ab", size = 238359, upload-time = "2025-11-02T12:26:25.284Z" }, + { url = "https://files.pythonhosted.org/packages/68/3a/9f93cff5c025029a36d9a92fef47220ab4692ee7f2be0fba9f92813d0cb8/psutil-7.1.3-cp36-abi3-macosx_11_0_arm64.whl", hash = "sha256:bc31fa00f1fbc3c3802141eede66f3a2d51d89716a194bf2cd6fc68310a19880", size = 239171, upload-time = "2025-11-02T12:26:27.23Z" }, + { url = "https://files.pythonhosted.org/packages/ce/b1/5f49af514f76431ba4eea935b8ad3725cdeb397e9245ab919dbc1d1dc20f/psutil-7.1.3-cp36-abi3-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:3bb428f9f05c1225a558f53e30ccbad9930b11c3fc206836242de1091d3e7dd3", size = 263261, upload-time = "2025-11-02T12:26:29.48Z" }, + { url = "https://files.pythonhosted.org/packages/e0/95/992c8816a74016eb095e73585d747e0a8ea21a061ed3689474fabb29a395/psutil-7.1.3-cp36-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:56d974e02ca2c8eb4812c3f76c30e28836fffc311d55d979f1465c1feeb2b68b", size = 264635, upload-time = "2025-11-02T12:26:31.74Z" }, + { url = "https://files.pythonhosted.org/packages/55/4c/c3ed1a622b6ae2fd3c945a366e64eb35247a31e4db16cf5095e269e8eb3c/psutil-7.1.3-cp37-abi3-win_amd64.whl", hash = "sha256:f39c2c19fe824b47484b96f9692932248a54c43799a84282cfe58d05a6449efd", size = 247633, upload-time = "2025-11-02T12:26:33.887Z" }, + { url = "https://files.pythonhosted.org/packages/c9/ad/33b2ccec09bf96c2b2ef3f9a6f66baac8253d7565d8839e024a6b905d45d/psutil-7.1.3-cp37-abi3-win_arm64.whl", hash = "sha256:bd0d69cee829226a761e92f28140bec9a5ee9d5b4fb4b0cc589068dbfff559b1", size = 244608, upload-time = "2025-11-02T12:26:36.136Z" }, +] + +[[package]] +name = "psycopg" +version = "3.3.6" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "tzdata", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/76/26/3ea4ca5eaea1c0debcdf7ee7c1613fbe721dc27a03c461c0817ffd8a0601/psycopg-3.3.6.tar.gz", hash = "sha256:c081f2250df751a943036e42db6df4571c66cd0aabe8291a7a506512b12007d2", size = 168171, upload-time = "2026-09-18T13:22:55.152Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4e/de/748bd7609c71cae5d737f0ba9192f19329f70180ecda8fff3cac02c5abe3/psycopg-3.3.6-py3-none-any.whl", hash = "sha256:a1db9f7148b06a28606767efaca51fa6f9398c5c0a3810519be69d7000bdb631", size = 215490, upload-time = "2026-09-18T13:15:29.374Z" }, +] + +[package.optional-dependencies] +binary = [ + { name = "psycopg-binary", marker = "implementation_name != 'pypy'" }, +] +pool = [ + { name = "psycopg-pool" }, +] + +[[package]] +name = "psycopg-binary" +version = "3.3.6" +source = { registry = "https://pypi.org/simple" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6d/b9/60711317c284a442511644ea7185b56ebe627606d6741e732cd16108c47b/psycopg_binary-3.3.6-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:b3f75dee0f9afafabe4edc52c4842f1e1878ed2069bd05b22d6fe961e97e4dba", size = 4720512, upload-time = "2026-09-18T13:20:29.278Z" }, + { url = "https://files.pythonhosted.org/packages/63/da/28befc84454cbc6374550de7746f591f8fe1b6165c1fce249652cc8291c4/psycopg_binary-3.3.6-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:5927b7ba63153cd8e9862987290a2b783a5c590daf2a4ef981700cc3569166d4", size = 4782318, upload-time = "2026-09-18T13:20:35.401Z" }, + { url = "https://files.pythonhosted.org/packages/a4/8a/0d21c2c833cdc0d4244c77e858e0ed37fa2abec2623be4fd686f617109ce/psycopg_binary-3.3.6-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.whl", hash = "sha256:0bf08b749cc144f33b44a91b78e3f71c60eb07963746a0df5a100b36ce3d7475", size = 5567460, upload-time = "2026-09-18T13:20:41.902Z" }, + { url = "https://files.pythonhosted.org/packages/49/6d/7692d0d4e656b6cc9868d8acc2e3b42f17a0db4a625400a6d093cb0533a1/psycopg_binary-3.3.6-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:31cd942c23f613276b81a6e6598cefa12960058b0f46e1e874b540c793f6aca5", size = 5246902, upload-time = "2026-09-18T13:20:47.661Z" }, + { url = "https://files.pythonhosted.org/packages/d4/c1/b8a1f18fb1b7558a17f57f7cb3fc8bc93189feea2958925950b3acb15743/psycopg_binary-3.3.6-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4690cf67738f0e0e49a32aeec99bf0e4595cc2b4f1af984a4345394b1dcff91a", size = 6847192, upload-time = "2026-09-18T13:20:56.874Z" }, + { url = "https://files.pythonhosted.org/packages/a5/76/404f33519167c65cca88ec4998776f1dbebccc301ee977f0e62c47fb0826/psycopg_binary-3.3.6-cp314-cp314-manylinux_2_38_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:ad1c785e784cfd87e8436c6b7702f2d321fc39601bbaf29bc63a41a867091638", size = 5079573, upload-time = "2026-09-18T13:21:04.155Z" }, + { url = "https://files.pythonhosted.org/packages/f0/d9/79e8fbc8f37262a415f3550f0bcc5f98037442bf3d12ef6cbae2056655ae/psycopg_binary-3.3.6-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:79a2a1c3449f6c3409427078ed1cec10de79f3023cb5f2504f0597d350ad46c7", size = 4613633, upload-time = "2026-09-18T13:21:10.664Z" }, + { url = "https://files.pythonhosted.org/packages/d4/47/96225db74be7d2ce04b3a58678b53cda610225055edf5faa775c9f501d8b/psycopg_binary-3.3.6-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:86147cb5d140341c3363fb5bacce31f8d5543902a46699d3c536b101bbceaf9e", size = 4293375, upload-time = "2026-09-18T13:21:16.027Z" }, + { url = "https://files.pythonhosted.org/packages/2a/d2/18e9c779a5efd565250329adaf529ecc2b8b2ed5be5cb0f6ccee208cbfd9/psycopg_binary-3.3.6-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:7308c93cf0b19bbaf8e6ff0a6ad50d3c442385739245fe15a8d593bf841734a6", size = 4019883, upload-time = "2026-09-18T13:21:21.587Z" }, + { url = "https://files.pythonhosted.org/packages/ef/28/0cc654afc6c2cda982767f5679d3646b30b1ec86545bdaa9402202d6776c/psycopg_binary-3.3.6-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:05a83ac9fd52b9bca7cb5ab04b3691163170bd16f53defa27216ea3aa07ee781", size = 4332607, upload-time = "2026-09-18T13:21:27.63Z" }, + { url = "https://files.pythonhosted.org/packages/f1/3e/0a753a74fbd7aef120f286c016e09d3cc3f1daf7688f4a145d27281260b2/psycopg_binary-3.3.6-cp314-cp314-win_amd64.whl", hash = "sha256:1fbd30e537dab22cafdf080608f10148fe2a5f3a61294ddb5113caac8a623840", size = 3755671, upload-time = "2026-09-18T13:21:33.855Z" }, +] + +[[package]] +name = "psycopg-pool" +version = "3.3.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/74/5e/c0664b968b102ff68b811d999c728546c48d5c1eec03e3bbaf88c0cb4472/psycopg_pool-3.3.3.tar.gz", hash = "sha256:df87b5d9d0ad7db37f6cdad4fa8ce113d250f5997f6db38e9a99192fb67f9e1d", size = 32006, upload-time = "2026-09-22T15:53:24.947Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/5d/b4/452c6607a0f479465cd8a9b0d9956919fcb150050c1f83f9f11e6b8ee8dc/psycopg_pool-3.3.3-py3-none-any.whl", hash = "sha256:9b9cd6a4fcec47a410f7e82d408540e7f77b478509e91b44c1a5457a13e5ff37", size = 40304, upload-time = "2026-09-22T15:53:23.712Z" }, +] + +[[package]] +name = "py-serializable" +version = "2.2.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "defusedxml" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/48/8c/cad9596066de835b304be48b0eefa30dae1834afae6e670805831cc05ea2/py_serializable-2.2.0.tar.gz", hash = "sha256:8e4fa02e8de819c0488ccdb69c2d3109274adcf224c02357fd8729cb12727aab", size = 52608, upload-time = "2026-11-06T13:43:39.943Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7e/56/94f6a9ac81193713e6be0d41c62d6b916b53c814c05d8b3a0d90976db0d6/py_serializable-2.2.0-py3-none-any.whl", hash = "sha256:2cce775abc5aac12115f9ff572a145c7276d04a770090334bd4e51ed9c782415", size = 23101, upload-time = "2026-11-06T13:43:38.593Z" }, +] + +[[package]] +name = "pycparser" +version = "3.12" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/cb/27/eeb9f307bf07060f3d9f9aa0fb8c15b01bdfded0a941e4b2719c7f94cacd/pycparser-3.12.tar.gz", hash = "sha256:f03387877eab82ce01bbdfd0ba7252ee55a90b1c708d5129e2ce915475cf1db6", size = 158785, upload-time = "2026-10-22T13:40:03.56Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b6/ae/315bbeee126a769cbde43cf4908acb4b40408d8bf8bbf334dd7368d8dadf/pycparser-3.12-py3-none-any.whl", hash = "sha256:a076f3f489b39b43ed13563a1dafe42447445bec2e294154ec5c57fcdda4c85e", size = 62600, upload-time = "2026-10-22T13:40:02.021Z" }, +] + +[[package]] +name = "pycryptodome" +version = "4.5.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d6/4d/dfbdfacc0579fa4394e3a442f034c2fb41a44d95d21bf9cd85cee89c3df6/pycryptodome-4.5.0.tar.gz", hash = "sha256:51e97a8d1cf101974bc40c20b3191cb1903891e5c172346943d5d4f3bc4f9d83", size = 1863771, upload-time = "2026-11-15T13:03:45.262Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/33/73/d1058461b29c5092cea78316a033918253223d8f64e928ba10b59e72a75b/pycryptodome-4.5.0-cp39-abi3-macosx_10_9_universal2.whl", hash = "sha256:081af2cbd5d85ff282b0f22013b60bd87b7507d87790e0227e42050880adb1d4", size = 1828280, upload-time = "2026-11-15T13:03:07.867Z" }, + { url = "https://files.pythonhosted.org/packages/c1/9d/2f38ba3af1f024adc50eb113d1ff472603756e1e86b73b3c80e2ac958c83/pycryptodome-4.5.0-cp39-abi3-macosx_10_9_x86_64.whl", hash = "sha256:e031a0a430ce1d8a11ef37f2caaf51c5f1c0d9a037db8ffa2753b28a93fc5005", size = 1578107, upload-time = "2026-11-15T13:03:09.607Z" }, + { url = "https://files.pythonhosted.org/packages/e0/7a/47fcebddc746738a5ca6adb7fb0b19ea74188b83aac8ba03011755861742/pycryptodome-4.5.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:04c1b9feaf73db4f6aae714589bdabdf2c3d991b579976e1f734de6de133a099", size = 2591108, upload-time = "2026-11-15T13:03:11.352Z" }, + { url = "https://files.pythonhosted.org/packages/41/2d/e4d8e0ac2e1192c05ac7078fc37aaeb2bd21083af7c0561092ff3268e19f/pycryptodome-4.5.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:3afbe7ecd62357203a588d451c604a61af7d7c9d3f0aa0b792de0612cffb8f8d", size = 3101721, upload-time = "2026-11-15T13:03:13.479Z" }, + { url = "https://files.pythonhosted.org/packages/75/46/e4e348fb1b4bc56704f7696a67f08a39afd7ea6bb751eca858bafbf459b7/pycryptodome-4.5.0-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:38229c875772dea2bbbe46061e2e5573b5810c52cd7bb5a9225f07cb2c9c00a9", size = 2610488, upload-time = "2026-11-15T13:03:15.134Z" }, + { url = "https://files.pythonhosted.org/packages/a5/c5/6cbd9d4394a94a3c0ee2081f3283736ce17df7e11dfc811ee8722a8a8ced/pycryptodome-4.5.0-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:33094d990610bf205f2b841599f514429d9ef61aca40e6c11ff1a08aeef5cbb9", size = 3663825, upload-time = "2026-11-15T13:03:16.913Z" }, + { url = "https://files.pythonhosted.org/packages/5a/ac/e0bf3f1d1bd55041051acb543b7a5f291848c62b3f73f2d3fc5badd753c2/pycryptodome-4.5.0-cp39-abi3-win32.whl", hash = "sha256:0a2f83187938665ffd0b80758d3e26e811d01523ba332495ea82fae0f5ca78d0", size = 1360703, upload-time = "2026-11-15T13:03:18.668Z" }, + { url = "https://files.pythonhosted.org/packages/61/04/471045179e76295f5da06e8d1f167054a360d418a90cd3218ed10f99975f/pycryptodome-4.5.0-cp39-abi3-win_amd64.whl", hash = "sha256:b05fed07d07d69c5205689293c3b71a21b8bb4c6f4bb964d1c2d24dfdf22433d", size = 1731036, upload-time = "2026-11-15T13:03:20.355Z" }, + { url = "https://files.pythonhosted.org/packages/0c/bb/997ee5870f70bc3f6d2c611bc4a74a33f7812347ad29799fdbb6bb93072d/pycryptodome-4.5.0-cp39-abi3-win_arm64.whl", hash = "sha256:ae9ad9b4a49f1fb5299b07fb52bf1f00dbe3df0fdce8dd38b9379e5e0b067f46", size = 1417666, upload-time = "2026-11-15T13:03:21.894Z" }, +] + +[[package]] +name = "pydantic" +version = "2.14.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "annotated-types" }, + { name = "pydantic-core" }, + { name = "typing-extensions" }, + { name = "typing-inspection" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/7c/0b/8e10b2e693af8ec54346a14caf36221334775975a747c9ceaa3f8371d96d/pydantic-2.14.1.tar.gz", hash = "sha256:94f478203dd03404682a1ada216965651dd74b1d2d5ffd62e00e0837caab5c26", size = 900362, upload-time = "2026-10-11T18:37:55.396Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/35/ea/a56b9fe5066f3537b7882f77e9c5dfb26d8c2eefdaed9b5fc73d57b4dc22/pydantic-2.14.1-py3-none-any.whl", hash = "sha256:9195d967ec791692a04438115466764fb8b9a27b31f14a760437694f40d6b454", size = 488106, upload-time = "2026-10-11T18:37:53.437Z" }, +] + +[[package]] +name = "pydantic-core" +version = "2.50.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a6/24/af4ec4be49fbc810f35b0bdcacc3d433b56bbfa469fd3bfd4ae116cd9bf1/pydantic_core-2.50.1.tar.gz", hash = "sha256:e50d7b94baac6c7d09927fa5ca5800a0c7ee5015c7fcff65beb3a1931b5a6e09", size = 513515, upload-time = "2026-10-11T18:35:44.82Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/49/33/28b96e81677153715e3eafb9f26663a80841e859fde282a380359b0d3fa1/pydantic_core-2.50.1-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:1cf41f1ae3fa155cf167a72689ad044bcc1e3c97e064123677149bdfb5dafc4a", size = 2224428, upload-time = "2026-10-11T18:33:07.153Z" }, + { url = "https://files.pythonhosted.org/packages/94/40/15c06410c9b7b8da5805d27b64e09bd3f900e986728106db2689dbc51513/pydantic_core-2.50.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:4df197990c15b5a37c5a277d131d9f2c67de6133f2e5dafd80d9bba4b99f46f9", size = 2023740, upload-time = "2026-10-11T18:33:08.763Z" }, + { url = "https://files.pythonhosted.org/packages/a1/4e/5eb629f6efc2a27e421d789dd4bfacbb5f6d09c80c28b13d1e87d73163d5/pydantic_core-2.50.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0036473f5583e6a60e50b8b21651511564277a3f05cc5dab8cf579f552cd5f6c", size = 2049435, upload-time = "2026-10-11T18:33:10.366Z" }, + { url = "https://files.pythonhosted.org/packages/ba/8e/f195aebec49ad12318876ac2368c197a7939f5d52f8e156d2238ef8a4588/pydantic_core-2.50.1-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:992c3514ec891fa7858099183e4d64e6bd5a5d4ff452fae29df22faa77a006bb", size = 2172975, upload-time = "2026-10-11T18:33:12.368Z" }, + { url = "https://files.pythonhosted.org/packages/e0/f5/7ad9fb83010cd5ea0948409db105676ed779c4e709e2d3d89b9fe2558794/pydantic_core-2.50.1-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:739dc730e6be3bd5ec2f4ab5cfc7eb047cc45fc1497b3bafec74ff2ed07df597", size = 2364197, upload-time = "2026-10-11T18:33:14.244Z" }, + { url = "https://files.pythonhosted.org/packages/ca/fb/bf0aab3e78301d202b82a0322ec968cd703b11fc0623fde9a28708936f62/pydantic_core-2.50.1-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:32fad3a91e51b6d2039c572db04a5a873260b399f6bd62c3552671fa7a4a2899", size = 2444259, upload-time = "2026-10-11T18:33:15.79Z" }, + { url = "https://files.pythonhosted.org/packages/45/35/38f6d6564fae57d9b12e5676dfa947e0e7d5c46dbeaa7eb3352261d6d299/pydantic_core-2.50.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:42b54c2c90ad348b5e3a85e03e715d572c1fde357ef104cdfe3b03b697a404ea", size = 2159857, upload-time = "2026-10-11T18:33:17.51Z" }, + { url = "https://files.pythonhosted.org/packages/65/a0/fb0a3ca10f139dcf765b2d312d10cf0f65c57c59993229d00ad12b14ceff/pydantic_core-2.50.1-cp314-cp314-manylinux_2_31_riscv64.whl", hash = "sha256:2df1ff41884de2bc4b307bafd7c40a691094fad2ff8e767e5b45a319257bcf4e", size = 2233954, upload-time = "2026-10-11T18:33:19.591Z" }, + { url = "https://files.pythonhosted.org/packages/8c/6a/e63842252702aa4ec6e6b7178ca85e541a77459076592c23ebe2d9840b33/pydantic_core-2.50.1-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:fe90228920fd8ff2be62622b6bb8a2b11acd65046d50c6b130614b5879605a20", size = 2243876, upload-time = "2026-10-11T18:33:21.393Z" }, + { url = "https://files.pythonhosted.org/packages/39/25/5991cf8318b37e0dfab47b87541619a1df8501a793cba0d978846cba37a7/pydantic_core-2.50.1-cp314-cp314-musllinux_1_1_aarch64.whl", hash = "sha256:844b869f118e22a41a091bdcedda8a71bc1b0f62c38d1a0c3211cece47e1d8fc", size = 2277908, upload-time = "2026-10-11T18:33:23.324Z" }, + { url = "https://files.pythonhosted.org/packages/a7/3e/3ee8baaa6cc25a6961c69168cf9ff0f002d56f4e0d541ad6724c18fb61f3/pydantic_core-2.50.1-cp314-cp314-musllinux_1_1_armv7l.whl", hash = "sha256:2eb75304506894a281d346220a4f7481a1b8729577c5ed2a05395991966a8396", size = 2449285, upload-time = "2026-10-11T18:33:24.942Z" }, + { url = "https://files.pythonhosted.org/packages/c0/c7/acbec6deac13fe697a80c275a9b6661db62c4d323bac8a47347b1f39c7cd/pydantic_core-2.50.1-cp314-cp314-musllinux_1_1_x86_64.whl", hash = "sha256:6b20a4bffabdad0db2927ac034ae3b8a681b1f7a0182f3e60b479ad2fde21ebb", size = 2479013, upload-time = "2026-10-11T18:33:26.925Z" }, + { url = "https://files.pythonhosted.org/packages/10/08/21a3f237b264389f6219d053ee78fc1b5c2fd402c1b1cb2b6cb8b85f9834/pydantic_core-2.50.1-cp314-cp314-pyemscripten_2026_0_wasm32.whl", hash = "sha256:99ba9bc2b8062ea0c326a990f7f00e6530c23579de66dd246e72c4cafef950a5", size = 1484400, upload-time = "2026-10-11T18:33:28.693Z" }, + { url = "https://files.pythonhosted.org/packages/09/ce/077a6d262d12ef09108377ac0717f029f420d773ace63cafd6143af75568/pydantic_core-2.50.1-cp314-cp314-win32.whl", hash = "sha256:cf356f70551d40374eaffb1aa63f1eb6d2006681cbd7a9faea173ce0f4dd7cd2", size = 2103222, upload-time = "2026-10-11T18:33:30.326Z" }, + { url = "https://files.pythonhosted.org/packages/14/4c/350a2415209c43d670eb71d3c040f332c04a30583d39e311b05c7ac15762/pydantic_core-2.50.1-cp314-cp314-win_amd64.whl", hash = "sha256:d32f3acc081cc3923386d88f422cde8892335e95f034e0104bb4cf9310d9915f", size = 2171586, upload-time = "2026-10-11T18:33:32.139Z" }, + { url = "https://files.pythonhosted.org/packages/bf/92/9bea6ca96580a0902fed366f064f0829e404f41889b34543279a1162b888/pydantic_core-2.50.1-cp314-cp314-win_arm64.whl", hash = "sha256:bed5163e03b98bc1fa2eb05d74c63d9c5c95d8ed6254985481640fbf5e237dea", size = 2155773, upload-time = "2026-10-11T18:33:33.896Z" }, + { url = "https://files.pythonhosted.org/packages/86/8c/f121f073cf32bdd5cba7e6230b1ce0ac845b0cf43e44dd597d95af272db2/pydantic_core-2.50.1-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:9572c1369e9c9da2d64a7b7992c786d90ff295abc93964cfe3125e4290768070", size = 2234017, upload-time = "2026-10-11T18:33:35.588Z" }, + { url = "https://files.pythonhosted.org/packages/a4/69/2bb2bcd6146cffe98d760a46c42ae71efd5151d9b2f9c9bf6619a3b32083/pydantic_core-2.50.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:2005207aafe1231315718bf6ed5d064a7300fb4772754af35ee72fc68159492e", size = 2001016, upload-time = "2026-10-11T18:33:37.57Z" }, + { url = "https://files.pythonhosted.org/packages/20/b3/fbf854c7d07ec114260c26e9e2071a4381740f9ae09641dbfcbdf2a18c45/pydantic_core-2.50.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:64f6047f62a6c5ae08d0a6afb035667aa2d97c3d20d69762e034c5ea144d92a5", size = 2023015, upload-time = "2026-10-11T18:33:39.433Z" }, + { url = "https://files.pythonhosted.org/packages/65/20/6de55b2f92cdb614b745c6e9ced639fc4fd7e1e77604825a88bdece6fcbd/pydantic_core-2.50.1-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:1ef800dd7d85bcdadf4c3076e4c94e43939493558a3b69a1ea830c706d4617bb", size = 2192543, upload-time = "2026-10-11T18:33:41.381Z" }, + { url = "https://files.pythonhosted.org/packages/0c/d9/19e91c94bd5c405945ce2f15526808aea37e162c253160de8ed7bf70b406/pydantic_core-2.50.1-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b0135bcdcaa0f23573f286e4cb5e0fd2962700964ed13df085b85f2b97aeab9e", size = 2388704, upload-time = "2026-10-11T18:33:43.167Z" }, + { url = "https://files.pythonhosted.org/packages/b6/bc/2e24c8415eae1a25ee5a5484946a917123bad2e9d01689a759236928175a/pydantic_core-2.50.1-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0b3a6f334c6a2345ca15318ff894502a90012536404b37c844a976c76c846e0b", size = 2464118, upload-time = "2026-10-11T18:33:44.856Z" }, + { url = "https://files.pythonhosted.org/packages/bd/1f/945b8053cb061c64e102bcaf7bfb9ed740c0bd4349f9bb978a7d4ddff4ab/pydantic_core-2.50.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:06e01fbbfdb9be777b316a71b6c49efaf4a08b615d0a98d678cda3023f79d019", size = 2150142, upload-time = "2026-10-11T18:33:46.661Z" }, + { url = "https://files.pythonhosted.org/packages/2b/78/96a3e50bf0d64aaae781107eb9335b7529d05a85793ed6e7241c4cd1d931/pydantic_core-2.50.1-cp314-cp314t-manylinux_2_31_riscv64.whl", hash = "sha256:a29a061fec0b4e2d714f277e70a3a18125ecff803f2fea6eade2f2e53711d112", size = 2245577, upload-time = "2026-10-11T18:33:48.574Z" }, + { url = "https://files.pythonhosted.org/packages/7a/5d/a6038a0322232758a6ebfa709f4ca14a60bf5b93940cd0b345056a557da4/pydantic_core-2.50.1-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f5187624823423e1d1b82b1072ac41dc837389e18d3d0572cc19bbee46cd550a", size = 2263728, upload-time = "2026-10-11T18:33:50.527Z" }, + { url = "https://files.pythonhosted.org/packages/0d/4b/76ded3333a457a9344c4f2d63f2d82d0101654b05178fa4ddfe7d3627674/pydantic_core-2.50.1-cp314-cp314t-musllinux_1_1_aarch64.whl", hash = "sha256:3e46a9eb0a0901dd6275e6b06ac3a464885ef350ec4121fe486869de8053e4bb", size = 2293630, upload-time = "2026-10-11T18:33:52.362Z" }, + { url = "https://files.pythonhosted.org/packages/a9/00/9eca378335c9c1b72bc779bf6e4c2a82ce784f14ec48a0e87102c9870e05/pydantic_core-2.50.1-cp314-cp314t-musllinux_1_1_armv7l.whl", hash = "sha256:756d669f04e62ec4148ecfe22be6a4484d9b1181a6ef32e205ebfd200540858b", size = 2468048, upload-time = "2026-10-11T18:33:54.118Z" }, + { url = "https://files.pythonhosted.org/packages/35/ca/e3832e9cf93651251de43c8c5c029ed680a3c1a0a1b17ee26c81bed08cbd/pydantic_core-2.50.1-cp314-cp314t-musllinux_1_1_x86_64.whl", hash = "sha256:c516cc5367ca3448995d42cb994bf3f4c9002d2a7c22eac9622551269ad1b807", size = 2512159, upload-time = "2026-10-11T18:33:55.99Z" }, + { url = "https://files.pythonhosted.org/packages/4b/f2/773469b5a10a39116a2cb17edaf6d722f017dd8da07161b371465311c542/pydantic_core-2.50.1-cp314-cp314t-win32.whl", hash = "sha256:9d1bed94af6a63835461f3cf7502058eb166c58c4778e11d0f433cfb1bd69e19", size = 2098406, upload-time = "2026-10-11T18:33:58.043Z" }, + { url = "https://files.pythonhosted.org/packages/ee/42/0bb74f8f25204b259b11ab7c12dc7f180893b6bd706118b385147fb6efd5/pydantic_core-2.50.1-cp314-cp314t-win_amd64.whl", hash = "sha256:c8dce1f1e0e5358b682a6ad3fa5e31b31d4560997b8e61417e9217c8d60f8a0c", size = 2148481, upload-time = "2026-10-11T18:33:59.913Z" }, + { url = "https://files.pythonhosted.org/packages/47/0d/d801646c9679a4e630e15cf521d4108b93854b42a6e6e02391bd4c6b1095/pydantic_core-2.50.1-cp314-cp314t-win_arm64.whl", hash = "sha256:ceff0acc940be2715bd6ad17b24c0e5304abf44f6efd0f81ee8499e640f9dc86", size = 2174972, upload-time = "2026-10-11T18:34:01.875Z" }, +] + +[[package]] +name = "pygments" +version = "2.21.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/49/2e/ced460408999b33da6b31b0021b0f37d329e202d4169aeb164493778f25b/pygments-2.21.0.tar.gz", hash = "sha256:610ca751c9bc2492b38eb9a38a7fbc93edbbb2d7182edaf34e66ae493dee5c8c", size = 5005329, upload-time = "2026-08-17T08:02:48.824Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/71/46/17f022dd3e953bf20a04a028a21ec746d942f8d2af30fa0f124fa0e6a684/pygments-2.21.0-py3-none-any.whl", hash = "sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9", size = 1250147, upload-time = "2026-08-17T08:02:44.912Z" }, +] + +[[package]] +name = "pyparsing" +version = "3.3.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e4/11/b213bebff182584360cb8d17c72c1677fec5c5c228de439e63bcf8ab1c8f/pyparsing-3.3.3.tar.gz", hash = "sha256:928ae7e20211f3b6f3915a72f06a0cfd29ab9d24279dd6346b6b1a7146397d36", size = 1050487, upload-time = "2026-09-20T20:59:05.609Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/38/bb/d215ee7c73b61497b28a5503f9f53523f294fcc936762b7caf90e0c1c2b5/pyparsing-3.3.3-py3-none-any.whl", hash = "sha256:ece8c00a69cf01b45d0b1dedabb469c90d8caf996d4fda40f147627a122849a4", size = 126420, upload-time = "2026-09-20T20:59:04.025Z" }, +] + +[[package]] +name = "pytest" +version = "9.2.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "iniconfig" }, + { name = "packaging" }, + { name = "pluggy" }, + { name = "pygments" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/79/42/bb4641652e58dedeac2ec51abc1f8cae4fee4ec63899a0999016229a0f2a/pytest-9.2.0.tar.gz", hash = "sha256:97c4f3b1f3c7414aa36465e09b8220f1d03627993bd51b1282e193753c80557b", size = 1797555, upload-time = "2026-10-27T21:30:20.728Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/51/39/1f5d8c8877a0fa327db959c19341d4be61660de1ab6b7391f9eb805bcd67/pytest-9.2.0-py3-none-any.whl", hash = "sha256:07acdcf88ec174f907dc01af70bf52d49b014bbab03faeeade31c96b18c2e588", size = 411776, upload-time = "2026-10-27T21:30:19.131Z" }, +] + +[[package]] +name = "python-dateutil" +version = "4.0.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "tzdata" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/18/39/b3927f3616f6223832f9b760e4208e8a7c7e1dea2b4d9ad7d32a5d214c3a/python_dateutil-4.0.0.tar.gz", hash = "sha256:d7295ff14fdc0f92f662100bfb6c551d160ca090f2939f1ec5b9794265c03f06", size = 250419, upload-time = "2026-11-01T07:02:42.426Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2f/a9/52b89563d154433d79b51ed1eb4842bf7334cb2696891a7fe135618853d7/python_dateutil-4.0.0-py3-none-any.whl", hash = "sha256:a5e246f79eb80475e691bf93862cead98decd8a498cf53ba0516fcdc0f50dc1c", size = 92853, upload-time = "2026-11-01T07:02:40.797Z" }, +] + +[[package]] +name = "pyyaml" +version = "6.0.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/05/8e/961c0007c59b8dd7729d542c61a4d537767a59645b82a0b521206e1e25c2/pyyaml-6.0.3.tar.gz", hash = "sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f", size = 130960, upload-time = "2025-09-25T21:33:16.546Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9d/8c/f4bd7f6465179953d3ac9bc44ac1a8a3e6122cf8ada906b4f96c60172d43/pyyaml-6.0.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac", size = 181814, upload-time = "2025-09-25T21:32:35.712Z" }, + { url = "https://files.pythonhosted.org/packages/bd/9c/4d95bb87eb2063d20db7b60faa3840c1b18025517ae857371c4dd55a6b3a/pyyaml-6.0.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310", size = 173809, upload-time = "2025-09-25T21:32:36.789Z" }, + { url = "https://files.pythonhosted.org/packages/92/b5/47e807c2623074914e29dabd16cbbdd4bf5e9b2db9f8090fa64411fc5382/pyyaml-6.0.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7", size = 766454, upload-time = "2025-09-25T21:32:37.966Z" }, + { url = "https://files.pythonhosted.org/packages/02/9e/e5e9b168be58564121efb3de6859c452fccde0ab093d8438905899a3a483/pyyaml-6.0.3-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788", size = 836355, upload-time = "2025-09-25T21:32:39.178Z" }, + { url = "https://files.pythonhosted.org/packages/88/f9/16491d7ed2a919954993e48aa941b200f38040928474c9e85ea9e64222c3/pyyaml-6.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5", size = 794175, upload-time = "2025-09-25T21:32:40.865Z" }, + { url = "https://files.pythonhosted.org/packages/dd/3f/5989debef34dc6397317802b527dbbafb2b4760878a53d4166579111411e/pyyaml-6.0.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764", size = 755228, upload-time = "2025-09-25T21:32:42.084Z" }, + { url = "https://files.pythonhosted.org/packages/d7/ce/af88a49043cd2e265be63d083fc75b27b6ed062f5f9fd6cdc223ad62f03e/pyyaml-6.0.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35", size = 789194, upload-time = "2025-09-25T21:32:43.362Z" }, + { url = "https://files.pythonhosted.org/packages/23/20/bb6982b26a40bb43951265ba29d4c246ef0ff59c9fdcdf0ed04e0687de4d/pyyaml-6.0.3-cp314-cp314-win_amd64.whl", hash = "sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac", size = 156429, upload-time = "2025-09-25T21:32:57.844Z" }, + { url = "https://files.pythonhosted.org/packages/f4/f4/a4541072bb9422c8a883ab55255f918fa378ecf083f5b85e87fc2b4eda1b/pyyaml-6.0.3-cp314-cp314-win_arm64.whl", hash = "sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3", size = 143912, upload-time = "2025-09-25T21:32:59.247Z" }, + { url = "https://files.pythonhosted.org/packages/7c/f9/07dd09ae774e4616edf6cda684ee78f97777bdd15847253637a6f052a62f/pyyaml-6.0.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3", size = 189108, upload-time = "2025-09-25T21:32:44.377Z" }, + { url = "https://files.pythonhosted.org/packages/4e/78/8d08c9fb7ce09ad8c38ad533c1191cf27f7ae1effe5bb9400a46d9437fcf/pyyaml-6.0.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba", size = 183641, upload-time = "2025-09-25T21:32:45.407Z" }, + { url = "https://files.pythonhosted.org/packages/7b/5b/3babb19104a46945cf816d047db2788bcaf8c94527a805610b0289a01c6b/pyyaml-6.0.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c", size = 831901, upload-time = "2025-09-25T21:32:48.83Z" }, + { url = "https://files.pythonhosted.org/packages/8b/cc/dff0684d8dc44da4d22a13f35f073d558c268780ce3c6ba1b87055bb0b87/pyyaml-6.0.3-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702", size = 861132, upload-time = "2025-09-25T21:32:50.149Z" }, + { url = "https://files.pythonhosted.org/packages/b1/5e/f77dc6b9036943e285ba76b49e118d9ea929885becb0a29ba8a7c75e29fe/pyyaml-6.0.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c", size = 839261, upload-time = "2025-09-25T21:32:51.808Z" }, + { url = "https://files.pythonhosted.org/packages/ce/88/a9db1376aa2a228197c58b37302f284b5617f56a5d959fd1763fb1675ce6/pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065", size = 805272, upload-time = "2025-09-25T21:32:52.941Z" }, + { url = "https://files.pythonhosted.org/packages/da/92/1446574745d74df0c92e6aa4a7b0b3130706a4142b2d1a5869f2eaa423c6/pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65", size = 829923, upload-time = "2025-09-25T21:32:54.537Z" }, + { url = "https://files.pythonhosted.org/packages/f0/7a/1c7270340330e575b92f397352af856a8c06f230aa3e76f86b39d01b416a/pyyaml-6.0.3-cp314-cp314t-win_amd64.whl", hash = "sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9", size = 174062, upload-time = "2025-09-25T21:32:55.767Z" }, + { url = "https://files.pythonhosted.org/packages/f1/12/de94a39c2ef588c7e6455cfbe7343d3b2dc9d6b6b2f40c4c6565744c873d/pyyaml-6.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b", size = 149341, upload-time = "2025-09-25T21:32:56.828Z" }, +] + +[[package]] +name = "redis" +version = "8.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a8/99/604f0b666d4c616d891cf77ebb9db6bb21601344c051aebf1b72b9ff915f/redis-8.1.0.tar.gz", hash = "sha256:6e1a19beef9225c83efd689c7e6b7da2d5215b1f42cd13b7fc3714d0a09c7b25", size = 5254356, upload-time = "2026-07-30T08:51:00.269Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/66/9d/c5731f6e3608663d4d3656fd8d3aecee8b509c3082818f5a13eae925baea/redis-8.1.0-py3-none-any.whl", hash = "sha256:a4fe1aac3d3b3cc791d4b3d5931c5a956045dc951ee74d1c913ee3ac4d2ee9fb", size = 560618, upload-time = "2026-07-30T08:50:58.497Z" }, +] + +[[package]] +name = "referencing" +version = "0.36.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "attrs" }, + { name = "rpds-py" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/2f/db/98b5c277be99dd18bfd91dd04e1b759cad18d1a338188c936e92f921c7e2/referencing-0.36.2.tar.gz", hash = "sha256:df2e89862cd09deabbdba16944cc3f10feb6b3e6f18e902f7cc25609a34775aa", size = 74744, upload-time = "2025-01-25T08:48:16.138Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c1/b1/3baf80dc6d2b7bc27a95a67752d0208e410351e3feb4eb78de5f77454d8d/referencing-0.36.2-py3-none-any.whl", hash = "sha256:e8699adbbf8b5c7de96d8ffa0eb5c158b3beafce084968e2ea8bb08c6794dcd0", size = 26775, upload-time = "2025-01-25T08:48:14.241Z" }, +] + +[[package]] +name = "requests" +version = "2.34.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "certifi" }, + { name = "charset-normalizer" }, + { name = "idna" }, + { name = "urllib3" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ac/c3/e2a2b89f2d3e2179abd6d00ebd70bff6273f37fb3e0cc209f48b39d00cbf/requests-2.34.2.tar.gz", hash = "sha256:f288924cae4e29463698d6d60bc6a4da69c89185ad1e0bcc4104f584e960b9ed", size = 142856, upload-time = "2026-05-14T19:25:27.735Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a0/f4/c67b0b3f1b9245e8d266f0f112c500d50e5b4e83cb6f3b71b6528104182a/requests-2.34.2-py3-none-any.whl", hash = "sha256:2a0d60c172f83ac6ab31e4554906c0f3b3588d37b5cb939b1c061f4907e278e0", size = 73075, upload-time = "2026-05-14T19:25:26.443Z" }, +] + +[[package]] +name = "rfc3339-validator" +version = "0.1.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "six" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/28/ea/a9387748e2d111c3c2b275ba970b735e04e15cdb1eb30693b6b5708c4dbd/rfc3339_validator-0.1.4.tar.gz", hash = "sha256:138a2abdf93304ad60530167e51d2dfb9549521a836871b88d7f4695d0022f6b", size = 5513, upload-time = "2021-05-12T16:37:54.178Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7b/44/4e421b96b67b2daff264473f7465db72fbdf36a07e05494f50300cc7b0c6/rfc3339_validator-0.1.4-py2.py3-none-any.whl", hash = "sha256:24f6ec1eda14ef823da9e36ec7113124b39c04d50a4d3d3a3c2859577e7791fa", size = 3490, upload-time = "2021-05-12T16:37:52.536Z" }, +] + +[[package]] +name = "rich" +version = "15.0.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markdown-it-py" }, + { name = "pygments" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c0/8f/0722ca900cc807c13a6a0c696dacf35430f72e0ec571c4275d2371fca3e9/rich-15.0.0.tar.gz", hash = "sha256:edd07a4824c6b40189fb7ac9bc4c52536e9780fbbfbddf6f1e2502c31b068c36", size = 230680, upload-time = "2026-04-12T08:24:00.75Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/82/3b/64d4899d73f91ba49a8c18a8ff3f0ea8f1c1d75481760df8c68ef5235bf5/rich-15.0.0-py3-none-any.whl", hash = "sha256:33bd4ef74232fb73fe9279a257718407f169c09b78a87ad3d296f548e27de0bb", size = 310654, upload-time = "2026-04-12T08:24:02.83Z" }, +] + +[[package]] +name = "rpds-py" +version = "2026.9.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/42/68/3bd46b8a5e01d3c2ebdf9c5e9497912e3fe0cde02bac21a7130ca866e403/rpds_py-2026.9.1.tar.gz", hash = "sha256:4793ef7f78268b124b73fa933440f01d258bbae01de9fa53e9080c9ab0425a12", size = 63948, upload-time = "2026-10-04T16:32:36.469Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8a/f2/67b94be1532767803415c1c5a1fd88ea487643d74a673cec1ba140af77bb/rpds_py-2026.9.1-cp314-cp314-macosx_10_12_x86_64.whl", hash = "sha256:c9d1aca01f49170fdcf5c92761b1fafe97f554b721ca4570c5949fff778f0d4b", size = 347178, upload-time = "2026-10-04T16:30:00.865Z" }, + { url = "https://files.pythonhosted.org/packages/04/37/b751de2b59b0197a1d92a5dd491de88e8a5e928c2e6562581974f1e85263/rpds_py-2026.9.1-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:3f0e9ac28fc067d4d34b88ae43c48e9489455c97fee9633d851f7eeed5a05d35", size = 341878, upload-time = "2026-10-04T16:30:02.564Z" }, + { url = "https://files.pythonhosted.org/packages/72/e2/5873bc4643c250db9e05d48dc0c93763d4aa68bc3b81164cb1af3b45b284/rpds_py-2026.9.1-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:07deecbfce94c78473018bc7d10b337cc651d12df87a1eb2cb3e4024bc9c33d0", size = 373963, upload-time = "2026-10-04T16:30:04.026Z" }, + { url = "https://files.pythonhosted.org/packages/51/03/5acf7632158247f3f6386ff0af3a1ee48167d575037e8d0920594b76d92b/rpds_py-2026.9.1-cp314-cp314-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:821b2755db9194409254012f429c56643416fb96ef9be090be82ec8826b7f477", size = 377975, upload-time = "2026-10-04T16:30:05.555Z" }, + { url = "https://files.pythonhosted.org/packages/e6/00/63fda451b8bffa5808fc8bb311ee7c073b340974b09f273c7b2a145d3d62/rpds_py-2026.9.1-cp314-cp314-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3c91c210ae7645626c608400e3519b4a642f837cce09ca830db3beb2e9f274d4", size = 490347, upload-time = "2026-10-04T16:30:07.156Z" }, + { url = "https://files.pythonhosted.org/packages/a1/ae/c093ffd070ba0fb02f76c565d06fecc65ad6e4afdbae78f7031076d3cdac/rpds_py-2026.9.1-cp314-cp314-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:54ac2158a6f96cfbabff0b2eedaf94b90c5ec7ca8317fcadc61e1c2b2e0ff6ef", size = 392962, upload-time = "2026-10-04T16:30:08.77Z" }, + { url = "https://files.pythonhosted.org/packages/22/9d/d08a1128ab199b2f0cf25bfeb0639bd05119fff4b7c47bec24ef9a8ec23f/rpds_py-2026.9.1-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eac2f5dbafd585dfe31f86a23ebf0d3ba480a9d49ebc87947267b5608d4ea0cd", size = 371623, upload-time = "2026-10-04T16:30:10.501Z" }, + { url = "https://files.pythonhosted.org/packages/53/c7/4758ddcbb75609414bbccfcb11d612436f9b3ee821bd2f33f0f1604ee648/rpds_py-2026.9.1-cp314-cp314-manylinux_2_31_riscv64.whl", hash = "sha256:8aa5dda18d39b6143eb24809d158f9252c88f402749b6f1b62a506cc7d96cc35", size = 376997, upload-time = "2026-10-04T16:30:12.124Z" }, + { url = "https://files.pythonhosted.org/packages/87/e4/947bd7f608ff60faf46dc9d389c3dffd0e3d767d78a0be19978448ef0ce7/rpds_py-2026.9.1-cp314-cp314-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:5c90e7fa02e8f5de0d10c17595c568ada48c5302e749462c0ea1a4c362111a86", size = 400169, upload-time = "2026-10-04T16:30:13.804Z" }, + { url = "https://files.pythonhosted.org/packages/4b/35/fe93e020a0543b5670472c18d7e6af3197c08da571240ce1965c84f85c0f/rpds_py-2026.9.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:e6d198bad4e49dd6732fbd636e2fc5c082f45c8cad0b4acb756b00c82c76072e", size = 551615, upload-time = "2026-10-04T16:30:15.332Z" }, + { url = "https://files.pythonhosted.org/packages/0d/4f/5d2a0136bb03b2a56a39dc6ff92d58a6e3e53a2e17079238b86228882f16/rpds_py-2026.9.1-cp314-cp314-musllinux_1_2_i686.whl", hash = "sha256:96beca19ec79de272e8668585380ff9092c47077c1d7a1e098e00bbd921f4785", size = 614655, upload-time = "2026-10-04T16:30:16.92Z" }, + { url = "https://files.pythonhosted.org/packages/09/1c/3f1025aaf70d9bf7272cc41f8b64ee76b48bf01726248138430e16f23b38/rpds_py-2026.9.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:a5cf77eb04f20b720be95265a3e00eb2a14814074255cc27069c551b2db53118", size = 579602, upload-time = "2026-10-04T16:30:18.555Z" }, + { url = "https://files.pythonhosted.org/packages/53/0d/5c72e6204f76610608706da32b6b7e11ef7e10317558a7bb15a122e008dc/rpds_py-2026.9.1-cp314-cp314-win32.whl", hash = "sha256:a03d57b86d2a51d0a66c92177e2be154ad015f357791d306e714569999cdb4cc", size = 206315, upload-time = "2026-10-04T16:30:20.05Z" }, + { url = "https://files.pythonhosted.org/packages/a4/0b/489d48abbcc7d70cf3fbf662d9d22abf1f4650761c0a9ae05260800800d3/rpds_py-2026.9.1-cp314-cp314-win_amd64.whl", hash = "sha256:837c6b305e26fe0f75b15c92cf3b2ba29e0ae19dc40b1c557b026cb426347d0c", size = 222852, upload-time = "2026-10-04T16:30:21.604Z" }, + { url = "https://files.pythonhosted.org/packages/91/16/bbb05a7e6a10cf79ba639be7f799d770ee15f64175cc61d081b218dd402a/rpds_py-2026.9.1-cp314-cp314-win_arm64.whl", hash = "sha256:fce4b85234a0cbad67bf8e6e1201ee815d172c9aebad75f25645bc4d834f8e31", size = 218709, upload-time = "2026-10-04T16:30:23.036Z" }, + { url = "https://files.pythonhosted.org/packages/22/ac/ac507a0a4ec478ca470440a09583db4be5259ba7670aeba0620822f1e57a/rpds_py-2026.9.1-cp314-cp314t-macosx_10_12_x86_64.whl", hash = "sha256:3a72c11530d71abfb66c8d7696a2f86c43e63fca8b948f1a784ac490f4ec688e", size = 349596, upload-time = "2026-10-04T16:30:24.558Z" }, + { url = "https://files.pythonhosted.org/packages/e9/f2/817a46b658d5070f477f722c298ee9a24525b0e4017347964146ef5fdd0e/rpds_py-2026.9.1-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:068c37bba854ec2fe42f7365c640af11dd9895890ccbf2df5070d0c059bd7f96", size = 343114, upload-time = "2026-10-04T16:30:26.048Z" }, + { url = "https://files.pythonhosted.org/packages/6c/42/6ade976b13ac1b4cb3bf2eb603f1be2fe74df19a29988d4c2b386be59d6f/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d7fca4eb6df565e2a928f1c7dad92d27db8f9df0f449e76423ed5d7e713ed445", size = 374197, upload-time = "2026-10-04T16:30:27.699Z" }, + { url = "https://files.pythonhosted.org/packages/d9/70/77cdf1d3f1a07faabe936016ae623aec7981f73108a8fe7a203ed2e21998/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c933c6678c6f116ff8af47a4c6db0868b8ace74af0343016c0ef00f00272ea69", size = 378025, upload-time = "2026-10-04T16:30:29.451Z" }, + { url = "https://files.pythonhosted.org/packages/3f/6b/18a44a3beaa9b7931acb04af7bd9539836477c630a794452d4826d6185d4/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:028ad274ea951dac64491b5d1e65712a4aeabfdbdb9fccf797b57bd899b0c495", size = 491969, upload-time = "2026-10-04T16:30:30.995Z" }, + { url = "https://files.pythonhosted.org/packages/73/27/fb39cfd6bddaf741b024f813890374578ff8ac1f1adc473659c048b03b05/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:740d0a99cf9de0b17a3943388e9294a59becf75e7c43421f387bd3c7a9901f7c", size = 393905, upload-time = "2026-10-04T16:30:32.628Z" }, + { url = "https://files.pythonhosted.org/packages/ed/71/0fa7bb77b57af0d710273964180d11b503f62b8a5c358eb2d8c3f62feff6/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0da298fb372dc192610a4b9ecbc68a0cd8b675bbbd1fc519d01b41cfd658333e", size = 374569, upload-time = "2026-10-04T16:30:34.257Z" }, + { url = "https://files.pythonhosted.org/packages/54/22/f41cfac269af3b449513ef1bc3d7f32fde52abbbd2d01c7e76b47743acd9/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_31_riscv64.whl", hash = "sha256:eb61be926bb81567c1f48bdc8aa22b9855048dc2efd53871f9f7e6e9a5632346", size = 377482, upload-time = "2026-10-04T16:30:35.997Z" }, + { url = "https://files.pythonhosted.org/packages/b4/fc/312b49006e7f8f9ca5f96647577b8aa6f3df30519c46bd448f5c425af0b2/rpds_py-2026.9.1-cp314-cp314t-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:42e75466f83cd43f6026c81eab74246efb2bdadafb307b85700632d06c68f299", size = 400040, upload-time = "2026-10-04T16:30:37.76Z" }, + { url = "https://files.pythonhosted.org/packages/cf/a6/18cca7a878dc7fa95165a83343fd4d7b65643fd22e54e47340a451121d5c/rpds_py-2026.9.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:617f59cde379b4f648a09797b7f683d04b90a46344cddab85639da5aff0f5531", size = 551849, upload-time = "2026-10-04T16:30:39.443Z" }, + { url = "https://files.pythonhosted.org/packages/e4/6d/1f5685e20f39604691bdc3c05aaa6b8bd2f954e9e996477adf2376768e33/rpds_py-2026.9.1-cp314-cp314t-musllinux_1_2_i686.whl", hash = "sha256:3edae8c5ddfdb6985d49ae9d150516e5076888879022f91a26c2de9276ce0bdb", size = 614842, upload-time = "2026-10-04T16:30:41.231Z" }, + { url = "https://files.pythonhosted.org/packages/c6/25/98652109fd9f7e10268dd4571aa52b81987001b806f37ef1a18260de714a/rpds_py-2026.9.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:0f045bb053c9057720d72c56dffe30dffdc05997b2897a827b9325f0ab6623fa", size = 582606, upload-time = "2026-10-04T16:30:43.345Z" }, + { url = "https://files.pythonhosted.org/packages/19/03/11ca09099bab5f53373a80a334c424ec917c13d050760a59499d2af5171e/rpds_py-2026.9.1-cp314-cp314t-win32.whl", hash = "sha256:bf35d0568abda97233239ce32896d3ad53fccc537832c104e30c94aa5fb93569", size = 203341, upload-time = "2026-10-04T16:30:44.954Z" }, + { url = "https://files.pythonhosted.org/packages/6f/8a/88909e3ffd9f47f5b58211473875d8c3c09079f0058c46fb72c55a702a26/rpds_py-2026.9.1-cp314-cp314t-win_amd64.whl", hash = "sha256:1e8d4d79d828299bf44a55db22a9388ab967b49d17132c88eab0f4360b48da8e", size = 222843, upload-time = "2026-10-04T16:30:46.486Z" }, +] + +[[package]] +name = "ruff" +version = "0.17.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/84/0e/3d154514b5bad104f7e1c13169c2d09aa9959fccdc06eb47610ccdfa83ed/ruff-0.17.4.tar.gz", hash = "sha256:f32d178b50e826e00f6c6c1be3f56333068acb9b67fe167143527fa9b81e890d", size = 5357750, upload-time = "2026-11-05T18:52:17.638Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e0/61/c83c78bbb6108f6c6270a106cf12b54175f4f42da088b9bb880f18e31289/ruff-0.17.4-py3-none-linux_armv6l.whl", hash = "sha256:2b08c4ff98dc234f4a3871a3105353b922fa875ea1073ca31001eb8c06bb4d89", size = 10252195, upload-time = "2026-11-05T18:51:36.594Z" }, + { url = "https://files.pythonhosted.org/packages/0a/12/dd158708378866e8b53e145a465dbc51a7cccb9fa197a74d67eaedde7234/ruff-0.17.4-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:13e781c3c5f663e7fba737eaaeb70dd943dd55171daf316afb25cd5268cfe0c7", size = 10266044, upload-time = "2026-11-05T18:51:39.502Z" }, + { url = "https://files.pythonhosted.org/packages/28/32/89a94a8eb11fd505a381ae6f04e190d038d9958695209dc1786ce5cfcda3/ruff-0.17.4-py3-none-macosx_11_0_arm64.whl", hash = "sha256:7ed2f416349944f908f9574215994602242b0836844eba48eec61473033afca0", size = 9432227, upload-time = "2026-11-05T18:51:41.968Z" }, + { url = "https://files.pythonhosted.org/packages/58/de/a392dc38b215798ae72e639d228b7f6c02d826a95d1c0ad7c4c0ee49ef5b/ruff-0.17.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8ea6e0017c785f7282092b11e46338e4ebed1b9e575ebf2e55a8a1eda968241a", size = 10136900, upload-time = "2026-11-05T18:51:44.562Z" }, + { url = "https://files.pythonhosted.org/packages/b7/8f/a880f60f42005f6ffdf58f77af34c7ee327000b5607f48a2f6a69d8b242c/ruff-0.17.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:7e061dcc0933c7031a616ac8d66ac540309b2aa21ab558101a8f53e9ac7a1185", size = 10051245, upload-time = "2026-11-05T18:51:46.7Z" }, + { url = "https://files.pythonhosted.org/packages/09/55/98844264108af7d5ec27ca3a9cd5a989094ca657a14599c4b69a537a0e9a/ruff-0.17.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f99e95a1515161138be3cbd1b06c06e739d8feb38ade35564556999fffc3686e", size = 10704341, upload-time = "2026-11-05T18:51:49.228Z" }, + { url = "https://files.pythonhosted.org/packages/28/a2/5edf97659c3ac7c73f978003bd314936f671037fdac6b978e9de3e4b2b65/ruff-0.17.4-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:5f28cf0dd37cb172fa5a8d2e92e6ada3a9dbd0609f094ed24039929eef0b7524", size = 11394465, upload-time = "2026-11-05T18:51:51.534Z" }, + { url = "https://files.pythonhosted.org/packages/f2/8f/51371ae856b2bef4d15a044a574695fbc0f6ae63aafa42a2a22428070fb6/ruff-0.17.4-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6b21c771b296888e8a35c6f48555f4b44e4483f61675d6ed51810a5203469ce6", size = 10988262, upload-time = "2026-11-05T18:51:53.91Z" }, + { url = "https://files.pythonhosted.org/packages/af/1b/62874f14c7873f27c7887d2b1ea41de990e14ba9518801ffe8eacb5d51a6/ruff-0.17.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2cd025509b2e15721b426fc70fd946d71f43b3db3b08e946dfec2d696d911690", size = 10572829, upload-time = "2026-11-05T18:51:56.129Z" }, + { url = "https://files.pythonhosted.org/packages/98/30/860b9dae67432b16b88558a9cb2d3194825fa62838f8b9cc49f5d9022095/ruff-0.17.4-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:49b77f7b3921669466882a4881168801bdb06ec2cd83fb936049016cf5fdece1", size = 10617545, upload-time = "2026-11-05T18:51:58.172Z" }, + { url = "https://files.pythonhosted.org/packages/0f/08/781a4b41a1c83fd6e30fea610d6502a6f94e49cf94693fd37bdcbc6bfe11/ruff-0.17.4-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:e3b84eb74f260d1c2dbd236fd9d4c011d4fdd0a52bdf8aea57a10e3a1b71fca5", size = 10111955, upload-time = "2026-11-05T18:52:00.59Z" }, + { url = "https://files.pythonhosted.org/packages/3c/e9/94b1c7b677120f30839254518924f73a8157e9bcfa200edcd5796fecdb99/ruff-0.17.4-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:20e43d7a08e712e33067ba887e6574546c79bd4831596ce8f16803ac7ff9ad90", size = 10058355, upload-time = "2026-11-05T18:52:03.61Z" }, + { url = "https://files.pythonhosted.org/packages/27/5f/a825910b9f309336dc33cb8c0774126662c1d2f765699b3e0a1bd538d01f/ruff-0.17.4-py3-none-musllinux_1_2_i686.whl", hash = "sha256:0d1f4848fd2ec0499be4046db9b7dfcc952666885f00233cc7033515282556a8", size = 10415932, upload-time = "2026-11-05T18:52:06.264Z" }, + { url = "https://files.pythonhosted.org/packages/8b/b8/0796468423413ea4df1a6e2442ae26cf49b8f7dda0eecf246e0d5d0dde54/ruff-0.17.4-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:6007e7f3a0e55b0fbdb947af69cf24c21b4928df6be8ef3e767c69b5ccccf496", size = 10826033, upload-time = "2026-11-05T18:52:08.675Z" }, + { url = "https://files.pythonhosted.org/packages/b9/ab/d8e407669ffe5014429baf780c2df47e001968a6e4c17f615e2e7b13a9ba/ruff-0.17.4-py3-none-win32.whl", hash = "sha256:3971a78cba76298b284c8321e6d40d93045ed348bec5c369d85099efc97fb7cf", size = 9931993, upload-time = "2026-11-05T18:52:11.169Z" }, + { url = "https://files.pythonhosted.org/packages/bd/15/42af8a72d8946e3c9efd2bbf6641e462b6832783b0d043d63ef5b280ba7f/ruff-0.17.4-py3-none-win_amd64.whl", hash = "sha256:67c5a894fc054cf41f75f7afa24815de5a74329d97634126c2a1015740ff4e8c", size = 10292922, upload-time = "2026-11-05T18:52:13.436Z" }, + { url = "https://files.pythonhosted.org/packages/68/9e/f1dbffcfb8ff25dadbc21f87a8b73c3848abe4abada9d4b08ccef8bec40c/ruff-0.17.4-py3-none-win_arm64.whl", hash = "sha256:181ae38a9a8fb94925bf7d0794327b48d7fd7f4b50cfd84c0e999cc09ef8d131", size = 9889396, upload-time = "2026-11-05T18:52:15.549Z" }, +] + +[[package]] +name = "six" +version = "1.17.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81", size = 34031, upload-time = "2024-12-04T17:35:28.174Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050, upload-time = "2024-12-04T17:35:26.475Z" }, +] + +[[package]] +name = "sortedcontainers" +version = "2.4.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e8/c4/ba2f8066cceb6f23394729afe52f3bf7adec04bf9ed2c820b39e19299111/sortedcontainers-2.4.0.tar.gz", hash = "sha256:25caa5a06cc30b6b83d11423433f65d1f9d76c4c6a0c90e3379eaa43b9bfdb88", size = 30594, upload-time = "2021-05-16T22:03:42.897Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/32/46/9cb0e58b2deb7f82b84065f37f3bffeb12413f947f9388e4cac22c4621ce/sortedcontainers-2.4.0-py2.py3-none-any.whl", hash = "sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0", size = 29575, upload-time = "2021-05-16T22:03:41.177Z" }, +] + +[[package]] +name = "starlette" +version = "1.10.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/48/bb/3d8757f21e9a53d9035c9eb039a777047139a16bfdbedfc7a58241c3d914/starlette-1.10.0.tar.gz", hash = "sha256:b8399098d4c1e3522734f7235dc79b1fc967f96cf139c81e0fa30479e0685f9b", size = 2734356, upload-time = "2026-10-24T15:04:12.342Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/88/2e/947cfe02def9371c07cd5bf5b6b61c829e9aecb9904db02a66cfafbc1eec/starlette-1.10.0-py3-none-any.whl", hash = "sha256:478c0ab3b4ced6e82719849c118fa406f0278a3499c1a898cd15cd31bdc38ce4", size = 80571, upload-time = "2026-10-24T15:04:10.371Z" }, +] + +[[package]] +name = "tomli" +version = "2.5.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/b0/78/9ad63712633ed3ab5cc1a648d863d7e7da371e9425e209555a0fe711b695/tomli-2.5.0.tar.gz", hash = "sha256:264507556cd8b8c8e7c6ee037cdf443a463f03f4c958e57195e3d369711b8ff6", size = 17662, upload-time = "2026-10-07T12:23:37.892Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e4/49/caf6b307766eb9567664a8707e9d6be5fcc0e8903f18781c6677a60d80c7/tomli-2.5.0-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:d3182ee2d887e507bd67319a0a61105d1dd33facc111329559a233b772c1a105", size = 162899, upload-time = "2026-10-07T12:22:50.088Z" }, + { url = "https://files.pythonhosted.org/packages/d3/c8/68cfce773a2733a49c74f99d627fb461bd990756860099eac25617889585/tomli-2.5.0-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:521345fd1f19d45b8df87657aaa38b6f2ca3800059fadf428e7ebf479a383646", size = 162080, upload-time = "2026-10-07T12:22:51.558Z" }, + { url = "https://files.pythonhosted.org/packages/7e/b2/e5bb8651fdad593f670501a7d718b1a7f73f064d44dea15e04c04dfef45d/tomli-2.5.0-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6e95c7614e705bfe2b04b27aa124adec59752d15813df37e2156747cab3a006b", size = 273380, upload-time = "2026-10-07T12:22:52.918Z" }, + { url = "https://files.pythonhosted.org/packages/8d/d2/9e2d7f8b1dfe0e2b34c245986ebd55c4c553ea4ce6c47c443b332673253f/tomli-2.5.0-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7ac2027d37c3afbdf4bdd377f2676f6f1d2122a5be1f1137b49dced590b37e75", size = 283228, upload-time = "2026-10-07T12:22:54.173Z" }, + { url = "https://files.pythonhosted.org/packages/ba/df/ec7b876b7b1a2718bd74a3743c076fff565b04029ba33e8f61fac262739f/tomli-2.5.0-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:c414be4ed9d3cac80c42e348fa5a956117d1a48227f48026e31f59cb4a7671eb", size = 277189, upload-time = "2026-10-07T12:22:55.342Z" }, + { url = "https://files.pythonhosted.org/packages/7d/7b/e192d9eed0b9cb80da799f4d77052297fb9a2c3cc9b19f571f56ea88add6/tomli-2.5.0-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:9b03d7dc168353b4132965bde20feceabaa470e570c6f59660dfae59b1f9eeb3", size = 283632, upload-time = "2026-10-07T12:22:56.735Z" }, + { url = "https://files.pythonhosted.org/packages/84/50/ff94454e75461d75623e47401ed323d65c10aab8fe9033242c20cd2fdf32/tomli-2.5.0-cp314-cp314-win32.whl", hash = "sha256:6f041843c4d3a37245c0c056fd955b186bf8b1fb85690cbe40b81230891dc34b", size = 103535, upload-time = "2026-10-07T12:22:58.084Z" }, + { url = "https://files.pythonhosted.org/packages/54/0b/bdacf05f963bd6026ebf6eeb0beda847d1d60e03e440725c64a4e08a0afd/tomli-2.5.0-cp314-cp314-win_amd64.whl", hash = "sha256:f4b653094e18f9031102d3a1da5c729c8f222d85225b18037dac621695e46e1a", size = 114621, upload-time = "2026-10-07T12:22:59.2Z" }, + { url = "https://files.pythonhosted.org/packages/61/99/53f438fa6ae4f9d4ed0ddde3e7242b3bdc34b48c8f9948b72b9e9b127676/tomli-2.5.0-cp314-cp314-win_arm64.whl", hash = "sha256:3f89d10c1ff6a38d992c27fc8a4816af71a909e08a40ec66934240b1e74347c3", size = 111572, upload-time = "2026-10-07T12:23:00.479Z" }, + { url = "https://files.pythonhosted.org/packages/b9/20/1f88f19427d380a40e90a770e087489eaafe4aeee070ae88ed2bbec00acd/tomli-2.5.0-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:e9e15b4a6c7dd6b85b5fbab29488a73f1f70de516942308daa266bf0e0aeb0d4", size = 171814, upload-time = "2026-10-07T12:23:01.914Z" }, + { url = "https://files.pythonhosted.org/packages/d0/56/cbe5079c9f9a54b9b3e27fc82f08f3cb36edee75561679f53d2380c801d6/tomli-2.5.0-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:e12bbcd32897272fb05929110362ae9ff4c1b9bb26bd9e971e71dcd3275b4c3d", size = 171324, upload-time = "2026-10-07T12:23:03.18Z" }, + { url = "https://files.pythonhosted.org/packages/2b/30/1d53fd3b0f1cb3ba542e345ec32c26aefdddc4e829e4f3429af8a4f27782/tomli-2.5.0-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:20aa36de8f2cf87237143bc1fa1aae8d6612c09118f4da21c6a684db5dd1f6f9", size = 297441, upload-time = "2026-10-07T12:23:04.345Z" }, + { url = "https://files.pythonhosted.org/packages/66/d9/0800acb6a111686f764c1b91ef15cc42a20a66a46013bb42220f1d2c61c1/tomli-2.5.0-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:22185fad8a1e622f064e78008018a0dd3323550dcb479cb7a1d296888d74024f", size = 307476, upload-time = "2026-10-07T12:23:05.671Z" }, + { url = "https://files.pythonhosted.org/packages/e8/63/30a8f3cd51b5bec37f04744bad0b0dc6160df84aad4f27b0e9283d66f221/tomli-2.5.0-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:984012f71908165449a951de2050d52f276bfe3aa5d5f570f63ddad814370374", size = 296113, upload-time = "2026-10-07T12:23:07.202Z" }, + { url = "https://files.pythonhosted.org/packages/ab/18/0b9ffc597e69c5a1e20a7823cb60d54b39a9f54e91edcb8574f022186758/tomli-2.5.0-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:f79203b3965b4000e91808aaa7c040206093f2b8bf86f455982f2274c9ccf442", size = 307725, upload-time = "2026-10-07T12:23:08.508Z" }, + { url = "https://files.pythonhosted.org/packages/ab/c7/18f8baae0b5607a60e8e19b4a7fedee43a8ff6458e3896dcbbadeeac9c22/tomli-2.5.0-cp314-cp314t-win32.whl", hash = "sha256:91294a9fb94a75542f6e46e4a2ae709bd8d9b51134098cae5cf3bea5478b6d03", size = 108546, upload-time = "2026-10-07T12:23:09.956Z" }, + { url = "https://files.pythonhosted.org/packages/72/34/4cca9739254130627bde87500b3f2b512154fe2f278efa7e2a5e10ad4bcb/tomli-2.5.0-cp314-cp314t-win_amd64.whl", hash = "sha256:f15e3e0b835a6d68b10c86bf80a3149780498d6911c93c3ffd1861d19f9200f1", size = 117814, upload-time = "2026-10-07T12:23:11.486Z" }, + { url = "https://files.pythonhosted.org/packages/7d/fb/afa530d47dd80a78fce43beac6bc6e00f84558eafcffbc6f37b21e80d056/tomli-2.5.0-cp314-cp314t-win_arm64.whl", hash = "sha256:6664b7ae7af7294256c53960a6103077f4914cec8ff98479c352f622c6f6b2f0", size = 115188, upload-time = "2026-10-07T12:23:12.728Z" }, + { url = "https://files.pythonhosted.org/packages/60/3f/3e3f8fd0919249b0200c80fbc4f9a1e70be19f9883da71dfb7f8b9ab8aca/tomli-2.5.0-py3-none-any.whl", hash = "sha256:32a7b79ac57a2e83670ce329ccf675798bc5a2094783a63676866b70503f2e2b", size = 14765, upload-time = "2026-10-07T12:23:36.875Z" }, +] + +[[package]] +name = "tomli-w" +version = "1.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/19/75/241269d1da26b624c0d5e110e8149093c759b7a286138f4efd61a60e75fe/tomli_w-1.2.0.tar.gz", hash = "sha256:2dd14fac5a47c27be9cd4c976af5a12d87fb1f0b4512f81d69cce3b35ae25021", size = 7184, upload-time = "2025-01-15T12:07:24.262Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c7/18/c86eb8e0202e32dd3df50d43d7ff9854f8e0603945ff398974c1d91ac1ef/tomli_w-1.2.0-py3-none-any.whl", hash = "sha256:188306098d013b691fcadc011abd66727d3c414c571bb01b1a174ba8c983cf90", size = 6675, upload-time = "2025-01-15T12:07:22.074Z" }, +] + +[[package]] +name = "typing-extensions" +version = "4.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f6/cc/6253133b5bb138fc3306cebfbda2c520f545d36b5be2c7255cc528bb45d6/typing_extensions-4.16.0.tar.gz", hash = "sha256:dc983d19a509c94dba722ee6abd33940f7c05a89e243c47e907eb4db6f1a43e5", size = 113555, upload-time = "2026-07-02T08:40:05.92Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/49/d3/b8441a820a491ddfc024b0b0cf0393375b75ea13866d9c66727e54c2fc80/typing_extensions-4.16.0-py3-none-any.whl", hash = "sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8", size = 45571, upload-time = "2026-07-02T08:40:04.659Z" }, +] + +[[package]] +name = "typing-inspection" +version = "0.4.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/ff/50/0195198eb1d75bab716bb0a813abea4cc394bfa17a92a189f021a34859af/typing_inspection-0.4.5.tar.gz", hash = "sha256:7f16c411e7930dc79596d42ab44672a3fe5f60eb34b781a1647e7872363120c7", size = 81194, upload-time = "2026-11-04T14:13:23.774Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/de/0c/ea2544850a7c135e15033a5c7a8e7211136184b7ae63e2239d557c2b3019/typing_inspection-0.4.5-py3-none-any.whl", hash = "sha256:bc210535442b39e1bf2805e0c7a17dfd6a4ace760c84c7f7d16245d23a6b1c39", size = 14874, upload-time = "2026-11-04T14:13:22.616Z" }, +] + +[[package]] +name = "tzdata" +version = "2026.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7a/29/6a1391d31cd00ff9e927215a224a880e1e84e826b64ba80a499e51c074d8/tzdata-2026.6.tar.gz", hash = "sha256:85d2cd9c09f81f0bb29db27759fc83af4f1e620efb814f8c5bf8b4cc4feece6d", size = 201017, upload-time = "2026-10-28T09:57:09.137Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0a/66/9a06c2227fedfd4919f0eaaa8b94377d9730882a7e4f95823c9a331ab5e1/tzdata-2026.6-py2.py3-none-any.whl", hash = "sha256:0a10eec6e13ef16b627fabed9a5f2ba61a62b1c67f327305f4e7e412a70b4aec", size = 348210, upload-time = "2026-10-28T09:57:07.276Z" }, +] + +[[package]] +name = "urllib3" +version = "2.8.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/e3/05/b17359e1cefb4f909b5e40b1b90a496d987258916dbbf88e842c729f510e/urllib3-2.8.0.tar.gz", hash = "sha256:63bf2ead4c879426ebf22ef2a781eeb4aa3b4ae798a0435506f8687fd5bb9b63", size = 458972, upload-time = "2026-09-15T19:29:36.253Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/92/9d/c4e665119135114480843e7ab388fa94d8480650450e6f8e26b70d323a4c/urllib3-2.8.0-py3-none-any.whl", hash = "sha256:0cf3cae568d36aa9576b28dfb35f11328f1cb974ca7647d9475ebb86c75ac6e3", size = 135717, upload-time = "2026-09-15T19:29:34.577Z" }, +] + +[[package]] +name = "uvicorn" +version = "0.54.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click" }, + { name = "h11" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/da/34/30e9280707135d2cfc589dfff3cb796bd07a3aeb1a3e415ba09dd89d7bb4/uvicorn-0.54.0.tar.gz", hash = "sha256:a2e33cbfaa0306f8e6b0c13e0cb89d7d7a2da3e62b90c66e18c33d9807b28620", size = 112283, upload-time = "2026-09-25T06:52:37.601Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/38/0c/b54a4fdd7f90a3af8b02ebc9ce6712c2c208b7926a2f7bad95c33ebbe943/uvicorn-0.54.0-py3-none-any.whl", hash = "sha256:505bdb0f318731d45f1f712071fc781a8981f6847a31c902c9f5e652d4f67faf", size = 87427, upload-time = "2026-09-25T06:52:35.829Z" }, +] -- 2.54.0 From f2ea9d65a85879debdcc5e0ca019943a2747e936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D1=81=D0=BB=D0=BE=D0=B2?= Date: Fri, 20 Nov 2026 19:02:00 +0300 Subject: [PATCH 2/2] feat(security): add operator rotation and recovery commands --- .github/pull_request_template.md | 33 +- REPORT.md | 2 +- compose.test.yaml | 26 ++ compose.yaml | 52 ++- scripts/bootstrap_security.py | 22 +- scripts/credentials.py | 231 +++++++++++++ scripts/observe.py | 40 ++- scripts/operator_task.py | 57 ++++ scripts/pki.py | 359 ++++++++++++++++++++ scripts/prepare_dependencies.py | 15 +- scripts/research_slo.py | 3 + scripts/restart.sh | 3 +- scripts/restart_secure.py | 23 ++ scripts/stand.py | 39 ++- scripts/tls_client.py | 23 ++ scripts/up_security.py | 9 + scripts/verify_cleanup.py | 8 +- scripts/verify_observability_persistence.py | 10 +- scripts/verify_pipeline.py | 7 +- scripts/verify_telemetry.py | 15 +- src/security_probe.py | 8 +- student-unit/test_security.py | 44 +++ 22 files changed, 983 insertions(+), 46 deletions(-) create mode 100644 scripts/credentials.py create mode 100644 scripts/operator_task.py create mode 100644 scripts/pki.py create mode 100644 scripts/restart_secure.py create mode 100644 scripts/tls_client.py diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 8aef0ff..d8018f3 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,18 +1,23 @@ ## Лабораторная 7 -Автор / группа: TODO -Целевая оценка (3/4/5): TODO -Трек 5, если заявлен: TODO +Автор / группа: Маслов, БВТ2301. +Целевая оценка: 5, трек 2 — жизненный цикл сертификатов и секретов. -Что реализовано и что перенесено: TODO -Команды запуска из чистого clone: TODO -Результаты проверок и ссылка на REPORT.md: TODO -Ограничения / известные ошибки: TODO -Источники и использование ИИ: TODO +**Черновик. Работа пока не готова к сдаче.** -- [ ] Весь обязательный минимум текущей и предыдущих работ сохранён с объявленными переходами. -- [ ] Контракт и публичные тесты не ослаблены. -- [ ] make check и make test выполнены; приложен реальный вывод. -- [ ] Сценарии отказов/безопасности своего уровня воспроизведены. -- [ ] Все секреты и приватные ключи находятся вне Git; отчёт не содержит tokens. -- [ ] README задания сохранён, REPORT.md содержит инструкцию именно моего решения. +Перенесено собственное приложение ЛР6: API, очередь задач, обработка изображений отдельным worker, наблюдаемость. Добавлены TLS/mTLS, раздельные удостоверения и права сервисов, конфигурация OpenBao, короткие сертификаты и токены, операторские команды ротации и восстановления, ограничения входа перед хешированием пароля, обновление старого хеша при успешном входе. Границы доверия и ограничения описаны в REPORT.md, contracts/trust-matrix.md и security/THREAT_MODEL.md. + +Пройдены 29 unit-тестов, проверки структуры/OpenAPI/собственного Python-кода и конфигурации Compose. Первый вариант образов собран. pip-audit проверил 40 закреплённых runtime-зависимостей Python без известных уязвимостей по своей базе на момент запуска. Это не проверка безопасности образов. + +Не завершены: запуск всего защищённого стенда, HTTP-регрессия, положительные и отрицательные проверки mTLS/прав, исследование ротации/отзыва/истечения сертификатов и замены CA под нагрузкой, проверка образов и воспроизведение из чистого клона. Пока нет результатов, подтверждающих выполнение требований на оценку 5. + +Запуск оператора: `uv sync --locked`, `make up PYTHON=.venv/bin/python`. Предполагаемый API: `https://localhost:8443`; доверенный CA создаётся локально в `trust/ca.pem`. Команды и подробности: [REPORT.md](https://gitea.privcloud.tech/wh1tet3a/mtusi2026lab7/src/branch/solution/bvt2301-maslov/REPORT.md). + +Источники: задание, собственная ЛР6, официальная документация OpenBao/HAProxy/OWASP. Использована помощь ИИ при проектировании, реализации, проверках и подготовке отчёта; чужие студенческие решения не использовались. + +- [ ] Весь обязательный минимум подтверждён запуском и регрессией. +- [x] Контракт и публичные тесты сохранены. +- [ ] make test и сценарии безопасности выполнены на защищённом стенде. +- [ ] Исследование выбранного трека выполнено и измерения приложены. +- [x] Секреты и приватные ключи находятся вне Git. +- [x] README задания сохранён, собственный REPORT.md заполнен. diff --git a/REPORT.md b/REPORT.md index bcab577..8467b59 100644 --- a/REPORT.md +++ b/REPORT.md @@ -2,7 +2,7 @@ Цель — оценка 5, трек 2: жизненный цикл PKI и секретов. Собственный код ЛР6 перенесён поверх независимого skeleton ЛР7. README/COURSE/публичные tests/OpenAPI/check/validate сохранены; trust matrix заполнена как требует задание. -Текущий статус: реализация готовится к первому запуску. Пройдены 28 unit tests, offline/OpenAPI/lint, проверка конфигурации Compose. Сканирование pip-audit2.10.1 проверило 40 закреплённых runtime зависимостей и не нашло известных уязвимостей в своей базе на момент запуска (`evidence/dependency-scan-first.json`). Это не результат проверки образов или полного стенда. HTTP/mTLS/OpenBao/ротация/исследование/чистый clone пока не подтверждены. +Текущий статус: реализация готовится к первому запуску. Пройдены 29 unit tests, offline/OpenAPI/lint, проверка конфигурации Compose. Сканирование pip-audit2.10.1 проверило 40 закреплённых runtime зависимостей и не нашло известных уязвимостей в своей базе на момент запуска (`evidence/dependency-scan-first.json`). Это не результат проверки образов или полного стенда. HTTP/mTLS/OpenBao/ротация/исследование/чистый clone пока не подтверждены. ## Запуск оператора diff --git a/compose.test.yaml b/compose.test.yaml index 9de164b..608dfca 100644 --- a/compose.test.yaml +++ b/compose.test.yaml @@ -8,3 +8,29 @@ services: worker: environment: PIPELINE_FAULTS: '1' + controller: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + entrypoint: + - python + user: 10001:10001 + environment: + IDENTITY_ENABLED: '1' + volumes: + - ./secrets/operator-task:/run/identity:ro + - ./trust:/trust:ro + read_only: true + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + tmpfs: + - /tmp:rw,noexec,nosuid,size=8m + cpus: 0.5 + mem_limit: 192m + pids_limit: 64 + healthcheck: + disable: true + command: + - -c + - import time;time.sleep(86400) diff --git a/compose.yaml b/compose.yaml index 88a67c1..8fa8e65 100644 --- a/compose.yaml +++ b/compose.yaml @@ -123,7 +123,7 @@ services: depends_on: identity-api: condition: service_started - cpus: ${API_CPUS:-0.5} + cpus: ${API_CPUS:-1} mem_limit: 768m memswap_limit: 768m pids_limit: 128 @@ -144,6 +144,16 @@ services: - -m - src.runtime - src + healthcheck: + test: + - CMD + - python + - -c + - import urllib.request;urllib.request.urlopen('http://127.0.0.1:8080/health/ready',timeout=2).read() + interval: 3s + timeout: 3s + start_period: 45s + retries: 15 s3: image: ${S3_IMAGE:-mtusi-storage:lab7-minio-20251015} build: @@ -1450,13 +1460,22 @@ services: volumes: - ./trust:/trust:ro - ./secrets/probe:/probe-fixtures:ro + - identity_openbao:/identities/openbao:ro - identity_api:/identities/api:ro - identity_worker:/identities/worker:ro - identity_relay:/identities/relay:ro - - identity_lb:/identities/lb:ro - - identity_reconciler:/identities/reconciler:ro - identity_observer:/identities/observer:ro + - identity_reconciler:/identities/reconciler:ro + - identity_migrate:/identities/migrate:ro + - identity_lb:/identities/lb:ro + - identity_postgres:/identities/postgres:ro + - identity_s3:/identities/s3:ro + - identity_broker:/identities/broker:ro + - identity_cache:/identities/cache:ro - identity_otel:/identities/otel:ro + - identity_prometheus:/identities/prometheus:ro + - identity_loki:/identities/loki:ro + - identity_tempo:/identities/tempo:ro - identity_grafana:/identities/grafana:ro cap_drop: - ALL @@ -1472,6 +1491,33 @@ services: pids_limit: 64 healthcheck: disable: true + operator-task: + image: ${API_IMAGE:-mtusi-messenger:lab7} + pull_policy: never + profiles: + - operator + entrypoint: + - python + - -m + - src.operator + user: 10001:10001 + environment: + IDENTITY_ENABLED: '1' + volumes: + - ./secrets/operator-task:/run/identity:ro + - ./trust:/trust:ro + read_only: true + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + tmpfs: + - /tmp:rw,noexec,nosuid,size=8m + cpus: 0.5 + mem_limit: 192m + pids_limit: 64 + healthcheck: + disable: true secrets: postgres_password: file: ./secrets/postgres_password diff --git a/scripts/bootstrap_security.py b/scripts/bootstrap_security.py index f828c2a..df45cd1 100644 --- a/scripts/bootstrap_security.py +++ b/scripts/bootstrap_security.py @@ -270,7 +270,27 @@ def generate(): ).not_valid_after_utc < datetime.now(UTC) + timedelta(hours=1) ) - if not (directory / "key.pem").exists() or renew_operator: + renew_bootstrap = ( + role != "operator" + and (directory / "cert.pem").exists() + and x509.load_pem_x509_certificate( + (directory / "cert.pem").read_bytes() + ).not_valid_after_utc + < datetime.now(UTC) + timedelta(minutes=5) + ) + wrong_issuer = ( + directory / "cert.pem" + ).exists() and x509.load_pem_x509_certificate( + (directory / "cert.pem").read_bytes() + ).issuer != cert.subject + # Only this explicit operator command has the offline CA. Agents + # cannot refresh a bootstrap credential by themselves after expiry. + if ( + not (directory / "key.pem").exists() + or renew_operator + or renew_bootstrap + or wrong_issuer + ): leaf_key, leaf = sign_leaf( key, cert, diff --git a/scripts/credentials.py b/scripts/credentials.py new file mode 100644 index 0000000..089395f --- /dev/null +++ b/scripts/credentials.py @@ -0,0 +1,231 @@ +"""Operator helpers for explicit certificate repair and working-key rotation.""" + +import argparse +import io +import json +import os +import secrets +import ssl +import time +from uuid import uuid4 + +import urllib3 +from minio import Minio +from minio.credentials import StaticProvider +from minio.error import MinioAdminException, S3Error +from minio.minioadmin import MinioAdmin + +from scripts.bao_operator import Operator +from scripts.bootstrap_security import OPERATOR, ROLES, TRUST, write_private +from scripts.prepare_dependencies import attach_policy +from scripts.stand import compose + +INSTALL = """import json,os,pathlib,signal,sys,tempfile +data=json.load(sys.stdin) +base=pathlib.Path('/run/identity') +directory=pathlib.Path(tempfile.mkdtemp(prefix='generation-',dir=base)) +certificate=data['certificate']+'\\n'+'\\n'.join(data.get('ca_chain',[])) +for name,value in [('cert.pem',certificate),('key.pem',data['private_key']),('bundle.pem',certificate+'\\n'+data['private_key'])]: + path=directory/name;path.write_text(value);path.chmod(0o600) +link=base/'operator-next';link.unlink(missing_ok=True);link.symlink_to(directory.name);link.replace(base/'current') +if data.get('reload_lb'):os.kill(1,signal.SIGUSR2) +print('Operator installed a scoped short-lived leaf') +""" + + +def install(role, data): + payload = {**data, "reload_lb": role == "lb"} + args = ["--profile", "maintenance"] if role == "migrate" else [] + compose( + *args, + "run", + "--rm", + "--no-deps", + "-T", + "--entrypoint", + "python", + "identity-" + role, + "-c", + INSTALL, + input=json.dumps(payload), + ) + + +def issue(operator, role): + cfg = ROLES[role] + request = { + "common_name": role, + "alt_names": ",".join(cfg["dns"]), + "uri_sans": "spiffe://messenger/" + role, + "ttl": "120s", + } + if cfg.get("ip"): + request["ip_sans"] = ",".join(cfg["ip"]) + return operator.authorized("POST", "pki/issue/" + role, request)["data"] + + +def repair(operator, role): + result = issue(operator, role) + install(role, result) + return {key: result[key] for key in ["serial_number", "expiration"]} + + +def admin(): + raw = json.loads((OPERATOR / "service-secrets.json").read_text()) + context = ssl.create_default_context(cafile=TRUST / "ca.pem") + context.minimum_version = ssl.TLSVersion.TLSv1_3 + context.load_cert_chain( + OPERATOR / "client/cert.pem", OPERATOR / "client/key.pem" + ) + pool = urllib3.PoolManager( + ssl_context=context, + timeout=urllib3.Timeout(connect=2, read=8), + retries=False, + ) + return ( + raw, + MinioAdmin( + "localhost:" + os.getenv("S3_ADMIN_PORT", "9007"), + credentials=StaticProvider( + raw["s3_root_user"], raw["s3_root_password"] + ), + secure=True, + http_client=pool, + ), + pool, + ) + + +def rotate_s3(operator): + raw, client, pool = admin() + try: + journal_path = OPERATOR / "s3-rotation.json" + resumed = journal_path.exists() and not json.loads( + journal_path.read_text() + ).get("complete") + journal = json.loads(journal_path.read_text()) if resumed else {} + values = journal.get( + "previous_values", raw["services"]["api"]["values"] + ) + previous = values["S3_ACCESS_KEY"] + old = Minio( + "localhost:" + os.getenv("S3_ADMIN_PORT", "9007"), + credentials=StaticProvider(previous, values["S3_SECRET_KEY"]), + secure=True, + http_client=pool, + region="us-east-1", + ) + probe_key = journal.get( + "probe_key", "objects/staging/rotation-" + uuid4().hex + ) + current = journal.get("next_values") or { + **values, + "S3_ACCESS_KEY": "api-" + secrets.token_hex(12), + "S3_SECRET_KEY": secrets.token_urlsafe(32), + } + if not resumed: + old.put_object("messenger", probe_key, io.BytesIO(b"x"), 1) + journal = { + "previous_values": values, + "next_values": current, + "probe_key": probe_key, + "complete": False, + } + write_private(journal_path, json.dumps(journal) + "\n") + client.user_add(current["S3_ACCESS_KEY"], current["S3_SECRET_KEY"]) + attach_policy(client, "messenger-api", current["S3_ACCESS_KEY"]) + operator.authorized("POST", "secret/data/api", {"data": current}) + # Compare a fingerprint; credential values are not placed in argv/output. + import hashlib + + expected = hashlib.sha256( + current["S3_ACCESS_KEY"].encode() + ).hexdigest() + deadline = time.monotonic() + 45 + while time.monotonic() < deadline: + observed = compose( + "exec", + "-T", + "identity-api", + "python", + "-c", + "import hashlib,json;print(hashlib.sha256(json.load(open('/run/identity/secrets.json'))['values']['S3_ACCESS_KEY'].encode()).hexdigest())", + ) + if observed == expected: + break + time.sleep(1) + else: + raise TimeoutError("New scoped S3 key not observed") + raw["services"]["api"]["values"] = current + write_private( + OPERATOR / "service-secrets.json", json.dumps(raw, indent=2) + "\n" + ) + try: + client.user_remove(previous) + except MinioAdminException as error: + if json.loads(error._body).get("Code") != "XMinioAdminNoSuchUser": + raise + pool.clear() + try: + old.put_object("messenger", probe_key, io.BytesIO(b"x"), 1) + except S3Error as error: + assert error.code in {"AccessDenied", "InvalidAccessKeyId"}, ( + error.code + ) + else: + raise AssertionError( + "Removed working key accepted on a fresh connection" + ) + fresh = Minio( + "localhost:" + os.getenv("S3_ADMIN_PORT", "9007"), + credentials=StaticProvider( + current["S3_ACCESS_KEY"], current["S3_SECRET_KEY"] + ), + secure=True, + http_client=pool, + region="us-east-1", + ) + fresh.put_object("messenger", probe_key, io.BytesIO(b"x"), 1) + root = Minio( + "localhost:" + os.getenv("S3_ADMIN_PORT", "9007"), + credentials=StaticProvider( + raw["s3_root_user"], raw["s3_root_password"] + ), + secure=True, + http_client=pool, + region="us-east-1", + ) + root.remove_object("messenger", probe_key) + write_private( + journal_path, json.dumps({**journal, "complete": True}) + "\n" + ) + return { + "new_key_observed": True, + "old_account_removed": True, + "old_key_fresh_connection_denied": True, + "new_key_put_succeeded": True, + "image_rebuilt": False, + } + finally: + pool.clear() + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("action", choices=["repair-leaf", "rotate-s3"]) + parser.add_argument("--role", choices=ROLES, default="lb") + args = parser.parse_args() + operator = Operator() + try: + result = ( + repair(operator, args.role) + if args.action == "repair-leaf" + else rotate_s3(operator) + ) + print(json.dumps(result)) + finally: + operator.close() + + +if __name__ == "__main__": + main() diff --git a/scripts/observe.py b/scripts/observe.py index bc334e5..2a77643 100644 --- a/scripts/observe.py +++ b/scripts/observe.py @@ -8,10 +8,10 @@ from urllib.parse import urlencode from scripts.stand import compose ENDPOINTS = { - "prometheus": "http://prometheus:9090", - "loki": "http://loki:3100", - "tempo": "http://tempo:3200", - "otel": "http://otel:13133", + "prometheus": "https://prometheus:9900", + "loki": "https://loki:3310", + "tempo": "https://tempo:3320", + "otel": "https://otel:13333", } @@ -20,11 +20,20 @@ def fetch(service, path, *, params=None, json_result=True): if params: url += "?" + urlencode(params, doseq=True) code = ( - "import urllib.request; " - f"r=urllib.request.urlopen(urllib.request.Request({url!r},headers={{'Accept':'application/json'}}),timeout=8); " + f"import urllib.request; from src.security_probe import context; service={service!r}; " + f"r=urllib.request.urlopen(urllib.request.Request({url!r},headers={{'Accept':'application/json'}}),timeout=8,context=context('operator' if 'otel' == service else 'grafana')); " "print(r.read().decode())" ) - text = compose("exec", "-T", "observer", "python", "-c", code) + text = compose( + "--profile", + "operator", + "run", + "--rm", + "--no-deps", + "operator-probe", + "-c", + code, + ) return json.loads(text) if json_result else text @@ -50,14 +59,25 @@ def queries(expressions): for name, expression in expressions.items() } code = ( - "import json,urllib.request\n" + "import json,urllib.request\nfrom src.security_probe import context\n" f"urls={urls!r}\n" "result={}\n" "for name,url in urls.items():\n" - " with urllib.request.urlopen(url,timeout=8) as r: result[name]=json.load(r)['data']['result']\n" + " with urllib.request.urlopen(url,timeout=8,context=context('grafana')) as r: result[name]=json.load(r)['data']['result']\n" "print(json.dumps(result))" ) - return json.loads(compose("exec", "-T", "observer", "python", "-c", code)) + return json.loads( + compose( + "--profile", + "operator", + "run", + "--rm", + "--no-deps", + "operator-probe", + "-c", + code, + ) + ) def logs(trace_id, *, start=None): diff --git a/scripts/operator_task.py b/scripts/operator_task.py new file mode 100644 index 0000000..baa69f8 --- /dev/null +++ b/scripts/operator_task.py @@ -0,0 +1,57 @@ +"""Prepare a 60-second operator-only snapshot and run the audited pipeline CLI.""" + +import json +import sys +import time +from urllib.parse import quote + +from scripts.bootstrap_security import OPERATOR, SECRET, write_private +from scripts.stand import compose + + +def prepare(): + raw = json.loads((OPERATOR / "service-secrets.json").read_text()) + directory = SECRET / "operator-task" + directory.mkdir(mode=0o755, exist_ok=True) + for name in ["cert.pem", "key.pem"]: + write_private( + directory / "current" / name, + (OPERATOR / "client" / name).read_bytes(), + mode=0o644, + ) + values = { + "DATABASE_URL": "postgresql://messenger:" + + quote(raw["postgres_password"], safe="") + + "@postgres:5443/messenger?sslmode=verify-full&gssencmode=disable&sslrootcert=/trust/ca.pem&sslcert=/run/identity/current/cert.pem&sslkey=/run/identity/current/key.pem", + "BROKER_URL": "rediss://admin:" + + raw["broker_admin"] + + "@broker:6380/0", + "S3_ACCESS_KEY": raw["s3_root_user"], + "S3_SECRET_KEY": raw["s3_root_password"], + } + write_private( + directory / "secrets.json", + json.dumps({"valid_until": time.time() + 60, "values": values}) + "\n", + mode=0o644, + ) + + +def run(*args): + prepare() + return compose( + "--profile", + "operator", + "run", + "--rm", + "--no-deps", + "operator-task", + *args, + ) + + +def main(): + print(run(*sys.argv[1:])) + + +if __name__ == "__main__": + main() diff --git a/scripts/pki.py b/scripts/pki.py new file mode 100644 index 0000000..e8aec19 --- /dev/null +++ b/scripts/pki.py @@ -0,0 +1,359 @@ +"""Explicit operator PKI lifecycle; trust is never disabled.""" + +import argparse +import json +import time +from uuid import uuid4 + +from cryptography import x509 +from cryptography.hazmat.primitives import hashes + +from scripts.bao_operator import Operator +from scripts.bootstrap_security import ( + OPERATOR, + ROLES, + SECRET, + TRUST, + ca, + key_bytes, + make_root, + public, + sign_intermediate, + sign_leaf, + write_private, +) +from scripts.credentials import install, repair +from scripts.stand import compose + +REQUEST = ( + b"GET /health/live HTTP/1.1\r\nHost: api\r\nConnection: close\r\n\r\n" +) + + +def fixture_check(role, *, reject=False): + expression = f"exchange('api',8443,{role!r},{REQUEST!r})" + assertion = ( + "denied(lambda:" + expression + ")" + if reject + else "b' 200 ' in " + expression + ) + code = ( + "from src.security_probe import exchange,denied;assert " + + assertion + + ";print('Fresh TLS fixture check passed')" + ) + compile(code, "fixture-check", "exec") + return compose( + "--profile", + "operator", + "run", + "--rm", + "--no-deps", + "operator-probe", + "-c", + code, + ) + + +META = """import json,pathlib +from cryptography import x509 +result={} +for directory in pathlib.Path('/identities').iterdir(): + try: + cert=x509.load_pem_x509_certificate((directory/'current/cert.pem').read_bytes()) + result[directory.name]={'serial':format(cert.serial_number,'x'),'issuer':cert.issuer.rfc4514_string(),'expires_at':cert.not_valid_after_utc.timestamp()} + except FileNotFoundError:pass +print(json.dumps(result)) +""" + + +def metadata(): + return json.loads( + compose( + "--profile", + "operator", + "run", + "--rm", + "--no-deps", + "operator-probe", + "-c", + META, + ) + ) + + +def reload_lb(): + compose( + "exec", + "-T", + "identity-lb", + "python", + "-c", + "import os,signal;os.kill(1,signal.SIGUSR2)", + ) + + +def preserve_lb(): + data = json.loads( + compose( + "exec", + "-T", + "identity-lb", + "python", + "-c", + "import json,pathlib;p=pathlib.Path('/run/identity/current');print(json.dumps({name:(p/name).read_text() for name in ['cert.pem','key.pem']}))", + ) + ) + directory = SECRET / "probe/revoked-lb" + for name, value in data.items(): + write_private(directory / name, value, mode=0o644) + leaf = x509.load_pem_x509_certificate(data["cert.pem"].encode()) + return { + "serial": format(leaf.serial_number, "x"), + "expires_at": leaf.not_valid_after_utc.timestamp(), + } + + +def revoke(operator, leaf): + assert leaf["expires_at"] > time.time() + 5, ( + "Revocation must be tested before natural expiry" + ) + serial = leaf["serial"] + serial = ("0" + serial) if len(serial) % 2 else serial + colon = ":".join(serial[i : i + 2] for i in range(0, len(serial), 2)) + operator.authorized("POST", "pki/revoke", {"serial_number": colon}) + response = operator.http.get( + "pki/crl/pem", + headers={"X-Vault-Token": operator.token or operator.authenticate()}, + ) + response.raise_for_status() + operator.authorized( + "PUT", "auth/cert/crls/service-issuer", {"crl": response.text} + ) + revoked = json.loads((TRUST / "revoked.json").read_text()) + revoked[leaf["serial"]] = True + write_private( + TRUST / "revoked.json", json.dumps(revoked) + "\n", mode=0o644 + ) + fixture_check("revoked-lb", reject=True) + return { + "revoked_serial": leaf["serial"], + "still_unexpired_at_check": leaf["expires_at"] > time.time(), + "new_tls_connection_denied": True, + "bao_crl_updated": True, + } + + +def reload_bao(): + compose("restart", "openbao") + last = None + for _ in range(60): + operator = Operator() + try: + operator.unseal() + operator.authenticate() + return + except Exception as error: + last = type(error).__name__ + finally: + operator.close() + time.sleep(1) + raise TimeoutError("Verified Bao restart/unseal unavailable: " + str(last)) + + +def recover_bao(): + # Explicit operator recovery after the server leaf itself has expired. + key, root = ca() + leaf_key, leaf = sign_leaf( + key, + root, + "openbao", + ["openbao", "localhost"], + ["127.0.0.1"], + seconds=120, + ) + install( + "openbao", + { + "certificate": public(leaf).decode(), + "private_key": key_bytes(leaf_key).decode(), + "ca_chain": [public(root).decode()], + }, + ) + time.sleep(6) + operator = Operator() + try: + operator.unseal() + for role in ROLES: + if role != "migrate": + repair(operator, role) + finally: + operator.close() + + +def rollover(): + old_key, old_root = ca() + new_key, new_root = make_root() + directory = OPERATOR / ("rollover-" + uuid4().hex[:12]) + directory.mkdir(mode=0o700) + fixture_key, fixture = sign_leaf( + old_key, old_root, "lb", ["lb"], seconds=900 + ) + write_private( + SECRET / "probe/retired-ca-lb/cert.pem", + public(fixture) + public(old_root), + mode=0o644, + ) + write_private( + SECRET / "probe/retired-ca-lb/key.pem", + key_bytes(fixture_key), + mode=0o644, + ) + fixture_check("retired-ca-lb") + for name, value in [ + ("old-key.pem", key_bytes(old_key)), + ("old-ca.pem", public(old_root)), + ("new-key.pem", key_bytes(new_key)), + ("new-ca.pem", public(new_root)), + ]: + write_private(directory / name, value) + journal = { + "phase": "dual_trust", + "old_ca_sha256": old_root.fingerprint(hashes.SHA256()).hex(), + "new_ca_sha256": new_root.fingerprint(hashes.SHA256()).hex(), + } + write_private(directory / "state.json", json.dumps(journal) + "\n") + write_private( + TRUST / "ca.pem", public(old_root) + public(new_root), mode=0o644 + ) + reload_lb() # Load both roots before any API server leaf changes issuer. + reload_bao() # Native client CA requires an explicit listener restart. + operator = Operator() + try: + for role in [*ROLES, "operator"]: + operator.authorized( + "POST", + "auth/cert/certs/" + role + "-v2", + { + "display_name": role, + "certificate": public(new_root).decode(), + "allowed_common_names": [role], + "allowed_uri_sans": ["spiffe://messenger/" + role], + "token_policies": ["messenger-" + role], + "token_ttl": "900s" if role == "operator" else "120s", + "token_max_ttl": "3600s" if role == "operator" else "600s", + "token_no_default_policy": True, + }, + ) + csr = operator.authorized( + "POST", + "pki/intermediate/generate/internal", + { + "common_name": "Messenger rollover intermediate " + + uuid4().hex[:12], + "key_type": "ec", + "key_bits": 256, + }, + )["data"]["csr"] + intermediate = sign_intermediate( + new_key, new_root, x509.load_pem_x509_csr(csr.encode()) + ) + imported = operator.authorized( + "POST", + "pki/intermediate/set-signed", + { + "certificate": ( + public(intermediate) + public(new_root) + ).decode() + }, + )["data"]["imported_issuers"] + chosen = None + for issuer in imported: + details = operator.authorized("GET", "pki/issuer/" + issuer)[ + "data" + ] + if ( + x509.load_pem_x509_certificate( + details["certificate"].encode() + ).serial_number + == intermediate.serial_number + ): + chosen = issuer + assert chosen + operator.authorized( + "POST", + "pki/config/issuers", + {"default": chosen, "default_follows_latest_issuer": False}, + ) + journal["phase"] = "new_issuer_active" + write_private(directory / "state.json", json.dumps(journal) + "\n") + deadline = time.monotonic() + 120 + active = set(ROLES) - {"migrate"} + while time.monotonic() < deadline: + observed = metadata() + if active <= observed.keys() and all( + observed[r]["issuer"] == intermediate.subject.rfc4514_string() + for r in active + ): + break + time.sleep(3) + else: + raise TimeoutError( + "Not all active services renewed into new issuer" + ) + fixture_check("retired-ca-lb") + # Allow old L4 connections to expire, then remove old trust everywhere. + time.sleep(46) + for role in [*ROLES, "operator"]: + operator.authorized("DELETE", "auth/cert/certs/" + role + "-v1") + client_key, client_cert = sign_leaf( + new_key, new_root, "operator", ["operator"], seconds=86400 + ) + write_private(OPERATOR / "client/key.pem", key_bytes(client_key)) + write_private( + OPERATOR / "client/cert.pem", + public(client_cert) + public(new_root), + ) + write_private(OPERATOR / "ca-key.pem", key_bytes(new_key)) + write_private(OPERATOR / "ca.pem", public(new_root)) + write_private(TRUST / "ca.pem", public(new_root), mode=0o644) + journal["phase"] = "old_trust_retired" + write_private(directory / "state.json", json.dumps(journal) + "\n") + finally: + operator.close() + reload_lb() + reload_bao() + fixture_check("retired-ca-lb", reject=True) + fixture_check("lb") + journal["phase"] = "complete" + write_private(directory / "state.json", json.dumps(journal) + "\n") + return { + **journal, + "issuer_id": chosen, + "active_service_count": len(active), + "old_l4_connections_waited_seconds": 46, + "old_ca_fixture_valid_during_dual_trust": True, + "old_ca_new_connection_denied_after_retirement": True, + "services": metadata(), + "image_rebuilt": False, + } + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument( + "action", choices=["metadata", "rollover", "recover-bao"] + ) + args = parser.parse_args() + if args.action == "metadata": + result = metadata() + elif args.action == "rollover": + result = rollover() + else: + recover_bao() + result = {"recovered": True} + print(json.dumps(result)) + + +if __name__ == "__main__": + main() diff --git a/scripts/prepare_dependencies.py b/scripts/prepare_dependencies.py index f015e26..f87b60d 100644 --- a/scripts/prepare_dependencies.py +++ b/scripts/prepare_dependencies.py @@ -1,6 +1,7 @@ """Operator-only, idempotent SQL roles and scoped S3 accounts.""" import json +import os import ssl import time @@ -14,6 +15,12 @@ from scripts.bootstrap_security import OPERATOR, TRUST from scripts.stand import compose +def attach_policy(client, policy, user): + attached = json.loads(client.user_info(user)).get("policyName", "") or "" + if policy not in attached.split(","): + client.attach_policy([policy], user=user) + + def postgres(raw): # The bootstrap SQL channel is the server's local Unix socket. No password # or SQL literal is placed in argv; stdin and output are never recorded. @@ -190,13 +197,13 @@ def s3(raw): ) credentials = StaticProvider(raw["s3_root_user"], raw["s3_root_password"]) admin = MinioAdmin( - "localhost:9007", + "localhost:" + os.getenv("S3_ADMIN_PORT", "9007"), credentials=credentials, secure=True, http_client=pool, ) client = Minio( - "localhost:9007", + "localhost:" + os.getenv("S3_ADMIN_PORT", "9007"), credentials=credentials, secure=True, http_client=pool, @@ -248,9 +255,7 @@ def s3(raw): policy={"Version": "2012-10-17", "Statement": statements}, ) admin.user_add(values["S3_ACCESS_KEY"], values["S3_SECRET_KEY"]) - admin.attach_policy( - ["messenger-" + role], user=values["S3_ACCESS_KEY"] - ) + attach_policy(admin, "messenger-" + role, values["S3_ACCESS_KEY"]) pool.clear() diff --git a/scripts/research_slo.py b/scripts/research_slo.py index 483a26f..12b7bcc 100644 --- a/scripts/research_slo.py +++ b/scripts/research_slo.py @@ -16,6 +16,8 @@ from uuid import uuid4 import httpx from PIL import Image +from scripts.tls_client import FreshTrustTransport + os.environ.setdefault("COMPOSE_FILE", "compose.yaml:compose.test.yaml") from scripts.observe import fetch, logs, queries, spans, wait from scripts.stand import BASE, ROOT, actor, auth, command, compose, ready, sql @@ -215,6 +217,7 @@ def main(): load = None trigger = "lab6_slo_delay_" + uuid4().hex[:8] with httpx.Client( + transport=FreshTrustTransport(), base_url=BASE, timeout=8, trust_env=False, diff --git a/scripts/restart.sh b/scripts/restart.sh index f123bd9..91dd041 100755 --- a/scripts/restart.sh +++ b/scripts/restart.sh @@ -1,4 +1,3 @@ #!/bin/sh set -eu -docker compose restart api postgres cache s3 broker relay worker lb -docker compose up -d --no-build --no-recreate --wait +exec python3 -m scripts.restart_secure diff --git a/scripts/restart_secure.py b/scripts/restart_secure.py new file mode 100644 index 0000000..2e216ec --- /dev/null +++ b/scripts/restart_secure.py @@ -0,0 +1,23 @@ +"""Restart persistent services and rejoin their protected local namespaces.""" + +from scripts.stand import compose, ready + + +def main(): + compose( + "restart", + "api", + "postgres", + "cache", + "s3", + "broker", + "relay", + "worker", + "lb", + ) + compose("up", "-d", "--no-build", "--no-recreate", "--wait") + ready(timeout=90) + + +if __name__ == "__main__": + main() diff --git a/scripts/stand.py b/scripts/stand.py index 315d830..b7fe5f0 100644 --- a/scripts/stand.py +++ b/scripts/stand.py @@ -26,7 +26,44 @@ def command(args, *, input=None): def compose(*args, input=None): - return command(["docker", "compose", *args], input=input) + if args[0] == "exec" and "controller" in args: + from scripts.operator_task import prepare + + prepare() + result = command(["docker", "compose", *args], input=input) + # A restarted native container can get a new network namespace. Rejoin + # its TLS gateway explicitly instead of keeping an obsolete loopback hop. + native = { + "postgres", + "cache", + "broker", + "s3", + "lb", + "otel", + "prometheus", + "loki", + "tempo", + "grafana", + } + if args[0] in {"restart", "up"}: + targets = sorted(native.intersection(args[1:])) + if targets: + command( + [ + "docker", + "compose", + "up", + "-d", + "--no-deps", + "--force-recreate", + *[role + "-tls" for role in targets], + ] + ) + if "lb" in targets: + command( + ["docker", "compose", "up", "-d", "--no-deps", "identity-lb"] + ) + return result def sql(query, *, database="messenger"): diff --git a/scripts/tls_client.py b/scripts/tls_client.py new file mode 100644 index 0000000..d32fed4 --- /dev/null +++ b/scripts/tls_client.py @@ -0,0 +1,23 @@ +"""Verified public HTTPS with trust reloaded on every fresh connection.""" + +import ssl + +import httpx + +from scripts.bootstrap_security import TRUST + + +class FreshTrustTransport(httpx.BaseTransport): + def handle_request(self, request): + context = ssl.create_default_context(cafile=TRUST / "ca.pem") + context.minimum_version = ssl.TLSVersion.TLSv1_3 + with httpx.HTTPTransport( + verify=context, trust_env=False, retries=0 + ) as transport: + response = transport.handle_request(request) + return httpx.Response( + response.status_code, + headers=response.headers, + content=response.read(), + request=request, + ) diff --git a/scripts/up_security.py b/scripts/up_security.py index c41964f..a036fae 100644 --- a/scripts/up_security.py +++ b/scripts/up_security.py @@ -8,6 +8,7 @@ import time from scripts.bao_operator import Operator from scripts.bootstrap_security import OPERATOR, generate +from scripts.credentials import repair from scripts.prepare_dependencies import main as dependencies from scripts.prepare_dependencies import postgres from scripts.stand import ROOT, command, compose, ready @@ -42,6 +43,9 @@ def main(): operator.init() operator.unseal() operator.configure() + # The maintenance identity is intentionally stopped between migrations. + # Its expired leaf is repaired explicitly by the operator before reuse. + repair(operator, "migrate") finally: operator.close() agents = [ @@ -107,6 +111,11 @@ def main(): "observer", "reconciler", ) + if "compose.test.yaml" in os.getenv("COMPOSE_FILE", ""): + from scripts.operator_task import prepare + + prepare() + compose("up", "-d", "--no-deps", "controller") ready(timeout=120) print("Secure stand ready at https://localhost:8443; values remain local") diff --git a/scripts/verify_cleanup.py b/scripts/verify_cleanup.py index e4e622c..e9bacaf 100644 --- a/scripts/verify_cleanup.py +++ b/scripts/verify_cleanup.py @@ -10,6 +10,7 @@ from uuid import uuid4 import httpx from scripts.stand import BASE, ROOT, actor, auth, command, compose, ready +from scripts.tls_client import FreshTrustTransport from scripts.verify_pipeline import inside, operator, wait @@ -19,7 +20,12 @@ def seed(path): ready() compose("stop", "--timeout", "1", "reconciler") raw = (ROOT / "tests/fixtures/sample.png").read_bytes() - with httpx.Client(base_url=BASE, trust_env=False, timeout=20) as c: + with httpx.Client( + transport=FreshTrustTransport(), + base_url=BASE, + trust_env=False, + timeout=20, + ) as c: user, _, session = actor(c) headers = auth(session) result = c.post( diff --git a/scripts/verify_observability_persistence.py b/scripts/verify_observability_persistence.py index 13e2a59..174fe06 100644 --- a/scripts/verify_observability_persistence.py +++ b/scripts/verify_observability_persistence.py @@ -8,6 +8,8 @@ from datetime import UTC, datetime import httpx +from scripts.tls_client import FreshTrustTransport + os.environ.setdefault("COMPOSE_FILE", "compose.yaml:compose.test.yaml") from scripts.observe import fetch, logs, query, spans, wait from scripts.stand import ROOT, command, compose @@ -57,9 +59,13 @@ def main(): "complete": False, } password = (ROOT / "secrets/grafana_password").read_text().strip() - base = "http://127.0.0.1:" + os.getenv("GRAFANA_PORT", "3006") + base = "https://localhost:" + os.getenv("GRAFANA_PORT", "3447") with httpx.Client( - base_url=base, auth=("admin", password), timeout=10, trust_env=False + transport=FreshTrustTransport(), + base_url=base, + auth=("admin", password), + timeout=10, + trust_env=False, ) as grafana: preferences = grafana.get("/api/user/preferences") preferences.raise_for_status() diff --git a/scripts/verify_pipeline.py b/scripts/verify_pipeline.py index 28e9385..57d9f1d 100644 --- a/scripts/verify_pipeline.py +++ b/scripts/verify_pipeline.py @@ -13,6 +13,8 @@ from uuid import uuid4 import httpx from PIL import Image +from scripts.tls_client import FreshTrustTransport + os.environ.setdefault("COMPOSE_FILE", "compose.yaml:compose.test.yaml") os.environ.setdefault("NO_PROXY", "localhost,127.0.0.1") os.environ.setdefault("no_proxy", "localhost,127.0.0.1") @@ -149,7 +151,10 @@ def main(): ) stop("reconciler") with httpx.Client( - base_url=BASE, trust_env=False, timeout=25 + transport=FreshTrustTransport(), + base_url=BASE, + trust_env=False, + timeout=25, ) as client: user, _, session = actor(client) h = auth(session) diff --git a/scripts/verify_telemetry.py b/scripts/verify_telemetry.py index d2a8765..cce0d17 100644 --- a/scripts/verify_telemetry.py +++ b/scripts/verify_telemetry.py @@ -11,6 +11,8 @@ from uuid import uuid4 import httpx from PIL import Image +from scripts.tls_client import FreshTrustTransport + os.environ.setdefault("COMPOSE_FILE", "compose.yaml:compose.test.yaml") from scripts.observe import fetch, logs, query, spans, wait from scripts.stand import BASE, ROOT, actor, auth, command, compose, ready, sql @@ -78,7 +80,10 @@ def main(): raw = buffer.getvalue() sentinel = "PrivacyProbe-" + uuid4().hex with httpx.Client( - base_url=BASE, timeout=15, trust_env=False + transport=FreshTrustTransport(), + base_url=BASE, + timeout=15, + trust_env=False, ) as client: user, _, session = actor(client) headers = auth(session) @@ -266,10 +271,14 @@ def main(): assert all(sentinel not in json.dumps(s) for s in series) report["metric_series_count"] = len(series) report["metric_labels_low_cardinality"] = True - url = "http://127.0.0.1:" + os.getenv("GRAFANA_PORT", "3006") + url = "https://localhost:" + os.getenv("GRAFANA_PORT", "3447") password = (ROOT / "secrets/grafana_password").read_text().strip() with httpx.Client( - base_url=url, auth=("admin", password), trust_env=False, timeout=15 + transport=FreshTrustTransport(), + base_url=url, + auth=("admin", password), + trust_env=False, + timeout=15, ) as grafana: dashboard = grafana.get("/api/dashboards/uid/messenger-lab6") dashboard.raise_for_status() diff --git a/src/security_probe.py b/src/security_probe.py index 6bd6725..3fd214f 100644 --- a/src/security_probe.py +++ b/src/security_probe.py @@ -30,7 +30,11 @@ def context(role=None, *, foreign=False, wrong_ca=False): directory = ( Path("/probe-fixtures/foreign") if foreign - else Path("/identities") / role / "current" + else ( + Path("/probe-fixtures") / role + if role in {"revoked-lb", "retired-ca-lb"} + else Path("/identities") / role / "current" + ) ) ctx.load_cert_chain(directory / "cert.pem", directory / "key.pem") return ctx @@ -308,7 +312,7 @@ def main(): "worker_staging_write_denied": s3_denied( lambda: put("worker", staging) ), - "worker_other_bucket_denied": s3_denied( + "worker_list_all_buckets_denied": s3_denied( lambda: clients["worker"].list_buckets() ), "worker_delete_denied": s3_denied( diff --git a/student-unit/test_security.py b/student-unit/test_security.py index d01aeaf..2655ba7 100644 --- a/student-unit/test_security.py +++ b/student-unit/test_security.py @@ -1,4 +1,7 @@ +import io import json +import ssl +import sys import time import pytest @@ -58,3 +61,44 @@ def test_bootstrap_repairs_config_without_changing_credentials( assert config.read_bytes() == expected assert bootstrap.OPERATOR.stat().st_mode & 0o777 == 0o700 assert private.stat().st_mode & 0o777 == 0o600 + + +def test_operator_leaf_install_preserves_pem_and_matching_pair( + tmp_path, monkeypatch +): + from cryptography import x509 + + from scripts.bootstrap_security import ( + key_bytes, + make_root, + public, + sign_leaf, + ) + from scripts.credentials import INSTALL + + root_key, root_cert = make_root() + key, leaf = sign_leaf(root_key, root_cert, "worker", ["worker"]) + payload = { + "certificate": public(leaf).decode(), + "private_key": key_bytes(key).decode(), + "ca_chain": [public(root_cert).decode()], + } + monkeypatch.setattr(sys, "stdin", io.StringIO(json.dumps(payload))) + code = INSTALL.replace( + "pathlib.Path('/run/identity')", + "pathlib.Path(" + repr(str(tmp_path)) + ")", + ) + exec(compile(code, "operator-install-test", "exec"), {}) + current = tmp_path / "current" + assert current.is_symlink() + assert ( + len( + x509.load_pem_x509_certificates( + (current / "cert.pem").read_bytes() + ) + ) + == 2 + ) + context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) + context.load_cert_chain(current / "cert.pem", current / "key.pem") + assert (current / "key.pem").stat().st_mode & 0o777 == 0o600 -- 2.54.0