lab7: безопасность, mTLS, OpenBao и PKI lifecycle

This commit is contained in:
Vladislav Kunetskiy
2026-11-10 10:58:07 +03:00
parent 3d216fbd50
commit 3441f2269a
183 changed files with 216667 additions and 3165 deletions
+9 -5
View File
@@ -5,7 +5,7 @@ Run against a live stand. Writes raw CSV samples and a summary under
evidence/lab4/memory/. The primary metric is cgroup anon memory: memory.current
also includes page cache from the temporary spool files.
python3 scripts/lab4_memory_experiment.py --base-url http://localhost:8080
python3 scripts/lab4_memory_experiment.py --base-url https://localhost:8443
"""
from __future__ import annotations
@@ -22,8 +22,11 @@ from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(ROOT / 'tests'))
sys.path.insert(0, str(ROOT / 'student-tests'))
from client import Client # noqa: E402
from lab7_http import BASE_URL, CA_FILE # noqa: E402
from tests_helpers import compose # noqa: E402
OUTPUT = ROOT / 'evidence/lab4/memory'
@@ -44,7 +47,7 @@ def png_of_size(width: int, height: int, seed: int) -> bytes:
def containers(service: str) -> list[str]:
output = os.popen(f'docker compose ps -q {service}').read().split()
output = compose('ps', '-q', service).stdout.split()
if not output:
raise SystemExit(f'no running containers for service {service}')
return output
@@ -69,7 +72,8 @@ def memory_snapshot() -> dict[str, int]:
def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument('--base-url', default='http://localhost:8080')
parser.add_argument('--base-url', default=BASE_URL)
parser.add_argument('--ca-file', default=CA_FILE)
parser.add_argument('--concurrency', type=int, default=10)
parser.add_argument('--width', type=int, default=2100)
parser.add_argument('--height', type=int, default=1500)
@@ -80,7 +84,7 @@ def main() -> None:
if len(content) > 10 * 1024 * 1024:
raise SystemExit(f'generated PNG is {len(content)} bytes, above the 10 MiB contract limit')
client = Client(args.base_url, timeout=120)
client = Client(args.base_url, args.ca_file or CA_FILE, timeout=120)
alice, _, _, chat = client.bootstrap()
OUTPUT.mkdir(parents=True, exist_ok=True)
@@ -101,7 +105,7 @@ def main() -> None:
def upload(_: int) -> None:
path = '/api/v1/chats/' + chat['id'] + '/attachments?filename=memory.png'
client.call(
'POST', path, 201, actor=alice, raw=content,
'POST', path, 202, actor=alice, raw=content,
headers={'Content-Type': 'image/png'}, schema='Attachment',
)