fix(ci): validate release workflow version input#40
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Hardens the GitHub Actions release workflow against command injection by validating the workflow_dispatch version input and avoiding direct interpolation of the input in shell run blocks. It also reduces credential exposure during release-related checkouts by disabling persisted checkout credentials.
Changes:
- Introduces
RELEASE_VERSIONworkflow env var sourced from the dispatch input and uses it in shell steps. - Adds an early preflight validation step to enforce a v-prefixed SemVer-like tag format.
- Disables persisted checkout credentials (
persist-credentials: false) in preflight/build/release jobs and updates release/tag/dispatch steps to use the validated env var.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| - name: Validate version input | ||
| run: | | ||
| if [[ ! "$RELEASE_VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then |
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.
Motivation
workflow_dispatchversioninput by avoiding direct interpolation of${{ inputs.version }}into shellrunblocks and by validating the supplied value.Description
RELEASE_VERSIONderived from the workflow input and use it in shell steps instead of${{ inputs.version }}.Validate version inputstep that enforces a strict v-prefixed SemVer regex (e.g.v0.1.0) before any shell usage.CURRENT_TAG,softprops/action-gh-releasetag_name/name, and thegh workflow rundispatch).persist-credentials: false) in the release jobs to avoid exposing repo write creds to later shell commands.Testing
git diff --checkand resolved whitespace/format issues, success.ruby -e 'require "yaml"; YAML.load_file(".github/workflows/release.yml")', success.${{ inputs.version }}interpolation inside anyrunblocks with a Python check, success.RELEASE_VERSIONvia environment and verified the regex validation rejects payloads containing command substitutions and that no side-effect files are created, success.Codex Task