From 5aad71bdf9e9d4b9b75f39414bc3b4bd3aad8a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B0=D1=81=D0=B8=D0=BB=D1=8C=D0=B5=D0=B2=20=D0=9D?= =?UTF-8?q?=D0=B8=D0=BA=D0=B8=D1=82=D0=B0?= Date: Mon, 16 Nov 2026 13:13:46 +0300 Subject: [PATCH] Use read-only Prometheus requests and record reproducible security measurements --- research/auth_budget.py | 4 +++- research/readiness.py | 44 ++++++++++++++++++++++++++++++++++++++ scripts/bootstrap.py | 1 + scripts/security_checks.py | 2 +- 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 research/readiness.py diff --git a/research/auth_budget.py b/research/auth_budget.py index 4599799..638449f 100644 --- a/research/auth_budget.py +++ b/research/auth_budget.py @@ -66,7 +66,9 @@ def main(): time.sleep(10.2) wrong = ( "Basic " - + base64.b64encode((actor["registration"]["username"] + ":incorrect").encode()).decode() + + base64.b64encode( + (actor["registration"]["username"] + ":incorrect-password-for-budget").encode() + ).decode() ) rows = [] for _ in range(12): diff --git a/research/readiness.py b/research/readiness.py new file mode 100644 index 0000000..e84c8a4 --- /dev/null +++ b/research/readiness.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +"""Concurrent health probes detect starvation without retrying readiness failures.""" + +import collections +import concurrent.futures +import json +import ssl +import urllib.error +import urllib.request +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] + + +def main(): + context = ssl.create_default_context(cafile=str(ROOT / "secrets/ca.pem")) + + def one(_): + try: + with urllib.request.urlopen( + "https://localhost:8447/health/ready", context=context, timeout=8 + ) as response: + return str(response.status) + except urllib.error.HTTPError as exc: + return str(exc.code) + except OSError: + return "connection_error" + + with concurrent.futures.ThreadPoolExecutor(max_workers=8) as pool: + counts = dict(collections.Counter(pool.map(one, range(64)))) + result = { + "concurrency": 8, + "requests": 64, + "status_counts": counts, + "passed": counts == {"200": 64}, + } + (ROOT / "evidence/readiness-concurrency.json").write_text(json.dumps(result, indent=2) + "\n") + print(json.dumps(result)) + if not result["passed"]: + raise SystemExit(1) + + +if __name__ == "__main__": + main() diff --git a/scripts/bootstrap.py b/scripts/bootstrap.py index 7234999..7642bbb 100644 --- a/scripts/bootstrap.py +++ b/scripts/bootstrap.py @@ -326,6 +326,7 @@ def main(): } if name == "prometheus": item["isDefault"] = True + item["jsonData"]["httpMethod"] = "GET" if name == "loki": item["jsonData"]["derivedFields"] = [ { diff --git a/scripts/security_checks.py b/scripts/security_checks.py index 40342f8..2445c08 100644 --- a/scripts/security_checks.py +++ b/scripts/security_checks.py @@ -207,7 +207,7 @@ def main(): "--no-deps", "-e", "OTEL_ENABLED=0", - "worker", + "api", "python", "-m", "messenger.kdf_probe",