forked from mtusi2026/mtusi2026lab6
ЛР 6 — БПИ2303 — Лазарев — на 4
Перенесена реализация lab5 (API x2 за HAProxy, PostgreSQL, SeaweedFS S3, RabbitMQ, relay outbox, worker x2, janitor) без изменения бизнес-API. Наблюдаемость: - OpenTelemetry SDK в API, relay, worker, janitor: traces, metrics, logs по OTLP/HTTP; структурные JSON-логи с trace_id/span_id - OTel Collector (memory_limiter, batch, ограниченные очереди и retry), Prometheus (метрики, alert rules), Loki (логи), Tempo (трассы), Grafana с provisioning datasources и dashboard - W3C trace context API -> outbox -> RabbitMQ -> worker (parent-child, включая retry); метрики очереди, пула БД, загрузки worker, CPU/RAM - SLI/SLO, 10 alert rules с unit-тестами promtool и runbooks - инциденты: остановка worker, блокировка БД, отказ telemetry backend; по наблюдениям исправлен простой worker в цикле AMQP (разбор x2.4)
This commit is contained in:
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Проверка перед commit: значения из secrets/ (пароли, ключи S3, URL брокера) не встречаются
|
||||
ни в одном файле репозитория вне secrets/ и .env. Значения не печатаются — только имена файлов.
|
||||
python3 scripts/scan_secrets.py (код 0 — чисто)"""
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SKIP_DIRS = {".git", "secrets", ".venv", "__pycache__", "node_modules"}
|
||||
values = set()
|
||||
for f in (ROOT / "secrets").glob("*"):
|
||||
text = f.read_text(encoding="utf-8", errors="replace").strip()
|
||||
if f.suffix == ".json":
|
||||
def walk(x):
|
||||
if isinstance(x, dict):
|
||||
for k, v in x.items():
|
||||
if k in ("accessKey", "secretKey", "password_hash"):
|
||||
values.add(str(v))
|
||||
walk(v)
|
||||
elif isinstance(x, list):
|
||||
for v in x:
|
||||
walk(v)
|
||||
walk(json.loads(text))
|
||||
elif len(text) >= 8:
|
||||
values.add(text)
|
||||
if "://" in text and "@" in text: # пароль из URL брокера
|
||||
values.add(text.split("://", 1)[1].split("@", 1)[0].split(":", 1)[-1])
|
||||
hits = []
|
||||
for p in ROOT.rglob("*"):
|
||||
if p.is_dir() or set(p.relative_to(ROOT).parts) & SKIP_DIRS or p.name == ".env":
|
||||
continue
|
||||
try:
|
||||
data = p.read_text(encoding="utf-8", errors="ignore")
|
||||
except OSError:
|
||||
continue
|
||||
if any(v in data for v in values):
|
||||
hits.append(str(p.relative_to(ROOT)))
|
||||
print("checked %d secret values; files with leaks: %s" % (len(values), hits or "none"))
|
||||
sys.exit(1 if hits else 0)
|
||||
Reference in New Issue
Block a user