diff --git a/.github/agent-guides/validation.md b/.github/agent-guides/validation.md index 71b79dd6..688b3139 100644 --- a/.github/agent-guides/validation.md +++ b/.github/agent-guides/validation.md @@ -59,7 +59,12 @@ tagged source, public artifact digest and fixed caller CI identity. A private, incomplete, failed or changed attempt is unsupported. Do not accept an arbitrary image repository, signer or caller-provided source identity. Pin only the image of one source-owned WebApp whose name, namespace and spec name match the caller; -reject linked/special deployment files. This is not complete controller schema +reject linked/special deployment files. In both modes the optional +`app-manifest` input names the app manifest relative to `deploy-path`; empty +keeps `deployment.yaml` / `webapp.yaml`. A named path must be plain components +(no leading `/`, empty, `.`, `..` or hidden component, no line break) reached +through regular directories to a regular file, checked once before any registry +write; Deployment mode pins the path its validation step resolved. This is not complete controller schema validation. Sign and verify both promoted digests with all fourteen paired claims, retaining the original image provenance. Keep helper refusal/pinning, promotion mutation, native cryptographic and workflow-interface controls in diff --git a/.github/scripts/prepare-prebuilt-webapp.sh b/.github/scripts/prepare-prebuilt-webapp.sh index 081eb169..265afcfa 100644 --- a/.github/scripts/prepare-prebuilt-webapp.sh +++ b/.github/scripts/prepare-prebuilt-webapp.sh @@ -36,16 +36,30 @@ esac [[ -n "${GITHUB_OUTPUT:-}" ]] || fail 'missing workflow output file' path="${DEPLOY_PATH#./}" [[ -n "$path" && "$path" != /* && "$path" != */ && "$path" != *//* ]] || fail 'require a relative deployment directory' +# The WebApp manifest is named relative to the deployment directory; empty keeps webapp.yaml. +manifest="${APP_MANIFEST:-webapp.yaml}" +[[ "$manifest" != *$'\n'* && "$manifest" != *$'\r'* && "$manifest" != /* && "$manifest" != */ && "$manifest" != *//* ]] || + fail 'require a relative app manifest inside the deployment directory' +# Walk below the cursor one component at a time; every directory must be a regular source +# directory and no component may be `.`, `..`, hidden or unusual. +walk() { + local component components + IFS=/ read -r -a components <<< "$1" + for component in "${components[@]}"; do + [[ "$component" =~ ^[A-Za-z0-9_-][A-Za-z0-9_.-]*$ && "$component" != . && "$component" != .. ]] || fail "unsafe $2" + cursor="$cursor/$component" + [[ -d "$cursor" && ! -L "$cursor" ]] || fail 'deployment directories must be regular source directories' + done +} cursor=. -IFS=/ read -r -a components <<< "$path" -for component in "${components[@]}"; do - [[ "$component" =~ ^[A-Za-z0-9_-][A-Za-z0-9_.-]*$ && "$component" != . && "$component" != .. ]] || fail 'unsafe deployment directory' - cursor="$cursor/$component" - [[ -d "$cursor" && ! -L "$cursor" ]] || fail 'deployment directories must be regular source directories' -done -file="$cursor/webapp.yaml" -[[ -f "$file" && ! -L "$file" ]] || fail 'require a regular webapp.yaml' -unsafe="$(find "$cursor" ! -type f ! -type d -print -quit)" || fail 'cannot inspect the complete deployment directory' +walk "$path" 'deployment directory' +deploy_dir="$cursor" +manifest_name="${manifest##*/}" +[[ "$manifest_name" =~ ^[A-Za-z0-9_-][A-Za-z0-9_.-]*$ ]] || fail 'unsafe app manifest path' +[[ "$manifest" == "$manifest_name" ]] || walk "${manifest%/*}" 'app manifest path' +file="$cursor/$manifest_name" +[[ -f "$file" && ! -L "$file" ]] || fail "require a regular $manifest" +unsafe="$(find "$deploy_dir" ! -type f ! -type d -print -quit)" || fail 'cannot inspect the complete deployment directory' [[ -z "$unsafe" ]] || fail 'deployment artifacts cannot contain linked or special files' work="$(mktemp -d)" trap 'rm -rf "$work"' EXIT diff --git a/.github/tests/test-prebuilt-webapp.sh b/.github/tests/test-prebuilt-webapp.sh index e1f85efc..7a57beda 100644 --- a/.github/tests/test-prebuilt-webapp.sh +++ b/.github/tests/test-prebuilt-webapp.sh @@ -26,6 +26,7 @@ yq -o=json '.' "$workflow" | jq -e ' .env == { REPOSITORY:"${{ github.repository }}",SOURCE_SHA:"${{ github.sha }}", APP_NAME:"${{ inputs.app-name }}",DEPLOY_PATH:"${{ inputs.deploy-path }}", + APP_MANIFEST:"${{ inputs.app-manifest }}", PREBUILT_IMAGE_DIGEST:"${{ inputs.prebuilt-image-digest }}", PREBUILT_PUBLIC_DIGEST:"${{ inputs.prebuilt-public-digest }}", PREBUILT_CI_RUN_ID:"${{ inputs.prebuilt-ci-run-id }}", @@ -354,4 +355,78 @@ reset_fixture ln -s "$work/run.json" "$work/deploy/unrelated.yaml" if invoke none > "$work/log" 2>&1; then fail 'accepted a linked file in the packaged deployment directory'; fi [[ ! -s "$work/output" && ! -s "$work/reads" ]] || fail 'linked deployment file reached verification' +rm "$work/deploy/unrelated.yaml" + +# app-manifest names the WebApp manifest inside the deployment directory; omitted, webapp.yaml is +# used as above, even beside a base/ copy. +reset_split_fixture() { # — the healthy WebApp moved to deploy/ + rm -rf "$work/deploy" "$work/outside" "$work/outside.yaml" "$work/webapp.yaml" + mkdir -p "$work/deploy" + reset_fixture + mkdir -p "$(dirname "$work/deploy/$1")" + [[ "$1" == webapp.yaml ]] || mv "$work/deploy/webapp.yaml" "$work/deploy/$1" + cp "$work/deploy/$1" "$work/before.yaml" + printf 'resources: [prod]\n' > "$work/deploy/kustomization.yaml" +} +pinned_only() { # — the selected image is pinned and every other document value is kept + yq -o=json -I=0 '.' "$1" | jq -s -e --arg image "ghcr.io/devantler-tech/app@$image_digest" ' + . == [ + {apiVersion:"v1",kind:"ConfigMap",metadata:{name:"unrelated"},data:{literal:"keep me"}}, + {apiVersion:"kro.run/v1alpha1",kind:"WebApp",metadata:{name:"app",namespace:"app"}, + spec:{name:"app",image:$image,host:"example.invalid"}} + ]' > /dev/null +} +reset_split_fixture webapp.yaml +mkdir -p "$work/deploy/base" +cp "$work/before.yaml" "$work/deploy/base/webapp.yaml" +invoke none > "$work/log" 2>&1 || fail "flat WebApp beside base/ refused: $(cat "$work/log")" +pinned_only "$work/deploy/webapp.yaml" || fail 'default did not pin the flat webapp.yaml' +cmp -s "$work/before.yaml" "$work/deploy/base/webapp.yaml" || fail 'default pinned a base/ manifest nobody named' +for manifest in base/webapp.yaml overlays/base/webapp.yaml app.yaml; do + reset_split_fixture "$manifest" + invoke none APP_MANIFEST="$manifest" > "$work/log" 2>&1 || fail "healthy WebApp at $manifest refused: $(cat "$work/log")" + pinned_only "$work/deploy/$manifest" || fail "did not pin only the selected image in $manifest" + [[ "$manifest" == app.yaml || ! -e "$work/deploy/webapp.yaml" ]] || fail "$manifest created a flat webapp.yaml" + grep -qx "digest=$image_digest" "$work/output" || fail "$manifest omitted the verified image output" +done +# Unsafe, linked or missing app-manifest values are refused before any external observation and +# change no file. A valid WebApp sits wherever each path would lead. +for case in \ + '../webapp.yaml|unsafe app manifest path' \ + '/webapp.yaml|require a relative app manifest inside the deployment directory' \ + 'base/./webapp.yaml|unsafe app manifest path' \ + 'base/../webapp.yaml|unsafe app manifest path' \ + 'base//webapp.yaml|require a relative app manifest inside the deployment directory' \ + 'base/|require a relative app manifest inside the deployment directory' \ + '.hidden/webapp.yaml|unsafe app manifest path' \ + "base/webapp.yaml"$'\n'"x|require a relative app manifest inside the deployment directory" \ + "base/webapp.yaml"$'\r'"|require a relative app manifest inside the deployment directory" \ + 'linked-dir|deployment directories must be regular source directories' \ + 'linked-file|require a regular base/webapp.yaml' \ + 'missing|require a regular base/webapp.yaml' \ + 'linked-sibling|deployment artifacts cannot contain linked or special files'; do + manifest="${case%%|*}" + expected="${case#*|}" + reset_split_fixture base/webapp.yaml + cp "$work/before.yaml" "$work/deploy/webapp.yaml" + cp "$work/before.yaml" "$work/webapp.yaml" + mkdir -p "$work/deploy/.hidden" + cp "$work/before.yaml" "$work/deploy/.hidden/webapp.yaml" + case "$manifest" in + linked-dir) mv "$work/deploy/base" "$work/outside" && ln -s ../outside "$work/deploy/base" ;; + linked-file) mv "$work/deploy/base/webapp.yaml" "$work/outside.yaml" && + ln -s ../../outside.yaml "$work/deploy/base/webapp.yaml" ;; + missing) rm "$work/deploy/base/webapp.yaml" ;; + # The whole packaged directory is scanned, not only the named manifest's directory. + linked-sibling) mkdir -p "$work/deploy/prod" && ln -s ../../run.json "$work/deploy/prod/linked.yaml" ;; + esac + case "$manifest" in linked-dir | linked-file | missing | linked-sibling) manifest=base/webapp.yaml ;; esac + find "$work" -type f -name '*webapp.yaml' -exec shasum {} + | sort > "$work/sums-before" + [[ -s "$work/sums-before" ]] || fail 'the refusal fixture has no manifests to compare' + if invoke none APP_MANIFEST="$manifest" > "$work/log" 2>&1; then fail "accepted app-manifest: $manifest"; fi + [[ ! -s "$work/output" && ! -s "$work/reads" ]] || fail "app-manifest $manifest reached verification" + grep -qF "$expected" "$work/log" || fail "app-manifest $manifest refused for the wrong reason: $(grep '::error::' "$work/log")" + find "$work" -type f -name '*webapp.yaml' -exec shasum {} + | sort | cmp -s - "$work/sums-before" || + fail "refused app-manifest $manifest changed manifests" +done echo 'prebuilt-webapp: real YAML pinning and source/CI/provenance/partial-observation refusals pass' diff --git a/.github/tests/test-publish-preflight.sh b/.github/tests/test-publish-preflight.sh index a9d7a268..ca41632c 100755 --- a/.github/tests/test-publish-preflight.sh +++ b/.github/tests/test-publish-preflight.sh @@ -663,6 +663,118 @@ nothing_pushed "publish-app with an unparsable manifest" refused_with "publish-app with an unparsable manifest" "FAILED at 🔍 Validate the deployment manifest" echo "ok publish-app refuses a bad manifest before pushing anything" +# ---- 2b. publish-app: the app-manifest input names the app manifest inside deploy-path ---------- + +new_split_app() { # — the same app with its Deployment moved to deploy/ + new_app "$1" + mkdir -p "$(dirname "$1/deploy/$2")" + mv "$1/deploy/deployment.yaml" "$1/deploy/$2" + printf 'resources: [prod]\n' >"$1/deploy/kustomization.yaml" +} + +# Without the input the flat file is resolved, checked and pinned exactly as before, even beside a +# base/ directory, and validation hands the pin that file. +wd="$scratch/app-flat" +new_app "$wd" +mkdir -p "$wd/deploy/base" +cp "$wd/deploy/deployment.yaml" "$wd/deploy/base/deployment.yaml" +run_job "$app" publish "$wd" tag v1.2.3 app-name=app || + fail "publish-app failed a good flat release: $(cat "$log")" +grep -qxF 'manifest.file=./deploy/deployment.yaml' "$sim_outputs" || + fail "publish-app did not resolve the flat manifest; outputs: $(cat "$sim_outputs")" +[[ "$(yq '.spec.template.spec.containers[] | select(.name == "app") | .image' "$wd/deploy/deployment.yaml")" == \ + "ghcr.io/devantler-tech/app@$image_digest" ]] || fail "publish-app did not pin the flat manifest by default" +[[ "$(yq '.spec.template.spec.containers[] | select(.name == "app") | .image' "$wd/deploy/base/deployment.yaml")" == \ + "ghcr.io/devantler-tech/app:placeholder" ]] || fail "publish-app pinned a base/ manifest nobody named" +grep -qF "flux push artifact oci://ghcr.io/devantler-tech/app/manifests:default-staging-123-2 --path=./deploy " "$calls" || + fail "publish-app no longer pushes the whole flat deploy-path; calls: $(cat "$calls")" +echo "ok publish-app resolves deploy-path/deployment.yaml without app-manifest, as before" + +for case in "deploy|base/deployment.yaml" "deploy|overlays/base/deployment.yaml" "deploy|app.yaml" "k8s|base/deployment.yaml"; do + deploy="${case%%|*}" + manifest="${case#*|}" + wd="$scratch/app-input-$deploy-${manifest//\//-}" + new_split_app "$wd" "$manifest" + [[ "$deploy" == deploy ]] || mv "$wd/deploy" "$wd/$deploy" + passed=(app-name=app "app-manifest=$manifest") + [[ "$deploy" == deploy ]] || passed+=("deploy-path=./$deploy") + run_job "$app" publish "$wd" tag v1.2.3 "${passed[@]}" || + fail "publish-app failed a good release with app-manifest=$manifest in ./$deploy: $(cat "$log")" + grep -qxF "manifest.file=./$deploy/$manifest" "$sim_outputs" || + fail "publish-app did not resolve ./$deploy/$manifest; outputs: $(cat "$sim_outputs")" + pinned="$(yq '.spec.template.spec.containers[] | select(.name == "app") | .image' "$wd/$deploy/$manifest")" + [[ "$pinned" == "ghcr.io/devantler-tech/app@$image_digest" ]] || + fail "publish-app did not pin the built digest into ./$deploy/$manifest; got: $pinned" + sidecar="$(yq '.spec.template.spec.containers[] | select(.name == "sidecar") | .image' "$wd/$deploy/$manifest")" + [[ "$sidecar" == "ghcr.io/devantler-tech/sidecar:1.0.0" ]] || fail "publish-app changed another container: $sidecar" + [[ "$manifest" == app.yaml || ! -e "$wd/$deploy/deployment.yaml" ]] || fail "publish-app created a flat manifest" + grep -qF "flux push artifact oci://ghcr.io/devantler-tech/app/manifests:default-staging-123-2 --path=./$deploy " "$calls" || + fail "publish-app did not push the whole ./$deploy directory; calls: $(cat "$calls")" + [[ "$(head -n 1 "$calls")" == "image push 🐳 Build & push image" ]] || + fail "publish-app's first registry write is not the image push with app-manifest=$manifest" +done +echo "ok publish-app validates and pins the app-manifest it is given and pushes the whole deploy-path" + +# An unsafe, linked or missing app-manifest is refused before the first registry write. Each case +# keeps a valid Deployment where the path would lead, so only the input check can refuse it. +plain='app-manifest must be a relative path of plain names inside deploy-path' +for case in \ + "../deployment.yaml|$plain" \ + "/deployment.yaml|$plain" \ + "base/./deployment.yaml|$plain" \ + "base/../deployment.yaml|$plain" \ + "base//deployment.yaml|$plain" \ + "base/|$plain" \ + ".hidden/deployment.yaml|$plain" \ + "linked-dir|app-manifest base/deployment.yaml passes through a link at ./deploy/base" \ + "linked-file|app-manifest base/deployment.yaml passes through a link at ./deploy/base/deployment.yaml" \ + "linked-deploy|deploy-path ./deploy passes through a link at ./deploy" \ + "missing|manifest ./deploy/base/deployment.yaml not found"; do + manifest="${case%%|*}" + expected="${case#*|}" + wd="$scratch/app-refused" + rm -rf "$wd" + new_split_app "$wd" base/deployment.yaml + cp "$wd/deploy/base/deployment.yaml" "$wd/deploy/deployment.yaml" + cp "$wd/deploy/base/deployment.yaml" "$wd/deployment.yaml" + mkdir -p "$wd/deploy/.hidden" + cp "$wd/deploy/base/deployment.yaml" "$wd/deploy/.hidden/deployment.yaml" + case "$manifest" in + linked-dir) mv "$wd/deploy/base" "$wd/outside" && ln -s ../outside "$wd/deploy/base" ;; + linked-file) mv "$wd/deploy/base/deployment.yaml" "$wd/outside.yaml" && + ln -s ../../outside.yaml "$wd/deploy/base/deployment.yaml" ;; + linked-deploy) mv "$wd/deploy" "$wd/manifests" && ln -s manifests "$wd/deploy" ;; + missing) rm "$wd/deploy/base/deployment.yaml" ;; + esac + case "$manifest" in linked-dir | linked-file | linked-deploy | missing) manifest=base/deployment.yaml ;; esac + if run_job "$app" publish "$wd" tag v1.2.3 app-name=app "app-manifest=$manifest"; then + fail "publish-app accepted app-manifest '$manifest' ($expected)" + fi + nothing_pushed "publish-app with app-manifest '$manifest'" + refused_with "publish-app with app-manifest '$manifest'" "$expected" + refused_with "publish-app with app-manifest '$manifest'" "FAILED at 🔍 Validate the deployment manifest" + ! grep -rqF "@$image_digest" "$wd" || fail "publish-app pinned a file for a refused app-manifest '$manifest'" +done + +# A line break cannot be passed through the simulated caller, so run the shipped validation step on +# its own: it refuses the input without echoing it, and resolves no manifest for the pin. +validate="$(yq -r '.jobs.publish.steps[] | select(.id == "manifest") | .run' "$app")" +[[ -n "$validate" ]] || fail "publish-app has no validation step with id manifest" +wd="$scratch/app-line-break" +rm -rf "$wd" +new_split_app "$wd" base/deployment.yaml +for manifest in $'base/deployment.yaml\n::error::injected' $'base/deployment.yaml\r' $'\nbase/deployment.yaml'; do + : >"$scratch/direct-output" + if (cd "$wd" && env -i PATH="$PATH" APP_NAME=app DEPLOY_PATH=./deploy APP_MANIFEST="$manifest" \ + GITHUB_OUTPUT="$scratch/direct-output" bash --noprofile --norc -e -c "$validate") >"$scratch/direct.log" 2>&1; then + fail "publish-app accepted an app-manifest with a line break" + fi + grep -qF "$plain" "$scratch/direct.log" || fail "line break refused for the wrong reason: $(cat "$scratch/direct.log")" + ! grep -qF 'injected' "$scratch/direct.log" || fail "publish-app echoed an unchecked app-manifest" + [[ ! -s "$scratch/direct-output" ]] || fail "a refused app-manifest still resolved a manifest for the pin" +done +echo "ok publish-app refuses an unsafe, linked or missing app-manifest before pushing anything" + # ---- 3. both workflows: only a complete semantic-version tag publishes -------------------------- # tag|published version. SemVer 2.0.0 examples, including its own edge cases. diff --git a/.github/workflows/publish-app.yaml b/.github/workflows/publish-app.yaml index bfe2ca5e..5016d5d1 100644 --- a/.github/workflows/publish-app.yaml +++ b/.github/workflows/publish-app.yaml @@ -11,6 +11,11 @@ on: required: false default: ./deploy type: string + app-manifest: + description: "Path, relative to deploy-path, of the manifest holding the app: the Deployment with the app-name container, or the WebApp in prebuilt mode. Empty means deployment.yaml (webapp.yaml in prebuilt mode)." + required: false + default: "" + type: string dry-run: description: "Skip publish (validate workflow interface only)." required: false @@ -210,24 +215,60 @@ jobs: persist-credentials: false - name: 🔍 Validate the deployment manifest + id: manifest if: ${{ !inputs.enable-signed-recovery && !inputs.enable-prebuilt-webapp }} env: APP_NAME: ${{ inputs.app-name }} DEPLOY_PATH: ${{ inputs.deploy-path }} + APP_MANIFEST: ${{ inputs.app-manifest }} run: | # Every manifest check runs here, before anything reaches the registry. A release that fails # after the image push leaves GHCR changed — `latest` included — with no deployable manifest # to go with the image. Only the digest injection waits for the build, because the digest # does not exist before it. set -euo pipefail + export LC_ALL=C + # The app manifest is resolved once, here; the pin step reuses this exact path. Without + # app-manifest it is deploy-path/deployment.yaml, checked as it always was. file="${DEPLOY_PATH}/deployment.yaml" + if [ -n "$APP_MANIFEST" ]; then + # A caller-named manifest is plain names below deploy-path: no leading /, no empty, `.` + # or `..` component, no line break. No component may be a link, so the file cannot leave + # deploy-path. The input is not echoed until it has passed this check. + name='[A-Za-z0-9_-][A-Za-z0-9_.-]*' + if ! [[ "$APP_MANIFEST" =~ ^${name}(/${name})*$ ]]; then + echo "::error::app-manifest must be a relative path of plain names inside deploy-path (letters, digits, '.', '_' and '-'; no leading '/', no empty, '.' or '..' component)"; exit 1 + fi + # deploy-path and each of its ancestors must not be a link either: a linked deploy + # directory would carry the named manifest outside the deploy tree just the same. + prefix="${DEPLOY_PATH%/}" + while [ -n "$prefix" ]; do + if [ -L "$prefix" ]; then + echo "::error::deploy-path $DEPLOY_PATH passes through a link at $prefix"; exit 1 + fi + [[ "$prefix" == */* ]] || break + prefix="${prefix%/*}" + done + file="$DEPLOY_PATH" + IFS=/ read -r -a components <<< "$APP_MANIFEST" + for component in "${components[@]}"; do + file="$file/$component" + if [ -L "$file" ]; then + echo "::error::app-manifest $APP_MANIFEST passes through a link at $file"; exit 1 + fi + done + fi if [ ! -f "$file" ]; then - echo "::error::manifest $file not found (check the deploy-path input)"; exit 1 + echo "::error::manifest $file not found (check the deploy-path and app-manifest inputs)"; exit 1 fi matches=$(yq '[.spec.template.spec.containers[] | select(.name == strenv(APP_NAME))] | length' "$file") if [ "$matches" != "1" ]; then echo "::error::expected exactly one container named '$APP_NAME' in $file, found $matches"; exit 1 fi + case "$file" in + *$'\n'* | *$'\r'*) echo "::error::deploy-path must not contain a line break"; exit 1 ;; + esac + echo "file=$file" >> "$GITHUB_OUTPUT" # Installed before anything is pushed, so a failed download also fails the job while the # registry is still untouched. @@ -273,6 +314,7 @@ jobs: SOURCE_SHA: ${{ github.sha }} APP_NAME: ${{ inputs.app-name }} DEPLOY_PATH: ${{ inputs.deploy-path }} + APP_MANIFEST: ${{ inputs.app-manifest }} PREBUILT_IMAGE_DIGEST: ${{ inputs.prebuilt-image-digest }} PREBUILT_PUBLIC_DIGEST: ${{ inputs.prebuilt-public-digest }} PREBUILT_CI_RUN_ID: ${{ inputs.prebuilt-ci-run-id }} @@ -346,14 +388,18 @@ jobs: IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} DIGEST: ${{ steps.build.outputs.digest }} APP_NAME: ${{ inputs.app-name }} - DEPLOY_PATH: ${{ inputs.deploy-path }} + MANIFEST: ${{ steps.manifest.outputs.file }} run: | # The manifest was validated before the build; this step only injects the digest the build - # produced, and checks that the injection took. A registry reference must be lowercase, - # which is also how docker/metadata-action named the image it pushed. + # produced into the file that validation resolved, and checks that the injection took. A + # registry reference must be lowercase, which is also how docker/metadata-action named the + # image it pushed. set -euo pipefail IMAGE="$(printf '%s' "$IMAGE" | tr '[:upper:]' '[:lower:]')" - file="${DEPLOY_PATH}/deployment.yaml" + file="$MANIFEST" + if [ -z "$file" ]; then + echo "::error::the validation step did not resolve the app manifest"; exit 1 + fi if [ -z "$DIGEST" ]; then echo "::error::build did not produce an image digest"; exit 1 fi diff --git a/README.md b/README.md index ab7f3632..d994921f 100644 --- a/README.md +++ b/README.md @@ -633,11 +633,14 @@ jobs: packages: write # push image + manifests OCI artifact id-token: write # keyless cosign signing with: - app-name: my-app # container name in deploy/deployment.yaml + app-name: my-app # container name in the app manifest deploy-path: ./deploy # optional + app-manifest: base/deployment.yaml # optional; default deployment.yaml (webapp.yaml in prebuilt mode) ``` -> **Note:** Must be invoked from a complete semantic-version tag (`vMAJOR.MINOR.PATCH`, optionally with `-PRERELEASE` and `+BUILD`) — Docker semver tagging and Flux `OCIRepository` semver selection depend on it. Anything else, such as `v1.2.3garbage` or a version whose numbers exceed 15 digits, is refused before publishing; build metadata is dropped from the published version because an OCI tag cannot carry `+`. The `app-name` container check on `deploy-path/deployment.yaml` also runs before anything is pushed, so a bad manifest leaves the registry untouched. The calling job must grant `packages: write` and `id-token: write` (and `contents: read` for checkout); no secrets are required (auth uses the GHCR-scoped `GITHUB_TOKEN`). +> **Note:** Must be invoked from a complete semantic-version tag (`vMAJOR.MINOR.PATCH`, optionally with `-PRERELEASE` and `+BUILD`) — Docker semver tagging and Flux `OCIRepository` semver selection depend on it. Anything else, such as `v1.2.3garbage` or a version whose numbers exceed 15 digits, is refused before publishing; build metadata is dropped from the published version because an OCI tag cannot carry `+`. The `app-name` container check on the app manifest also runs before anything is pushed, so a bad manifest leaves the registry untouched. The calling job must grant `packages: write` and `id-token: write` (and `contents: read` for checkout); no secrets are required (auth uses the GHCR-scoped `GITHUB_TOKEN`). +> +> **App manifest location:** the app manifest is `deploy-path/deployment.yaml` (`webapp.yaml` in prebuilt WebApp mode) unless `app-manifest` names another file, relative to `deploy-path`. A product that splits `deploy-path` into kustomize overlays sets it, for example to `base/deployment.yaml`, in the same change that moves the file. The value must be plain names joined by `/` (letters, digits, `.`, `_` and `-`; no leading `/`, no empty, `.` or `..` component, no line break), and no directory on the way or the file itself may be a link. Anything else, or a missing file, stops publication before any registry write. The whole `deploy-path` directory is still the signed manifests artifact. #### Secrets and Inputs @@ -645,6 +648,7 @@ jobs: |---------------|----------------|------------|----------|----------------------------------------------------------------------------| | `app-name` | Input (string) | - | Yes | Deployment container name, or the matching WebApp metadata name/namespace and spec name | | `deploy-path` | Input (string) | `./deploy` | No | Path to the Kubernetes manifests directory packaged as the OCI artifact | +| `app-manifest` | Input (string) | empty | No | Path, relative to `deploy-path`, of the manifest holding the app (the Deployment, or the WebApp in prebuilt mode). Empty means `deployment.yaml` (`webapp.yaml` in prebuilt mode) | | `dry-run` | Input (boolean) | `false` | No | Skip publication and validate only the workflow interface | | `enable-caller-pin` | Input (boolean) | `true` | No | Require a 40-character commit-SHA caller before signing. The authenticated OIDC calling ref is the certificate identity. Explicit false remains supported during caller cleanup in #284 | | `enable-signed-promotion` | Input (boolean) | `false` | No | Verify both signature identities and paired publication claims before exposing version tags, then move latest only for stable releases. Requires `enable-caller-pin`; rollout is tracked in #371 | @@ -664,7 +668,7 @@ jobs: Enable `enable-prebuilt-webapp`, `enable-caller-pin` and `enable-signed-promotion` together to reuse the caller's tested image without a raw-source build. Supply all four prebuilt evidence inputs. The image must belong to the calling repository, with the same source commit as the release tag. Its original signer must be that repository's exact `.github/workflows/ci.yaml@refs/heads/main` identity. Complete public GitHub observations must establish successful main-push CI at the specified current attempt. Private or unreadable CI is not supported by this mode; it adds no token permissions. -Before any registry content write, Cosign verifies the original signature and SLSA source, subject, build, production-template profile, public digest and CI claims. A regular `webapp.yaml` in the bounded relative deployment directory must contain exactly one `kro.run/v1alpha1` WebApp. Its metadata name, namespace and spec name must equal `app-name`. Only its image is pinned; unrelated document values are preserved. Linked directories, linked files and special files are refused. This validates image selection, not the full Platform schema or controller behavior. +Before any registry content write, Cosign verifies the original signature and SLSA source, subject, build, production-template profile, public digest and CI claims. A regular `webapp.yaml` in the bounded relative deployment directory (or the file `app-manifest` names inside it, reached only through regular directories) must contain exactly one `kro.run/v1alpha1` WebApp. Its metadata name, namespace and spec name must equal `app-name`. Only its image is pinned; unrelated document values are preserved. Linked directories, linked files and special files are refused. This validates image selection, not the full Platform schema or controller behavior. The existing signed-promotion path then signs and verifies both unchanged digests with the paired publication claims plus the public digest, profile and original CI/producer binding. Stable/prerelease tag behavior is unchanged. Prebuilt recovery is unsupported: admission rejects the combined inputs, and legacy recovery independently refuses prebuilt-marked signatures even when the mode input is omitted. Original main-CI provenance remains attached to the image. Caller and Platform verifier adoption require a separately reviewed immutable publisher pin; no consumer is activated here. Rollout review and gate retirement are tracked in #684.