Skip to content

Sanitize Semantic Version Input#419

Open
sshropshire wants to merge 2 commits intodevelopfrom
sanitize_version_input
Open

Sanitize Semantic Version Input#419
sshropshire wants to merge 2 commits intodevelopfrom
sanitize_version_input

Conversation

@sshropshire
Copy link
Collaborator

Summary of changes

  • This PR sanitizes the version string input to the create release PR workflow during manual dispatch

Checklist

  • Added a changelog entry

Authors

List GitHub usernames for everyone who contributed to this pull request.

@sshropshire sshropshire mentioned this pull request Feb 18, 2026
@sshropshire sshropshire marked this pull request as ready for review February 18, 2026 17:17
Comment on lines +16 to +21
- name: Validate Version Name
run: |
# Ref: https://github.com/orgs/community/discussions/48373#discussioncomment-7543209
# Ref: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
echo "Validating version name to make sure it adheres to semantic versioning..."
echo "${{ github.event.inputs.versionName }}" | grep -P '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ${{ }} expression is interpolated directly into the bash command before validation occurs, which means an attacker could inject commands before the regex check happens.

Suggested change
- name: Validate Version Name
run: |
# Ref: https://github.com/orgs/community/discussions/48373#discussioncomment-7543209
# Ref: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
echo "Validating version name to make sure it adheres to semantic versioning..."
echo "${{ github.event.inputs.versionName }}" | grep -P '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'
- name: Validate Version Name
env:
VERSION_INPUT: ${{ github.event.inputs.versionName }}
run: |
# Ref: https://github.com/orgs/community/discussions/48373#discussioncomment-7543209
# Ref: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
echo "Validating version name to make sure it adheres to semantic versioning..."
echo "$VERSION_INPUT" | grep -P '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments