Prepare Assignment 8 secure delivery and rollback
vpn-dns-gateway/pipeline/head This commit looks good
vpn-dns-gateway/pipeline/pr-main This commit looks good

Add the locked pricing service, trusted-agent pipeline, Ansible deployments, security gates, recovery runbooks, prerequisite evidence, and preparation manual.

Prepared with Codex assistance. Vincent explicitly authorized this local commit and will handle the push. Assessed releases and recovery exercises remain pending.
This commit is contained in:
2026-11-14 17:09:25 -05:00
parent 8beefde2a4
commit bf28adc7fb
51 changed files with 2091 additions and 14 deletions
+77
View File
@@ -0,0 +1,77 @@
"""Create and verify non-secret release records used by Ansible."""
import argparse
import ast
import json
import re
import subprocess
from datetime import datetime, timezone
from pathlib import Path
URLS = {"staging": "https://staging.yebilly.me", "production": "https://app.yebilly.me"}
IMAGE = re.compile(r"git\.yebilly\.me/ssw590-group1/pricing@sha256:[0-9a-f]{64}")
COMMIT = re.compile(r"[0-9a-f]{40}")
def verify(record):
required = {"release_image", "expected_commit", "configuration_commit",
"expected_version", "expected_total", "proxy_network", "target_env", "public_url"}
if not required <= record.keys() or record.keys() - required - {"build_url", "created_at"}:
raise ValueError("Missing or unexpected release fields")
if not IMAGE.fullmatch(record["release_image"]):
raise ValueError("Release requires the team registry image and exact digest")
for name in ("expected_commit", "configuration_commit"):
value = record[name]
if not COMMIT.fullmatch(value):
raise ValueError(f"Invalid {name}")
subprocess.run(["git", "merge-base", "--is-ancestor", value, "origin/main"], check=True)
version = record["expected_version"]
if version not in {"v1", "v2"}:
raise ValueError("Unsupported application release")
if record["expected_total"] != {"v1": 30, "v2": 36}[version]:
raise ValueError("Unexpected business result")
environment = record["target_env"]
if record["public_url"] != URLS[environment] or record["proxy_network"] != "gitea_web":
raise ValueError("Unexpected deployment target")
def main():
parser = argparse.ArgumentParser()
commands = parser.add_subparsers(dest="action", required=True)
create = commands.add_parser("create")
create.add_argument("--image", required=True)
create.add_argument("--build-url", required=True)
create.add_argument("--output", required=True)
check = commands.add_parser("verify")
check.add_argument("record")
check.add_argument("--environment", choices=["staging", "production"])
args = parser.parse_args()
if args.action == "verify":
record = json.loads(Path(args.record).read_text())
verify(record)
if args.environment and record["target_env"] != args.environment:
raise ValueError("Release environment does not match the authorized pipeline stage")
return
values = {}
for node in ast.parse(Path("delivery/app/app.py").read_text()).body:
if isinstance(node, ast.Assign):
for target in node.targets:
if isinstance(target, ast.Name) and target.id in {"VERSION", "UNIT_PRICE"}:
values[target.id] = ast.literal_eval(node.value)
commit = subprocess.check_output(["git", "rev-parse", "HEAD"], text=True).strip()
record = {
"release_image": args.image, "expected_commit": commit,
"configuration_commit": commit, "expected_version": values["VERSION"],
"expected_total": values["UNIT_PRICE"] * 3, "proxy_network": "gitea_web",
"build_url": args.build_url, "created_at": datetime.now(timezone.utc).isoformat(),
}
output = Path(args.output)
output.mkdir(parents=True, exist_ok=True)
for environment, url in URLS.items():
target = dict(record, target_env=environment, public_url=url)
verify(target)
(output / f"{values['VERSION']}-{environment}.json").write_text(json.dumps(target, indent=2))
if __name__ == "__main__":
main()