Skip to content
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

fix: only warn missing CPEs if CPEs wanted #1710

Merged
merged 1 commit into from
Feb 12, 2024
Merged

Conversation

willmurphyscode
Copy link
Contributor

Previously, a warning would be logged about missing CPEs even when processing packages for which CPEs would never be generated. Instead, return a specific error when attempting to match by CPEs on a package with no CPEs.

This change improves the user experience in 2 ways:

  1. The user will only see a warning about missing CPEs if Grype actually tries to search by CPE on a package that has no CPEs, which means the warning is only ever shown if it's affecting matchign
  2. The warning contains the package name, so the user has a better ability to try to investigate.

But with the following tradeoff:

  1. If the user has a lot of packages missing CPEs for a matcher that has CPE matching turned on, they will see this log line a lot of times.

Fixes #1634

Example runs

Before, even with CPE matching disabled

❯ grype cgr.dev/chainguard/go                                                             
...
[0009]  WARN some package(s) are missing CPEs. This may result in missing vulnerabilities. You may autogenerate these using: --add-cpes-if-none
NAME                INSTALLED  FIXED-IN  TYPE  VULNERABILITY        SEVERITY 
...

After this change, with CPE matching disabled, no warning is printed.

After this change, if when Grype attempts to match on a package by CPEs that has no CPEs, the flag is still suggested:

❯ GRYPE_MATCH_GOLANG_USING_CPES=true go run cmd/grype/main.go willtmp/chainguard.syft.json
...
[0000]  WARN attempted CPE search on cmd/addr2line, which has no CPEs. Consider re-running with --add-cpes-if-none
NAME                INSTALLED  FIXED-IN  TYPE  VULNERABILITY        SEVERITY 
...

Previously, a warning would be logged about missing CPEs even when
processing packages for which CPEs would never be generated. Instead,
return a specific error when attempting to match by CPEs on a package
with no CPEs.

Signed-off-by: Will Murphy <will.murphy@anchore.com>
This was referenced Feb 11, 2024
@willmurphyscode willmurphyscode merged commit 6b38079 into main Feb 12, 2024
10 checks passed
@willmurphyscode willmurphyscode deleted the fix/grype1634 branch February 12, 2024 14:26
spiffcs added a commit to jneate/grype that referenced this pull request Feb 13, 2024
* main: (224 commits)
  fix: only warn missing CPEs if CPEs wanted (anchore#1710)
  fix: ensure version output to stdout (anchore#1709)
  chore(deps): update bootstrap tools to latest versions (anchore#1706)
  chore(deps): update Syft to v0.104.0 (anchore#1704)
  Bump Syft in Grype to pull in unmarshaling fix (anchore#1703)
  chore(deps): bump github.com/docker/docker (anchore#1702)
  chore(deps): bump gorm.io/gorm from 1.25.6 to 1.25.7 (anchore#1700)
  chore(deps): update bootstrap tools to latest versions (anchore#1698)
  chore(deps): bump actions/upload-artifact from 4.3.0 to 4.3.1 (anchore#1699)
  chore(deps): bump github.com/gkampitakis/go-snaps from 0.5.0 to 0.5.2 (anchore#1697)
  chore(deps): bump peter-evans/create-pull-request from 5.0.2 to 6.0.0 (anchore#1687)
  chore(deps): bump anchore/sbom-action from 0.15.6 to 0.15.8 (anchore#1690)
  chore(deps): bump sigstore/cosign-installer from 3.3.0 to 3.4.0 (anchore#1691)
  chore(deps): bump github.com/docker/docker (anchore#1692)
  chore(deps): bump github.com/opencontainers/runc from 1.1.5 to 1.1.12 (anchore#1689)
  Upgrade syft to v0.103.1 (anchore#1688)
  chore(deps): bump github.com/google/go-containerregistry (anchore#1685)
  chore(deps): bump anchore/sbom-action from 0.15.5 to 0.15.6 (anchore#1684)
  ensure releases only use released versions of syft (anchore#1680)
  chore(deps): bump gorm.io/gorm from 1.25.5 to 1.25.6 (anchore#1683)
  ...

Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
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.

Seeing "WARN some package(s) are missing CPEs" but it's not clear why
2 participants