in providers/snyk/schema/convert.go [114:154]
func (advisory *Advisory) newConfigurations() *nvd.NVDCVEFeedJSON10DefConfigurations {
nodes := []*nvd.NVDCVEFeedJSON10DefNode{
&nvd.NVDCVEFeedJSON10DefNode{Operator: "OR"},
}
var err error
var product string
if product, err = wfn.WFNize(advisory.Package); err != nil {
flog.Errorf("can't wfnize %q\n", advisory.Package)
product = advisory.Package
}
cpe := wfn.Attributes{Part: "a", Product: product}
cpe22URI := cpe.BindToURI()
cpe23URI := cpe.BindToFmtString()
for _, versions := range advisory.VulnerableVersions {
vRanges, err := parseVersionRange(versions)
if err != nil {
flog.Errorf("could not generate configuration for item %s, vulnerable ver %q: %v", advisory.SnykID, versions, err)
continue
}
for _, vRange := range vRanges {
node := &nvd.NVDCVEFeedJSON10DefCPEMatch{
CPEName: []*nvd.NVDCVEFeedJSON10DefCPEName{
&nvd.NVDCVEFeedJSON10DefCPEName{
Cpe22Uri: cpe22URI,
Cpe23Uri: cpe23URI,
},
},
Cpe23Uri: cpe23URI,
VersionStartIncluding: vRange.minVerIncl,
VersionStartExcluding: vRange.minVerExcl,
VersionEndIncluding: vRange.maxVerIncl,
VersionEndExcluding: vRange.maxVerExcl,
Vulnerable: true,
}
nodes[0].CPEMatch = append(nodes[0].CPEMatch, node)
}
}
return &nvd.NVDCVEFeedJSON10DefConfigurations{
Nodes: nodes,
}
}