From 8fc7efd46437afac395cd5ed537e7aa8cef2eee1 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Fri, 28 Aug 2020 12:20:23 -0400 Subject: [PATCH] result: add a helper to get packages by ID Signed-off-by: Alfredo Deza --- grype/result/result.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/grype/result/result.go b/grype/result/result.go index ff49a305..c8d5ffaf 100644 --- a/grype/result/result.go +++ b/grype/result/result.go @@ -19,6 +19,15 @@ func NewResult() Result { } } +// GetByPkgID returns a slice of potential matches from an ID +func (r *Result) GetByPkgID(id pkg.ID) []match.Match { + matches, ok := r.byPackage[id] + if !ok { + return nil + } + return matches +} + func (r *Result) Merge(other Result) { // note: de-duplication of matches is an upstream concern (not here) for pkgID, matches := range other.byPackage {