chore: add support for Git tag aliases in vuln GHA check #1065
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.
Summary
This PR adds a utility function to identify the highest semantic version tag from a set of Git tags, specifically for cases where multiple tags point to the same commit SHA in a third-party GitHub Action. This is necessary because a single release may have multiple tag aliases, such as
v4
andv4.2.1
and we want to consistently resolve to the most specific and recent tag.Description of changes
The new
find_highest_git_tag
function uses Python’spackaging.version
module to determine the highest (most recent) version according to semantic versioning rules. It handles common edge cases such as empty tag sets and invalid version strings, raising a customGitTagError
when appropriate.This functionality is especially useful for automation workflows that need to programmatically resolve the latest stable tag associated with a GitHub Action or similar dependency, ensuring accurate and consistent version comparisons.
Related issues
This change addresses an issue where the
v4
tag (an alias forv4.2.1
) was incorrectly selected during the GitHub Action vulnerability check. Sincev4
is numerically lower than the patched versionv4.1.3
, the check failed even though the underlying code was up to date. By resolving to the highest version (v4.2.1
), this function ensures the highest tag is used if there are aliases.