Skip to content

Commit d837ff8

Browse files
committed
internal/scan: improve textual output for binary traces
There are no traces in binary mode, just vulnerable symbols detected. Change-Id: I9f1ccc83c0527537d8d42d7397de0562ed8d2842 Reviewed-on: https://go-review.googlesource.com/c/vuln/+/577675 Reviewed-by: Ian Cottrell <iancottrell@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
1 parent 4a8a6ff commit d837ff8

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Vulnerability #1: GO-2021-0265
1010
Module: github.com/tidwall/gjson
1111
Found in: github.com/tidwall/gjson@v1.6.5
1212
Fixed in: github.com/tidwall/gjson@v1.9.3
13-
Example traces found:
13+
Vulnerable symbols found:
1414
#1: gjson.Get
1515
#2: gjson.Result.Get
1616

@@ -23,7 +23,7 @@ Vulnerability #2: GO-2021-0113
2323
Module: golang.org/x/text
2424
Found in: golang.org/x/text@v0.3.0
2525
Fixed in: golang.org/x/text@v0.3.7
26-
Example traces found:
26+
Vulnerable symbols found:
2727
#1: language.Parse
2828

2929
Vulnerability #3: GO-2021-0054
@@ -34,7 +34,7 @@ Vulnerability #3: GO-2021-0054
3434
Module: github.com/tidwall/gjson
3535
Found in: github.com/tidwall/gjson@v1.6.5
3636
Fixed in: github.com/tidwall/gjson@v1.6.6
37-
Example traces found:
37+
Vulnerable symbols found:
3838
#1: gjson.Result.ForEach
3939

4040
Your code is affected by 3 vulnerabilities from 2 modules.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Vulnerability #1: GO-2021-0265
1010
Module: github.com/tidwall/gjson
1111
Found in: github.com/tidwall/gjson@v1.6.5
1212
Fixed in: github.com/tidwall/gjson@v1.9.3
13-
Example traces found:
13+
Vulnerable symbols found:
1414
#1: gjson.Get
1515
#2: gjson.Result.Get
1616

@@ -23,7 +23,7 @@ Vulnerability #2: GO-2021-0113
2323
Module: golang.org/x/text
2424
Found in: golang.org/x/text@v0.3.0
2525
Fixed in: golang.org/x/text@v0.3.7
26-
Example traces found:
26+
Vulnerable symbols found:
2727
#1: language.Parse
2828

2929
Vulnerability #3: GO-2021-0054
@@ -34,7 +34,7 @@ Vulnerability #3: GO-2021-0054
3434
Module: github.com/tidwall/gjson
3535
Found in: github.com/tidwall/gjson@v1.6.5
3636
Fixed in: github.com/tidwall/gjson@v1.6.6
37-
Example traces found:
37+
Vulnerable symbols found:
3838
#1: gjson.Result.ForEach
3939

4040
Your code is affected by 3 vulnerabilities from 2 modules.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Vulnerability #1: GO-2021-0113
1212
Module: golang.org/x/text
1313
Found in: golang.org/x/text@v0.3.0
1414
Fixed in: golang.org/x/text@v0.3.7
15-
Example traces found:
15+
Vulnerable symbols found:
1616
#1: language.MatchStrings
1717
#2: language.MustParse
1818
#3: language.Parse
@@ -24,7 +24,7 @@ Vulnerability #2: GO-2020-0015
2424
Module: golang.org/x/text
2525
Found in: golang.org/x/text@v0.3.0
2626
Fixed in: golang.org/x/text@v0.3.3
27-
Example traces found:
27+
Vulnerable symbols found:
2828
#1: transform.String
2929
#2: unicode.bomOverride.Transform
3030
#3: unicode.utf16Decoder.Transform

internal/scan/text.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type TextHandler struct {
3838
osvs []*osv.Entry
3939
findings []*findingSummary
4040
scanLevel govulncheck.ScanLevel
41+
scanMode govulncheck.ScanMode
4142

4243
err error
4344

@@ -84,9 +85,9 @@ func (h *TextHandler) Flush() error {
8485

8586
// Config writes version information only if --version was set.
8687
func (h *TextHandler) Config(config *govulncheck.Config) error {
87-
if config.ScanLevel != "" {
88-
h.scanLevel = config.ScanLevel
89-
}
88+
h.scanLevel = config.ScanLevel
89+
h.scanMode = config.ScanMode
90+
9091
if !h.showVersion {
9192
return nil
9293
}
@@ -300,10 +301,14 @@ func (h *TextHandler) traces(traces []*findingSummary) {
300301
count := 1
301302
for _, entry := range traces {
302303
if entry.Compact == "" {
303-
continue
304+
continue // skip package and module level traces
304305
}
305306
if first {
306-
h.style(keyStyle, " Example traces found:\n")
307+
if h.scanMode == govulncheck.ScanModeBinary {
308+
h.style(keyStyle, " Vulnerable symbols found:\n")
309+
} else {
310+
h.style(keyStyle, " Example traces found:\n")
311+
}
307312
}
308313
first = false
309314

0 commit comments

Comments
 (0)