Skip to content

Commit

Permalink
internal/vulncheck: emit fetch db and vuln checking progress messages
Browse files Browse the repository at this point in the history
Fixes golang/go#66872

Change-Id: I32c92767a62b3425bff0f1496c76e47170d39885
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/580216
Run-TryBot: Zvonimir Pavlinovic <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Ian Cottrell <[email protected]>
  • Loading branch information
zpavlinovic committed Apr 18, 2024
1 parent f3bc44a commit 086b27b
Show file tree
Hide file tree
Showing 19 changed files with 151 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ $ govulncheck -format json -mode binary ${common_vuln_binary}
"message": "Scanning your binary for known vulnerabilities..."
}
}
{
"progress": {
"message": "Fetching vulnerabilities from the database..."
}
}
{
"progress": {
"message": "Checking the code against the vulnerabilities..."
}
}
{
"osv": {
"schema_version": "1.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ $ govulncheck -format json -mode binary ${common_vendored_binary}
"message": "Scanning your binary for known vulnerabilities..."
}
}
{
"progress": {
"message": "Fetching vulnerabilities from the database..."
}
}
{
"progress": {
"message": "Checking the code against the vulnerabilities..."
}
}
{
"osv": {
"schema_version": "1.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ $ govulncheck -format json -mode binary -scan module ${common_vuln_binary}
"message": "Scanning your binary for known vulnerabilities..."
}
}
{
"progress": {
"message": "Fetching vulnerabilities from the database..."
}
}
{
"progress": {
"message": "Checking the code against the vulnerabilities..."
}
}
{
"osv": {
"schema_version": "1.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ $ govulncheck -format json -mode binary -scan package ${common_vuln_binary}
"message": "Scanning your binary for known vulnerabilities..."
}
}
{
"progress": {
"message": "Fetching vulnerabilities from the database..."
}
}
{
"progress": {
"message": "Checking the code against the vulnerabilities..."
}
}
{
"osv": {
"schema_version": "1.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ $ govulncheck -C ${moddir}/vuln -format json ./...
"message": "Scanning your code and P packages across M dependent modules for known vulnerabilities..."
}
}
{
"progress": {
"message": "Fetching vulnerabilities from the database..."
}
}
{
"progress": {
"message": "Checking the code against the vulnerabilities..."
}
}
{
"osv": {
"schema_version": "1.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ Use '-show verbose' for more details.
$ govulncheck -C ${moddir}/vuln -show verbose ./... --> FAIL 3
Scanning your code and P packages across M dependent modules for known vulnerabilities...

Fetching vulnerabilities from the database...

Checking the code against the vulnerabilities...

=== Symbol Results ===

Vulnerability #1: GO-2021-0265
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ $ govulncheck -format json -C ${moddir}/multientry .
"message": "Scanning your code and P packages across M dependent modules for known vulnerabilities..."
}
}
{
"progress": {
"message": "Fetching vulnerabilities from the database..."
}
}
{
"progress": {
"message": "Checking the code against the vulnerabilities..."
}
}
{
"osv": {
"schema_version": "1.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Use '-show verbose' for more details.
$ govulncheck -show verbose -C ${moddir}/multientry -show=traces ./... --> FAIL 3
Scanning your code and P packages across M dependent modules for known vulnerabilities...

Fetching vulnerabilities from the database...

Checking the code against the vulnerabilities...

=== Symbol Results ===

Vulnerability #1: GO-2021-0113
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ $ govulncheck -C ${moddir}/replace -format json ./...
"message": "Scanning your code and P packages across M dependent modules for known vulnerabilities..."
}
}
{
"progress": {
"message": "Fetching vulnerabilities from the database..."
}
}
{
"progress": {
"message": "Checking the code against the vulnerabilities..."
}
}
{
"osv": {
"schema_version": "1.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ $ govulncheck -C ${moddir}/vendored -format json ./...
"message": "Scanning your code and P packages across M dependent modules for known vulnerabilities..."
}
}
{
"progress": {
"message": "Fetching vulnerabilities from the database..."
}
}
{
"progress": {
"message": "Checking the code against the vulnerabilities..."
}
}
{
"osv": {
"schema_version": "1.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
$ govulncheck -C ${moddir}/vendored -show verbose ./... --> FAIL 3
Scanning your code and P packages across M dependent modules for known vulnerabilities...

Fetching vulnerabilities from the database...

Checking the code against the vulnerabilities...

=== Symbol Results ===

Vulnerability #1: GO-2021-0265
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ $ govulncheck -format json -scan module -C ${moddir}/multientry
"message": "Scanning your code across 2 dependent modules for known vulnerabilities..."
}
}
{
"progress": {
"message": "Fetching vulnerabilities from the database..."
}
}
{
"progress": {
"message": "Checking the code against the vulnerabilities..."
}
}
{
"osv": {
"schema_version": "1.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Use '-scan symbol' for more fine grained vulnerability detection.
$ govulncheck -scan module -show verbose -C ${moddir}/multientry --> FAIL 3
Scanning your code across 2 dependent modules for known vulnerabilities...

Fetching vulnerabilities from the database...

Checking the code against the vulnerabilities...

=== Module Results ===

Vulnerability #1: GO-2021-0113
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ $ govulncheck -format json -scan package -C ${moddir}/multientry .
"message": "Scanning your code and P packages across M dependent modules for known vulnerabilities..."
}
}
{
"progress": {
"message": "Fetching vulnerabilities from the database..."
}
}
{
"progress": {
"message": "Checking the code against the vulnerabilities..."
}
}
{
"osv": {
"schema_version": "1.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ verbose' for more details.
$ govulncheck -show verbose -scan package -C ${moddir}/multientry . --> FAIL 3
Scanning your code and P packages across M dependent modules for known vulnerabilities...

Fetching vulnerabilities from the database...

Checking the code against the vulnerabilities...

=== Package Results ===

Vulnerability #1: GO-2021-0113
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ $ govulncheck -C ${moddir}/stdlib -format json .
"message": "Scanning your code and P packages across M dependent module for known vulnerabilities..."
}
}
{
"progress": {
"message": "Fetching vulnerabilities from the database..."
}
}
{
"progress": {
"message": "Checking the code against the vulnerabilities..."
}
}
{
"osv": {
"schema_version": "1.3.1",
Expand Down
8 changes: 8 additions & 0 deletions internal/vulncheck/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func binary(ctx context.Context, handler govulncheck.Handler, bin *Bin, cfg *gov
graph.AddModules(bin.Modules...)
mods := append(bin.Modules, graph.GetModule(internal.GoStdModulePath))

if err := handler.Progress(&govulncheck.Progress{Message: fetchingVulnsMessage}); err != nil {
return nil, err
}

mv, err := FetchVulnerabilities(ctx, client, mods)
if err != nil {
return nil, err
Expand All @@ -59,6 +63,10 @@ func binary(ctx context.Context, handler govulncheck.Handler, bin *Bin, cfg *gov
return nil, err
}

if err := handler.Progress(&govulncheck.Progress{Message: checkingVulnsMessage}); err != nil {
return nil, err
}

if bin.GOOS == "" || bin.GOARCH == "" {
fmt.Printf("warning: failed to extract build system specification GOOS: %s GOARCH: %s\n", bin.GOOS, bin.GOARCH)
}
Expand Down
8 changes: 8 additions & 0 deletions internal/vulncheck/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func source(ctx context.Context, handler govulncheck.Handler, cfg *govulncheck.C
}()
}

if err := handler.Progress(&govulncheck.Progress{Message: fetchingVulnsMessage}); err != nil {
return nil, err
}

mv, err := FetchVulnerabilities(ctx, client, graph.Modules())
if err != nil {
return nil, err
Expand All @@ -67,6 +71,10 @@ func source(ctx context.Context, handler govulncheck.Handler, cfg *govulncheck.C
return nil, err
}

if err := handler.Progress(&govulncheck.Progress{Message: checkingVulnsMessage}); err != nil {
return nil, err
}

affVulns := affectingVulnerabilities(mv, "", "")
if err := emitModuleFindings(handler, affVulns); err != nil {
return nil, err
Expand Down
5 changes: 5 additions & 0 deletions internal/vulncheck/vulncheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import (
"golang.org/x/vuln/internal/semver"
)

const (
fetchingVulnsMessage = "Fetching vulnerabilities from the database..."
checkingVulnsMessage = "Checking the code against the vulnerabilities..."
)

// Result contains information on detected vulnerabilities.
// For call graph analysis, it provides information on reachability
// of vulnerable symbols through entry points of the program.
Expand Down

0 comments on commit 086b27b

Please sign in to comment.