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

Feat/multiple platform cpes #203

Merged
merged 15 commits into from
Dec 5, 2023
Merged

Conversation

willmurphyscode
Copy link
Contributor

@willmurphyscode willmurphyscode commented Nov 23, 2023

PR with the goal of representing NVD CVEs that affect multiple specific platforms in grypeDB schema v5, which only supports one platform CPE constraint per row.

The transform to be accomplished is explained at anchore/grype#1042 (comment) in detail, but basically, emit a row for each affected platform, rather than emitting a single row with no platform constraint.

One thing we need to discover is whether there are lots of NVD issues that have multiple application nodes ORed with multiple platform nodes. If so, this needs to be expanded to be a cross join. - DONE, this does a cross join now.

TODO

@willmurphyscode willmurphyscode marked this pull request as ready for review November 27, 2023 13:28
@willmurphyscode
Copy link
Contributor Author

willmurphyscode commented Dec 1, 2023

This change will roughly triple the number of unique platform CPEs present in Grype DB:

❯ sqlite3 willtmp/newdb/5/vulnerability.db \
'select distinct package_qualifiers from vulnerability where namespace like "nvd:cpe" order by id limit 10000000000;' |\
 rg platform-cpe | jq -r '.[0].cpe' | sort | uniq | wc -l
    2380

❯ sqlite3 ~/Library/Caches/grype/db/5/vulnerability.db \
'select distinct package_qualifiers from vulnerability where namespace like "nvd:cpe" order by id limit 10000000000;' |\
 rg platform-cpe | jq -r '.[0].cpe' | sort | uniq | wc -l
     819

Before merging, I'd like to take a look through the new platform CPEs and see what grype will do with them.

Edit: I think this discrepancy is because of things that shouldn't be ending up as platform CPEs. Converting back to draft PR while I investigate.

Edit on the edit:

It turns out that we use vulnerable == false to determine whether a CPE Match is a "running on/with" config, not the type o.

Signed-off-by: Will Murphy <[email protected]>
@willmurphyscode willmurphyscode marked this pull request as draft December 1, 2023 20:16
For example, Redis or OpenShift might be coded as a type "a" CPE (for
"application"), but might be a platform (displayed in the "running on or
with" section of the NVD UI). For these, consider them platforms and
emit a platform CPE.

Signed-off-by: Will Murphy <[email protected]>
@@ -20,18 +20,18 @@ type pkgCandidate struct {
Product string
Vendor string
TargetSoftware string
PlatformCPE *string
PlatformCPE string
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This struct is used as a map key in uniquePkgTracker. Have a pointer in a struct that's used as a hash key results in key collision being assessed based on pointer equality, not string equality. I think string equality is the right semantics. (Put another way: we wouldn't say one pkg candidate was different from another if the only difference was the memory location where the platform CPE was stored.)

I could be talked into pulling this out into its own PR.

Signed-off-by: Will Murphy <[email protected]>
@willmurphyscode willmurphyscode marked this pull request as ready for review December 5, 2023 16:39
@willmurphyscode willmurphyscode enabled auto-merge (squash) December 5, 2023 16:44
@willmurphyscode willmurphyscode merged commit af631d9 into main Dec 5, 2023
13 checks passed
@willmurphyscode willmurphyscode deleted the feat/multiple-platform-cpes branch December 5, 2023 17:39
willmurphyscode pushed a commit that referenced this pull request Mar 27, 2024
Bumps [orjson](https://github.com/ijl/orjson) from 3.8.13 to 3.9.1.
- [Release notes](https://github.com/ijl/orjson/releases)
- [Changelog](https://github.com/ijl/orjson/blob/master/CHANGELOG.md)
- [Commits](ijl/orjson@3.8.13...3.9.1)

---
updated-dependencies:
- dependency-name: orjson
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.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.

2 participants