@@ -229,7 +229,7 @@ func CVEToPackageInfo(cve models.NVDCVE, repos []string, cache *git.RepoTagsCach
229229}
230230
231231// FindRepos attempts to find the source code repositories for a given CVE.
232- func FindRepos (cve models.NVDCVE , vpRepoCache * cves.VPRepoCache , repoTagsCache * git.RepoTagsCache , metrics * models.ConversionMetrics ) []string {
232+ func FindRepos (cve models.NVDCVE , vpRepoCache * cves.VPRepoCache , repoTagsCache * git.RepoTagsCache , metrics * models.ConversionMetrics , httpClient * http. Client ) []string {
233233 // Find repos
234234 refs := cve .References
235235 CPEs := cves .CPEs (cve )
@@ -244,47 +244,34 @@ func FindRepos(cve models.NVDCVE, vpRepoCache *cves.VPRepoCache, repoTagsCache *
244244 return nil
245245 }
246246
247- // Edge case: No CPEs, but perhaps usable references.
248247 if len (refs ) > 0 && len (CPEs ) == 0 {
249- repos := cves .ReposFromReferences (nil , nil , refs , cves .RefTagDenyList , repoTagsCache , metrics )
248+ repos := cves .ReposFromReferences (nil , nil , refs , cves .RefTagDenyList , repoTagsCache , metrics , httpClient )
250249 if len (repos ) == 0 {
251250 metrics .AddNote ("Failed to derive any repos and there were no CPEs" )
252251 return nil
253252 }
254253 metrics .AddNote ("Derived repos for CVE with no CPEs: %v" , repos )
255254 reposForCVE = repos
256255 }
257- appCPECount := 0
256+
258257 vendorProductCombinations := make (map [cves.VendorProduct ]bool )
259258 for _ , CPEstr := range CPEs {
260259 CPE , err := cves .ParseCPE (CPEstr )
261260 if err != nil {
262261 metrics .AddNote ("Failed to parse CPE: %v" , CPEstr )
263262 continue
264263 }
265- if CPE .Part != "a" {
266- continue
267- }
268- appCPECount += 1
269264 vendorProductCombinations [cves.VendorProduct {Vendor : CPE .Vendor , Product : CPE .Product }] = true
270265 }
271266
272- if len (CPEs ) > 0 && appCPECount == 0 {
273- // This CVE is not for software (based on there being CPEs but not any application ones), skip.
274- metrics .Outcome = models .NoSoftware
275- return nil
276- }
277-
278267 // If there wasn't a repo from the CPE Dictionary, try and derive one from the CVE references.
279268 for vendorProductKey := range vendorProductCombinations {
280- // Does it have any application CPEs? Look for pre-computed repos based on VendorProduct.
281269 if repos , ok := vpRepoCache .Get (vendorProductKey ); ok {
282270 metrics .AddNote ("Pre-references, derived repos using cache: %v" , repos )
283271 if len (reposForCVE ) == 0 {
284272 reposForCVE = repos
285273 continue
286274 }
287- // Don't append duplicates.
288275 for _ , repo := range repos {
289276 if ! slices .Contains (reposForCVE , repo ) {
290277 reposForCVE = append (reposForCVE , repo )
@@ -295,7 +282,7 @@ func FindRepos(cve models.NVDCVE, vpRepoCache *cves.VPRepoCache, repoTagsCache *
295282 if slices .Contains (cves .VendorProductDenyList , vendorProductKey ) {
296283 continue
297284 }
298- repos := cves .ReposFromReferences (vpRepoCache , & vendorProductKey , refs , cves .RefTagDenyList , repoTagsCache , metrics )
285+ repos := cves .ReposFromReferences (vpRepoCache , & vendorProductKey , refs , cves .RefTagDenyList , repoTagsCache , metrics , httpClient )
299286 if len (repos ) == 0 {
300287 metrics .AddNote ("Failed to derive any repos for %s/%s" , vendorProductKey .Vendor , vendorProductKey .Product )
301288 continue
@@ -305,22 +292,6 @@ func FindRepos(cve models.NVDCVE, vpRepoCache *cves.VPRepoCache, repoTagsCache *
305292 }
306293 }
307294
308- logger .Info ("Finished processing " + string (CVEID ),
309- slog .String ("cve" , string (CVEID )),
310- slog .Int ("cpes" , len (CPEs )),
311- slog .Int ("app_cpes" , appCPECount ),
312- slog .Int ("derived_repos" , len (reposForCVE )))
313-
314- // If we've made it to here, we may have a CVE:
315- // * that has Application-related CPEs (so applies to software)
316- // * has a reference that is a known repository URL
317- // OR
318- // * a derived repository for the software package
319- //
320- // We do not yet have:
321- // * any knowledge of the language used
322- // * definitive version information
323-
324295 if len (reposForCVE ) == 0 {
325296 // We have nothing useful to work with, so we'll assume it's out of scope
326297 metrics .AddNote ("Passing due to lack of viable repository" )
0 commit comments