anchore / grype

A vulnerability scanner for container images and filesystems
Apache License 2.0
8.19k stars 529 forks source link

Refactor matching process to be chained processors #1869

Open wagoodman opened 1 month ago

wagoodman commented 1 month ago

Today the matching process is governed by the VulnerabilityMatcher object, which gives us a single place to control aspects of the matching process. The main FindMatches() function has been decomposed into ever-smaller functions that deal with smaller concerns of the matching process, which is ultimately good, however, each decomposition is bespoke in terms of what data it has access to and what the return signature is. This means that changes to the matching process may result in changing these function signatures, which isn't ideal.

Additionally, there is a common theme of the following return signature:

func somename(...) (remainingMatches *match.Matches, ignoredMatches []match.IgnoredMatch, err error) {}

...or similar variants. This return signature is at risk of growing for every new data element we want to track.

I have two changes I'd like to propose: