forked from mtusi2026/mtusi2026lab7
Implement lab7 security and compromised worker recovery evidence
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from capture import run
|
||||
from provision import compose, prepare, initialize_db
|
||||
|
||||
|
||||
def permission(statement):
|
||||
compose(
|
||||
"exec",
|
||||
"-T",
|
||||
"db",
|
||||
"psql",
|
||||
"-U",
|
||||
"operator",
|
||||
"-d",
|
||||
"messenger",
|
||||
"-v",
|
||||
"ON_ERROR_STOP=1",
|
||||
stdin=statement,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--faults-only", action="store_true")
|
||||
args = parser.parse_args()
|
||||
prepare()
|
||||
initialize_db()
|
||||
compose("restart", "broker")
|
||||
os.environ["PYTHONPATH"] = "tests"
|
||||
os.environ["BASE_URL"] = "https://127.0.0.1:8443"
|
||||
os.environ["CA_FILE"] = str(Path("secrets/public/ca.crt").resolve())
|
||||
for name in (
|
||||
"pipeline_core",
|
||||
"pipeline_filename",
|
||||
"pipeline_history_capacity",
|
||||
"pipeline_boundaries",
|
||||
"pipeline_upload_crash",
|
||||
):
|
||||
if not args.faults_only:
|
||||
run(name, [sys.executable, "student-tests/" + name + ".py"])
|
||||
os.environ["COMPOSE_FILE"] = os.pathsep.join(("docker-compose.yml", "compose.test.yaml"))
|
||||
permission("GRANT SELECT,UPDATE ON pipeline_faults TO worker,dispatcher;")
|
||||
try:
|
||||
compose("up", "-d", "--wait", "--wait-timeout", "180", "api", "worker", "dispatcher")
|
||||
for name in ("pipeline_faults", "pipeline_ack_guard", "pipeline_retention", "observe"):
|
||||
run(name, [sys.executable, "student-tests/" + name + ".py"])
|
||||
finally:
|
||||
os.environ.pop("COMPOSE_FILE", None)
|
||||
compose("up", "-d", "--wait", "--wait-timeout", "180", "api", "worker", "dispatcher")
|
||||
permission("REVOKE ALL ON pipeline_faults FROM worker,dispatcher;")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user