Repository navigation
ci: pass the manual image tag through env, as the release workflow does - #1688
Open
Dhairya-007 wants to merge 1 commit into
Open
Dhairya-007 wants to merge 1 commit into
Dhairya-007 wants to merge 1 commit into
Conversation
`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 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
.github/workflows/build-image-for-manual.ymlinterpolates${{ inputs.tag_name }}directly into itsrun:block, in two places:GitHub substitutes
${{ }}expressions textually, before bash parses the script, so the value becomes part of the command rather than an argument to it. The surrounding double quotes don't help, because they are already in the text by the time the value is pasted in. Atag_namecontaining shell metacharacters therefore executes in a job that holds the DockerHub credentials.The fix is already in the repo. The sibling
build-image-for-release.ymldoes the same build and gets this right:So this PR just brings the manual workflow in line with the release one. Bound through
env:, the value arrives as an environment variable and the existing quoting makes it inert.On severity, to be straight about it:
workflow_dispatchcan only be triggered by someone who already has write access, so this is not a hole open to the public, and I would not call it urgent. It is hardening — but the correct pattern costs nothing and the repo already uses it two files over.build-image-for-manual.ymlis the only workflow in the repo with this pattern; the other four image/binary workflows are already clean.What I deliberately did not change
The release workflow strips a leading
v(${IMAGE_TAG#v}) because its value is a git ref likev1.2.3. Here the value is a tag name the operator types into the dispatch form, so I kept it as${IMAGE_TAG}. Adding#vwould change which image tag gets published, which is a behaviour change rather than a hardening one.I also left the
docker loginline alone. It interpolates${{ secrets.* }}, which GitHub treats as trusted and zizmor does not flag, and piping the token via--password-stdinis already the right shape — so changing it would be churn on a line this PR has no reason to touch.Verification
Before the change, zizmor reported two
error[template-injection]findings on lines 56 and 60 of this file, both at high confidence.The built image tag is unchanged:
apache/answer:<tag_name>, exactly as before.Claude Code assisted in writing this patch; I checked the sibling workflows for the same pattern and confirmed the before/after with the tools above.