diff --git a/cmd/govulncheck/main_test.go b/cmd/govulncheck/main_test.go index 418b3ba8..a5815251 100644 --- a/cmd/govulncheck/main_test.go +++ b/cmd/govulncheck/main_test.go @@ -76,7 +76,7 @@ var fixups = []fixup{ pattern: `"scanner_version": "[^"]*"`, replace: `"scanner_version": "v0.0.0-00000000000-20000101010101"`, }, { - pattern: `file:///(.*)/testdata/vulndb`, + pattern: `file:///(.*)/testdata/(.*)/vulndb`, replace: `testdata/vulndb`, }, { pattern: `package (.*) is not in (GOROOT|std) (.*)`, @@ -110,6 +110,31 @@ func init() { } } +// testCase models a group of tests in cmd/govulncheck testdata. +type testCase struct { + dir string // subdirectory in testdata containing tests + skipGOOS []string // GOOS to skip, if any + strip bool // indicates if binaries should be stripped +} + +func (tc testCase) skip() bool { + for _, sg := range tc.skipGOOS { + if runtime.GOOS == sg { + return true + } + } + return false +} + +// testCases contains the list of major groups of tests in +// cmd/govulncheck/testdata folder with information on how +// to run them. +var testCases = []testCase{ + {dir: "common"}, + // Binaries are not stripped on darwin with go1.21 and earlier. See #61051. + {dir: "strip", skipGOOS: []string{"darwin"}, strip: true}, +} + func TestCommand(t *testing.T) { if testing.Short() { t.Skip("skipping test that uses internet in short mode") @@ -119,55 +144,59 @@ func TestCommand(t *testing.T) { if err != nil { t.Fatal(err) } - vulndbDir, err := filepath.Abs(filepath.Join(testDir, "testdata", "vulndb-v1")) - if err != nil { - t.Fatal(err) - } - govulndbURI, err := web.URLFromFilePath(vulndbDir) - if err != nil { - t.Fatalf("failed to create make vulndb url: %v", err) - } - - moduleDirs, err := filepath.Glob("testdata/modules/*") - if err != nil { - t.Fatal(err) - } - os.Setenv("moddir", filepath.Join(testDir, "testdata", "modules")) - for _, md := range moduleDirs { - // Skip nogomod module. It has intended build issues. - if filepath.Base(md) == "nogomod" { - noModDir, err := filepath.Abs(t.TempDir()) - if err != nil { - t.Fatal(err) - } - os.Setenv("nomoddir", noModDir) - b, err := os.ReadFile(filepath.Join(md, "vuln.go")) - if err != nil { - t.Fatal(err) - } - err = os.WriteFile(filepath.Join(noModDir, "vuln.go"), b, 0644) - if err != nil { - t.Fatal(err) - } + for _, tc := range testCases { + if tc.skip() { continue } + base := tc.dir - // Build test module binary. - binary, cleanup := test.GoBuild(t, md, "", filepath.Base(md) == "strip") - t.Cleanup(cleanup) - // Set an environment variable to the path to the binary, so tests - // can refer to it. - varName := filepath.Base(md) + "_binary" - os.Setenv(varName, binary) - } - testFilesDir := filepath.Join(testDir, "testdata", "testfiles") - os.Setenv("testdir", testFilesDir) + vulndbDir, err := filepath.Abs(filepath.Join(testDir, "testdata", base, "vulndb-v1")) + if err != nil { + t.Fatal(err) + } + govulndbURI, err := web.URLFromFilePath(vulndbDir) + if err != nil { + t.Fatalf("failed to create make vulndb url: %v", err) + } - runTestSuite(t, testFilesDir, govulndbURI.String(), *update) - if runtime.GOOS != "darwin" { - // Binaries are not stripped on darwin with go1.21 and earlier. See #61051. - runTestSuite(t, filepath.Join(testDir, "testdata", "strip"), govulndbURI.String(), *update) + moduleDirs, err := filepath.Glob(fmt.Sprintf("testdata/%s/modules/*", base)) + if err != nil { + t.Fatal(err) + } + + os.Setenv("moddir", filepath.Join(testDir, "testdata", base, "modules")) + for _, md := range moduleDirs { + // Skip nogomod module. It has intended build issues. + if filepath.Base(md) == "nogomod" { + noModDir, err := filepath.Abs(t.TempDir()) + if err != nil { + t.Fatal(err) + } + os.Setenv("nomoddir", noModDir) + b, err := os.ReadFile(filepath.Join(md, "vuln.go")) + if err != nil { + t.Fatal(err) + } + err = os.WriteFile(filepath.Join(noModDir, "vuln.go"), b, 0644) + if err != nil { + t.Fatal(err) + } + continue + } + + // Build test module binary. + binary, cleanup := test.GoBuild(t, md, "", tc.strip) + t.Cleanup(cleanup) + // Set an environment variable to the path to the binary, so tests + // can refer to it. The binary name is unique across all test cases. + varName := tc.dir + "_" + filepath.Base(md) + "_binary" + os.Setenv(varName, binary) + } + testFilesDir := filepath.Join(testDir, "testdata", base, "testfiles") + os.Setenv("testdir", testFilesDir) + + runTestSuite(t, testFilesDir, govulndbURI.String(), *update) } } @@ -189,10 +218,10 @@ var ( parallelLimiterInit sync.Once ) -// testSuite creates a cmdtest suite from dir. It also defines +// testSuite creates a cmdtest suite from tsReadDir. It also defines // a govulncheck command on the suite that runs govulncheck // against vulnerability database available at vulndbDir. -func runTestSuite(t *testing.T, dir string, govulndb string, update bool) { +func runTestSuite(t *testing.T, tsReadDir string, govulndb string, update bool) { parallelLimiterInit.Do(func() { limit := (runtime.GOMAXPROCS(0) + 3) / 4 if limit > 2 && unsafe.Sizeof(uintptr(0)) < 8 { @@ -200,11 +229,7 @@ func runTestSuite(t *testing.T, dir string, govulndb string, update bool) { } parallelLimiter = make(chan struct{}, limit) }) - tsReadDir := dir - if filepath.Base(dir) != "strip" { - tsReadDir = filepath.Join(tsReadDir, "*") - } - ts, err := cmdtest.Read(tsReadDir) + ts, err := cmdtest.Read(filepath.Join(tsReadDir, "*")) if err != nil { t.Fatal(err) } @@ -221,7 +246,7 @@ func runTestSuite(t *testing.T, dir string, govulndb string, update bool) { cmd.Stdout = buf cmd.Stderr = buf if inputFile != "" { - input, err := os.Open(filepath.Join(dir, inputFile)) + input, err := os.Open(filepath.Join(tsReadDir, inputFile)) if err != nil { return nil, err } @@ -299,7 +324,7 @@ func runTestSuite(t *testing.T, dir string, govulndb string, update bool) { ts.Run(t, true) return } - ts.RunParallel(t, false) + ts.Run(t, false) // TODO: make parallel } func isJSONMode(args []string) bool { diff --git a/cmd/govulncheck/testdata/modules/informational/go.mod b/cmd/govulncheck/testdata/common/modules/informational/go.mod similarity index 100% rename from cmd/govulncheck/testdata/modules/informational/go.mod rename to cmd/govulncheck/testdata/common/modules/informational/go.mod diff --git a/cmd/govulncheck/testdata/modules/informational/go.sum b/cmd/govulncheck/testdata/common/modules/informational/go.sum similarity index 100% rename from cmd/govulncheck/testdata/modules/informational/go.sum rename to cmd/govulncheck/testdata/common/modules/informational/go.sum diff --git a/cmd/govulncheck/testdata/modules/informational/vuln.go b/cmd/govulncheck/testdata/common/modules/informational/vuln.go similarity index 100% rename from cmd/govulncheck/testdata/modules/informational/vuln.go rename to cmd/govulncheck/testdata/common/modules/informational/vuln.go diff --git a/cmd/govulncheck/testdata/modules/multientry/go.mod b/cmd/govulncheck/testdata/common/modules/multientry/go.mod similarity index 100% rename from cmd/govulncheck/testdata/modules/multientry/go.mod rename to cmd/govulncheck/testdata/common/modules/multientry/go.mod diff --git a/cmd/govulncheck/testdata/modules/multientry/go.sum b/cmd/govulncheck/testdata/common/modules/multientry/go.sum similarity index 100% rename from cmd/govulncheck/testdata/modules/multientry/go.sum rename to cmd/govulncheck/testdata/common/modules/multientry/go.sum diff --git a/cmd/govulncheck/testdata/modules/multientry/main.go b/cmd/govulncheck/testdata/common/modules/multientry/main.go similarity index 100% rename from cmd/govulncheck/testdata/modules/multientry/main.go rename to cmd/govulncheck/testdata/common/modules/multientry/main.go diff --git a/cmd/govulncheck/testdata/modules/nogomod/vuln.go b/cmd/govulncheck/testdata/common/modules/nogomod/vuln.go similarity index 100% rename from cmd/govulncheck/testdata/modules/nogomod/vuln.go rename to cmd/govulncheck/testdata/common/modules/nogomod/vuln.go diff --git a/cmd/govulncheck/testdata/modules/replace/go.mod b/cmd/govulncheck/testdata/common/modules/replace/go.mod similarity index 100% rename from cmd/govulncheck/testdata/modules/replace/go.mod rename to cmd/govulncheck/testdata/common/modules/replace/go.mod diff --git a/cmd/govulncheck/testdata/modules/replace/go.sum b/cmd/govulncheck/testdata/common/modules/replace/go.sum similarity index 100% rename from cmd/govulncheck/testdata/modules/replace/go.sum rename to cmd/govulncheck/testdata/common/modules/replace/go.sum diff --git a/cmd/govulncheck/testdata/modules/replace/main.go b/cmd/govulncheck/testdata/common/modules/replace/main.go similarity index 100% rename from cmd/govulncheck/testdata/modules/replace/main.go rename to cmd/govulncheck/testdata/common/modules/replace/main.go diff --git a/cmd/govulncheck/testdata/modules/stdlib/go.mod b/cmd/govulncheck/testdata/common/modules/stdlib/go.mod similarity index 100% rename from cmd/govulncheck/testdata/modules/stdlib/go.mod rename to cmd/govulncheck/testdata/common/modules/stdlib/go.mod diff --git a/cmd/govulncheck/testdata/modules/stdlib/go.sum b/cmd/govulncheck/testdata/common/modules/stdlib/go.sum similarity index 100% rename from cmd/govulncheck/testdata/modules/stdlib/go.sum rename to cmd/govulncheck/testdata/common/modules/stdlib/go.sum diff --git a/cmd/govulncheck/testdata/modules/stdlib/stdlib.go b/cmd/govulncheck/testdata/common/modules/stdlib/stdlib.go similarity index 100% rename from cmd/govulncheck/testdata/modules/stdlib/stdlib.go rename to cmd/govulncheck/testdata/common/modules/stdlib/stdlib.go diff --git a/cmd/govulncheck/testdata/modules/vendored/go.mod b/cmd/govulncheck/testdata/common/modules/vendored/go.mod similarity index 100% rename from cmd/govulncheck/testdata/modules/vendored/go.mod rename to cmd/govulncheck/testdata/common/modules/vendored/go.mod diff --git a/cmd/govulncheck/testdata/modules/vendored/go.sum b/cmd/govulncheck/testdata/common/modules/vendored/go.sum similarity index 100% rename from cmd/govulncheck/testdata/modules/vendored/go.sum rename to cmd/govulncheck/testdata/common/modules/vendored/go.sum diff --git a/cmd/govulncheck/testdata/modules/vendored/subdir/subdir.go b/cmd/govulncheck/testdata/common/modules/vendored/subdir/subdir.go similarity index 100% rename from cmd/govulncheck/testdata/modules/vendored/subdir/subdir.go rename to cmd/govulncheck/testdata/common/modules/vendored/subdir/subdir.go diff --git a/cmd/govulncheck/testdata/modules/vendored/vendor/github.com/tidwall/gjson/gjson.go b/cmd/govulncheck/testdata/common/modules/vendored/vendor/github.com/tidwall/gjson/gjson.go similarity index 100% rename from cmd/govulncheck/testdata/modules/vendored/vendor/github.com/tidwall/gjson/gjson.go rename to cmd/govulncheck/testdata/common/modules/vendored/vendor/github.com/tidwall/gjson/gjson.go diff --git a/cmd/govulncheck/testdata/modules/vendored/vendor/golang.org/x/text/language/language.go b/cmd/govulncheck/testdata/common/modules/vendored/vendor/golang.org/x/text/language/language.go similarity index 100% rename from cmd/govulncheck/testdata/modules/vendored/vendor/golang.org/x/text/language/language.go rename to cmd/govulncheck/testdata/common/modules/vendored/vendor/golang.org/x/text/language/language.go diff --git a/cmd/govulncheck/testdata/modules/vendored/vendor/modules.txt b/cmd/govulncheck/testdata/common/modules/vendored/vendor/modules.txt similarity index 100% rename from cmd/govulncheck/testdata/modules/vendored/vendor/modules.txt rename to cmd/govulncheck/testdata/common/modules/vendored/vendor/modules.txt diff --git a/cmd/govulncheck/testdata/modules/vendored/vendor/private.com/privateuser/fakemod/mod.go b/cmd/govulncheck/testdata/common/modules/vendored/vendor/private.com/privateuser/fakemod/mod.go similarity index 100% rename from cmd/govulncheck/testdata/modules/vendored/vendor/private.com/privateuser/fakemod/mod.go rename to cmd/govulncheck/testdata/common/modules/vendored/vendor/private.com/privateuser/fakemod/mod.go diff --git a/cmd/govulncheck/testdata/modules/vendored/vendored.go b/cmd/govulncheck/testdata/common/modules/vendored/vendored.go similarity index 100% rename from cmd/govulncheck/testdata/modules/vendored/vendored.go rename to cmd/govulncheck/testdata/common/modules/vendored/vendored.go diff --git a/cmd/govulncheck/testdata/modules/vuln/go.mod b/cmd/govulncheck/testdata/common/modules/vuln/go.mod similarity index 100% rename from cmd/govulncheck/testdata/modules/vuln/go.mod rename to cmd/govulncheck/testdata/common/modules/vuln/go.mod diff --git a/cmd/govulncheck/testdata/modules/vuln/go.sum b/cmd/govulncheck/testdata/common/modules/vuln/go.sum similarity index 100% rename from cmd/govulncheck/testdata/modules/vuln/go.sum rename to cmd/govulncheck/testdata/common/modules/vuln/go.sum diff --git a/cmd/govulncheck/testdata/modules/vuln/subdir/subdir.go b/cmd/govulncheck/testdata/common/modules/vuln/subdir/subdir.go similarity index 100% rename from cmd/govulncheck/testdata/modules/vuln/subdir/subdir.go rename to cmd/govulncheck/testdata/common/modules/vuln/subdir/subdir.go diff --git a/cmd/govulncheck/testdata/modules/vuln/vuln.go b/cmd/govulncheck/testdata/common/modules/vuln/vuln.go similarity index 100% rename from cmd/govulncheck/testdata/modules/vuln/vuln.go rename to cmd/govulncheck/testdata/common/modules/vuln/vuln.go diff --git a/cmd/govulncheck/testdata/modules/vuln/vuln_dont_run_me b/cmd/govulncheck/testdata/common/modules/vuln/vuln_dont_run_me similarity index 100% rename from cmd/govulncheck/testdata/modules/vuln/vuln_dont_run_me rename to cmd/govulncheck/testdata/common/modules/vuln/vuln_dont_run_me diff --git a/cmd/govulncheck/testdata/modules/wholemodvuln/go.mod b/cmd/govulncheck/testdata/common/modules/wholemodvuln/go.mod similarity index 100% rename from cmd/govulncheck/testdata/modules/wholemodvuln/go.mod rename to cmd/govulncheck/testdata/common/modules/wholemodvuln/go.mod diff --git a/cmd/govulncheck/testdata/modules/wholemodvuln/go.sum b/cmd/govulncheck/testdata/common/modules/wholemodvuln/go.sum similarity index 100% rename from cmd/govulncheck/testdata/modules/wholemodvuln/go.sum rename to cmd/govulncheck/testdata/common/modules/wholemodvuln/go.sum diff --git a/cmd/govulncheck/testdata/modules/wholemodvuln/whole_mod_vuln.go b/cmd/govulncheck/testdata/common/modules/wholemodvuln/whole_mod_vuln.go similarity index 100% rename from cmd/govulncheck/testdata/modules/wholemodvuln/whole_mod_vuln.go rename to cmd/govulncheck/testdata/common/modules/wholemodvuln/whole_mod_vuln.go diff --git a/cmd/govulncheck/testdata/testfiles/binary-call/binary_call_json.ct b/cmd/govulncheck/testdata/common/testfiles/binary-call/binary_call_json.ct similarity index 99% rename from cmd/govulncheck/testdata/testfiles/binary-call/binary_call_json.ct rename to cmd/govulncheck/testdata/common/testfiles/binary-call/binary_call_json.ct index c19a3a0f..05369d7f 100644 --- a/cmd/govulncheck/testdata/testfiles/binary-call/binary_call_json.ct +++ b/cmd/govulncheck/testdata/common/testfiles/binary-call/binary_call_json.ct @@ -1,6 +1,6 @@ ##### # Test basic binary scanning with json output -$ govulncheck -format json -mode binary ${vuln_binary} +$ govulncheck -format json -mode binary ${common_vuln_binary} { "config": { "protocol_version": "v1.0.0", diff --git a/cmd/govulncheck/testdata/testfiles/binary-call/binary_call_text.ct b/cmd/govulncheck/testdata/common/testfiles/binary-call/binary_call_text.ct similarity index 96% rename from cmd/govulncheck/testdata/testfiles/binary-call/binary_call_text.ct rename to cmd/govulncheck/testdata/common/testfiles/binary-call/binary_call_text.ct index 82aa4735..54dd19ab 100644 --- a/cmd/govulncheck/testdata/testfiles/binary-call/binary_call_text.ct +++ b/cmd/govulncheck/testdata/common/testfiles/binary-call/binary_call_text.ct @@ -1,6 +1,6 @@ ##### # Test basic binary scanning with text output -$ govulncheck -mode=binary ${vuln_binary} --> FAIL 3 +$ govulncheck -mode=binary ${common_vuln_binary} --> FAIL 3 Scanning your binary for known vulnerabilities... === Symbol Results === diff --git a/cmd/govulncheck/testdata/testfiles/binary-call/binary_sarif.ct b/cmd/govulncheck/testdata/common/testfiles/binary-call/binary_sarif.ct similarity index 99% rename from cmd/govulncheck/testdata/testfiles/binary-call/binary_sarif.ct rename to cmd/govulncheck/testdata/common/testfiles/binary-call/binary_sarif.ct index 81347c7c..a6e400c5 100644 --- a/cmd/govulncheck/testdata/testfiles/binary-call/binary_sarif.ct +++ b/cmd/govulncheck/testdata/common/testfiles/binary-call/binary_sarif.ct @@ -1,6 +1,6 @@ ##### # Test basic binary scanning with sarif output -$ govulncheck -format sarif -mode binary ${vuln_binary} +$ govulncheck -format sarif -mode binary ${common_vuln_binary} { "version": "2.1.0", "$schema": "https://json.schemastore.org/sarif-2.1.0.json", diff --git a/cmd/govulncheck/testdata/testfiles/binary-call/binary_vendored_json.ct b/cmd/govulncheck/testdata/common/testfiles/binary-call/binary_vendored_json.ct similarity index 99% rename from cmd/govulncheck/testdata/testfiles/binary-call/binary_vendored_json.ct rename to cmd/govulncheck/testdata/common/testfiles/binary-call/binary_vendored_json.ct index f7b5b342..9ea6fc77 100644 --- a/cmd/govulncheck/testdata/testfiles/binary-call/binary_vendored_json.ct +++ b/cmd/govulncheck/testdata/common/testfiles/binary-call/binary_vendored_json.ct @@ -1,6 +1,6 @@ ##### # Test basic binary scanning with json output -$ govulncheck -format json -mode binary ${vendored_binary} +$ govulncheck -format json -mode binary ${common_vendored_binary} { "config": { "protocol_version": "v1.0.0", diff --git a/cmd/govulncheck/testdata/testfiles/binary-module/binary_module_json.ct b/cmd/govulncheck/testdata/common/testfiles/binary-module/binary_module_json.ct similarity index 99% rename from cmd/govulncheck/testdata/testfiles/binary-module/binary_module_json.ct rename to cmd/govulncheck/testdata/common/testfiles/binary-module/binary_module_json.ct index 9c60471a..c41ffdf4 100644 --- a/cmd/govulncheck/testdata/testfiles/binary-module/binary_module_json.ct +++ b/cmd/govulncheck/testdata/common/testfiles/binary-module/binary_module_json.ct @@ -1,6 +1,6 @@ ##### # Test binary scanning at the module level with json output -$ govulncheck -format json -mode binary -scan module ${vuln_binary} +$ govulncheck -format json -mode binary -scan module ${common_vuln_binary} { "config": { "protocol_version": "v1.0.0", diff --git a/cmd/govulncheck/testdata/testfiles/binary-module/binary_module_text.ct b/cmd/govulncheck/testdata/common/testfiles/binary-module/binary_module_text.ct similarity index 95% rename from cmd/govulncheck/testdata/testfiles/binary-module/binary_module_text.ct rename to cmd/govulncheck/testdata/common/testfiles/binary-module/binary_module_text.ct index 75146a37..2565cfb3 100644 --- a/cmd/govulncheck/testdata/testfiles/binary-module/binary_module_text.ct +++ b/cmd/govulncheck/testdata/common/testfiles/binary-module/binary_module_text.ct @@ -1,6 +1,6 @@ ##### # Test binary scanning at the module level -$ govulncheck -mode=binary -scan module ${vuln_binary} --> FAIL 3 +$ govulncheck -mode=binary -scan module ${common_vuln_binary} --> FAIL 3 Scanning your binary for known vulnerabilities... === Module Results === diff --git a/cmd/govulncheck/testdata/testfiles/binary-package/binary_package_json.ct b/cmd/govulncheck/testdata/common/testfiles/binary-package/binary_package_json.ct similarity index 99% rename from cmd/govulncheck/testdata/testfiles/binary-package/binary_package_json.ct rename to cmd/govulncheck/testdata/common/testfiles/binary-package/binary_package_json.ct index 782b1bd3..05f59877 100644 --- a/cmd/govulncheck/testdata/testfiles/binary-package/binary_package_json.ct +++ b/cmd/govulncheck/testdata/common/testfiles/binary-package/binary_package_json.ct @@ -1,6 +1,6 @@ ##### # Test binary scanning at the package level with json output -$ govulncheck -format json -mode binary -scan package ${vuln_binary} +$ govulncheck -format json -mode binary -scan package ${common_vuln_binary} { "config": { "protocol_version": "v1.0.0", diff --git a/cmd/govulncheck/testdata/testfiles/binary-package/binary_package_text.ct b/cmd/govulncheck/testdata/common/testfiles/binary-package/binary_package_text.ct similarity index 95% rename from cmd/govulncheck/testdata/testfiles/binary-package/binary_package_text.ct rename to cmd/govulncheck/testdata/common/testfiles/binary-package/binary_package_text.ct index ca3deb52..712aa263 100644 --- a/cmd/govulncheck/testdata/testfiles/binary-package/binary_package_text.ct +++ b/cmd/govulncheck/testdata/common/testfiles/binary-package/binary_package_text.ct @@ -1,5 +1,5 @@ # Test binary scanning at the package level. -$ govulncheck -mode=binary -scan package ${vuln_binary} --> FAIL 3 +$ govulncheck -mode=binary -scan package ${common_vuln_binary} --> FAIL 3 Scanning your binary for known vulnerabilities... === Package Results === diff --git a/cmd/govulncheck/testdata/testfiles/convert/convert_input.json b/cmd/govulncheck/testdata/common/testfiles/convert/convert_input.json similarity index 100% rename from cmd/govulncheck/testdata/testfiles/convert/convert_input.json rename to cmd/govulncheck/testdata/common/testfiles/convert/convert_input.json diff --git a/cmd/govulncheck/testdata/testfiles/convert/convert_text.ct b/cmd/govulncheck/testdata/common/testfiles/convert/convert_text.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/convert/convert_text.ct rename to cmd/govulncheck/testdata/common/testfiles/convert/convert_text.ct diff --git a/cmd/govulncheck/testdata/testfiles/extract/binary_extract.ct b/cmd/govulncheck/testdata/common/testfiles/extract/binary_extract.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/extract/binary_extract.ct rename to cmd/govulncheck/testdata/common/testfiles/extract/binary_extract.ct diff --git a/cmd/govulncheck/testdata/testfiles/extract/vuln.blob b/cmd/govulncheck/testdata/common/testfiles/extract/vuln.blob similarity index 100% rename from cmd/govulncheck/testdata/testfiles/extract/vuln.blob rename to cmd/govulncheck/testdata/common/testfiles/extract/vuln.blob diff --git a/cmd/govulncheck/testdata/testfiles/failures/after_body.blob b/cmd/govulncheck/testdata/common/testfiles/failures/after_body.blob similarity index 100% rename from cmd/govulncheck/testdata/testfiles/failures/after_body.blob rename to cmd/govulncheck/testdata/common/testfiles/failures/after_body.blob diff --git a/cmd/govulncheck/testdata/testfiles/failures/binary_fail.ct b/cmd/govulncheck/testdata/common/testfiles/failures/binary_fail.ct similarity index 90% rename from cmd/govulncheck/testdata/testfiles/failures/binary_fail.ct rename to cmd/govulncheck/testdata/common/testfiles/failures/binary_fail.ct index 687c645a..915b556c 100644 --- a/cmd/govulncheck/testdata/testfiles/failures/binary_fail.ct +++ b/cmd/govulncheck/testdata/common/testfiles/failures/binary_fail.ct @@ -55,15 +55,15 @@ govulncheck: unrecognized binary format ##### # Test of trying to analyze multiple binaries -$ govulncheck -mode=binary ${vuln_binary} ${vuln_binary} --> FAIL 2 +$ govulncheck -mode=binary ${common_vuln_binary} ${common_vuln_binary} --> FAIL 2 only 1 binary can be analyzed at a time ##### # Test of trying to run -mode=binary with -tags flag -$ govulncheck -tags=foo -mode=binary ${vuln_binary} --> FAIL 2 +$ govulncheck -tags=foo -mode=binary ${common_vuln_binary} --> FAIL 2 the -tags flag is not supported in binary mode ##### # Test of trying to run -mode=binary with the -test flag -$ govulncheck -test -mode=binary ${vuln_binary} --> FAIL 2 +$ govulncheck -test -mode=binary ${common_vuln_binary} --> FAIL 2 the -test flag is not supported in binary mode diff --git a/cmd/govulncheck/testdata/testfiles/failures/empty.blob b/cmd/govulncheck/testdata/common/testfiles/failures/empty.blob similarity index 100% rename from cmd/govulncheck/testdata/testfiles/failures/empty.blob rename to cmd/govulncheck/testdata/common/testfiles/failures/empty.blob diff --git a/cmd/govulncheck/testdata/testfiles/failures/empty_message.blob b/cmd/govulncheck/testdata/common/testfiles/failures/empty_message.blob similarity index 100% rename from cmd/govulncheck/testdata/testfiles/failures/empty_message.blob rename to cmd/govulncheck/testdata/common/testfiles/failures/empty_message.blob diff --git a/cmd/govulncheck/testdata/testfiles/failures/extract_fail.ct b/cmd/govulncheck/testdata/common/testfiles/failures/extract_fail.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/failures/extract_fail.ct rename to cmd/govulncheck/testdata/common/testfiles/failures/extract_fail.ct diff --git a/cmd/govulncheck/testdata/testfiles/failures/invalid_header.blob b/cmd/govulncheck/testdata/common/testfiles/failures/invalid_header.blob similarity index 100% rename from cmd/govulncheck/testdata/testfiles/failures/invalid_header.blob rename to cmd/govulncheck/testdata/common/testfiles/failures/invalid_header.blob diff --git a/cmd/govulncheck/testdata/testfiles/failures/invalid_header_name.blob b/cmd/govulncheck/testdata/common/testfiles/failures/invalid_header_name.blob similarity index 100% rename from cmd/govulncheck/testdata/testfiles/failures/invalid_header_name.blob rename to cmd/govulncheck/testdata/common/testfiles/failures/invalid_header_name.blob diff --git a/cmd/govulncheck/testdata/testfiles/failures/invalid_header_version.blob b/cmd/govulncheck/testdata/common/testfiles/failures/invalid_header_version.blob similarity index 100% rename from cmd/govulncheck/testdata/testfiles/failures/invalid_header_version.blob rename to cmd/govulncheck/testdata/common/testfiles/failures/invalid_header_version.blob diff --git a/cmd/govulncheck/testdata/testfiles/failures/multi_header.blob b/cmd/govulncheck/testdata/common/testfiles/failures/multi_header.blob similarity index 100% rename from cmd/govulncheck/testdata/testfiles/failures/multi_header.blob rename to cmd/govulncheck/testdata/common/testfiles/failures/multi_header.blob diff --git a/cmd/govulncheck/testdata/testfiles/failures/no_body.blob b/cmd/govulncheck/testdata/common/testfiles/failures/no_body.blob similarity index 100% rename from cmd/govulncheck/testdata/testfiles/failures/no_body.blob rename to cmd/govulncheck/testdata/common/testfiles/failures/no_body.blob diff --git a/cmd/govulncheck/testdata/testfiles/failures/no_header.blob b/cmd/govulncheck/testdata/common/testfiles/failures/no_header.blob similarity index 100% rename from cmd/govulncheck/testdata/testfiles/failures/no_header.blob rename to cmd/govulncheck/testdata/common/testfiles/failures/no_header.blob diff --git a/cmd/govulncheck/testdata/testfiles/failures/query_fail.ct b/cmd/govulncheck/testdata/common/testfiles/failures/query_fail.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/failures/query_fail.ct rename to cmd/govulncheck/testdata/common/testfiles/failures/query_fail.ct diff --git a/cmd/govulncheck/testdata/testfiles/failures/source_fail.ct b/cmd/govulncheck/testdata/common/testfiles/failures/source_fail.ct similarity index 95% rename from cmd/govulncheck/testdata/testfiles/failures/source_fail.ct rename to cmd/govulncheck/testdata/common/testfiles/failures/source_fail.ct index fded793e..2694ab3e 100644 --- a/cmd/govulncheck/testdata/testfiles/failures/source_fail.ct +++ b/cmd/govulncheck/testdata/common/testfiles/failures/source_fail.ct @@ -10,7 +10,7 @@ See https://go.dev/doc/modules/managing-dependencies for more information. ##### # Test of handing a binary to source mode -$ govulncheck ${vuln_binary} --> FAIL 2 +$ govulncheck ${common_vuln_binary} --> FAIL 2 govulncheck: myfile is a file. By default, govulncheck runs source analysis on Go modules. diff --git a/cmd/govulncheck/testdata/testfiles/failures/usage_fail.ct b/cmd/govulncheck/testdata/common/testfiles/failures/usage_fail.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/failures/usage_fail.ct rename to cmd/govulncheck/testdata/common/testfiles/failures/usage_fail.ct diff --git a/cmd/govulncheck/testdata/testfiles/query/query_json.ct b/cmd/govulncheck/testdata/common/testfiles/query/query_json.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/query/query_json.ct rename to cmd/govulncheck/testdata/common/testfiles/query/query_json.ct diff --git a/cmd/govulncheck/testdata/testfiles/query/query_multi_json.ct b/cmd/govulncheck/testdata/common/testfiles/query/query_multi_json.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/query/query_multi_json.ct rename to cmd/govulncheck/testdata/common/testfiles/query/query_multi_json.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-call/source_call_json.ct b/cmd/govulncheck/testdata/common/testfiles/source-call/source_call_json.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-call/source_call_json.ct rename to cmd/govulncheck/testdata/common/testfiles/source-call/source_call_json.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-call/source_call_sarif.ct b/cmd/govulncheck/testdata/common/testfiles/source-call/source_call_sarif.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-call/source_call_sarif.ct rename to cmd/govulncheck/testdata/common/testfiles/source-call/source_call_sarif.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-call/source_call_text.ct b/cmd/govulncheck/testdata/common/testfiles/source-call/source_call_text.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-call/source_call_text.ct rename to cmd/govulncheck/testdata/common/testfiles/source-call/source_call_text.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-call/source_informational_text.ct b/cmd/govulncheck/testdata/common/testfiles/source-call/source_informational_text.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-call/source_informational_text.ct rename to cmd/govulncheck/testdata/common/testfiles/source-call/source_informational_text.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-call/source_multientry_json.ct b/cmd/govulncheck/testdata/common/testfiles/source-call/source_multientry_json.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-call/source_multientry_json.ct rename to cmd/govulncheck/testdata/common/testfiles/source-call/source_multientry_json.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-call/source_multientry_text.ct b/cmd/govulncheck/testdata/common/testfiles/source-call/source_multientry_text.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-call/source_multientry_text.ct rename to cmd/govulncheck/testdata/common/testfiles/source-call/source_multientry_text.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-call/source_replace_json.ct b/cmd/govulncheck/testdata/common/testfiles/source-call/source_replace_json.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-call/source_replace_json.ct rename to cmd/govulncheck/testdata/common/testfiles/source-call/source_replace_json.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-call/source_replace_text.ct b/cmd/govulncheck/testdata/common/testfiles/source-call/source_replace_text.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-call/source_replace_text.ct rename to cmd/govulncheck/testdata/common/testfiles/source-call/source_replace_text.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-call/source_subdir_text.ct b/cmd/govulncheck/testdata/common/testfiles/source-call/source_subdir_text.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-call/source_subdir_text.ct rename to cmd/govulncheck/testdata/common/testfiles/source-call/source_subdir_text.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-call/source_vendored_json.ct b/cmd/govulncheck/testdata/common/testfiles/source-call/source_vendored_json.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-call/source_vendored_json.ct rename to cmd/govulncheck/testdata/common/testfiles/source-call/source_vendored_json.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-call/source_vendored_text.ct b/cmd/govulncheck/testdata/common/testfiles/source-call/source_vendored_text.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-call/source_vendored_text.ct rename to cmd/govulncheck/testdata/common/testfiles/source-call/source_vendored_text.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-call/source_wholemodvuln_text.ct b/cmd/govulncheck/testdata/common/testfiles/source-call/source_wholemodvuln_text.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-call/source_wholemodvuln_text.ct rename to cmd/govulncheck/testdata/common/testfiles/source-call/source_wholemodvuln_text.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-module/source_module_json.ct b/cmd/govulncheck/testdata/common/testfiles/source-module/source_module_json.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-module/source_module_json.ct rename to cmd/govulncheck/testdata/common/testfiles/source-module/source_module_json.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-module/source_module_sarif.ct b/cmd/govulncheck/testdata/common/testfiles/source-module/source_module_sarif.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-module/source_module_sarif.ct rename to cmd/govulncheck/testdata/common/testfiles/source-module/source_module_sarif.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-module/source_module_text.ct b/cmd/govulncheck/testdata/common/testfiles/source-module/source_module_text.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-module/source_module_text.ct rename to cmd/govulncheck/testdata/common/testfiles/source-module/source_module_text.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-package/source_package_json.ct b/cmd/govulncheck/testdata/common/testfiles/source-package/source_package_json.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-package/source_package_json.ct rename to cmd/govulncheck/testdata/common/testfiles/source-package/source_package_json.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-package/source_package_sarif.ct b/cmd/govulncheck/testdata/common/testfiles/source-package/source_package_sarif.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-package/source_package_sarif.ct rename to cmd/govulncheck/testdata/common/testfiles/source-package/source_package_sarif.ct diff --git a/cmd/govulncheck/testdata/testfiles/source-package/source_package_text.ct b/cmd/govulncheck/testdata/common/testfiles/source-package/source_package_text.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/source-package/source_package_text.ct rename to cmd/govulncheck/testdata/common/testfiles/source-package/source_package_text.ct diff --git a/cmd/govulncheck/testdata/testfiles/stdlib/query_stdlib_json.ct b/cmd/govulncheck/testdata/common/testfiles/stdlib/query_stdlib_json.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/stdlib/query_stdlib_json.ct rename to cmd/govulncheck/testdata/common/testfiles/stdlib/query_stdlib_json.ct diff --git a/cmd/govulncheck/testdata/testfiles/stdlib/query_vstdlib_json.ct b/cmd/govulncheck/testdata/common/testfiles/stdlib/query_vstdlib_json.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/stdlib/query_vstdlib_json.ct rename to cmd/govulncheck/testdata/common/testfiles/stdlib/query_vstdlib_json.ct diff --git a/cmd/govulncheck/testdata/testfiles/stdlib/source_stdlib_json.ct b/cmd/govulncheck/testdata/common/testfiles/stdlib/source_stdlib_json.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/stdlib/source_stdlib_json.ct rename to cmd/govulncheck/testdata/common/testfiles/stdlib/source_stdlib_json.ct diff --git a/cmd/govulncheck/testdata/testfiles/stdlib/source_stdlib_text.ct b/cmd/govulncheck/testdata/common/testfiles/stdlib/source_stdlib_text.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/stdlib/source_stdlib_text.ct rename to cmd/govulncheck/testdata/common/testfiles/stdlib/source_stdlib_text.ct diff --git a/cmd/govulncheck/testdata/testfiles/usage/format.ct b/cmd/govulncheck/testdata/common/testfiles/usage/format.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/usage/format.ct rename to cmd/govulncheck/testdata/common/testfiles/usage/format.ct diff --git a/cmd/govulncheck/testdata/testfiles/usage/source_no_packages.ct b/cmd/govulncheck/testdata/common/testfiles/usage/source_no_packages.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/usage/source_no_packages.ct rename to cmd/govulncheck/testdata/common/testfiles/usage/source_no_packages.ct diff --git a/cmd/govulncheck/testdata/testfiles/usage/usage.ct b/cmd/govulncheck/testdata/common/testfiles/usage/usage.ct similarity index 100% rename from cmd/govulncheck/testdata/testfiles/usage/usage.ct rename to cmd/govulncheck/testdata/common/testfiles/usage/usage.ct diff --git a/cmd/govulncheck/testdata/vulndb-v1/ID/GO-2020-0015.json b/cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2020-0015.json similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/ID/GO-2020-0015.json rename to cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2020-0015.json diff --git a/cmd/govulncheck/testdata/vulndb-v1/ID/GO-2020-0015.json.gz b/cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2020-0015.json.gz similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/ID/GO-2020-0015.json.gz rename to cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2020-0015.json.gz diff --git a/cmd/govulncheck/testdata/vulndb-v1/ID/GO-2021-0054.json b/cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2021-0054.json similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/ID/GO-2021-0054.json rename to cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2021-0054.json diff --git a/cmd/govulncheck/testdata/vulndb-v1/ID/GO-2021-0054.json.gz b/cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2021-0054.json.gz similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/ID/GO-2021-0054.json.gz rename to cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2021-0054.json.gz diff --git a/cmd/govulncheck/testdata/vulndb-v1/ID/GO-2021-0059.json b/cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2021-0059.json similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/ID/GO-2021-0059.json rename to cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2021-0059.json diff --git a/cmd/govulncheck/testdata/vulndb-v1/ID/GO-2021-0059.json.gz b/cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2021-0059.json.gz similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/ID/GO-2021-0059.json.gz rename to cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2021-0059.json.gz diff --git a/cmd/govulncheck/testdata/vulndb-v1/ID/GO-2021-0113.json b/cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2021-0113.json similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/ID/GO-2021-0113.json rename to cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2021-0113.json diff --git a/cmd/govulncheck/testdata/vulndb-v1/ID/GO-2021-0113.json.gz b/cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2021-0113.json.gz similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/ID/GO-2021-0113.json.gz rename to cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2021-0113.json.gz diff --git a/cmd/govulncheck/testdata/vulndb-v1/ID/GO-2021-0265.json b/cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2021-0265.json similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/ID/GO-2021-0265.json rename to cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2021-0265.json diff --git a/cmd/govulncheck/testdata/vulndb-v1/ID/GO-2021-0265.json.gz b/cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2021-0265.json.gz similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/ID/GO-2021-0265.json.gz rename to cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2021-0265.json.gz diff --git a/cmd/govulncheck/testdata/vulndb-v1/ID/GO-2022-0956.json b/cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2022-0956.json similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/ID/GO-2022-0956.json rename to cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2022-0956.json diff --git a/cmd/govulncheck/testdata/vulndb-v1/ID/GO-2022-0969.json b/cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2022-0969.json similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/ID/GO-2022-0969.json rename to cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2022-0969.json diff --git a/cmd/govulncheck/testdata/vulndb-v1/ID/GO-2022-0969.json.gz b/cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2022-0969.json.gz similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/ID/GO-2022-0969.json.gz rename to cmd/govulncheck/testdata/common/vulndb-v1/ID/GO-2022-0969.json.gz diff --git a/cmd/govulncheck/testdata/vulndb-v1/index/db.json b/cmd/govulncheck/testdata/common/vulndb-v1/index/db.json similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/index/db.json rename to cmd/govulncheck/testdata/common/vulndb-v1/index/db.json diff --git a/cmd/govulncheck/testdata/vulndb-v1/index/db.json.gz b/cmd/govulncheck/testdata/common/vulndb-v1/index/db.json.gz similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/index/db.json.gz rename to cmd/govulncheck/testdata/common/vulndb-v1/index/db.json.gz diff --git a/cmd/govulncheck/testdata/vulndb-v1/index/modules.json b/cmd/govulncheck/testdata/common/vulndb-v1/index/modules.json similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/index/modules.json rename to cmd/govulncheck/testdata/common/vulndb-v1/index/modules.json diff --git a/cmd/govulncheck/testdata/vulndb-v1/index/modules.json.gz b/cmd/govulncheck/testdata/common/vulndb-v1/index/modules.json.gz similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/index/modules.json.gz rename to cmd/govulncheck/testdata/common/vulndb-v1/index/modules.json.gz diff --git a/cmd/govulncheck/testdata/vulndb-v1/index/vulns.json b/cmd/govulncheck/testdata/common/vulndb-v1/index/vulns.json similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/index/vulns.json rename to cmd/govulncheck/testdata/common/vulndb-v1/index/vulns.json diff --git a/cmd/govulncheck/testdata/vulndb-v1/index/vulns.json.gz b/cmd/govulncheck/testdata/common/vulndb-v1/index/vulns.json.gz similarity index 100% rename from cmd/govulncheck/testdata/vulndb-v1/index/vulns.json.gz rename to cmd/govulncheck/testdata/common/vulndb-v1/index/vulns.json.gz diff --git a/cmd/govulncheck/testdata/modules/strip/go.mod b/cmd/govulncheck/testdata/strip/modules/vuln/go.mod similarity index 100% rename from cmd/govulncheck/testdata/modules/strip/go.mod rename to cmd/govulncheck/testdata/strip/modules/vuln/go.mod diff --git a/cmd/govulncheck/testdata/modules/strip/go.sum b/cmd/govulncheck/testdata/strip/modules/vuln/go.sum similarity index 100% rename from cmd/govulncheck/testdata/modules/strip/go.sum rename to cmd/govulncheck/testdata/strip/modules/vuln/go.sum diff --git a/cmd/govulncheck/testdata/modules/strip/vuln.go b/cmd/govulncheck/testdata/strip/modules/vuln/vuln.go similarity index 100% rename from cmd/govulncheck/testdata/modules/strip/vuln.go rename to cmd/govulncheck/testdata/strip/modules/vuln/vuln.go diff --git a/cmd/govulncheck/testdata/strip/strip.ct b/cmd/govulncheck/testdata/strip/testfiles/binary/strip.ct similarity index 95% rename from cmd/govulncheck/testdata/strip/strip.ct rename to cmd/govulncheck/testdata/strip/testfiles/binary/strip.ct index 9e618093..5d8a6b7a 100644 --- a/cmd/govulncheck/testdata/strip/strip.ct +++ b/cmd/govulncheck/testdata/strip/testfiles/binary/strip.ct @@ -1,6 +1,6 @@ ##### # Test for stripped binaries (see #57764) -$ govulncheck -mode=binary ${strip_binary} --> FAIL 3 +$ govulncheck -mode=binary ${strip_vuln_binary} --> FAIL 3 Scanning your binary for known vulnerabilities... === Symbol Results === diff --git a/cmd/govulncheck/testdata/strip/vulndb-v1/ID/GO-2020-0015.json b/cmd/govulncheck/testdata/strip/vulndb-v1/ID/GO-2020-0015.json new file mode 100644 index 00000000..816c28d2 --- /dev/null +++ b/cmd/govulncheck/testdata/strip/vulndb-v1/ID/GO-2020-0015.json @@ -0,0 +1 @@ +{"schema_version":"1.3.1","id":"GO-2020-0015","modified":"2023-04-03T15:57:51Z","published":"2021-04-14T20:04:52Z","aliases":["CVE-2020-14040","GHSA-5rcv-m4m3-hfh7"],"summary":"Infinite loop when decoding some inputs in golang.org/x/text","details":"An attacker could provide a single byte to a UTF16 decoder instantiated with UseBOM or ExpectBOM to trigger an infinite loop if the String function on the Decoder is called, or the Decoder is passed to transform.String. If used to parse user supplied input, this may be used as a denial of service vector.","affected":[{"package":{"name":"golang.org/x/text","ecosystem":"Go"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"0.3.3"}]}],"ecosystem_specific":{"imports":[{"path":"golang.org/x/text/encoding/unicode","symbols":["bomOverride.Transform","utf16Decoder.Transform"]},{"path":"golang.org/x/text/transform","symbols":["String"]}]}}],"references":[{"type":"FIX","url":"https://go.dev/cl/238238"},{"type":"FIX","url":"https://go.googlesource.com/text/+/23ae387dee1f90d29a23c0e87ee0b46038fbed0e"},{"type":"REPORT","url":"https://go.dev/issue/39491"},{"type":"WEB","url":"https://groups.google.com/g/golang-announce/c/bXVeAmGOqz0"}],"credits":[{"name":"@abacabadabacaba and Anton Gyllenberg"}],"database_specific":{"url":"https://pkg.go.dev/vuln/GO-2020-0015"}} diff --git a/cmd/govulncheck/testdata/strip/vulndb-v1/ID/GO-2020-0015.json.gz b/cmd/govulncheck/testdata/strip/vulndb-v1/ID/GO-2020-0015.json.gz new file mode 100644 index 00000000..2a964529 Binary files /dev/null and b/cmd/govulncheck/testdata/strip/vulndb-v1/ID/GO-2020-0015.json.gz differ diff --git a/cmd/govulncheck/testdata/strip/vulndb-v1/ID/GO-2021-0113.json b/cmd/govulncheck/testdata/strip/vulndb-v1/ID/GO-2021-0113.json new file mode 100644 index 00000000..43d4208d --- /dev/null +++ b/cmd/govulncheck/testdata/strip/vulndb-v1/ID/GO-2021-0113.json @@ -0,0 +1 @@ +{"schema_version":"1.3.1","id":"GO-2021-0113","modified":"2023-04-03T15:57:51Z","published":"2021-10-06T17:51:21Z","aliases":["CVE-2021-38561","GHSA-ppp9-7jff-5vj2"],"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.","affected":[{"package":{"name":"golang.org/x/text","ecosystem":"Go"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"0.3.7"}]}],"ecosystem_specific":{"imports":[{"path":"golang.org/x/text/language","symbols":["MatchStrings","MustParse","Parse","ParseAcceptLanguage"]}]}}],"references":[{"type":"FIX","url":"https://go.dev/cl/340830"},{"type":"FIX","url":"https://go.googlesource.com/text/+/383b2e75a7a4198c42f8f87833eefb772868a56f"}],"credits":[{"name":"Guido Vranken"}],"database_specific":{"url":"https://pkg.go.dev/vuln/GO-2021-0113"}} \ No newline at end of file diff --git a/cmd/govulncheck/testdata/strip/vulndb-v1/ID/GO-2021-0113.json.gz b/cmd/govulncheck/testdata/strip/vulndb-v1/ID/GO-2021-0113.json.gz new file mode 100644 index 00000000..7d63cef9 Binary files /dev/null and b/cmd/govulncheck/testdata/strip/vulndb-v1/ID/GO-2021-0113.json.gz differ diff --git a/cmd/govulncheck/testdata/strip/vulndb-v1/index/db.json b/cmd/govulncheck/testdata/strip/vulndb-v1/index/db.json new file mode 100644 index 00000000..dc248551 --- /dev/null +++ b/cmd/govulncheck/testdata/strip/vulndb-v1/index/db.json @@ -0,0 +1 @@ +{"modified":"2023-04-03T15:57:51Z"} \ No newline at end of file diff --git a/cmd/govulncheck/testdata/strip/vulndb-v1/index/db.json.gz b/cmd/govulncheck/testdata/strip/vulndb-v1/index/db.json.gz new file mode 100644 index 00000000..202f44d1 Binary files /dev/null and b/cmd/govulncheck/testdata/strip/vulndb-v1/index/db.json.gz differ diff --git a/cmd/govulncheck/testdata/strip/vulndb-v1/index/modules.json b/cmd/govulncheck/testdata/strip/vulndb-v1/index/modules.json new file mode 100644 index 00000000..4f7bd87f --- /dev/null +++ b/cmd/govulncheck/testdata/strip/vulndb-v1/index/modules.json @@ -0,0 +1 @@ +[{"path":"golang.org/x/text","vulns":[{"id":"GO-2020-0015","modified":"2023-04-03T15:57:51Z","fixed":"0.3.3"},{"id":"GO-2021-0113","modified":"2023-04-03T15:57:51Z","fixed":"0.3.7"}]}] diff --git a/cmd/govulncheck/testdata/strip/vulndb-v1/index/modules.json.gz b/cmd/govulncheck/testdata/strip/vulndb-v1/index/modules.json.gz new file mode 100644 index 00000000..113a2100 Binary files /dev/null and b/cmd/govulncheck/testdata/strip/vulndb-v1/index/modules.json.gz differ diff --git a/cmd/govulncheck/testdata/strip/vulndb-v1/index/vulns.json b/cmd/govulncheck/testdata/strip/vulndb-v1/index/vulns.json new file mode 100644 index 00000000..a4f660c1 --- /dev/null +++ b/cmd/govulncheck/testdata/strip/vulndb-v1/index/vulns.json @@ -0,0 +1 @@ +[{"id":"GO-2020-0015","modified":"2023-04-03T15:57:51Z","aliases":["CVE-2020-14040","GHSA-5rcv-m4m3-hfh7"]},{"id":"GO-2021-0113","modified":"2023-04-03T15:57:51Z","aliases":["CVE-2021-38561","GHSA-ppp9-7jff-5vj2"]}] diff --git a/cmd/govulncheck/testdata/strip/vulndb-v1/index/vulns.json.gz b/cmd/govulncheck/testdata/strip/vulndb-v1/index/vulns.json.gz new file mode 100644 index 00000000..fa71d33c Binary files /dev/null and b/cmd/govulncheck/testdata/strip/vulndb-v1/index/vulns.json.gz differ