Skip to content

Commit 883be2a

Browse files
committed
cmd/vulnreport: move find GHSA logic to newReport
This allows us to re-use the addGHSA function. Note this does slightly change the behavior of vulnreport create, as the added GHSAs are not taken into account when initially creating the report. This does not matter much with the current implementation, as we arbitrarily choose one alias to create the report based on. Change-Id: Ia99eac8aaec603f5fd44f7b9d017957f8147fe06 Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/467295 Reviewed-by: Tim King <[email protected]> Run-TryBot: Tatiana Bradley <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: David Chase <[email protected]>
1 parent a662819 commit 883be2a

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

cmd/vulnreport/main.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -293,18 +293,6 @@ func createReport(ctx context.Context, cfg *createCfg, iss *issues.Issue) (r *re
293293
if err != nil {
294294
return nil, err
295295
}
296-
if len(parsed.ghsas) == 0 && len(parsed.cves) > 0 {
297-
for _, cve := range parsed.cves {
298-
sas, err := cfg.ghsaClient.ListForCVE(ctx, cve)
299-
if err != nil {
300-
return nil, err
301-
}
302-
for _, sa := range sas {
303-
parsed.ghsas = append(parsed.ghsas, sa.ID)
304-
}
305-
}
306-
parsed.ghsas = dedupeAndSort(parsed.ghsas)
307-
}
308296

309297
r, err = newReport(ctx, cfg, parsed)
310298
if err != nil {
@@ -449,6 +437,8 @@ func newReport(ctx context.Context, cfg *createCfg, parsed *parsedIssue) (*repor
449437
r = &report.Report{}
450438
}
451439

440+
addGHSAs(ctx, r, cfg.ghsaClient)
441+
452442
// Fill an any CVEs and GHSAs we found that may have been missed
453443
// in report creation.
454444
r.CVEs = dedupeAndSort(append(r.CVEs, parsed.cves...))

0 commit comments

Comments
 (0)