Skip to content

Commit ac87c5f

Browse files
committed
cmd/vulnreport: add flag to populate symbols in vulnreport create
Add flag "symbols" which causes vulnreport create to attempt to automatically add symbols to a newly created report. Change-Id: I0ba9e4fc1365fd05f06915e82d6b33ab9528fbc2 Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/560779 Reviewed-by: Maceo Thompson <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 60408cb commit ac87c5f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

cmd/vulnreport/create.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ import (
2323
"golang.org/x/vulndb/internal/osv"
2424
"golang.org/x/vulndb/internal/proxy"
2525
"golang.org/x/vulndb/internal/report"
26+
"golang.org/x/vulndb/internal/symbols"
2627
)
2728

2829
var (
29-
preferCVE = flag.Bool("cve", false, "for create, prefer CVEs over GHSAs as canonical source")
30-
closedOk = flag.Bool("closed-ok", false, "for create & create-excluded, allow closed issues to be created")
31-
graphQL = flag.Bool("graphql", false, "for create, fetch GHSAs from the Github GraphQL API instead of the OSV database")
32-
issueRepo = flag.String("issue-repo", "github.com/golang/vulndb", "for create, repo locate Github issues")
33-
useAI = flag.Bool("ai", false, "for create, use AI to write draft summary and description when creating report")
30+
preferCVE = flag.Bool("cve", false, "for create, prefer CVEs over GHSAs as canonical source")
31+
closedOk = flag.Bool("closed-ok", false, "for create & create-excluded, allow closed issues to be created")
32+
graphQL = flag.Bool("graphql", false, "for create, fetch GHSAs from the Github GraphQL API instead of the OSV database")
33+
issueRepo = flag.String("issue-repo", "github.com/golang/vulndb", "for create, repo locate Github issues")
34+
useAI = flag.Bool("ai", false, "for create, use AI to write draft summary and description when creating report")
35+
populateSymbols = flag.Bool("symbols", false, "for create, attempt to auto-populate symbols")
3436
)
3537

3638
type create struct {
@@ -227,6 +229,12 @@ func reportFromAliases(ctx context.Context, id, modulePath string, aliases []str
227229
}
228230
}
229231

232+
if *populateSymbols {
233+
if err := symbols.Populate(r, log.Err); err != nil {
234+
log.Warnf("could not auto-populate symbols: %s", err)
235+
}
236+
}
237+
230238
return r, nil
231239
}
232240

0 commit comments

Comments
 (0)