Skip to content

Commit e3a5c49

Browse files
ianthehatgopherbot
authored andcommitted
internal/scan: add -version flag
Only print the config block when -version is present Change to be more verbose but more readable now it is not always printed. Also don't print the usage just because there were no patterns. Fixes #53867 Change-Id: I282a5332c11eef535286133fc2425afa7f46942b Reviewed-on: https://go-review.googlesource.com/c/vuln/+/519815 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Maceo Thompson <maceothompson@google.com> Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com> Auto-Submit: Ian Cottrell <iancottrell@google.com>
1 parent 242ecf7 commit e3a5c49

26 files changed

+49
-102
lines changed

cmd/govulncheck/main_command_118_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ var fixups = []fixup{
5959
pattern: `Scanning your code and (\d+) packages across (\d+)`,
6060
replace: `Scanning your code and P packages across M`,
6161
}, {
62-
pattern: `govulncheck@v([^ ]*) `,
63-
replace: `govulncheck@v0.0.0-00000000000-20000101010101 `,
62+
pattern: `Scanner: govulncheck@v.*`,
63+
replace: `Scanner: govulncheck@v1.0.0`,
6464
}, {
6565
pattern: `"([^"]*") is a file`,
6666
replace: `govulncheck: myfile is a file`,
@@ -77,8 +77,8 @@ var fixups = []fixup{
7777
pattern: `modified (.*)\)`,
7878
replace: `modified 01 Jan 21 00:00 UTC)`,
7979
}, {
80-
pattern: `Using (go1.[\.\d]*|devel).* and`,
81-
replace: `Using go1.18 and`,
80+
pattern: `Go: (go1.[\.\d]*|devel).*`,
81+
replace: `Go: go1.18`,
8282
}, {
8383
pattern: `"go_version": "go[^\s"]*"`,
8484
replace: `"go_version": "go1.18"`,

cmd/govulncheck/testdata/binary_fail.ct

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ $ govulncheck -mode=binary notafile --> FAIL 2
66
#####
77
# Test of passing a non-binary file to -mode=binary
88
$ govulncheck -mode=binary ${moddir}/vuln/go.mod --> FAIL 1
9-
Using govulncheck@v0.0.0-00000000000-20000101010101 with vulnerability data from testdata/vulndb-v1 (last modified 01 Jan 21 00:00 UTC).
10-
119
Scanning your binary for known vulnerabilities...
1210

1311
govulncheck: could not parse provided binary: unrecognized file format

cmd/govulncheck/testdata/binary_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 ${vuln_binary} --> FAIL 3
4-
Using govulncheck@v0.0.0-00000000000-20000101010101 with vulnerability data from testdata/vulndb-v1 (last modified 01 Jan 21 00:00 UTC).
5-
64
Scanning your binary for known vulnerabilities...
75

86
Vulnerability #1: GO-2021-0265

cmd/govulncheck/testdata/convert_text.ct

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#####
22
# Test using the conversion from json on stdin to text on stdout
33
$ govulncheck -mode=convert < convert_input.json
4-
Using go1.18 and govulncheck@v0.0.0-00000000000-20000101010101 with vulnerability data from testdata/vulndb-v1 (last modified 01 Jan 21 00:00 UTC).
5-
64
Scanning your code and P packages across M dependent modules for known vulnerabilities...
75

86
Vulnerability #1: GO-2021-0265

cmd/govulncheck/testdata/source_fail.ct

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#####
22
# Test of missing go.mod error message.
33
$ govulncheck -C ${moddir}/nogomod . --> FAIL 1
4-
Using go1.18 and govulncheck@v0.0.0-00000000000-20000101010101 with vulnerability data from testdata/vulndb-v1 (last modified 01 Jan 21 00:00 UTC).
5-
64
govulncheck: no go.mod file
75

86
govulncheck only works with Go modules. Try navigating to your module directory.
@@ -24,8 +22,6 @@ For details, run govulncheck -h.
2422
#####
2523
# Test of handing an invalid package pattern to source mode
2624
$ govulncheck -C ${moddir}/vuln blah --> FAIL 1
27-
Using go1.18 and govulncheck@v0.0.0-00000000000-20000101010101 with vulnerability data from testdata/vulndb-v1 (last modified 01 Jan 21 00:00 UTC).
28-
2925
govulncheck: loading packages:
3026
There are errors with the provided package patterns:
3127

cmd/govulncheck/testdata/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 souce mode with no callstacks
33
$ govulncheck -C ${moddir}/informational -show=traces .
4-
Using go1.18 and govulncheck@v0.0.0-00000000000-20000101010101 with vulnerability data from testdata/vulndb-v1 (last modified 01 Jan 21 00:00 UTC).
5-
64
Scanning your code and P packages across M dependent modules for known vulnerabilities...
75

86
=== Informational ===

cmd/govulncheck/testdata/source_multientry_text.ct

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#####
22
# Test for multiple call stacks in source mode with expanded traces
33
$ govulncheck -C ${moddir}/multientry . --> FAIL 3
4-
Using go1.18 and govulncheck@v0.0.0-00000000000-20000101010101 with vulnerability data from testdata/vulndb-v1 (last modified 01 Jan 21 00:00 UTC).
5-
64
Scanning your code and P packages across M dependent module for known vulnerabilities...
75

86
Vulnerability #1: GO-2021-0113
@@ -25,8 +23,6 @@ Share feedback at https://go.dev/s/govulncheck-feedback.
2523
#####
2624
# Test for multple call stacks in source mode with expanded traces
2725
$ govulncheck -C ${moddir}/multientry -show=traces ./... --> FAIL 3
28-
Using go1.18 and govulncheck@v0.0.0-00000000000-20000101010101 with vulnerability data from testdata/vulndb-v1 (last modified 01 Jan 21 00:00 UTC).
29-
3026
Scanning your code and P packages across M dependent module for known vulnerabilities...
3127

3228
Vulnerability #1: GO-2021-0113

cmd/govulncheck/testdata/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-
Using go1.18 and govulncheck@v0.0.0-00000000000-20000101010101 with vulnerability data from testdata/vulndb-v1 (last modified 01 Jan 21 00:00 UTC).
6-
75
Scanning your code and P packages across M dependent module for known vulnerabilities...
86

97
Vulnerability #1: GO-2021-0113

cmd/govulncheck/testdata/source_stdlib_text.ct

Lines changed: 0 additions & 4 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-
Using go1.18 and govulncheck@v0.0.0-00000000000-20000101010101 with vulnerability data from testdata/vulndb-v1 (last modified 01 Jan 21 00:00 UTC).
5-
64
Scanning your code and P packages across M dependent modules for known vulnerabilities...
75

86
Vulnerability #1: GO-2022-0969
@@ -23,8 +21,6 @@ Share feedback at https://go.dev/s/govulncheck-feedback.
2321
#####
2422
# Test finding stdlib vulnerability in source mode with expanded traces
2523
$ govulncheck -C ${moddir}/stdlib -show=traces . --> FAIL 3
26-
Using go1.18 and govulncheck@v0.0.0-00000000000-20000101010101 with vulnerability data from testdata/vulndb-v1 (last modified 01 Jan 21 00:00 UTC).
27-
2824
Scanning your code and P packages across M dependent modules for known vulnerabilities...
2925

3026
Vulnerability #1: GO-2022-0969

cmd/govulncheck/testdata/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-
Using go1.18 and govulncheck@v0.0.0-00000000000-20000101010101 with vulnerability data from testdata/vulndb-v1 (last modified 01 Jan 21 00:00 UTC).
5-
64
Scanning your code and P packages across M dependent module for known vulnerabilities...
75

86
Vulnerability #1: GO-2021-0113
@@ -24,8 +22,6 @@ Share feedback at https://go.dev/s/govulncheck-feedback.
2422
#####
2523
# Test govulncheck runs on the subdirectory of a module
2624
$ govulncheck -C ${moddir}/vuln/subdir -show=traces . --> FAIL 3
27-
Using go1.18 and govulncheck@v0.0.0-00000000000-20000101010101 with vulnerability data from testdata/vulndb-v1 (last modified 01 Jan 21 00:00 UTC).
28-
2925
Scanning your code and P packages across M dependent module for known vulnerabilities...
3026

3127
Vulnerability #1: GO-2021-0113

0 commit comments

Comments
 (0)