feat: complete lab 7 grade 4 security controls and report
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user