fix(wizard): pin emitted action ref to the latest GitHub release SHA#280
Merged
Conversation
The emitted workflow's `uses:` ref was built from the running build's
__version__. Dev/Docker builds report a PEP 440 local version like
26.7.0+ad3dc1d, so the tag->SHA lookup 404'd and the fallback emitted
the invalid ref sbomify/sbomify-action@v26.7.0+ad3dc1d — flagged by
SonarCloud ("Use full commit SHA hash for this dependency").
Resolve the pin from GitHub's latest published release instead of
assuming the built version exists as a tag, and only default to the
build's version (with the +local segment stripped) when GitHub is
unreachable.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the wizard’s emitted uses: reference for sbomify/sbomify-action so it is reliably SHA-pinned to a valid GitHub release commit (even when the running build version is a dev/local PEP 440 version that does not correspond to any GitHub tag).
Changes:
- Resolve the action ref by querying GitHub’s latest published release tag and pinning the emitted workflow to that release’s full commit SHA.
- Strip PEP 440 local-version metadata (
+...) from the build version so the offline fallback never emits an invalid tag ref. - Add tests covering latest-release lookup behavior and the new resolution/fallback paths; update the global offline test fixture to stub both network boundaries.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
sbomify_action/cli/wizard/ci_emitter.py |
Adds latest-release tag resolution + tag sanitization; updates action-ref resolution to prefer latest release and strips local version metadata for offline fallback. |
tests/test_wizard_emitter.py |
Adds unit tests for local-version stripping, latest-release tag resolution edge cases, and latest-release SHA pinning behavior. |
tests/conftest.py |
Extends the autouse offline fixture to stub both the latest-release and tag→SHA GitHub lookups to prevent network calls. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Problem
The wizard-emitted workflow could contain an invalid, unpinned action reference:
(seen in Screenly/Anthias#3186, flagged by SonarCloud: "Use full commit SHA hash for this dependency").
Two failures compounded:
uses:ref was derived from the running build's__version__. Dev/Docker builds report a PEP 440 local version like26.7.0+ad3dc1d, so the GitHub tag→SHA lookup 404'd and no SHA pin was emitted.v26.7.0tag on GitHub at all; the newest release isv26.2.0).Fix
resolve_action_ref()now asks GitHub for the latest published release (/releases/latest) and pins to that release's full commit SHA:sbomify/sbomify-action@<full-sha> # <release-tag>. It never assumes the built version exists as a tag._action_version()now strips the+localbuild-metadata segment so the fallback is@v26.7.0, never@v26.7.0+ad3dc1d.Testing
sbomify/sbomify-action@ac8b0d423c90447f3011ef8ab5f9ff2e854c6931 # v26.2.0.Note for maintainers
GitHub releases currently stop at
v26.2.0while PyPI is at26.7.0— until a release is published for the current version, the wizard will (correctly) pin tov26.2.0's commit.🤖 Generated with Claude Code