-
Notifications
You must be signed in to change notification settings - Fork 1
ci: guard releases against version/changelog drift #405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,8 +16,38 @@ env: | |||||||||||||||||||||
| REGISTRY_IMAGE: cipherstash/proxy | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||
| verify-release: | ||||||||||||||||||||||
| name: Verify release metadata | ||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||
| timeout-minutes: 5 | ||||||||||||||||||||||
| steps: | ||||||||||||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Only enforced for numbered releases. On push/PR/workflow_dispatch this | ||||||||||||||||||||||
| # job is a no-op so it can still gate the build matrix below. | ||||||||||||||||||||||
| - name: Check version + changelog match the release tag | ||||||||||||||||||||||
| if: github.event_name == 'release' | ||||||||||||||||||||||
| run: | | ||||||||||||||||||||||
| tag='${{ github.event.release.tag_name }}' | ||||||||||||||||||||||
| version="${tag#v}" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
Comment on lines
+31
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Validate tag format before use to prevent potential code injection. Directly interpolating 🛡️ Proposed fix to validate tag format run: |
tag='${{ github.event.release.tag_name }}'
+ # Validate tag format before using it
+ if ! [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
+ echo "::error::Release tag must match vX.Y.Z format (with optional pre-release suffix), got: $tag"
+ exit 1
+ fi
version="${tag#v}"📝 Committable suggestion
Suggested change
🧰 Tools🪛 zizmor (1.25.2)[error] 31-31: code injection via template expansion (template-injection): may expand into attacker-controllable code (template-injection) 🤖 Prompt for AI Agents |
||||||||||||||||||||||
| cargo_version="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)" | ||||||||||||||||||||||
| if [ "$cargo_version" != "$version" ]; then | ||||||||||||||||||||||
| echo "::error::Cargo.toml workspace version ($cargo_version) does not match release tag $tag. Bump the version in a prepare-release PR before tagging." | ||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Fixed-string match so dots in the version aren't treated as regex wildcards. | ||||||||||||||||||||||
| if ! grep -qF "## [$version]" CHANGELOG.md; then | ||||||||||||||||||||||
| echo "::error::CHANGELOG.md has no '## [$version]' section. Add release notes in a prepare-release PR before tagging." | ||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||
| fi | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| echo "OK: tag $tag matches Cargo.toml version and CHANGELOG has a [$version] section." | ||||||||||||||||||||||
|
Comment on lines
+19
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add explicit permissions block to follow least-privilege principle. The 🔒 Proposed fix to restrict permissions verify-release:
name: Verify release metadata
runs-on: ubuntu-latest
timeout-minutes: 5
+ permissions:
+ contents: read
steps:🧰 Tools🪛 zizmor (1.25.2)[warning] 24-27: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false (artipacked) [warning] 19-46: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block (excessive-permissions) [error] 31-31: code injection via template expansion (template-injection): may expand into attacker-controllable code (template-injection) [error] 24-24: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy) (unpinned-uses) 🤖 Prompt for AI Agents |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| build: | ||||||||||||||||||||||
| name: Build binaries + Docker images | ||||||||||||||||||||||
| needs: verify-release | ||||||||||||||||||||||
| strategy: | ||||||||||||||||||||||
| fail-fast: false | ||||||||||||||||||||||
| matrix: | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pin action to commit SHA and disable credential persistence.
Two security concerns:
@v4is not pinned to an immutable commit SHA, violating the security policy flagged by static analysis. Mutable tags can be updated maliciously.persist-credentials: falsemeans the GitHub token persists in.git/configand could leak through uploaded artifacts.🔒 Proposed fix to pin action and disable credential persistence
📝 Committable suggestion
🧰 Tools
🪛 zizmor (1.25.2)
[warning] 24-27: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[error] 24-24: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
🤖 Prompt for AI Agents