ci: sanitize PR head ref usage in calm-models publish workflow - #3021
Merged
jpgough-ms merged 1 commit intoAug 26, 2026
Merged
Conversation
…els publish workflow The Maven Central publish workflow interpolated github.event.pull_request.head.ref directly into a run: script, and the derived release version then flowed into two further shell steps the same way. Pass both through env: instead so bash treats them as data, and validate the extracted version against a strict semver pattern before it's used to tag, deploy, or open a follow-up PR. Closes the OSPS-BR-01.01 / OSPS-BR-01.02 findings from the LFX Insights build and release review.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the release-calm-models-maven-publish.yml GitHub Actions workflow against shell-injection risks by avoiding direct interpolation of untrusted PR branch refs into run: script bodies and by validating the derived release version before use.
Changes:
- Pass
github.event.pull_request.head.refviaenv:and deriveRELEASE_VERSIONinside the shell, rather than embedding the ref directly into the script. - Validate the extracted release version against a strict
MAJOR.MINOR.PATCHregex before writing it toGITHUB_OUTPUT. - Pass the derived
RELEASE_VERSIONviaenv:into later steps that tag the release and create the next-development-iteration PR.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
jpgough
approved these changes
Aug 26, 2026
jpgough-ms
approved these changes
Aug 26, 2026
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.
Description
Closes the OSPS-BR-01.01 / OSPS-BR-01.02 findings from the LFX Insights build & release review.
release-calm-models-maven-publish.ymlinterpolatedgithub.event.pull_request.head.refdirectly into arun:script to extract the release version, and that derived value then flowed the same way into two further shell steps (tag + next-dev-iteration PR). A branch name containing shell metacharacters could inject commands into a job that hascontents: writeand Maven Central deploy credentials.Fix: pass the ref and the derived version through
env:in all three steps instead of template-interpolating them into the script body, and validate the extracted version against a strictMAJOR.MINOR.PATCHpattern before it's used anywhere — the job already gates onstartsWith(head.ref, 'release-prep/calm-models-v'), so this catches any unexpected suffix.Type of Change
Affected Components
Commit Message Format ✅
Used
ci:(unscopedfix/feat/perftrigger releases percli/.releaserc.json's fallback rule;ciis release-neutral).Testing
This workflow only runs on a merged
release-prep/calm-models-v*PR againstmain, so it can't be exercised in CI here. Verified: YAML parses correctly, and the shell logic (prefix-strip, semver validation,env:substitution) was traced by hand against the existing step outputs and Copilot CLI reviewed the diff with no findings.Checklist