Skip to content

Commit 7a1acac

Browse files
committed
internal/govulncheck: implement new Source and Binary APIs
This is a first in the series of refactoring CLs that implement new govulncheck API. Please see opening message for more details on actual changes. For golang/go#56042 Change-Id: I6ec699204e21e94bf577220bfe040ed6db873d29 Reviewed-on: https://go-review.googlesource.com/c/vuln/+/446715 Run-TryBot: Zvonimir Pavlinovic <[email protected]> Reviewed-by: Jonathan Amsterdam <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
1 parent 9daea05 commit 7a1acac

File tree

18 files changed

+874
-1092
lines changed

18 files changed

+874
-1092
lines changed

cmd/govulncheck/main.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ var (
2525
tagsFlag buildutil.TagsFlag
2626

2727
// testmode flags. See main_testmode.go.
28-
dirFlag string
29-
summaryJSONFlag bool
28+
dirFlag string
3029
)
3130

3231
func init() {
@@ -63,10 +62,7 @@ For details, see https://pkg.go.dev/golang.org/x/vuln/cmd/govulncheck.
6362
outputType := govulncheck.OutputTypeText
6463
if *jsonFlag {
6564
outputType = govulncheck.OutputTypeJSON
66-
} else if summaryJSONFlag { // accessible only in testmode.
67-
outputType = govulncheck.OutputTypeSummary
68-
}
69-
if outputType == govulncheck.OutputTypeText && *verboseFlag {
65+
} else if *verboseFlag {
7066
outputType = govulncheck.OutputTypeVerbose
7167
}
7268

cmd/govulncheck/main_testmode.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ import "flag"
1010

1111
func init() {
1212
flag.StringVar(&dirFlag, "dir", "", "directory to use for loading source files")
13-
flag.BoolVar(&summaryJSONFlag, "summary-json", false, "output govulnchecklib.Summary JSON")
1413
}

cmd/govulncheck/testdata/json-binary.ct

Lines changed: 14 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,10 @@
11
$ govulncheck -json ${novuln_binary}
22
{
3-
"Calls": null,
4-
"Imports": null,
5-
"Requires": null,
6-
"Vulns": null,
7-
"Modules": [
8-
{
9-
"Path": "golang.org/x/text",
10-
"Version": "v0.3.7",
11-
"Dir": "",
12-
"Replace": null
13-
},
14-
{
15-
"Path": "stdlib",
16-
"Version": "",
17-
"Dir": "",
18-
"Replace": null
19-
}
20-
]
3+
"Vulns": null
214
}
225

236
$ govulncheck -json ${vuln_binary}
247
{
25-
"Calls": null,
26-
"Imports": null,
27-
"Requires": null,
288
"Vulns": [
299
{
3010
"OSV": {
@@ -87,44 +67,19 @@ $ govulncheck -json ${vuln_binary}
8767
}
8868
]
8969
},
90-
"Symbol": "Parse",
91-
"PkgPath": "golang.org/x/text/language",
92-
"ModPath": "golang.org/x/text",
93-
"CallSink": 0,
94-
"ImportSink": 0,
95-
"RequireSink": 0
96-
}
97-
],
98-
"Modules": [
99-
{
100-
"Path": "github.com/tidwall/gjson",
101-
"Version": "v1.9.2",
102-
"Dir": "",
103-
"Replace": null
104-
},
105-
{
106-
"Path": "github.com/tidwall/match",
107-
"Version": "v1.1.0",
108-
"Dir": "",
109-
"Replace": null
110-
},
111-
{
112-
"Path": "github.com/tidwall/pretty",
113-
"Version": "v1.2.0",
114-
"Dir": "",
115-
"Replace": null
116-
},
117-
{
118-
"Path": "golang.org/x/text",
119-
"Version": "v0.3.0",
120-
"Dir": "",
121-
"Replace": null
122-
},
123-
{
124-
"Path": "stdlib",
125-
"Version": "",
126-
"Dir": "",
127-
"Replace": null
70+
"Modules": [
71+
{
72+
"Path": "golang.org/x/text",
73+
"FoundVersion": "v0.3.0",
74+
"FixedVersion": "v0.3.7",
75+
"Packages": [
76+
{
77+
"Path": "golang.org/x/text/language",
78+
"CallStacks": null
79+
}
80+
]
81+
}
82+
]
12883
}
12984
]
13085
}

cmd/govulncheck/testdata/json-summary.ct

Lines changed: 0 additions & 268 deletions
This file was deleted.

0 commit comments

Comments
 (0)