in pkg/vul/convert/grype/grype.go [28:62]
func Convert(s *utils.Source) (types.NoteOccurrencesMap, error) {
if s == nil || s.Data == nil {
return nil, errors.New("valid source required")
}
if !s.Data.Search("matches").Exists() {
return nil, errors.New("unable to find vulnerabilities in source data")
}
list := make(types.NoteOccurrencesMap, 0)
for _, v := range s.Data.Search("matches").Children() {
// create note
n := convertNote(s, v)
// don't add notes with no CVSS score
if n == nil || n.GetVulnerability().CvssScore == 0 {
continue
}
noteID := utils.GetPrefixNoteName(n.GetShortDescription())
// If cve is not found, add to map
if _, ok := list[noteID]; !ok {
list[noteID] = types.NoteOccurrences{Note: n}
}
nocc := list[noteID]
occ := convertOccurrence(s, v, noteID)
if occ != nil {
nocc.Occurrences = append(nocc.Occurrences, occ)
}
list[noteID] = nocc
}
return list, nil
}