add level 3
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
Матвей
2026-11-07 22:00:19 +03:00
parent 7b6c10cde9
commit 9cb708335d
14 changed files with 482 additions and 22 deletions
+35
View File
@@ -0,0 +1,35 @@
"""Check that request-controlled secrets are absent from actual access logs."""
from datetime import datetime, timezone
import os
from pathlib import Path
import ssl
import subprocess
import time
import urllib.error
import urllib.request
from uuid import uuid4
root = Path(__file__).resolve().parents[1]
ctx = ssl.create_default_context(cafile=str(root / 'secrets/ca.crt'))
base = os.environ.get('BASE_URL', 'https://localhost:8443').rstrip('/')
marker = 'audit-private-' + uuid4().hex
since = datetime.now(timezone.utc).isoformat()
for path in ('/health/ready?token=' + marker, '/missing/' + marker):
request = urllib.request.Request(base + path, headers={
'Authorization': 'Bearer ' + marker, 'X-Request-Id': marker})
try:
with urllib.request.urlopen(request, context=ctx, timeout=10) as response:
response.read()
except urllib.error.HTTPError as error:
assert error.code == 404
error.read()
for attempt in range(20):
logs = subprocess.check_output(['docker', 'compose', 'logs', '--since', since,
'load_balancer', 'api-a', 'api-b'], cwd=root, text=True)
assert marker not in logs, 'request secret leaked into container logs'
if 'ingress status=200' in logs and 'ingress status=404' in logs and 'http.request' in logs:
break
time.sleep(0.25)
else:
raise AssertionError('missing positive evidence of access logging')
print('PASS: ingress/API access records present; query, path and header markers absent')