Skip to content

Commit 26305ce

Browse files
author
Maceo Thompson
committed
internal/scan: Improve "Informational" text output
This change changes the text output to only include messages relating to vulnerabilities that actually appear. This means that if there is a package level vuln but no module level vulnerabilities, govulncheck will no longer say "There are also 0 vulnerabilities in modules that you import". Additionally, this change cleans up how the informational section actually builds the string, using strings.Builder and automatically wrapping text with handler.wrap() instead of manually wrapping the text. Change-Id: Ia933ee777d87004ec94918954619e916ec307dd7 Reviewed-on: https://go-review.googlesource.com/c/vuln/+/540315 Reviewed-by: Ian Cottrell <iancottrell@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
1 parent c8f88df commit 26305ce

16 files changed

+57
-74
lines changed

cmd/govulncheck/testdata/convert_text.ct

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ Vulnerability #2: GO-2021-0113
2828
=== Informational ===
2929

3030
Found 1 vulnerability in packages that you import, but there are no
31-
call stacks leading to the use of this vulnerability. You may not
32-
need to take any action. There are also 0 vulnerabilities in modules
33-
that you require that are neither imported nor called.
31+
call stacks leading to the use of this vulnerability. You may not need
32+
to take any action.
3433
See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck for details.
3534

3635
Vulnerability #1: GO-2021-0054

cmd/govulncheck/testdata/source_informational_text.ct

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Scanning your code and P packages across M dependent modules for known vulnerabi
66
=== Informational ===
77

88
Found 1 vulnerability in packages that you import, but there are no
9-
call stacks leading to the use of this vulnerability. You may not
10-
need to take any action. There is also 1 vulnerability in modules
11-
that you require that is neither imported nor called.
9+
call stacks leading to the use of this vulnerability. There is also 1
10+
vulnerability in modules that you require that is neither imported nor
11+
called. You may not need to take any action.
1212
See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck for details.
1313

1414
Vulnerability #1: GO-2022-0969

cmd/govulncheck/testdata/source_multientry_text.ct

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ Vulnerability #1: GO-2021-0113
1818

1919
=== Informational ===
2020

21-
Found 0 vulnerabilities in packages that you import, but there are no
22-
call stacks leading to the use of these vulnerabilities. You may not
23-
need to take any action. There is also 1 vulnerability in modules
24-
that you require that is neither imported nor called.
21+
There is 1 vulnerability in modules that you require that is neither
22+
imported nor called. You may not need to take any action.
2523
See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck for details.
2624

2725
Vulnerability #1: GO-2022-0969
@@ -64,10 +62,8 @@ Vulnerability #1: GO-2021-0113
6462

6563
=== Informational ===
6664

67-
Found 0 vulnerabilities in packages that you import, but there are no
68-
call stacks leading to the use of these vulnerabilities. You may not
69-
need to take any action. There is also 1 vulnerability in modules
70-
that you require that is neither imported nor called.
65+
There is 1 vulnerability in modules that you require that is neither
66+
imported nor called. You may not need to take any action.
7167
See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck for details.
7268

7369
Vulnerability #1: GO-2022-0969

cmd/govulncheck/testdata/source_replace_text.ct

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ Vulnerability #1: GO-2021-0113
1818

1919
=== Informational ===
2020

21-
Found 0 vulnerabilities in packages that you import, but there are no
22-
call stacks leading to the use of these vulnerabilities. You may not
23-
need to take any action. There are also 2 vulnerabilities in modules
24-
that you require that are neither imported nor called.
21+
There are 2 vulnerabilities in modules that you require that are
22+
neither imported nor called. You may not need to take any action.
2523
See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck for details.
2624

2725
Vulnerability #1: GO-2022-0969

cmd/govulncheck/testdata/source_subdir_text.ct

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ Vulnerability #1: GO-2021-0113
1717

1818
=== Informational ===
1919

20-
Found 0 vulnerabilities in packages that you import, but there are no
21-
call stacks leading to the use of these vulnerabilities. You may not
22-
need to take any action. There are also 4 vulnerabilities in modules
23-
that you require that are neither imported nor called.
20+
There are 4 vulnerabilities in modules that you require that are
21+
neither imported nor called. You may not need to take any action.
2422
See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck for details.
2523

2624
Vulnerability #1: GO-2022-0969
@@ -85,10 +83,8 @@ Vulnerability #1: GO-2021-0113
8583

8684
=== Informational ===
8785

88-
Found 0 vulnerabilities in packages that you import, but there are no
89-
call stacks leading to the use of these vulnerabilities. You may not
90-
need to take any action. There are also 4 vulnerabilities in modules
91-
that you require that are neither imported nor called.
86+
There are 4 vulnerabilities in modules that you require that are
87+
neither imported nor called. You may not need to take any action.
9288
See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck for details.
9389

9490
Vulnerability #1: GO-2022-0969

cmd/govulncheck/testdata/source_vuln_text.ct

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ Vulnerability #2: GO-2021-0113
2828
=== Informational ===
2929

3030
Found 1 vulnerability in packages that you import, but there are no
31-
call stacks leading to the use of this vulnerability. You may not
32-
need to take any action. There are also 2 vulnerabilities in modules
33-
that you require that are neither imported nor called.
31+
call stacks leading to the use of this vulnerability. There are also 2
32+
vulnerabilities in modules that you require that are neither imported
33+
nor called. You may not need to take any action.
3434
See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck for details.
3535

3636
Vulnerability #1: GO-2022-0969
@@ -100,9 +100,9 @@ Vulnerability #2: GO-2021-0113
100100
=== Informational ===
101101

102102
Found 1 vulnerability in packages that you import, but there are no
103-
call stacks leading to the use of this vulnerability. You may not
104-
need to take any action. There are also 2 vulnerabilities in modules
105-
that you require that are neither imported nor called.
103+
call stacks leading to the use of this vulnerability. There are also 2
104+
vulnerabilities in modules that you require that are neither imported
105+
nor called. You may not need to take any action.
106106
See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck for details.
107107

108108
Vulnerability #1: GO-2022-0969

internal/scan/testdata/module-vuln.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
=== Informational ===
22

3-
Found 0 vulnerabilities in packages that you import, but there are no
4-
call stacks leading to the use of these vulnerabilities. You may not
5-
need to take any action. There is also 1 vulnerability in modules
6-
that you require that is neither imported nor called.
3+
There is 1 vulnerability in modules that you require that is neither
4+
imported nor called. You may not need to take any action.
75
See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck for details.
86

97
Vulnerability #1: GO-0000-0001

internal/scan/testdata/multi-stack-modlevel.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ Vulnerability #1: GO-0000-0001
1010

1111
=== Informational ===
1212

13-
Found 0 vulnerabilities in packages that you import, but there are no
14-
call stacks leading to the use of these vulnerabilities. You may not
15-
need to take any action. There is also 1 vulnerability in modules
16-
that you require that is neither imported nor called.
13+
There is 1 vulnerability in modules that you require that is neither
14+
imported nor called. You may not need to take any action.
1715
See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck for details.
1816

1917
Vulnerability #1: GO-0000-0002

internal/scan/testdata/platform-all.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
=== Informational ===
22

33
Found 1 vulnerability in packages that you import, but there are no
4-
call stacks leading to the use of this vulnerability. You may not
5-
need to take any action. There are also 0 vulnerabilities in modules
6-
that you require that are neither imported nor called.
4+
call stacks leading to the use of this vulnerability. You may not need
5+
to take any action.
76
See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck for details.
87

98
Vulnerability #1: All

internal/scan/testdata/platform-one-arch-only.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
=== Informational ===
22

33
Found 1 vulnerability in packages that you import, but there are no
4-
call stacks leading to the use of this vulnerability. You may not
5-
need to take any action. There are also 0 vulnerabilities in modules
6-
that you require that are neither imported nor called.
4+
call stacks leading to the use of this vulnerability. You may not need
5+
to take any action.
76
See https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck for details.
87

98
Vulnerability #1: one-arch-only

0 commit comments

Comments
 (0)