@@ -365,6 +365,24 @@ func createGHSAIssues(ctx context.Context, st store.Store, client *issues.Client
365
365
if limit > 0 && numCreated >= limit {
366
366
break
367
367
}
368
+ // TODO(https://github.com/golang/go/issues/54049): Move this
369
+ // check to the triage step of the worker.
370
+ if isDuplicate (ctx , gr .GHSA , allReports ) {
371
+ // Update the GHSARecord in the DB to reflect that the GHSA
372
+ // already has an advisory.
373
+ if err = st .RunTransaction (ctx , func (ctx context.Context , tx store.Transaction ) error {
374
+ r , err := tx .GetGHSARecord (gr .GetID ())
375
+ if err != nil {
376
+ return err
377
+ }
378
+ r .TriageState = store .TriageStateHasVuln
379
+ return tx .SetGHSARecord (r )
380
+ }); err != nil {
381
+ return err
382
+ }
383
+ // Do not create an issue.
384
+ continue
385
+ }
368
386
ref , err := createIssue (ctx , gr , client , allReports )
369
387
if err != nil {
370
388
return err
@@ -389,6 +407,16 @@ func createGHSAIssues(ctx context.Context, st store.Store, client *issues.Client
389
407
return nil
390
408
}
391
409
410
+ func isDuplicate (ctx context.Context , sa * ghsa.SecurityAdvisory , allReports map [string ]* report.Report ) bool {
411
+ r := report .GHSAToReport (sa , "" )
412
+ for _ , aliases := range report .XRef (r , allReports ) {
413
+ if slices .Contains (aliases , sa .ID ) {
414
+ return true
415
+ }
416
+ }
417
+ return false
418
+ }
419
+
392
420
func CreateGHSABody (sa * ghsa.SecurityAdvisory , allReports map [string ]* report.Report ) (body string , err error ) {
393
421
r := report .GHSAToReport (sa , "" )
394
422
rs , err := r .ToString ()
0 commit comments