Skip to content

Commit f3bc44a

Browse files
committed
internal/scan: print progress messages only in verbose mode
And also update the documentation. Updates golang/go#66872 Change-Id: I73f0c7e9c1f46b66711b878748bf78571d26f66b Reviewed-on: https://go-review.googlesource.com/c/vuln/+/580175 Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent 640d2c8 commit f3bc44a

File tree

20 files changed

+11
-52
lines changed

20 files changed

+11
-52
lines changed

cmd/govulncheck/doc.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,27 @@ To control which files are processed, use the -tags flag to provide a
4141
comma-separated list of build tags, and the -test flag to indicate that test
4242
files should be included.
4343
44-
To include more detailed stack traces, pass -show=traces, this will cause it to
44+
To include more detailed stack traces, pass '-show traces', this will cause it to
4545
print the full call stack for each entry.
4646
47+
To include progress messages and more details on findings, pass '-show verbose'.
48+
4749
To run govulncheck on a compiled binary, pass it the path to the binary file
48-
with the -mode=binary flag:
50+
with the '-mode binary' flag:
4951
50-
$ govulncheck -mode=binary $HOME/go/bin/my-go-program
52+
$ govulncheck -mode binary $HOME/go/bin/my-go-program
5153
5254
Govulncheck uses the binary's symbol information to find mentions of vulnerable
5355
functions. Its output omits call stacks, which require source code analysis.
5456
55-
Govulncheck also supports -mode=extract on a Go binary for extraction of minimal
57+
Govulncheck also supports '-mode extract' on a Go binary for extraction of minimal
5658
information needed to analyze the binary. This will produce a blob, typically much
5759
smaller than the binary, that can also be passed to govulncheck as an argument with
58-
-mode=binary. The users should not rely on the contents or representation of the blob.
60+
'-mode binary'. The users should not rely on the contents or representation of the blob.
5961
6062
Govulncheck exits successfully (exit code 0) if there are no vulnerabilities,
6163
and exits unsuccessfully if there are. It also exits successfully if the -json flag
62-
is provided, regardless of the number of detected vulnerabilities.
64+
(or '-format json') is provided, regardless of the number of detected vulnerabilities.
6365
6466
Govulncheck supports streaming JSON. For more details, please see [golang.org/x/vuln/internal/govulncheck].
6567

cmd/govulncheck/testdata/common/testfiles/binary-call/binary_call_text.ct

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#####
22
# Test basic binary scanning with text output
33
$ govulncheck -mode=binary ${common_vuln_binary} --> FAIL 3
4-
Scanning your binary for known vulnerabilities...
5-
64
=== Symbol Results ===
75

86
Vulnerability #1: GO-2021-0265

cmd/govulncheck/testdata/common/testfiles/binary-module/binary_module_text.ct

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#####
22
# Test binary scanning at the module level
33
$ govulncheck -mode=binary -scan module ${common_vuln_binary} --> FAIL 3
4-
Scanning your binary for known vulnerabilities...
5-
64
=== Module Results ===
75

86
Vulnerability #1: GO-2021-0265

cmd/govulncheck/testdata/common/testfiles/binary-package/binary_package_text.ct

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# Test binary scanning at the package level.
22
$ govulncheck -mode=binary -scan package ${common_vuln_binary} --> FAIL 3
3-
Scanning your binary for known vulnerabilities...
4-
53
=== Package Results ===
64

75
Vulnerability #1: GO-2021-0265

cmd/govulncheck/testdata/common/testfiles/convert/convert_text.ct

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# Test using the conversion from json on stdin to text on stdout
33
# location of convert input is subdirectory/convert_intput
44
$ govulncheck -mode=convert < convert/convert_input.json --> FAIL 3
5-
Scanning your code and P packages across M dependent modules for known vulnerabilities...
6-
75
=== Symbol Results ===
86

97
Vulnerability #1: GO-2021-0265

cmd/govulncheck/testdata/common/testfiles/extract/binary_extract.ct

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#####
22
# Test binary mode using the extracted binary blob.
33
$ govulncheck -mode=binary ${testdir}/extract/vuln.blob --> FAIL 3
4-
Scanning your binary for known vulnerabilities...
5-
64
=== Symbol Results ===
75

86
Vulnerability #1: GO-2021-0265

cmd/govulncheck/testdata/common/testfiles/source-call/source_call_text.ct

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#####
22
# Test of basic govulncheck in source mode
33
$ govulncheck -C ${moddir}/vuln ./... --> FAIL 3
4-
Scanning your code and P packages across M dependent modules for known vulnerabilities...
5-
64
=== Symbol Results ===
75

86
Vulnerability #1: GO-2021-0265
@@ -47,8 +45,6 @@ Use '-show verbose' for more details.
4745
#####
4846
# Test of basic govulncheck in source mode with expanded traces
4947
$ govulncheck -C ${moddir}/vuln -show=traces ./... --> FAIL 3
50-
Scanning your code and P packages across M dependent modules for known vulnerabilities...
51-
5248
=== Symbol Results ===
5349

5450
Vulnerability #1: GO-2021-0265

cmd/govulncheck/testdata/common/testfiles/source-call/source_informational_text.ct

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#####
22
# Test source mode with no callstacks
33
$ govulncheck -C ${moddir}/informational -show=traces .
4-
Scanning your code and P packages across M dependent modules for known vulnerabilities...
5-
64
=== Symbol Results ===
75

86
No vulnerabilities found.

cmd/govulncheck/testdata/common/testfiles/source-call/source_multientry_text.ct

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#####
22
# Test for multiple call stacks in source mode
33
$ govulncheck -C ${moddir}/multientry . --> FAIL 3
4-
Scanning your code and P packages across M dependent modules for known vulnerabilities...
5-
64
=== Symbol Results ===
75

86
Vulnerability #1: GO-2021-0113

cmd/govulncheck/testdata/common/testfiles/source-call/source_replace_text.ct

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# Test of source mode on a module with a replace directive.
33

44
$ govulncheck -C ${moddir}/replace ./... --> FAIL 3
5-
Scanning your code and P packages across M dependent modules for known vulnerabilities...
6-
75
=== Symbol Results ===
86

97
Vulnerability #1: GO-2021-0113

cmd/govulncheck/testdata/common/testfiles/source-call/source_subdir_text.ct

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#####
22
# Test govulncheck runs on the subdirectory of a module
33
$ govulncheck -C ${moddir}/vuln/subdir . --> FAIL 3
4-
Scanning your code and P packages across M dependent modules for known vulnerabilities...
5-
64
=== Symbol Results ===
75

86
Vulnerability #1: GO-2021-0113
@@ -26,8 +24,6 @@ Use '-show verbose' for more details.
2624
#####
2725
# Test govulncheck runs on the subdirectory of a module
2826
$ govulncheck -C ${moddir}/vuln/subdir -show=traces . --> FAIL 3
29-
Scanning your code and P packages across M dependent modules for known vulnerabilities...
30-
3127
=== Symbol Results ===
3228

3329
Vulnerability #1: GO-2021-0113

cmd/govulncheck/testdata/common/testfiles/source-call/source_wholemodvuln_text.ct

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# Test of govulncheck call analysis for vulns with no package info available.
33
# All symbols of the module are vulnerable.
44
$ govulncheck -C ${moddir}/wholemodvuln ./... --> FAIL 3
5-
Scanning your code and P packages across M dependent modules for known vulnerabilities...
6-
75
=== Symbol Results ===
86

97
Vulnerability #1: GO-2022-0956

cmd/govulncheck/testdata/common/testfiles/source-module/source_module_text.ct

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# Testing that govulncheck doesn't mention calls when it doesn't
33
# have callstack information
44
$ govulncheck -scan module -C ${moddir}/multientry --> FAIL 3
5-
Scanning your code across 2 dependent modules for known vulnerabilities...
6-
75
=== Module Results ===
86

97
Vulnerability #1: GO-2021-0113

cmd/govulncheck/testdata/common/testfiles/source-package/source_package_text.ct

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#####
22
# Testing that govulncheck doesn't mention calls when it doesn't have the relevant info
33
$ govulncheck -scan package -C ${moddir}/multientry . --> FAIL 3
4-
Scanning your code and P packages across M dependent modules for known vulnerabilities...
5-
64
=== Package Results ===
75

86
Vulnerability #1: GO-2021-0113

cmd/govulncheck/testdata/common/testfiles/usage/format.ct

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#####
22
# Test of explicit text format
33
$ govulncheck -C ${moddir}/informational -format text .
4-
Scanning your code and P packages across M dependent modules for known vulnerabilities...
5-
64
=== Symbol Results ===
75

86
No vulnerabilities found.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#####
22
# Test message when there are no packages matching the provided pattern (#59623).
33
$ govulncheck -C ${moddir}/vuln pkg/no-govulncheck/...
4-
No packages matching the provided pattern.
5-
64
No vulnerabilities found.

cmd/govulncheck/testdata/stdlib/testfiles/stdlib/source_stdlib_text.ct

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#####
22
# Test finding stdlib vulnerability in source mode
33
$ govulncheck -C ${moddir}/stdlib . --> FAIL 3
4-
Scanning your code and P packages across M dependent module for known vulnerabilities...
5-
64
=== Symbol Results ===
75

86
Vulnerability #1: GO-2022-0969
@@ -25,8 +23,6 @@ Use '-show verbose' for more details.
2523
#####
2624
# Test finding stdlib vulnerability in source mode with expanded traces
2725
$ govulncheck -C ${moddir}/stdlib -show=traces . --> FAIL 3
28-
Scanning your code and P packages across M dependent module for known vulnerabilities...
29-
3026
=== Symbol Results ===
3127

3228
Vulnerability #1: GO-2022-0969
@@ -55,8 +51,6 @@ Use '-show verbose' for more details.
5551
#####
5652
# Test finding stdlib vulnerability in source mode at the package level
5753
$ govulncheck -C ${moddir}/stdlib -scan package . --> FAIL 3
58-
Scanning your code and P packages across M dependent module for known vulnerabilities...
59-
6054
=== Package Results ===
6155

6256
Vulnerability #1: GO-2022-0969
@@ -77,8 +71,6 @@ verbose' for more details.
7771
#####
7872
# Test finding stdlib vulnerability in source mode at the module level
7973
$ govulncheck -C ${moddir}/stdlib -scan module --> FAIL 3
80-
Scanning your code across 1 dependent module for known vulnerabilities...
81-
8274
=== Module Results ===
8375

8476
Vulnerability #1: GO-2022-0969

cmd/govulncheck/testdata/strip/testfiles/binary/strip.ct

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#####
22
# Test for stripped binaries (see #57764)
33
$ govulncheck -mode=binary ${strip_vuln_binary} --> FAIL 3
4-
Scanning your binary for known vulnerabilities...
5-
64
=== Symbol Results ===
75

86
Vulnerability #1: GO-2021-0113

internal/scan/run.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ func RunGovulncheck(ctx context.Context, env []string, r io.Reader, stdout io.Wr
4747
handler = th
4848
}
4949

50-
// Write the introductory message to the user.
5150
if err := handler.Config(&cfg.Config); err != nil {
5251
return err
5352
}

internal/scan/text.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ func (h *TextHandler) Config(config *govulncheck.Config) error {
116116

117117
// Progress writes progress updates during govulncheck execution.
118118
func (h *TextHandler) Progress(progress *govulncheck.Progress) error {
119-
h.print(progress.Message, "\n\n")
119+
if h.showVerbose {
120+
h.print(progress.Message, "\n\n")
121+
}
120122
return h.err
121123
}
122124

0 commit comments

Comments
 (0)