Use read-only Prometheus requests and record reproducible security measurements
This commit is contained in:
@@ -66,7 +66,9 @@ def main():
|
|||||||
time.sleep(10.2)
|
time.sleep(10.2)
|
||||||
wrong = (
|
wrong = (
|
||||||
"Basic "
|
"Basic "
|
||||||
+ base64.b64encode((actor["registration"]["username"] + ":incorrect").encode()).decode()
|
+ base64.b64encode(
|
||||||
|
(actor["registration"]["username"] + ":incorrect-password-for-budget").encode()
|
||||||
|
).decode()
|
||||||
)
|
)
|
||||||
rows = []
|
rows = []
|
||||||
for _ in range(12):
|
for _ in range(12):
|
||||||
|
|||||||
@@ -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()
|
||||||
@@ -326,6 +326,7 @@ def main():
|
|||||||
}
|
}
|
||||||
if name == "prometheus":
|
if name == "prometheus":
|
||||||
item["isDefault"] = True
|
item["isDefault"] = True
|
||||||
|
item["jsonData"]["httpMethod"] = "GET"
|
||||||
if name == "loki":
|
if name == "loki":
|
||||||
item["jsonData"]["derivedFields"] = [
|
item["jsonData"]["derivedFields"] = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ def main():
|
|||||||
"--no-deps",
|
"--no-deps",
|
||||||
"-e",
|
"-e",
|
||||||
"OTEL_ENABLED=0",
|
"OTEL_ENABLED=0",
|
||||||
"worker",
|
"api",
|
||||||
"python",
|
"python",
|
||||||
"-m",
|
"-m",
|
||||||
"messenger.kdf_probe",
|
"messenger.kdf_probe",
|
||||||
|
|||||||
Reference in New Issue
Block a user