Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(deploy): lock Codex proxy isolation contracts
Alfredo Lopeze95616a6f644
diff --git a/scripts/tests/test-codex-llm-proxy-deploy-contract.sh b/scripts/tests/test-codex-llm-proxy-deploy-contract.shindex 0f4e7d356..61c49c048 100755--- a/scripts/tests/test-codex-llm-proxy-deploy-contract.sh+++ b/scripts/tests/test-codex-llm-proxy-deploy-contract.sh@@ -10,6 +10,7 @@ MANIFEST="$ROOT/deploy/base/control-plane/codex-llm-proxy.yaml"KUSTOMIZE="$ROOT/deploy/base/control-plane/kustomization.yaml"CONFIGMAPS="$ROOT/deploy/base/control-plane/configmaps.yaml"RBAC="$ROOT/deploy/base/control-plane/rbac.yaml"+NETWORKPOLICIES="$ROOT/deploy/base/control-plane/networkpolicies.yaml"TOKENS="$ROOT/deploy/scripts/apply-inter-service-tokens.sh"IMAGES="$ROOT/deploy/images.json"BUILD_IMAGES="$ROOT/scripts/minikube/build-images.sh"@@ -22,10 +23,10 @@ if [[ ! -f "$MANIFEST" ]]; thenexit 1fi-python3 - "$MANIFEST" "$KUSTOMIZE" "$CONFIGMAPS" "$RBAC" "$TOKENS" "$IMAGES" "$BUILD_IMAGES" "$WORKFLOW" "$GHCR" "$MINIKUBE" <<'PY'+python3 - "$MANIFEST" "$KUSTOMIZE" "$CONFIGMAPS" "$RBAC" "$NETWORKPOLICIES" "$TOKENS" "$IMAGES" "$BUILD_IMAGES" "$WORKFLOW" "$GHCR" "$MINIKUBE" <<'PY'import json, pathlib, re, sys-manifest, kustomize, configmaps, rbac, tokens, images, build_images, workflow, ghcr, minikube = map(pathlib.Path, sys.argv[1:])+manifest, kustomize, configmaps, rbac, networkpolicies, tokens, images, build_images, workflow, ghcr, minikube = map(pathlib.Path, sys.argv[1:])errors = []text = manifest.read_text()@@ -53,8 +54,34 @@ for needle in (if "kind: Role" in text or "kind: RoleBinding" in text:errors.append("proxy manifest must not declare Role/RoleBinding")+if "kind: ClusterRole" in text or "kind: ClusterRoleBinding" in text:+ errors.append("proxy manifest must not declare ClusterRole/ClusterRoleBinding")+if "kind: Namespace" in text or "kind: CustomResourceDefinition" in text:+ errors.append("proxy must not introduce a namespace or CRD")+if "kind: Ingress" in text or "kind: Gateway" in text:+ errors.append("proxy must not expose Ingress or Gateway")+if "automountServiceAccountToken: true" in text:+ errors.append("proxy must not automount a service account token")if "type: LoadBalancer" in text or "type: NodePort" in text:errors.append("proxy Service must stay ClusterIP")+for forbidden in (+ "DATABASE_URL",+ "POSTGRES",+ "CONTROL_API_DATABASE",+ "control-api-internal-tokens",+ "CONTROL_API_INTERNAL_SERVICE_TOKENS",+ "CONTROL_API_INTERNAL_TOKENS",+):+ if forbidden in text:+ errors.append(f"proxy must not carry {forbidden}")+if re.search(r"capabilities:[\s\S]{0,80}\n\s+add:", text):+ errors.append("proxy must not add Linux capabilities")+container_block = re.search(r"^ containers:\n((?: .+\n)+)", text, re.M)+named_containers = re.findall(+ r"^ - name: (\S+)", container_block.group(1) if container_block else "", re.M+)+if named_containers != ["codex-llm-proxy"]:+ errors.append(f"proxy must keep a single container, found {named_containers}")if "codex-llm-proxy.yaml" not in kustomize.read_text():errors.append("kustomization does not include codex-llm-proxy.yaml")@@ -74,6 +101,22 @@ if cm.count("location / {\n return 403;") < 2:errors.append("gateways must keep catch-all 403")if "kind: Service" in cm and "codex-llm-gateway" in cm:errors.append("must not add a third gateway")+if re.search(r"location\s+/api/v1/mcp-host/llm", cm):+ errors.append("authorize path must stay exact-match, not a prefix wildcard")+if re.search(r"location\s+/api/v1/internal/llm", cm):+ errors.append("redeem/finalize paths must stay exact-match, not a prefix wildcard")+if "codex-llm-gateway" in text or "nginx-codex" in cm:+ errors.append("must not introduce a dedicated Codex gateway")++np = networkpolicies.read_text()+ingress = np[np.find("name: codex-llm-proxy-ingress"): np.find("name: codex-llm-proxy-egress")]+egress = np[np.find("name: codex-llm-proxy-egress"):]+if "namespaceSelector: {}" in ingress:+ errors.append("proxy ingress must not admit every namespace")+if "podSelector: {}" in ingress.split("spec:", 1)[-1][:400]:+ errors.append("proxy ingress must not select every pod")+if "cidr: 0.0.0.0/0" in ingress:+ errors.append("proxy ingress must not open the public internet")token_src = tokens.read_text()if "codex-llm-proxy=${TOKEN_CODEX_LLM_PROXY}" not in token_src and "codex-llm-proxy=${TOKEN_CODEX" not in token_src: