Skip to content

fix: normalize apk package fallback versions for CPE matching - #3687

Open
sueun-dev wants to merge 1 commit into
anchore:mainfrom
sueun-dev:fix-apk-cpe-fallback-version
Open

sueun-dev wants to merge 1 commit into
anchore:mainfrom
sueun-dev:fix-apk-cpe-fallback-version

Conversation

@sueun-dev

Copy link
Copy Markdown

When a package CPE has an unspecified version (*, -, or unknown), FindResultsByCPEs falls back to p.Version. For APK packages, that fallback used the raw package version because cpeversion.Alpine(...) had already run.

This moves APK CPE-version normalization after the fallback and adds a regression for an unversioned OpenSSL CPE. The fixture also has a < 1.0.1f control record so the normalized 1.0.1f search does not over-match.

Checked:

  • go test ./grype/matcher/internal -run 'TestFindMatchesByPackageCPE/fallback_to_apk_package_version_normalizes_build_suffix' -count=1
  • go test -race ./grype/matcher/internal -run 'TestFindMatchesByPackageCPE/fallback_to_apk_package_version_normalizes_build_suffix' -count=5
  • go test ./grype/matcher/internal ./grype/matcher/internal/result ./grype/matcher/apk -count=1
  • go test ./grype/matcher/... -count=1
  • make static-analysis
  • git diff --check

Signed-off-by: sueun-dev <sueun.dev@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant