@@ -37,6 +37,7 @@ import (
37
37
"golang.org/x/vulndb/internal/cvelistrepo"
38
38
"golang.org/x/vulndb/internal/database"
39
39
"golang.org/x/vulndb/internal/derrors"
40
+ "golang.org/x/vulndb/internal/genericosv"
40
41
"golang.org/x/vulndb/internal/ghsa"
41
42
"golang.org/x/vulndb/internal/gitrepo"
42
43
"golang.org/x/vulndb/internal/issues"
52
53
githubToken = flag .String ("ghtoken" , "" , "GitHub access token (default: value of VULN_GITHUB_ACCESS_TOKEN)" )
53
54
skipSymbols = flag .Bool ("skip-symbols" , false , "for lint and fix, don't load package for symbols checks" )
54
55
skipAlias = flag .Bool ("skip-alias" , false , "for fix, skip adding new GHSAs and CVEs" )
56
+ ghsaOSV = flag .Bool ("ghsa-osv" , false , "for create, fetch GHSAs in OSV format (experimental)" )
55
57
updateIssue = flag .Bool ("up" , false , "for commit, create a CL that updates (doesn't fix) the tracking bug" )
56
58
closedOk = flag .Bool ("closed-ok" , false , "for create & create-excluded, allow closed issues to be created" )
57
59
cpuprofile = flag .String ("cpuprofile" , "" , "write cpuprofile to file" )
@@ -478,11 +480,19 @@ func newReport(ctx context.Context, cfg *createCfg, parsed *parsedIssue) (*repor
478
480
var r * report.Report
479
481
switch {
480
482
case len (parsed .ghsas ) > 0 :
481
- ghsa , err := cfg .ghsaClient .FetchGHSA (ctx , parsed .ghsas [0 ])
482
- if err != nil {
483
- return nil , err
483
+ if * ghsaOSV {
484
+ ghsa , err := genericosv .Fetch (parsed .ghsas [0 ])
485
+ if err != nil {
486
+ return nil , err
487
+ }
488
+ r = ghsa .ToReport (parsed .id )
489
+ } else {
490
+ ghsa , err := cfg .ghsaClient .FetchGHSA (ctx , parsed .ghsas [0 ])
491
+ if err != nil {
492
+ return nil , err
493
+ }
494
+ r = report .GHSAToReport (ghsa , parsed .modulePath )
484
495
}
485
- r = report .GHSAToReport (ghsa , parsed .modulePath )
486
496
case len (parsed .cves ) > 0 :
487
497
cve , err := cvelistrepo .FetchCVE (ctx , loadCVERepo (ctx ), parsed .cves [0 ])
488
498
if err != nil {
0 commit comments