From a294dd71db45072cabb93654c34beb7fe161a947 Mon Sep 17 00:00:00 2001 From: dhairya05 <83921853+Dhairya-007@users.noreply.github.com> Date: Sat, 28 Nov 2026 19:51:09 +0530 Subject: [PATCH] ci: pass the manual image tag through env, as the release workflow does `build-image-for-manual.yml` interpolates `${{ inputs.tag_name }}` straight into its `run:` block, twice. GitHub substitutes expressions textually before bash sees the script, so the value is spliced into the command rather than passed as an argument -- a tag containing shell metacharacters runs as code in the job, which holds the DockerHub credentials. The sibling `build-image-for-release.yml` already handles this correctly: - name: Build and push env: IMAGE_TAG: ${{ github.ref_name }} run: | ... --tag "apache/answer:${IMAGE_TAG#v}" \ So this only brings the manual workflow in line with the release one. Values bound through `env:` reach the script as environment variables, where the existing quoting makes them inert. Deliberately not stripping a leading `v` the way the release workflow does: there the value is a git ref (`v1.2.3`), here it is a tag name the operator types, and changing that would alter which image gets published. Triggering `workflow_dispatch` already requires write access, so this is hardening rather than a hole open to the public -- but the pattern is free, and zizmor reports the file clean afterwards. Co-Authored-By: Claude Opus 5 --- .github/workflows/build-image-for-manual.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-image-for-manual.yml b/.github/workflows/build-image-for-manual.yml index 459e0f3a2..fd47396ec 100644 --- a/.github/workflows/build-image-for-manual.yml +++ b/.github/workflows/build-image-for-manual.yml @@ -47,15 +47,17 @@ jobs: run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login --username "${{ secrets.DOCKERHUB_USER }}" --password-stdin - name: Build and push + env: + IMAGE_TAG: ${{ inputs.tag_name }} run: | BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" docker buildx build \ --file ./Dockerfile \ --platform linux/amd64,linux/arm64 \ --push \ - --tag "apache/answer:${{ inputs.tag_name }}" \ + --tag "apache/answer:${IMAGE_TAG}" \ --label org.opencontainers.image.created="${BUILD_DATE}" \ --label org.opencontainers.image.revision="${GITHUB_SHA}" \ --label org.opencontainers.image.source="https://github.com/${GITHUB_REPOSITORY}" \ - --label org.opencontainers.image.version="${{ inputs.tag_name }}" \ + --label org.opencontainers.image.version="${IMAGE_TAG}" \ .