chore(ci): validate bumper version input before downstream use#60
Conversation
`NEW` is sourced from `github.event.client_payload.version` /
`inputs.version` and flows into git refs (`branch=bump/givenergy-modbus-${NEW}`,
`git checkout -B`, `git push -f origin`), commit messages, PR titles and
bodies, `GITHUB_OUTPUT`, and — most subtly — a Python `re.sub` backref
template (`\g<1>{new}\g<2>`) in the bump step. The trust boundary is
the BUMP_PAT used to fire the dispatch; a compromised PAT shouldn't be
able to inject shell metacharacters, newlines (GITHUB_OUTPUT injection),
git ref operators (`:`, `^`, `..`), or `\g<...>` regex backrefs.
Validates against a SemVer-ish regex that accepts every modbus release
tag in history (`X.Y.Z`, `X.Y.ZrcN`, `X.Y.ZaN`) plus forward-looking
PEP 440 `.dev`/`.post` suffixes, rejecting everything else. A single
guard at the top of the step defends every downstream use.
Refs: https://github.blog/security/vulnerability-research/how-to-catch-github-actions-workflow-injections-before-attackers-do/
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Note Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds version format validation to the givenergy-modbus bump workflow. A bash regex check now enforces PEP 440-ish format (X.Y.Z with optional ChangesVersion Validation in Bump Workflow
🎯 4 (Complex) | ⏱️ ~45 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
I found one edge case worth tightening before this lands: the new validation still allows consecutive dots in the suffix because For example, these pass the regex locally: They then flow into That also means the current PR description overstates the coverage a little, since Everything else I checked in the workflow looked aligned with the intended hardening, and the GitHub checks are green. |
The original `[a-z0-9.]+` class accepted `2.0.0..`,
`2.0.0.post..1`, `2.0.0.`, and similar — values that pass the
regex but then break `git checkout -B "bump/givenergy-modbus-${NEW}"`
downstream with "not a valid branch name".
Tighten the suffix to `[-.]?[a-z0-9]+(\.[a-z0-9]+)*` so each
dot-separated segment is required to contain at least one
alphanumeric character. All historical and forward-looking PEP 440
tags still pass; the `..` / trailing-`.` family no longer does.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Fixed in 43ea36f — tightened the suffix to Also fleshed out the inline comment to call out the empty-segment carve-out explicitly so future-us doesn't loosen it again without thinking. |
Squash-merges the release/1.1.0 branch into main. Changes since v1.0.2: - feat: persist PlantCapabilities across restarts (#48) - feat: expose_recommended_entities service + voice/LLM docs (#65) - docs: GivTCP → givenergy_local migration guide and script (#67) - docs: passive mode and parallel-running notes - build: bump requires-python floor to >=3.14.2 (#61) - chore: retire v1.0 branch, bump givenergy-modbus to >=2.0.4,<2.1 (#59) - chore: auto-bumper version-format validation (#60)
What
Adds a single regex validation guard near the top of
bump-givenergy-modbus.yml's "Determine target version and base branch" step. Rejects anyNEWthat doesn't match^[0-9]+\.[0-9]+\.[0-9]+(-?[a-z0-9.]+)?$, with::error::+exit 1.Why
NEWis sourced fromgithub.event.client_payload.version/inputs.versionand flows into several shell-interpolated contexts downstream:branch="bump/givenergy-modbus-${NEW}"+git checkout -B "$branch"+git push -f origin "$branch":,^,..)echo "new=$NEW" >> "$GITHUB_OUTPUT"GITHUB_OUTPUTinjection via newlinepattern.subn(rf'\g<1>{new}\g<2>', text)in the bump step\g<...>git commit -m "...${NEW}",gh pr create --title "..." --body "...@${NEW}](.../v${NEW})..."The trust boundary is the
BUMP_PATused to fire therepository_dispatch— small but non-zero attack surface (PAT compromise, supply-chain). A single validation guard at the top defends every downstream use rather than scattering escapes everywhere.Acceptance behaviour (verified locally)
Accepts every historical modbus release tag —
2.0.4,2.0.0rc1,2.0.0a6,2.0.0a3— plus forward-looking PEP 440 forms (.dev0,.post1,-alpha.1).Rejects empty string; every shell metacharacter (
;,\$(), backticks,|,&); path traversal (../etc); newline injection; regex backref injection (\g<0>); quote injection; git ref operators (:,^,..); branch-style strings (main,v2.0.0).What's not in scope
bump-python-floor-for-modbus-v2,claude/beautiful-chaplygin-c3f28d) — separate cleanup.dashboard/generate.pyruff format drift on main — unrelated.Refs: GitHub Actions workflow injection vulnerabilities
🤖 Generated with Claude Code
Summary by CodeRabbit