Skip to content

Commit 1a5d3d8

Browse files
committed
cmd/govulncheck/testdata: add test for json mode for multiple entry points
When govulncheck finds that the same vulnerable symbol is called more than once, only one invocation is displayed to the user in -json mode. Add a test for this behavior, before it is changed in a later CL. For golang/go#59485 Change-Id: I667e3e3c9c113991383b040191edb25858f992bb Reviewed-on: https://go-review.googlesource.com/c/vuln/+/485898 Auto-Submit: Julie Qiu <[email protected]> Run-TryBot: Julie Qiu <[email protected]> Reviewed-by: Julie Qiu <[email protected]> Reviewed-by: Tatiana Bradley <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Zvonimir Pavlinovic <[email protected]>
1 parent c0de090 commit 1a5d3d8

File tree

1 file changed

+165
-0
lines changed

1 file changed

+165
-0
lines changed
+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
$ govulncheck -json -C ${moddir}/multientry .
2+
{
3+
"config": {
4+
"version": [email protected]
5+
"data_source": "testdata/vulndb-v1",
6+
"last_modified": "2023-04-03T15:57:51Z",
7+
"go_version": "go1.18"
8+
}
9+
}
10+
{
11+
"progress": {
12+
"message": "Scanning your code and P packages across M dependent module for known vulnerabilities..."
13+
}
14+
}
15+
{
16+
"vulnerability": {
17+
"osv": {
18+
"schema_version": "1.3.1",
19+
"id": "GO-2021-0113",
20+
"modified": "2023-04-03T15:57:51Z",
21+
"published": "2021-10-06T17:51:21Z",
22+
"aliases": [
23+
"CVE-2021-38561",
24+
"GHSA-ppp9-7jff-5vj2"
25+
],
26+
"details": "Due to improper index calculation, an incorrectly formatted language tag can cause Parse to panic via an out of bounds read. If Parse is used to process untrusted user inputs, this may be used as a vector for a denial of service attack.",
27+
"affected": [
28+
{
29+
"package": {
30+
"name": "golang.org/x/text",
31+
"ecosystem": "Go"
32+
},
33+
"ranges": [
34+
{
35+
"type": "SEMVER",
36+
"events": [
37+
{
38+
"introduced": "0"
39+
},
40+
{
41+
"fixed": "0.3.7"
42+
}
43+
]
44+
}
45+
],
46+
"ecosystem_specific": {
47+
"imports": [
48+
{
49+
"path": "golang.org/x/text/language",
50+
"symbols": [
51+
"MatchStrings",
52+
"MustParse",
53+
"Parse",
54+
"ParseAcceptLanguage"
55+
]
56+
}
57+
]
58+
}
59+
}
60+
],
61+
"references": [
62+
{
63+
"type": "FIX",
64+
"url": "https://go.dev/cl/340830"
65+
},
66+
{
67+
"type": "FIX",
68+
"url": "https://go.googlesource.com/text/+/383b2e75a7a4198c42f8f87833eefb772868a56f"
69+
}
70+
],
71+
"credits": [
72+
{
73+
"name": "Guido Vranken"
74+
}
75+
],
76+
"database_specific": {
77+
"url": "https://pkg.go.dev/vuln/GO-2021-0113"
78+
}
79+
},
80+
"modules": [
81+
{
82+
"path": "golang.org/x/text",
83+
"found_version": "v0.3.5",
84+
"fixed_version": "v0.3.7",
85+
"packages": [
86+
{
87+
"path": "golang.org/x/text/language",
88+
"callstacks": [
89+
{
90+
"symbol": "MustParse",
91+
"summary": ".../main.go:99:20: golang.org/multientry.foobar calls golang.org/x/text/language.MustParse",
92+
"frames": [
93+
{
94+
"package": "golang.org/multientry",
95+
"function": "main",
96+
"position": {
97+
"filename": ".../main.go",
98+
"offset": 441,
99+
"line": 26,
100+
"column": 3
101+
}
102+
},
103+
{
104+
"package": "golang.org/multientry",
105+
"function": "D",
106+
"position": {
107+
"filename": ".../main.go",
108+
"offset": 705,
109+
"line": 48,
110+
"column": 8
111+
}
112+
},
113+
{
114+
"package": "golang.org/multientry",
115+
"function": "foobar",
116+
"position": {
117+
"filename": ".../main.go",
118+
"offset": 1694,
119+
"line": 99,
120+
"column": 20
121+
}
122+
},
123+
{
124+
"package": "golang.org/x/text/language",
125+
"function": "MustParse"
126+
}
127+
]
128+
},
129+
{
130+
"symbol": "Parse",
131+
"summary": ".../main.go:44:23: golang.org/multientry.C calls golang.org/x/text/language.Parse",
132+
"frames": [
133+
{
134+
"package": "golang.org/multientry",
135+
"function": "main",
136+
"position": {
137+
"filename": ".../main.go",
138+
"offset": 340,
139+
"line": 22,
140+
"column": 3
141+
}
142+
},
143+
{
144+
"package": "golang.org/multientry",
145+
"function": "C",
146+
"position": {
147+
"filename": ".../main.go",
148+
"offset": 679,
149+
"line": 44,
150+
"column": 23
151+
}
152+
},
153+
{
154+
"package": "golang.org/x/text/language",
155+
"function": "Parse"
156+
}
157+
]
158+
}
159+
]
160+
}
161+
]
162+
}
163+
]
164+
}
165+
}

0 commit comments

Comments
 (0)