Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(nginx): require fixed NGINX releases and wait for TLS test log lines
Alfredo Lopez9174c7805fae
diff --git a/.github/workflows/ci-public.yml b/.github/workflows/ci-public.ymlindex 1d5e7e446..a12cf5fb8 100644--- a/.github/workflows/ci-public.yml+++ b/.github/workflows/ci-public.yml@@ -932,6 +932,8 @@ jobs:run: bash scripts/validate-nginx-images.sh- name: Test NGINX image guardrun: bash scripts/tests/test-validate-nginx-images.sh+ - name: Verify pinned NGINX digests against the registry+ run: bash scripts/verify-nginx-image-digests.sh# ─── Remote MCP egress proxy TLS contract (native amd64 + arm64) ──────────nginx-egress-proxy-tls:@@ -945,7 +947,7 @@ jobs:- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4with:- node-version: '24'+ node-version-file: .nvmrccache: npmcache-dependency-path: host-context-controller/package-lock.json- name: Install host-context-controller dependenciesdiff --git a/docs/agents/CLERUM_WORKFLOW_RECIPE_GUIDE.md b/docs/agents/CLERUM_WORKFLOW_RECIPE_GUIDE.mdindex 3e214b4b6..6cc25ef7c 100644--- a/docs/agents/CLERUM_WORKFLOW_RECIPE_GUIDE.md+++ b/docs/agents/CLERUM_WORKFLOW_RECIPE_GUIDE.md@@ -1512,7 +1512,7 @@ same `control-api-config` key by default.| OAuth secret missing | `/oauth/authorize-url` returns 503 `integration_not_configured`. NOTE: `/oauth/token` does **not** — with no grant it returns `404 no_grant` and never reads the Secret (§7.2.1). | Create K8s Secret in `sandbox-recipes`. || UI workload declares `envSecret` | Admission ACCEPTS it (no CEL rule blocks this), then the pod sticks in `CreateContainerConfigError`: `secret "X" not found`, even though the Secret exists in `sandbox-recipes`. UI workloads run in `sandbox-ui`, which has no Secrets (§6.3). | Split the recipe: thin UI workload (no creds) + sibling backend workload in `sandbox-recipes` that owns the `envSecret`. Wire them with `spec.bindings[]`. || OAuth callback `400 invalid_recipe_namespace` | Recipe in wrong namespace. | Use `sandbox-recipes`. |-| Workload runs as root | Image entrypoint requires root (`nginx:alpine` etc). | Switch to non-root variant or set `security.runAsUser`. |+| Workload runs as root | Image entrypoint requires root (the upstream `nginx` image, etc). | Switch to non-root variant or set `security.runAsUser`. || StatefulSet PVC mount fails to chown | `fsGroup` missing. | Set `fsGroup` = `runAsGroup`. || OAuth refresh fails after weeks | Provider rotated secret or user revoked. | `/oauth/token` returns 502 `refresh_failed`; show Reconnect UI. || Embed stuck on "still updating" | Pod not Ready. | Check `healthCheck` returns 2xx; binding `0.0.0.0:8080`. |diff --git a/scripts/tests/test-nginx-egress-proxy-tls.sh b/scripts/tests/test-nginx-egress-proxy-tls.shindex 1f37986eb..9cb82ab74 100755--- a/scripts/tests/test-nginx-egress-proxy-tls.sh+++ b/scripts/tests/test-nginx-egress-proxy-tls.sh@@ -239,21 +239,54 @@ upstream_handshake() {"https://upstream.test:$hp/liveness"}+READY_SECONDS=30+LOG_SECONDS=15++# Polls until the command prints 200, for at most READY_SECONDS of wall-clock+# time (each attempt has its own curl --max-time, so attempts are not counted).wait_for() {local what="$1" container="$2"shift 2- local _- for _ in $(seq 1 60); do+ local deadline=$((SECONDS + READY_SECONDS))+ while [ "$SECONDS" -lt "$deadline" ]; doif [ "$("$@" 2>/dev/null || true)" = "200" ]; thenreturn 0fisleep 0.5done- echo "FAIL: $what did not become ready within 30s" >&2+ echo "FAIL: $what did not become ready within ${READY_SECONDS}s" >&2docker logs "$container" >&2 2>&1 || trueexit 1}+# Container log (nginx writes its error log to stderr). Returns 2 when the log+# cannot be read, so an unreadable log never reads as "line absent". Callers+# run it in a command substitution and must check that status.+container_log() {+ local out+ if ! out="$(docker logs "$1" 2>&1)"; then+ echo "FAIL: could not read the log of $1: $out" >&2+ return 2+ fi+ printf '%s\n' "$out"+}++# Waits up to LOG_SECONDS for a fixed string in a container log. nginx writes a+# log line after it answers, so a single read right after the response races it.+# Returns 1 on timeout and 2 on a log read error.+wait_log() {+ local container="$1" text="$2" log+ local deadline=$((SECONDS + LOG_SECONDS))+ while [ "$SECONDS" -lt "$deadline" ]; do+ log="$(container_log "$container")" || return 2+ if printf '%s\n' "$log" | grep -qF -- "$text"; then+ return 0+ fi+ sleep 0.2+ done+ return 1+}+for cert in valid chain2 untrusted expired wrongsan; dowait_for "upstream port $(port_of "$cert")" "$UPSTREAM" upstream_handshake "$(port_of "$cert")" "ready-$cert"done@@ -347,8 +380,12 @@ proxy_request() {"http://127.0.0.1:$(host_port "$container" 3000)/mcp"}+# Prints the upstream log lines for a token (empty when none). Returns 2 when+# the upstream log cannot be read.upstream_log_line() {- docker logs "$UPSTREAM" 2>&1 | grep -F "token=$1 " || true+ local log+ log="$(container_log "$UPSTREAM")" || return 2+ printf '%s\n' "$log" | grep -F "token=$1 " || true}expect_accept() {@@ -359,13 +396,14 @@ expect_accept() {cases=$((cases + 1))start_proxy "$case_name" "$port" yescode="$(proxy_request "$container" "$token")"- line="$(upstream_log_line "$token")"if [ "$code" != "200" ]; then- fail "$case_name: expected 200, got $code; proxy log: $(docker logs "$container" 2>&1 | tail -n 5)"+ fail "$case_name: expected 200, got $code; proxy log: $(container_log "$container" | tail -n 5)"elif ! grep -qF "echo token=$token" "$WORK/body"; thenfail "$case_name: response body does not carry the token: $(cat "$WORK/body")"- elif [ -z "$line" ]; then- fail "$case_name: upstream never logged token $token"+ elif ! wait_log "$UPSTREAM" "token=$token "; then+ fail "$case_name: upstream did not log token $token within ${LOG_SECONDS}s"+ elif ! line="$(upstream_log_line "$token")"; then+ fail "$case_name: could not read the upstream log"elif ! printf '%s' "$line" | grep -qF "port=$port uri=/mcp token=$token sni=upstream.test auth=\"Bearer $AUTH_SECRET\""; thenfail "$case_name: upstream saw the wrong port, path, SNI or Authorization: $line"else@@ -375,7 +413,7 @@ expect_accept() {}expect_reject() {- local case_name="$1" mount_ca="$2" reason="$3" port container token code live+ local case_name="$1" mount_ca="$2" reason="$3" port container token code live after seenport="$(port_of "$case_name")"container="$NAME-proxy-$case_name"token="tok-$case_name-$RUN_ID"@@ -387,14 +425,21 @@ expect_reject() {fistart_proxy "$case_name" "$port" "$mount_ca"code="$(proxy_request "$container" "$token")"+ after="after-$case_name-$RUN_ID"if [ "$code" != "502" ]; thenfail "$case_name: expected 502, got $code"- elif ! docker logs "$container" 2>&1 | grep -qF -- "$reason"; then- fail "$case_name: proxy log has no '$reason': $(docker logs "$container" 2>&1 | tail -n 5)"- elif [ -n "$(upstream_log_line "$token")" ]; then- fail "$case_name: request token reached the upstream"+ elif ! wait_log "$container" "$reason"; then+ fail "$case_name: proxy log has no '$reason' within ${LOG_SECONDS}s: $(container_log "$container" | tail -n 5)"+ # The upstream logs requests in order. Once a direct request sent after the+ # proxy attempt is in its log, a forwarded token would be there too.+ elif [ "$(upstream_handshake "$port" "$after")" != "200" ] || ! wait_log "$UPSTREAM" "token=$after "; then+ fail "$case_name: the upstream did not log the direct request $after sent after the proxy attempt"+ elif ! seen="$(upstream_log_line "$token")"; then+ fail "$case_name: could not read the upstream log"+ elif [ -n "$seen" ]; then+ fail "$case_name: request token reached the upstream: $seen"else- echo "PASS: $case_name -> 502 ($reason), upstream live, token not forwarded"+ echo "PASS: $case_name -> 502 ($reason), upstream live and logging, token not forwarded"fidocker rm -f "$container" >/dev/null}diff --git a/scripts/tests/test-validate-nginx-images.sh b/scripts/tests/test-validate-nginx-images.shindex 3a53bfdfc..33660c1e6 100755--- a/scripts/tests/test-validate-nginx-images.sh+++ b/scripts/tests/test-validate-nginx-images.sh@@ -1,12 +1,16 @@#!/usr/bin/env bash# Contract for scripts/validate-nginx-images.sh: it passes the current tree,-# rejects every vulnerable or floating platform NGINX tag in both image-# families and names the file that carries it, accepts the fixed releases,-# enforces the pinned egress-proxy FROM line, and reports a failed scan.+# rejects every vulnerable, floating, untagged or variable platform NGINX+# reference in both image families and names the file and line that carry it,+# accepts the fixed releases (with or without a digest), checks kustomize+# images: entries, enforces the pinned egress-proxy FROM line, fails on a+# missing scan path, and reports a failed scan.## The validator runs on a copy of the files it reads, so injected cases never# touch the checkout. Every injected case writes into a path the validator-# scans, and every rejection must name that path.+# scans. Every rejection must name that path; every accepted injection must+# raise the validator's reference count by one, which proves the injected+# reference was read rather than skipped.set -euo pipefailREPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"@@ -17,18 +21,49 @@ COPY="$WORK/repo"OUT="$WORK/out"failures=0cases=0+baseline_refs=""++# The scan list the validator must carry. A path dropped from, or added to,+# the validator fails here until this list is updated with it.+EXPECTED_SCAN_PATHS="deploy+host-context-controller/src/config.ts+host-context-controller/src/__tests__/reconciler.remote.test.ts+host-context-controller/src/__tests__/reconciler.sanitize.test.ts+control-api/src/routes/admin/registry.ts+control-api/src/routes/admin/remoteMcp.ts+nginx-egress-proxy/Dockerfile+control-ui/e2e/registry-install.spec.ts+control-ui/e2e/qa-recorder-recipe-scope-copy.spec.ts+control-ui/components/__tests__/RegistryCatalog.test.tsx+desktop-app/test/e2e-playwright/sandbox-ui-apps-catalog-authz.test.ts+scripts/minikube/build-images.sh+scripts/bootstrap-cluster.sh+scripts/e2e+docs/deploy/workflow-recipes-guide.md+docs/agents/CLERUM_WORKFLOW_RECIPE_GUIDE.md+workflow-recipes/samples+workflow-recipes/src+tests/e2e/integration/control-api-k8s.test.ts+tests/e2e/playwright/control-ui/recipes.spec.ts+tests/e2e/playwright/control-ui/workflow-recipe-egressbindings.spec.ts+workflow-recipes/tests/e2e+workflow-recipes/tests/fixtures/workflow/invalid-scheduling-no-steps.yaml"fail() {echo "FAIL: $*" >&2failures=$((failures + 1))}+validator_scan_paths() {+ sed -n '/^scan_paths=(/,/^)/p' "$REPO_ROOT/$VALIDATOR_REL" | sed -n 's/^[[:space:]]*"\([^"]*\)"$/\1/p'+}+# Copy the validator and every path it scans or requires, read from the# validator itself so the copy cannot drift from what it checks.copy_inputs() {local paths ppaths="$(- sed -n '/^scan_paths=(/,/^)/p' "$REPO_ROOT/$VALIDATOR_REL" | sed -n 's/^[[:space:]]*"\([^"]*\)"$/\1/p'+ validator_scan_pathssed -n 's/^require_[a-z_]* "\([^"]*\)".*/\1/p' "$REPO_ROOT/$VALIDATOR_REL")"if [ -z "$paths" ]; then@@ -38,42 +73,68 @@ copy_inputs() {mkdir -p "$COPY/scripts"cp "$REPO_ROOT/$VALIDATOR_REL" "$COPY/$VALIDATOR_REL"while IFS= read -r p; do- [ -e "$REPO_ROOT/$p" ] || continue+ if [ ! -e "$REPO_ROOT/$p" ]; then+ echo "FAIL: $VALIDATOR_REL names $p, which does not exist in the repository" >&2+ exit 1+ fimkdir -p "$COPY/$(dirname "$p")"cp -R "$REPO_ROOT/$p" "$COPY/$(dirname "$p")/"done <<<"$paths"}run_validator() {- PATH="$1" bash "$COPY/$VALIDATOR_REL" >"$OUT" 2>&1+ PATH="$1" bash "$COPY/$VALIDATOR_REL" "${@:2}" >"$OUT" 2>&1+}++reported_refs() {+ sed -n 's/^OK -- .*(\([0-9][0-9]*\) references checked)$/\1/p' "$OUT"}+# expect_pass PATH NAME [EXTRA_REFS]: the validator passes, prints the OK line,+# and reports the baseline reference count plus EXTRA_REFS.expect_pass() {- local scanner_path="$1" name="$2"+ local scanner_path="$1" name="$2" extra="${3:-0}" gotcases=$((cases + 1))if ! run_validator "$scanner_path"; thenfail "$name should pass: $(cat "$OUT")"- elif ! grep -q '^OK -- ' "$OUT"; then+ return+ fi+ got="$(reported_refs)"+ if [ -z "$got" ]; thenfail "$name passed without the OK line: $(cat "$OUT")"+ elif [ -n "$baseline_refs" ] && [ "$got" -ne $((baseline_refs + extra)) ]; then+ fail "$name checked $got references, expected $((baseline_refs + extra)): $(cat "$OUT")"fi}expect_fail_naming() {- local scanner_path="$1" name="$2" expected="$3"+ local scanner_path="$1" name="$2" expected+ shift 2cases=$((cases + 1))if run_validator "$scanner_path"; thenfail "$name should fail: $(cat "$OUT")"- elif ! grep -qF -- "$expected" "$OUT"; then- fail "$name should name '$expected': $(cat "$OUT")"+ returnfi+ for expected in "$@"; do+ if ! grep -qF -- "$expected" "$OUT"; then+ fail "$name should name '$expected': $(cat "$OUT")"+ fi+ done}# Scanned by the validator only since the October 2026 baseline: the whole-# recipe samples directory and scripts/e2e.+# recipe samples directory, scripts/e2e, all of deploy/ and the deploying+# E2E specs.SAMPLE_REL="workflow-recipes/samples/zz-injected-nginx.yaml"E2E_REL="scripts/e2e/zz-injected-nginx.sh"REMOTE_MCP_REL="control-api/src/routes/admin/remoteMcp.ts"DOCKERFILE_REL="nginx-egress-proxy/Dockerfile"+KUSTOMIZE_REL="deploy/overlays/zz-injected/kustomization.yaml"+FIXED_DIGEST="sha256:c59d1f8b1e0e42da75be973424cd72e23f7f8adfb54e982f4d1cd0216a5a5576"+OLD_DIGEST="sha256:c819f83c54b0361f5557601bf5eb4943d09360e7a7fdf426afc466570f45874d"+BELOW="is below 1.30.6"+NOT_FIXED="is not a fixed x.y.z release"+UNTAGGED="untagged NGINX image (implicit :latest)"inject() {local rel="$1" image="$2"@@ -81,58 +142,129 @@ inject() {printf ' image: %s\n' "$image" >"$COPY/$rel"}+inject_kustomize() {+ mkdir -p "$COPY/$(dirname "$KUSTOMIZE_REL")"+ printf 'apiVersion: kustomize.config.k8s.io/v1beta1\nkind: Kustomization\n%s\n' "$1" >"$COPY/$KUSTOMIZE_REL"+}+run_matrix() {- local scanner="$1" scanner_path="$2" family tag image target+ local scanner="$1" scanner_path="$2" family tag image target rel line+ baseline_refs=""expect_pass "$scanner_path" "[$scanner] the current tree"+ baseline_refs="$(reported_refs)"+ if [ -z "$baseline_refs" ] || [ "$baseline_refs" -eq 0 ]; then+ echo "FAIL: [$scanner] the current tree reported no checked references: $(cat "$OUT")" >&2+ exit 1+ fi- for family in nginx nginxinc/nginx-unprivileged; do+ for family in nginx nginxinc/nginx-unprivileged docker.io/library/nginx; dofor tag in 1.30.0 1.30.1 1.30.2 1.30.3 1.30.4 1.30.5 1.30.5-alpine \- 1.31.0 1.31.1 1.31.2 1.31.3 1.31.4 1.31.5 1.31.6 1.31.6-alpine \- latest alpine stable mainline stable-alpine 1 1-alpine 1.30 1.30-alpine 1.31 \- 1.27-alpine 1.29.9; do+ 1.31.0 1.31.1 1.31.2 1.31.3 1.31.4 1.31.5 1.31.6 1.31.6-alpine 1.27.5-alpine 1.29.9; doimage="$family:$tag"inject "$SAMPLE_REL" "$image"- expect_fail_naming "$scanner_path" "[$scanner] $image in a recipe sample" "$SAMPLE_REL"+ expect_fail_naming "$scanner_path" "[$scanner] $image in a recipe sample" "$SAMPLE_REL:1: " "$BELOW"rm -f "$COPY/$SAMPLE_REL"done- for tag in 1.30.6 1.30.6-alpine 1.30.7 1.31.7 1.31.8 1.31.8-alpine 1.30.50 1.30.60 1.31.60; do+ # shellcheck disable=SC2016 # variable tags are injected literally+ for tag in latest alpine stable mainline stable-alpine bookworm trixie alpine-slim \+ 1 1-alpine 1.30 1.30-alpine 1.31 1.27-alpine '${NGINX_TAG}' '$NGINX_TAG' '${TAG:-1.30.6}'; doimage="$family:$tag"inject "$SAMPLE_REL" "$image"- expect_pass "$scanner_path" "[$scanner] $image in a recipe sample"+ expect_fail_naming "$scanner_path" "[$scanner] $image in a recipe sample" "$SAMPLE_REL:1: " "$NOT_FIXED"rm -f "$COPY/$SAMPLE_REL"done++ for tag in 1.30.6 1.30.6-alpine 1.30.7 1.31.7 1.31.8 1.31.8-alpine 1.30.50 1.30.60 1.31.60 1.32.0 2.0.0; do+ image="$family:$tag"+ inject "$SAMPLE_REL" "$image"+ expect_pass "$scanner_path" "[$scanner] $image in a recipe sample" 1+ rm -f "$COPY/$SAMPLE_REL"+ done++ # An untagged image field pulls :latest.+ inject "$SAMPLE_REL" "$family"+ expect_fail_naming "$scanner_path" "[$scanner] untagged $family in a recipe sample" "$SAMPLE_REL:1: " "$UNTAGGED"+ rm -f "$COPY/$SAMPLE_REL"done- for image in nginx:1.30.5-alpine nginxinc/nginx-unprivileged:1.27-alpine; do- inject "$E2E_REL" "$image"- expect_fail_naming "$scanner_path" "[$scanner] $image in scripts/e2e" "$E2E_REL"+ for line in '"image": "nginx",' '--image=nginx' 'IMAGE=nginx' "image: 'nginx'"; do+ mkdir -p "$COPY/$(dirname "$E2E_REL")"+ printf '%s\n' "$line" >"$COPY/$E2E_REL"+ expect_fail_naming "$scanner_path" "[$scanner] untagged $line in scripts/e2e" "$E2E_REL:1: " "$UNTAGGED"rm -f "$COPY/$E2E_REL"done- cp "$COPY/$REMOTE_MCP_REL" "$WORK/remoteMcp.ts.orig"- printf '// image: nginx:1.31.6\n' >>"$COPY/$REMOTE_MCP_REL"- expect_fail_naming "$scanner_path" "[$scanner] nginx:1.31.6 in remoteMcp.ts" "$REMOTE_MCP_REL"- cp "$WORK/remoteMcp.ts.orig" "$COPY/$REMOTE_MCP_REL"+ # Digests: accepted only next to a fixed tag, and only well formed.+ inject "$SAMPLE_REL" "nginx:1.30.6-alpine@$FIXED_DIGEST"+ expect_pass "$scanner_path" "[$scanner] fixed tag with a digest" 1+ inject "$SAMPLE_REL" "nginx@$FIXED_DIGEST"+ expect_fail_naming "$scanner_path" "[$scanner] digest without a tag" "$SAMPLE_REL:1: " "digest without a version tag"+ inject "$SAMPLE_REL" "nginx:1.30.1-alpine@$OLD_DIGEST"+ expect_fail_naming "$scanner_path" "[$scanner] old tag with its digest" "$SAMPLE_REL:1: " "$BELOW"+ inject "$SAMPLE_REL" "nginx:1.30.6-alpine@sha256:c59d1f8b"+ expect_fail_naming "$scanner_path" "[$scanner] malformed digest" "$SAMPLE_REL:1: " "malformed digest"+ rm -f "$COPY/$SAMPLE_REL"- for image in nginx-egress-proxy clerum/nginx-egress-proxy:0.1.0; do+ # Strings that are not image references are left alone; the count shows they+ # were not counted as references either.+ for image in nginx-egress-proxy clerum/nginx-egress-proxy:0.1.0 'nginx:*' 'nginx:'; doinject "$SAMPLE_REL" "$image"- expect_pass "$scanner_path" "[$scanner] unrelated string $image"+ expect_pass "$scanner_path" "[$scanner] non-reference string $image" 0rm -f "$COPY/$SAMPLE_REL"done+ # Paths that deploy or install platform NGINX.+ for rel in "$E2E_REL" deploy/base/profiles/zz-injected.yaml deploy/components/ghcr-images/zz-injected.yaml \+ deploy/overlays/zz-injected/zz-injected.yaml; do+ inject "$rel" "nginx:1.30.5-alpine"+ expect_fail_naming "$scanner_path" "[$scanner] nginx:1.30.5-alpine in $rel" "$rel:1: " "$BELOW"+ rm -f "$COPY/$rel"+ done+ for rel in "$REMOTE_MCP_REL" tests/e2e/playwright/control-ui/recipes.spec.ts \+ tests/e2e/playwright/control-ui/workflow-recipe-egressbindings.spec.ts \+ tests/e2e/integration/control-api-k8s.test.ts docs/agents/CLERUM_WORKFLOW_RECIPE_GUIDE.md; do+ cp "$COPY/$rel" "$WORK/appended.orig"+ printf '// image: nginx:1.31.6\n' >>"$COPY/$rel"+ expect_fail_naming "$scanner_path" "[$scanner] nginx:1.31.6 appended to $rel" "$rel:" "nginx:1.31.6: release 1.31.6 $BELOW"+ cp "$WORK/appended.orig" "$COPY/$rel"+ done++ # kustomize images: entries rewrite an image without naming its tag inline.+ inject_kustomize $'images:\n- name: nginx\n newTag: 1.30.1-alpine'+ expect_fail_naming "$scanner_path" "[$scanner] kustomize newTag below the baseline" "$KUSTOMIZE_REL:4: nginx:1.30.1-alpine: " "$BELOW"+ inject_kustomize $'images:\n - name: clerum/gateway\n newName: docker.io/library/nginx\n newTag: "1.31.6"'+ expect_fail_naming "$scanner_path" "[$scanner] kustomize newName to NGINX below the baseline" "$KUSTOMIZE_REL:4: docker.io/library/nginx:1.31.6: " "$BELOW"+ inject_kustomize $'images:\n- name: clerum/gateway\n newName: nginx'+ expect_fail_naming "$scanner_path" "[$scanner] kustomize newName to NGINX with no newTag" "$KUSTOMIZE_REL:4: nginx:<no newTag>: " "$NOT_FIXED"+ inject_kustomize $'images:\n- name: nginx\n newTag: stable-alpine'+ expect_fail_naming "$scanner_path" "[$scanner] kustomize floating newTag" "$KUSTOMIZE_REL:4: nginx:stable-alpine: " "$NOT_FIXED"+ inject_kustomize $'images:\n- name: nginx\n digest: '"$FIXED_DIGEST"+ expect_fail_naming "$scanner_path" "[$scanner] kustomize digest without newTag" "$KUSTOMIZE_REL:4: nginx@$FIXED_DIGEST: " "digest without a version tag"+ inject_kustomize $'images:\n- name: nginx\n newTag: 1.30.6-alpine # fixed baseline'+ expect_pass "$scanner_path" "[$scanner] kustomize newTag on the baseline" 1+ inject_kustomize $'images:\n- name: clerum/control-api\n newName: ghcr.io/evenfire-ai/control-api\n newTag: v0.11.0'+ expect_pass "$scanner_path" "[$scanner] kustomize entry for another image" 0+ rm -rf "${COPY:?}/$(dirname "$KUSTOMIZE_REL")"+# Scan errors must fail the guard instead of reading as "nothing found".target="$COPY/$(dirname "$E2E_REL")/zz-unreadable.sh"printf 'echo unreadable\n' >"$target"chmod 000 "$target"- expect_fail_naming "$scanner_path" "[$scanner] unreadable scanned file" "platform NGINX image scan failed with status"+ expect_fail_naming "$scanner_path" "[$scanner] unreadable scanned file" "platform NGINX image scan (scan_refs) failed with status"chmod 600 "$target"rm -f "$target"- expect_pass "$scanner_path" "[$scanner] the restored tree"+ expect_pass "$scanner_path" "[$scanner] the restored tree" 0}+if [ "$(validator_scan_paths)" != "$EXPECTED_SCAN_PATHS" ]; then+ echo "FAIL: $VALIDATOR_REL scan_paths differ from this test's list:" >&2+ diff <(printf '%s\n' "$EXPECTED_SCAN_PATHS") <(validator_scan_paths) >&2 || true+ exit 1+fi+copy_inputsif [ "$(id -u)" -eq 0 ]; then@@ -140,7 +272,7 @@ if [ "$(id -u)" -eq 0 ]; thenexit 1fi-# The validator uses rg when it is installed and grep -RInE otherwise. Run the+# The validator uses rg when it is installed and grep -R otherwise. Run the# matrix with each scanner that this host can provide.no_rg_path=""IFS=: read -r -a path_dirs <<<"$PATH"@@ -156,6 +288,12 @@ firun_matrix grep "$no_rg_path"scanners=$((scanners + 1))+# A scan path that no longer exists is an error, never a silent skip.+moved="tests/e2e/integration/control-api-k8s.test.ts"+mv "$COPY/$moved" "$WORK/moved.orig"+expect_fail_naming "$PATH" "missing scan path" "scan path $moved does not exist"+mv "$WORK/moved.orig" "$COPY/$moved"+# Dockerfile FROM contract (independent of the scanner).expected_from="$(grep -E '^FROM ' "$COPY/$DOCKERFILE_REL")"cp "$COPY/$DOCKERFILE_REL" "$WORK/Dockerfile.orig"@@ -170,8 +308,23 @@ expect_fail_naming "$PATH" "Dockerfile pinned by tag only" "$DOCKERFILE_REL must{ cat "$WORK/Dockerfile.orig"; echo "$expected_from AS second"; } >"$COPY/$DOCKERFILE_REL"expect_fail_naming "$PATH" "Dockerfile with a second FROM" "$DOCKERFILE_REL must have exactly one FROM line"+# Dockerfile instructions are case-insensitive; a lowercase stage still runs.+{ cat "$WORK/Dockerfile.orig"; echo "from busybox:1.36 AS second"; } >"$COPY/$DOCKERFILE_REL"+expect_fail_naming "$PATH" "Dockerfile with a lowercase second from" "$DOCKERFILE_REL must have exactly one FROM line" "from busybox:1.36"+cp "$WORK/Dockerfile.orig" "$COPY/$DOCKERFILE_REL"-expect_pass "$PATH" "Dockerfile restored"+expect_pass "$PATH" "Dockerfile restored" 0++# --list-digest-pins feeds verify-nginx-image-digests.sh: every valid tag@digest+# once, nothing else.+inject "$SAMPLE_REL" "${expected_from#FROM }"+cases=$((cases + 1))+if ! run_validator "$PATH" --list-digest-pins; then+ fail "--list-digest-pins failed: $(cat "$OUT")"+elif [ "$(cat "$OUT")" != "${expected_from#FROM }" ]; then+ fail "--list-digest-pins should print '${expected_from#FROM }' once: $(cat "$OUT")"+fi+rm -f "$COPY/$SAMPLE_REL"echo "cases=$cases scanners=$scanners failures=$failures"if [ "$cases" -eq 0 ]; thendiff --git a/scripts/validate-nginx-images.sh b/scripts/validate-nginx-images.shindex b7c3b7c0b..fd6d808bd 100755--- a/scripts/validate-nginx-images.sh+++ b/scripts/validate-nginx-images.sh@@ -6,6 +6,15 @@# intentionally out of scope; this guard covers manifests, generated proxy# defaults, deploy helpers, shipped recipe samples, and E2E fixtures that# install platform-owned NGINX surfaces.+#+# Every nginx / nginxinc/nginx-unprivileged reference in the scanned paths must+# carry a full x.y.z tag at or above the fixed release of its line (1.30.6,+# 1.31.7, or any 1.32+). Floating, untagged and variable tags are rejected. A+# digest is accepted only next to such a tag; scripts/verify-nginx-image-digests.sh+# checks in CI that each pinned digest really is that NGINX version.+#+# --list-digest-pins print every tag@digest reference and exit+# (input for verify-nginx-image-digests.sh)set -euo pipefail@@ -15,20 +24,23 @@ PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"FIXED_NGINX_IMAGE="nginx:1.30.6-alpine"FIXED_NGINX_IMAGE_DIGEST="sha256:c59d1f8b1e0e42da75be973424cd72e23f7f8adfb54e982f4d1cd0216a5a5576"EGRESS_PROXY_IMAGE="clerum/nginx-egress-proxy:0.1.0"-# Rejected tags: floating tags (latest, alpine, stable, mainline, 1, 1.30, 1.31),-# every release below 1.30 (incl. CVE-2026-42945, fixed in 1.30.1), stable-# 1.30.0-1.30.5 and mainline 1.31.0-1.31.6 (October 2026 CVEs, fixed in 1.30.6-# and 1.31.7). Each alternative ends at a non-alphanumeric, non-dot character so-# 1.30.50 or 1.31.60 are not mistaken for 1.30.5 or 1.31.6.-FORBIDDEN_PLATFORM_NGINX_TAG='(latest|alpine|stable|mainline|1([^[:alnum:].]|$)|1\.([0-9]|[12][0-9])(\.[0-9]+)?([^[:alnum:].]|$)|1\.3[01]([^[:alnum:].]|$)|1\.30\.[0-5]([^[:alnum:].]|$)|1\.31\.[0-6]([^[:alnum:].]|$))'-FORBIDDEN_PLATFORM_NGINX_REGEX="nginx:${FORBIDDEN_PLATFORM_NGINX_TAG}|nginxinc/nginx-unprivileged:${FORBIDDEN_PLATFORM_NGINX_TAG}"+BASELINE_TEXT="1.30.6 (1.30 line), 1.31.7 (1.31 line) or 1.32+"+# An NGINX image reference: the repository name, then a tag and/or digest. The+# leading group keeps clerum/nginx-egress-proxy and foo-nginx:1 out and lets a+# registry prefix (docker.io/library/nginx:...) match after its '/'. '$', '{',+# '}' and '*' are captured so variable and glob tags are seen.+# shellcheck disable=SC2016 # literal '$', '{' and '}' in a regular expression+NGINX_REF_REGEX='(^|[^[:alnum:]_.-])(nginx|nginxinc/nginx-unprivileged)[:@][[:alnum:]_.:@${}*-]*'+# An untagged NGINX image in an image field: image: nginx, "image": "nginx",+# --image=nginx, IMAGE=docker.io/library/nginx (implicitly :latest).+NGINX_UNTAGGED_REGEX='image["'"'"']?[[:space:]]*[:=][[:space:]]*["'"'"']?([[:alnum:]_.-]+(:[0-9]+)?/)*(nginx|nginxinc/nginx-unprivileged)["'"'"']?[[:space:]]*,?[[:space:]]*$'++# Every path must exist: a renamed or deleted path is an error, never a+# silent skip. deploy/ covers base, components and every overlay, including+# the GCP overlays when the infra repository assembles this tree.scan_paths=(- "deploy/base/control-plane"- "deploy/base/profiles/profile-control-funnel.yaml"- "deploy/overlays/gcp-dev"- "deploy/overlays/gcp-prod"- "deploy/overlays/minikube"+ "deploy""host-context-controller/src/config.ts""host-context-controller/src/__tests__/reconciler.remote.test.ts""host-context-controller/src/__tests__/reconciler.sanitize.test.ts"@@ -36,29 +48,224 @@ scan_paths=("control-api/src/routes/admin/remoteMcp.ts""nginx-egress-proxy/Dockerfile""control-ui/e2e/registry-install.spec.ts"- "control-ui/components/__tests__/RegistryInstallModal.test.tsx"+ "control-ui/e2e/qa-recorder-recipe-scope-copy.spec.ts""control-ui/components/__tests__/RegistryCatalog.test.tsx"+ "desktop-app/test/e2e-playwright/sandbox-ui-apps-catalog-authz.test.ts""scripts/minikube/build-images.sh""scripts/bootstrap-cluster.sh""scripts/e2e""docs/deploy/workflow-recipes-guide.md"+ "docs/agents/CLERUM_WORKFLOW_RECIPE_GUIDE.md""workflow-recipes/samples""workflow-recipes/src""tests/e2e/integration/control-api-k8s.test.ts""tests/e2e/playwright/control-ui/recipes.spec.ts"+ "tests/e2e/playwright/control-ui/workflow-recipe-egressbindings.spec.ts""workflow-recipes/tests/e2e""workflow-recipes/tests/fixtures/workflow/invalid-scheduling-no-steps.yaml")-# Keep only paths present in this checkout so the guard is portable across the-# public repo (base + minikube, no gcp overlays) and the infra-assembled tree-# (with gcp-dev/gcp-prod overlays). Missing paths are skipped, not errors — the-# base manifests the overlays inherit from are always scanned.-_present=()+failed=0for _p in "${scan_paths[@]}"; do- [ -e "$PROJECT_DIR/$_p" ] && _present+=("$_p")+ if [ ! -e "$PROJECT_DIR/$_p" ]; then+ echo "ERROR: scan path $_p does not exist; update scan_paths" >&2+ failed=1+ fidone-scan_paths=("${_present[@]}")+if [ "$failed" -ne 0 ]; then+ exit 1+fi++# Prints why an x.y.z[-suffix] tag is not acceptable; prints nothing if it is.+nginx_tag_problem() {+ local tag="$1" major minor patch+ if ! [[ "$tag" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)(-[[:alnum:]_.-]+)?$ ]]; then+ echo "tag '$tag' is not a fixed x.y.z release"+ return+ fi+ major=$((10#${BASH_REMATCH[1]}))+ minor=$((10#${BASH_REMATCH[2]}))+ patch=$((10#${BASH_REMATCH[3]}))+ if [ "$major" -gt 1 ] ||+ { [ "$major" -eq 1 ] && [ "$minor" -ge 32 ]; } ||+ { [ "$major" -eq 1 ] && [ "$minor" -eq 31 ] && [ "$patch" -ge 7 ]; } ||+ { [ "$major" -eq 1 ] && [ "$minor" -eq 30 ] && [ "$patch" -ge 6 ]; }; then+ return+ fi+ echo "release $major.$minor.$patch is below $BASELINE_TEXT"+}++# Splits [registry/]name[:tag][@digest] into the globals ref_tag and ref_digest.+split_ref() {+ local last="${1##*/}" rest+ rest="${last#"${last%%[:@]*}"}"+ ref_tag=""+ ref_digest=""+ case "$rest" in+ :*@*) ref_tag="${rest#:}"; ref_tag="${ref_tag%%@*}"; ref_digest="${rest#*@}" ;;+ :*) ref_tag="${rest#:}" ;;+ @*) ref_digest="${rest#@}" ;;+ esac+}++# Prints why an NGINX reference is not acceptable; prints nothing if it is.+nginx_ref_problem() {+ split_ref "$1"+ if [ -n "$ref_digest" ]; then+ if [ -z "$ref_tag" ]; then+ echo "digest without a version tag (write nginx:<x.y.z>[-suffix]@sha256:...)"+ return+ fi+ if ! [[ "$ref_digest" =~ ^sha256:[0-9a-f]{64}$ ]]; then+ echo "malformed digest '$ref_digest'"+ return+ fi+ fi+ nginx_tag_problem "$ref_tag"+}++is_nginx_name() {+ case "$1" in+ nginx | */nginx | nginxinc/nginx-unprivileged | */nginxinc/nginx-unprivileged) return 0 ;;+ esac+ return 1+}++# path:line:token for every tagged or digested NGINX reference.+scan_refs() {+ cd "$PROJECT_DIR"+ if command -v rg >/dev/null 2>&1; then+ rg --with-filename --line-number --only-matching --no-heading "$NGINX_REF_REGEX" "${scan_paths[@]}"+ else+ grep -RHnoE "$NGINX_REF_REGEX" "${scan_paths[@]}"+ fi+}++scan_untagged() {+ cd "$PROJECT_DIR"+ if command -v rg >/dev/null 2>&1; then+ rg --with-filename --line-number --no-heading --ignore-case "$NGINX_UNTAGGED_REGEX" "${scan_paths[@]}"+ else+ grep -RHniE "$NGINX_UNTAGGED_REGEX" "${scan_paths[@]}"+ fi+}++# path:line:name|newName|newTag|digest for each entry of a top-level images:+# list in every kustomization file under the scanned paths.+scan_kustomize_images() {+ local files+ cd "$PROJECT_DIR"+ files="$(find "${scan_paths[@]}" -type f \( -name kustomization.yaml -o -name kustomization.yml \))"+ [ -n "$files" ] || return 1+ # shellcheck disable=SC2086 # repository paths contain no whitespace+ awk '+ # flush() runs on the first line of the next file too, so the entry keeps+ # the file it was read from.+ function flush() {+ if (entry_line) print entry_file ":" entry_line ":" name "|" newname "|" newtag "|" digest+ entry_line = 0; name = ""; newname = ""; newtag = ""; digest = ""+ }+ function value(line) {+ sub(/^[^:]*:[[:space:]]*/, "", line); sub(/[[:space:]]+#.*$/, "", line)+ gsub(/^["\047]|["\047][[:space:]]*$/, "", line); return line+ }+ FNR == 1 { flush(); in_images = 0 }+ /^images:/ { flush(); in_images = 1; next }+ /^[^[:space:]#-]/ { flush(); in_images = 0 }+ !in_images { next }+ /^[[:space:]]*-[[:space:]]/ { flush(); entry_file = FILENAME; entry_line = FNR; sub(/-[[:space:]]+/, "") }+ /^[[:space:]]*name:/ { name = value($0) }+ /^[[:space:]]*newName:/ { newname = value($0) }+ /^[[:space:]]*newTag:/ { newtag = value($0) }+ /^[[:space:]]*digest:/ { digest = value($0) }+ END { flush() }+ ' $files+}++# Runs a scan and prints its output. Status 1 means "no match"; above 1 is a+# scan error, which must fail the guard instead of reading as "nothing found".+scan_or_fail() {+ local out status=0+ out="$("$1")" || status=$?+ if [ "$status" -gt 1 ]; then+ printf '%s\n' "$out"+ echo "ERROR: platform NGINX image scan ($1) failed with status $status." >&2+ return 1+ fi+ printf '%s' "$out"+}++# Turns scan hits into "path:line<TAB>ref" lines: tagged references as written,+# kustomize images entries composed into newName-or-name[:newTag][@digest].+collect_refs() {+ local hit path rest line token entry name newname newtag digest ref+ while IFS= read -r hit; do+ [ -n "$hit" ] || continue+ path="${hit%%:*}"; rest="${hit#*:}"; line="${rest%%:*}"; token="${rest#*:}"+ case "$token" in [!A-Za-z0-9_.-]*) token="${token#?}" ;; esac+ split_ref "$token"+ # "nginx:" alone is a YAML key or prose; a '*' tag is a policy glob.+ [ -z "$ref_tag" ] && [ -z "$ref_digest" ] && continue+ case "$ref_tag" in *'*'*) continue ;; esac+ printf '%s:%s\t%s\n' "$path" "$line" "$token"+ done <<<"$ref_hits"+ while IFS= read -r entry; do+ [ -n "$entry" ] || continue+ path="${entry%%:*}"; rest="${entry#*:}"; line="${rest%%:*}"; rest="${rest#*:}"+ IFS='|' read -r name newname newtag digest <<<"$rest"+ is_nginx_name "$name" || is_nginx_name "$newname" || continue+ ref="${newname:-$name}"+ if [ -z "$newtag" ] && [ -z "$digest" ]; then+ if ! is_nginx_name "$name"; then+ printf '%s:%s\t%s\n' "$path" "$line" "$ref:<no newTag>"+ fi+ continue+ fi+ [ -n "$newtag" ] && ref="$ref:$newtag"+ [ -n "$digest" ] && ref="$ref@$digest"+ printf '%s:%s\t%s\n' "$path" "$line" "$ref"+ done <<<"$kustomize_hits"+}++if ! ref_hits="$(scan_or_fail scan_refs)"; then failed=1; fi+if ! untagged_hits="$(scan_or_fail scan_untagged)"; then failed=1; fi+if ! kustomize_hits="$(scan_or_fail scan_kustomize_images)"; then failed=1; fi+if [ "$failed" -ne 0 ]; then+ exit 1+fi+refs="$(collect_refs)"++if [ "${1:-}" = "--list-digest-pins" ]; then+ pins=""+ while IFS=$'\t' read -r where ref; do+ [ -n "$ref" ] || continue+ split_ref "$ref"+ if [ -n "$ref_digest" ] && [ -z "$(nginx_ref_problem "$ref")" ]; then+ pins="$pins$ref"$'\n'+ fi+ done <<<"$refs"+ printf '%s' "$pins" | sort -u+ exit 0+fi++bad=0+while IFS=$'\t' read -r where ref; do+ [ -n "$ref" ] || continue+ problem="$(nginx_ref_problem "$ref")"+ if [ -n "$problem" ]; then+ echo "ERROR: $where: $ref: $problem" >&2+ bad=1+ fi+done <<<"$refs"+while IFS= read -r hit; do+ [ -n "$hit" ] || continue+ echo "ERROR: ${hit%%:*}:$(printf '%s' "${hit#*:}" | cut -d: -f1): untagged NGINX image (implicit :latest)" >&2+ bad=1+done <<<"$untagged_hits"+if [ "$bad" -ne 0 ]; then+ echo "ERROR: vulnerable or floating platform NGINX image reference found; use $BASELINE_TEXT." >&2+ failed=1+firequire_text() {local path="$1"@@ -69,41 +276,20 @@ require_text() {fi}-# The egress proxy Dockerfile must have exactly one FROM, equal to the fixed-# image pinned by its multi-arch index digest.+# The egress proxy Dockerfile must have exactly one FROM instruction (Dockerfile+# instructions are case-insensitive), equal to the fixed image pinned by its+# multi-arch index digest.require_single_from() {local path="$1"local expected="$2"local from_lines- from_lines="$(grep -E '^[[:space:]]*FROM[[:space:]]' "$PROJECT_DIR/$path" || true)"+ from_lines="$(grep -iE '^[[:space:]]*FROM[[:space:]]' "$PROJECT_DIR/$path" || true)"if [ "$from_lines" != "$expected" ]; thenecho "ERROR: $path must have exactly one FROM line, '$expected'; found: ${from_lines:-<none>}" >&2return 1fi}-scan_forbidden_nginx_refs() {- cd "$PROJECT_DIR"- if command -v rg >/dev/null 2>&1; then- rg -n "$FORBIDDEN_PLATFORM_NGINX_REGEX" "${scan_paths[@]}"- else- grep -RInE "$FORBIDDEN_PLATFORM_NGINX_REGEX" "${scan_paths[@]}"- fi-}--failed=0--if scan_forbidden_nginx_refs; then- echo "ERROR: vulnerable or floating platform NGINX image reference found." >&2- failed=1-else- scan_status=$?- if [ "$scan_status" -gt 1 ]; then- echo "ERROR: platform NGINX image scan failed with status $scan_status." >&2- failed=1- fi-fi-require_text "deploy/base/control-plane/control-api-rpc-gateway.yaml" "$FIXED_NGINX_IMAGE" || failed=1require_text "deploy/base/control-plane/host-context-controller-api-gateway.yaml" "$FIXED_NGINX_IMAGE" || failed=1require_text "deploy/base/control-plane/nginx-workflow-approval-gateway.yaml" "$FIXED_NGINX_IMAGE" || failed=1@@ -124,4 +310,5 @@ if [ "$failed" -ne 0 ]; thenexit 1fi-echo "OK -- platform NGINX images use fixed ${FIXED_NGINX_IMAGE} security baseline"+checked="$(printf '%s\n' "$refs" | grep -c . || true)"+echo "OK -- platform NGINX images use fixed ${FIXED_NGINX_IMAGE} security baseline ($checked references checked)"diff --git a/scripts/verify-nginx-image-digests.sh b/scripts/verify-nginx-image-digests.shnew file mode 100644index 000000000..48e084ef3--- /dev/null+++ b/scripts/verify-nginx-image-digests.sh@@ -0,0 +1,69 @@+#!/usr/bin/env bash+# Verify that every digest-pinned platform NGINX reference really is the NGINX+# release its tag names. scripts/validate-nginx-images.sh checks tags; a digest+# next to a good tag could still point at an older image, so this reads the+# immutable digest from the registry: the image config of the linux/amd64 and+# linux/arm64 manifests under it must both declare NGINX_VERSION equal to the+# tag's x.y.z.+#+# Usage: verify-nginx-image-digests.sh [name:tag@sha256:digest ...]+# With no arguments, the references come from+# validate-nginx-images.sh --list-digest-pins. Needs docker buildx and jq.+set -euo pipefail++SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+REQUIRED_PLATFORMS="linux/amd64 linux/arm64"++if [ "$#" -gt 0 ]; then+ refs="$(printf '%s\n' "$@")"+else+ refs="$(bash "$SCRIPT_DIR/validate-nginx-images.sh" --list-digest-pins)"+fi+if [ -z "$refs" ]; then+ echo "ERROR: no digest-pinned NGINX references to verify" >&2+ exit 1+fi++failed=0+checked=0+while IFS= read -r ref; do+ name_tag="${ref%@*}"+ digest="${ref#*@}"+ tag="${name_tag##*:}"+ if [ "$name_tag" = "$ref" ] || ! [[ "$tag" =~ ^([0-9]+\.[0-9]+\.[0-9]+)(-[[:alnum:]_.-]+)?$ ]]; then+ echo "ERROR: $ref is not name:<x.y.z>[-suffix]@sha256:<digest>" >&2+ failed=1+ continue+ fi+ want="${BASH_REMATCH[1]}"+ if ! image_json="$(docker buildx imagetools inspect "${name_tag%:*}@$digest" --format '{{json .Image}}')"; then+ echo "ERROR: could not inspect $ref" >&2+ failed=1+ continue+ fi+ # A multi-platform index gives a map keyed by platform; a single-platform+ # manifest gives one config object.+ versions="$(jq -r '+ (if has("config") then {"single": .} else . end)+ | to_entries[]+ | "\(.key) \([.value.config.Env[]? | select(startswith("NGINX_VERSION=")) | ltrimstr("NGINX_VERSION=")] | first // "<none>")"+ ' <<<"$image_json")"+ for platform in $REQUIRED_PLATFORMS; do+ got="$(awk -v p="$platform" '$1 == p { print $2 }' <<<"$versions")"+ if [ -z "$got" ]; then+ echo "ERROR: $ref has no $platform manifest" >&2+ failed=1+ elif [ "$got" != "$want" ]; then+ echo "ERROR: $ref $platform declares NGINX_VERSION=$got, tag says $want" >&2+ failed=1+ else+ echo "ok: $ref $platform NGINX_VERSION=$got"+ fi+ done+ checked=$((checked + 1))+done <<<"$refs"++if [ "$failed" -ne 0 ]; then+ exit 1+fi+echo "OK -- $checked digest-pinned NGINX reference(s) match their tag on $REQUIRED_PLATFORMS"