126 lines
5.4 KiB
Makefile
126 lines
5.4 KiB
Makefile
PYTHON ?= python3
|
|
BASE_URL ?= https://localhost:8443
|
|
CA_FILE ?= $(CURDIR)/secrets/tls/trust/ca.crt
|
|
ACTION_SCRIPT ?=
|
|
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
|
|
|
|
.PHONY: help check validate test load test-persistence test-failover test-security
|
|
|
|
help:
|
|
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
|
|
|
|
check:
|
|
$(PYTHON) scripts/check_contract.py
|
|
|
|
validate:
|
|
$(PYTHON) scripts/validate_openapi.py
|
|
|
|
test:
|
|
$(PYTHON) tests/smoke.py --base-url "$(BASE_URL)" $(TLS_ARGS)
|
|
|
|
load:
|
|
$(PYTHON) tests/load.py --base-url "$(BASE_URL)" $(TLS_ARGS)
|
|
|
|
test-persistence:
|
|
@test -n "$(ACTION_SCRIPT)" || (echo "Set ACTION_SCRIPT to your implemented executable restart hook"; exit 2)
|
|
$(PYTHON) tests/resilience.py --mode persistence --action-script "$(ACTION_SCRIPT)" --base-url "$(BASE_URL)" $(TLS_ARGS)
|
|
|
|
test-failover:
|
|
@test -n "$(ACTION_SCRIPT)" || (echo "Set ACTION_SCRIPT to your implemented executable stop-one hook"; exit 2)
|
|
$(PYTHON) tests/resilience.py --mode failover --action-script "$(ACTION_SCRIPT)" --base-url "$(BASE_URL)" $(TLS_ARGS)
|
|
|
|
test-security:
|
|
$(PYTHON) tests/security.py --base-url "$(BASE_URL)" $(TLS_ARGS)
|
|
|
|
# ============================================================================== решение lab7
|
|
# Все команды — с хоста (Linux/macOS); Windows PowerShell — эквиваленты в REPORT.md (scripts\*.ps1).
|
|
COMPOSE ?= docker compose --env-file .env
|
|
ALL_PROFILES = --profile ttl --profile fault --profile tools --profile tests
|
|
GHSA_DB ?= /tmp/ghsa
|
|
export NO_PROXY := 127.0.0.1,localhost
|
|
export CA_FILE
|
|
|
|
.PHONY: secrets up ps logs down destroy-data unseal seal bao-status restore stop-worker start-worker \
|
|
test-internal test-student-security test-hardening test-lifecycle test-student jobs-invariants \
|
|
rotate-db rotate-s3 rotate-cert renew-certs track1 login-dos kdf-bench dep-scan image-scan secret-scan evidence
|
|
|
|
# Оператор: локальные secrets + PKI (идемпотентно), затем OpenBao init/unseal/bootstrap и весь стенд.
|
|
secrets:
|
|
./scripts/init-secrets.sh
|
|
up: secrets
|
|
PROFILES="--profile ttl" ./scripts/up.sh
|
|
ps:
|
|
$(COMPOSE) $(ALL_PROFILES) ps -a
|
|
logs:
|
|
$(COMPOSE) logs --tail=100 lb api worker nats openbao otel-collector
|
|
# Безопасная остановка: контейнеры удаляются, ВСЕ volumes (данные, raft OpenBao, telemetry) сохраняются.
|
|
down:
|
|
$(COMPOSE) $(ALL_PROFILES) down --remove-orphans
|
|
# НАМЕРЕННОЕ удаление учебных данных (volumes + материал оператора OpenBao + выданные SecretID), с подтверждением.
|
|
destroy-data:
|
|
./scripts/reset.sh
|
|
# OpenBao после каждого рестарта запечатан: unseal — 2 из 3 shares из каталога оператора.
|
|
unseal:
|
|
$(PYTHON) scripts/bao_admin.py unseal
|
|
seal:
|
|
$(PYTHON) scripts/bao_admin.py seal
|
|
bao-status:
|
|
$(PYTHON) scripts/bao_admin.py status
|
|
restore:
|
|
./scripts/start-replicas.sh
|
|
stop-worker:
|
|
./scripts/stop-worker.sh
|
|
start-worker:
|
|
./scripts/start-worker.sh
|
|
|
|
# Уровни 3–4: матрица доверия изнутри сетей (probe), внешняя граница/ACL, hardening, lifecycle.
|
|
test-internal:
|
|
$(COMPOSE) --profile tests run --rm -T probe student-tests/internal_security.py
|
|
test-student-security:
|
|
$(PYTHON) student-tests/test_security.py
|
|
test-hardening:
|
|
$(PYTHON) student-tests/test_hardening.py
|
|
test-lifecycle:
|
|
$(PYTHON) student-tests/test_lifecycle.py --json evidence/lifecycle.json
|
|
# Регрессия lab2–lab6 поверх HTTPS/mTLS. Учебные хуки отказов lab5 включаются только на время прогона:
|
|
# переменная экспортируется, т.к. тесты сами пересоздают worker; в конце api/worker возвращаются без хуков.
|
|
test-student: export FAULT_HOOKS := lab
|
|
test-student:
|
|
$(COMPOSE) up -d --no-deps --force-recreate --wait api worker
|
|
for t in test_api test_idempotency test_attachments test_expiry test_pipeline test_failures test_observability \
|
|
test_jobs_failures test_storage_failures test_pipeline_idempotency test_telemetry_persistence; do \
|
|
$(PYTHON) student-tests/$$t.py || exit 1; done
|
|
FAULT_HOOKS= $(COMPOSE) up -d --no-deps --force-recreate --wait api worker
|
|
jobs-invariants:
|
|
$(COMPOSE) --profile tools exec -T ops python -m messenger jobs invariants --settled --verify-bytes
|
|
|
|
# Ротация без пересборки: SVC=api|worker; CERT=lb|ingress|api|worker|nats|...
|
|
SVC ?= worker
|
|
CERT ?= lb
|
|
rotate-db:
|
|
$(PYTHON) scripts/rotate_credentials.py db $(SVC)
|
|
rotate-s3:
|
|
$(PYTHON) scripts/rotate_credentials.py s3 $(SVC)
|
|
rotate-cert:
|
|
$(PYTHON) scripts/rotate_cert.py $(CERT)
|
|
renew-certs:
|
|
$(PYTHON) scripts/rotate_cert.py --renew 7
|
|
|
|
# Уровень 5 (трек 1) и бюджет login DoS.
|
|
track1:
|
|
$(PYTHON) research/worker_compromise.py --out evidence/track1
|
|
login-dos:
|
|
$(PYTHON) research/login_dos.py --out evidence/login_dos.json
|
|
kdf-bench:
|
|
$(COMPOSE) exec -T api python -m messenger kdf-bench
|
|
|
|
# Сканы: зависимости (GitHub Advisory DB, офлайн-клон), образы (Trivy), секреты в репозитории/evidence.
|
|
dep-scan:
|
|
$(PYTHON) scripts/dep_scan.py --db "$(GHSA_DB)" --json evidence/scan/deps.json
|
|
image-scan:
|
|
./scripts/scan.sh
|
|
secret-scan:
|
|
$(PYTHON) scripts/secret_scan.py
|
|
evidence:
|
|
GHSA_DB="$(GHSA_DB)" ./scripts/collect-evidence.sh
|