Skip to content

Commit 983341d

Browse files
authored
test: introduce a locks-many-with-insecure collection of testdata (#2267)
Currently a lot of our tests use specific files from the `testdata/locks-many` set for stuff that doesn't actually need vulnerabilities meaning they'll trigger the warning about ignored vulns that weren't found that is being introduced in #2216 since there are two vulns in that set. To make things cleaner I've copied the existing testdata set into a new `locks-many-with-insecure`, removed the vulns from the original testdata set, and updated any tests that do actually want vulnerabilities to use the new set
1 parent 807fac8 commit 983341d

File tree

14 files changed

+283
-211
lines changed

14 files changed

+283
-211
lines changed

cmd/osv-scanner/scan/source/__snapshots__/command_test.snap

Lines changed: 117 additions & 187 deletions
Large diffs are not rendered by default.

cmd/osv-scanner/scan/source/command_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func TestCommand(t *testing.T) {
169169
},
170170
{
171171
Name: "Sarif with vulns",
172-
Args: []string{"", "source", "--format", "sarif", "--config", "./testdata/osv-scanner-empty-config.toml", "./testdata/locks-many/package-lock.json"},
172+
Args: []string{"", "source", "--format", "sarif", "./testdata/locks-many-with-insecure/package-lock.json"},
173173
Exit: 1,
174174
},
175175
// output format: gh-annotations
@@ -180,13 +180,13 @@ func TestCommand(t *testing.T) {
180180
},
181181
{
182182
Name: "gh-annotations with vulns",
183-
Args: []string{"", "source", "--format", "gh-annotations", "--config", "./testdata/osv-scanner-empty-config.toml", "./testdata/locks-many/package-lock.json"},
183+
Args: []string{"", "source", "--format", "gh-annotations", "./testdata/locks-many-with-insecure/package-lock.json"},
184184
Exit: 1,
185185
},
186186
// output format: markdown table
187187
{
188188
Name: "output format: markdown table",
189-
Args: []string{"", "source", "--format", "markdown", "--config", "./testdata/osv-scanner-empty-config.toml", "./testdata/locks-many/package-lock.json"},
189+
Args: []string{"", "source", "--format", "markdown", "./testdata/locks-many-with-insecure/package-lock.json"},
190190
Exit: 1,
191191
},
192192
// output format: cyclonedx 1.4
@@ -280,13 +280,13 @@ func TestCommand(t *testing.T) {
280280
// broad config file that overrides a whole ecosystem
281281
{
282282
Name: "config file can be broad",
283-
Args: []string{"", "source", "--config=./testdata/osv-scanner-composite-config.toml", "--licenses=MIT", "-L", "osv-scanner:./testdata/locks-insecure/osv-scanner-flutter-deps.json", "./testdata/locks-many", "./testdata/locks-insecure", "./testdata/maven-transitive"},
283+
Args: []string{"", "source", "--config=./testdata/osv-scanner-composite-config.toml", "--licenses=MIT", "-L", "osv-scanner:./testdata/locks-insecure/osv-scanner-flutter-deps.json", "./testdata/locks-many-with-insecure", "./testdata/locks-insecure", "./testdata/maven-transitive"},
284284
Exit: 1,
285285
},
286286
// ignored vulnerabilities and packages without a reason should be called out
287287
{
288288
Name: "ignores without reason should be explicitly called out",
289-
Args: []string{"", "source", "--config=./testdata/osv-scanner-reasonless-ignores-config.toml", "./testdata/locks-many/package-lock.json", "./testdata/locks-many/composer.lock"},
289+
Args: []string{"", "source", "--config=./testdata/osv-scanner-reasonless-ignores-config.toml", "./testdata/locks-many-with-insecure/package-lock.json", "./testdata/locks-many/composer.lock"},
290290
Exit: 0,
291291
},
292292
// invalid config file
@@ -879,8 +879,8 @@ func TestCommand_LocalDatabases(t *testing.T) {
879879
},
880880
{
881881
Name: "all supported lockfiles in the directory should be checked",
882-
Args: []string{"", "source", "--offline", "--download-offline-databases", "./testdata/locks-many"},
883-
Exit: 0,
882+
Args: []string{"", "source", "--offline", "--download-offline-databases", "./testdata/locks-many-with-insecure"},
883+
Exit: 1,
884884
},
885885
{
886886
Name: "all supported lockfiles in the directory should be checked",
@@ -948,7 +948,7 @@ func TestCommand_LocalDatabases_AlwaysOffline(t *testing.T) {
948948
tests := []testcmd.Case{
949949
{
950950
Name: "a bunch of different lockfiles and ecosystem",
951-
Args: []string{"", "source", "--offline", "./testdata/locks-requirements", "./testdata/locks-many"},
951+
Args: []string{"", "source", "--offline", "./testdata/locks-requirements", "./testdata/locks-many-with-insecure"},
952952
Exit: 127,
953953
},
954954
}
@@ -1010,12 +1010,12 @@ func TestCommand_Licenses(t *testing.T) {
10101010
},
10111011
{
10121012
Name: "Vulnerabilities and license summary",
1013-
Args: []string{"", "source", "--licenses", "--config=./testdata/osv-scanner-empty-config.toml", "./testdata/locks-many/package-lock.json"},
1013+
Args: []string{"", "source", "--licenses", "./testdata/locks-many-with-insecure/package-lock.json"},
10141014
Exit: 1,
10151015
},
10161016
{
10171017
Name: "Vulnerabilities and license violations with allowlist",
1018-
Args: []string{"", "source", "--licenses=MIT", "--config=./testdata/osv-scanner-empty-config.toml", "./testdata/locks-many/package-lock.json"},
1018+
Args: []string{"", "source", "--licenses=MIT", "./testdata/locks-many-with-insecure/package-lock.json"},
10191019
Exit: 1,
10201020
},
10211021
{
@@ -1025,7 +1025,7 @@ func TestCommand_Licenses(t *testing.T) {
10251025
},
10261026
{
10271027
Name: "Vulnerabilities and all license violations allowlisted",
1028-
Args: []string{"", "source", "--licenses=Apache-2.0", "--config=./testdata/osv-scanner-empty-config.toml", "./testdata/locks-many/package-lock.json"},
1028+
Args: []string{"", "source", "--licenses=Apache-2.0", "./testdata/locks-many-with-insecure/package-lock.json"},
10291029
Exit: 1,
10301030
},
10311031
{
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
ast (2.4.2)
5+
6+
PLATFORMS
7+
x86_64-linux
8+
9+
DEPENDENCIES
10+
ast
11+
12+
RUBY VERSION
13+
ruby 3.0.2p107
14+
15+
BUNDLED WITH
16+
2.2.28

cmd/osv-scanner/scan/source/testdata/locks-many-with-insecure/composer.lock

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
C:Q1Ef3iwt+cMdGngEgaFr2URIJhKzQ=
2+
P:apk-tools
3+
V:2.12.10-r1
4+
A:x86_64
5+
S:120973
6+
I:307200
7+
T:Alpine Package Keeper - package manager for alpine
8+
U:https://gitlab.alpinelinux.org/alpine/apk-tools
9+
L:GPL-2.0-only
10+
o:apk-tools
11+
m:Natanael Copa <[email protected]>
12+
t:1666552494
13+
c:0188f510baadbae393472103427b9c1875117136
14+
D:musl>=1.2 ca-certificates-bundle so:libc.musl-x86_64.so.1 so:libcrypto.so.3 so:libssl.so.3 so:libz.so.1
15+
p:so:libapk.so.3.12.0=3.12.0 cmd:apk=2.12.10-r1
16+
F:etc
17+
F:etc/apk
18+
F:etc/apk/keys
19+
F:etc/apk/protected_paths.d
20+
F:lib
21+
R:libapk.so.3.12.0
22+
a:0:0:755
23+
Z:Q1opjpYqXgzmOVo7EbNe8l5Xol08g=
24+
F:lib/apk
25+
F:lib/apk/exec
26+
F:sbin
27+
R:apk
28+
a:0:0:755
29+
Z:Q1/4bmOPe/H1YhHRzlrj27oufThMw=
30+
F:var
31+
F:var/lib
32+
F:var/lib/apk
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_="whatever this is, it's not a lockfile!"

cmd/osv-scanner/scan/source/testdata/locks-many-with-insecure/package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require (
2+
golang.org/x/net v1.2.3
3+
)
4+
5+
replace (
6+
golang.org/x/net v1.2.3 => ./fork/net
7+
)

0 commit comments

Comments
 (0)