Skip to content

Commit

Permalink
fix: filter duplicate vex ingest entries
Browse files Browse the repository at this point in the history
  • Loading branch information
dejanb authored and mrizzi committed Apr 17, 2024
1 parent aa6bfb6 commit aa948d3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/ingestor/parser/csaf/parser_csaf_red_hat.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ func (c *csafParserRedHat) findPkgSpec(ctx context.Context, product_id string) (
// It returns a pointer to an assembler.IngestPredicates struct containing the
// generated VEX and CertifyVuln predicates.
func (c *csafParserRedHat) GetPredicates(ctx context.Context) *assembler.IngestPredicates {
logger := logging.FromContext(ctx)
rv := &assembler.IngestPredicates{}
var vis []assembler.VexIngest
var vis = make(map[string]assembler.VexIngest)

for _, v := range c.csaf.Vulnerabilities {
vuln, err := helpers.CreateVulnInput(v.CVE)
Expand All @@ -168,10 +169,15 @@ func (c *csafParserRedHat) GetPredicates(ctx context.Context) *assembler.IngestP
if vi == nil {
continue
}
vis = append(vis, *vi)
var purl = helpers.PkgInputSpecToPurl(vi.Pkg)
if _, ok := vis[purl]; ok {
logger.Debugf("Duplicate ingest entry %v\n", vis)
} else {
vis[purl] = *vi
}
}
}
}
rv.Vex = vis
rv.Vex = maps.Values(vis)
return rv
}

0 comments on commit aa948d3

Please sign in to comment.