-
Notifications
You must be signed in to change notification settings - Fork 753
Description
What would you like to be added?
Grype should be able to report "negative matches," that is, package/vulnerability pairs where grype found evidence that the package is not affected by the vulnerability.
Right now, grype output consists of positive matches, that is, package/vulnerability pairs where the package is believed to be affected by the vulnerability. However, when matching is performed, that is, when grype asks whether a given package is vulnerable to a given vulnerability, there are 3 possible outcomes, and grype currently loses the distinction between the second and third:
- The package is vulnerable -> this yields a match
- There is a search miss, for example, the grype database has no record for that package or its upstream -> this does not yield a match
- There is a search hit, but grype concludes the package is not vulnerable. For example grype's database has a version constraint that excludes the version of the package being considered -> proposed: this yields a "negative match"
In other words, this proposal should enable users to distinguish between two situations that are currently lumped together: a search miss, where grype didn't match because there wasn't data in the database indicating a match, and a negative match, where there is evidence in the database that the package is not vulnerable.
In this proposal, grype can optionally display negative matches.
Why is this needed?
Why would users of grype want to distinguish between these two cases? Here are a few that come to mind:
More confidence in the results
Grype being able to say, "yes, package Foo is affected by CVE-123, but you have version 1.2.4 which is patched," may give users more confidence that they are not affected by CVE-123 than simply the absence of CVE-123 in the output.
Ability to investigate true negatives
Right now, in the case of matches, grype can output match details, that is, information about what artifact was matched, how it was found, why it's believed to be vulnerable. In the case of a negative match, where for example grype matches the package, but then rejects the match based on a version constraint, all of this information is available, but it is dropped in the middle of functions, so that users and even library consumers of grype can't access it.
Additionally, grype explain could be enhanced to explain negative matches.
Users can report on patching improvements directly
When users undertake the effort to patch dependencies in their project and upgrade their base images, rather than simply seeing grype's output shrink, they could see the set of CVEs reported in negative matches grow.
Possibility of implementing namespace precedence
In many cases, a distro has more specific vulnerability information than, for example, GHSA or NVD. Being able to encode this precedence provides a good way to implement #1373, and there are likely other business logic enhancements that could be made from surfacing negative matches.
User experience
- Negative matches will be made available in the context where grype reports are executed, so that users can write custom templates that use negative matches
- Negative matches will be omitted from the JSON by default, but can be included based on a config. If that config is supplied, they will be in a separate top level key.
- Negative matches will be omitted from the table output by default, but can be included based on a config. If that config is supplied, they'll be included in a separate section.
Implementation
Mostly TBD. If NegativeMatch were implemented as its own struct, that would give us 3 types of match structs (the other two are Match and IgnoredMatch). It might be preferable to make the Match struct able to represent why something didn't match, or look for another solution that doesn't involve having 3 nearly identical structs that represent related concepts.
FAQ
What's the difference between a negative match and an ignored match?
An ignored match is a positive match that a user chose to suppress. A negative match is a package/vulnerability combination for which grype is stating the package is likely not affected by the vulnerability.
Why is it called a "negative match"? Can we call it something else?
It's called a negative match because it's the opposite of a match. A regular match (a "positive" match) asserts that a package is vulnerable to a vulnerability; a negative match asserts that it isn't. We also considered the term "AntiMatch" and "PartialMatch." We can certainly change the name if saying things like, "This false positive should really be a negative match" is too confusing, but it's the best name I have right now.
Additional context:
The idea is first proposed under the name "anti-match" (instead of "negative match") at #1373 (comment)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status