feat: complete lab 7 grade 4 security controls and report

This commit is contained in:
Dmitrii Grishko
2026-11-15 21:58:27 +03:00
parent c5e3ac3aff
commit c69d735692
52 changed files with 1124 additions and 129 deletions
+12 -4
View File
@@ -9,7 +9,7 @@ from pathlib import Path
TLS = Path(__file__).resolve().parents[1] / "secrets/tls"
ENDPOINTS = (
("s3", 9000, None, False),
("broker", 5671, None, False),
("broker", 5671, "messenger_worker", False),
("redis", 6379, None, False),
("db", 5432, None, True),
("otel-collector", 4318, "otel-api", False),
@@ -34,7 +34,7 @@ def probe(address, service, port, identity, pg, ca):
assert conn.recv(1) == b"S", "PostgreSQL did not accept TLS negotiation"
with context.wrap_socket(conn, server_hostname=service) as encrypted:
assert encrypted.version() in {"TLSv1.2", "TLSv1.3"}
if identity:
if identity or (service, port) == ("otel-collector", 4318):
encrypted.sendall(b"GET / HTTP/1.0\r\n\r\n")
encrypted.recv(1)
@@ -52,9 +52,17 @@ def main():
pass
else:
raise AssertionError(f"{service}:{port} accepted a foreign CA")
if identity:
if (service, port) == ("otel-collector", 4318):
try:
probe(address, service, port, "wrong-role", pg, "lab7-ca")
probe(address, service, port, None, pg, "lab7-ca")
except ssl.SSLError:
print("PASS Collector: missing client certificate rejected")
else:
raise AssertionError("Collector accepted an anonymous client")
if identity:
foreign = "otel-wrong-role" if (service, port) == ("otel-collector", 4318) else "wrong-role"
try:
probe(address, service, port, foreign, pg, "lab7-ca")
except ssl.SSLError:
pass
else: