internal/worker: remove VTAStacks mode
Change-Id: I55b36c98fbeddb77ccc3c03bb38c47475c8012fa
Reviewed-on: https://go-review.googlesource.com/c/pkgsite-metrics/+/474555
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/cmd/vulncheck_sandbox/vulncheck_sandbox.go b/cmd/vulncheck_sandbox/vulncheck_sandbox.go
index 44bc035..22eea84 100644
--- a/cmd/vulncheck_sandbox/vulncheck_sandbox.go
+++ b/cmd/vulncheck_sandbox/vulncheck_sandbox.go
@@ -124,10 +124,6 @@
if err != nil {
return nil, err
}
- if mode == worker.ModeVTAStacks {
- // Do this for call graph analysis.
- _ = vulncheck.CallStacks(res)
- }
return res, nil
}
diff --git a/cmd/vulncheck_sandbox/vulncheck_sandbox_test.go b/cmd/vulncheck_sandbox/vulncheck_sandbox_test.go
index 57c68b0..ec4800b 100644
--- a/cmd/vulncheck_sandbox/vulncheck_sandbox_test.go
+++ b/cmd/vulncheck_sandbox/vulncheck_sandbox_test.go
@@ -36,7 +36,7 @@
}
t.Run("source", func(t *testing.T) {
- res, err := runTest([]string{worker.ModeVTAStacks, "testdata/module"}, "testdata/vulndb")
+ res, err := runTest([]string{worker.ModeImports, "testdata/module"}, "testdata/vulndb")
if err != nil {
t.Fatal(err)
}
@@ -74,7 +74,7 @@
},
{
name: "no vulndb",
- args: []string{worker.ModeVTAStacks, "testdata/module"},
+ args: []string{worker.ModeImports, "testdata/module"},
vulndb: "does not exist",
want: "no such file",
},
@@ -86,7 +86,7 @@
},
{
name: "no module",
- args: []string{worker.ModeVTAStacks, "testdata/nosuchmodule"},
+ args: []string{worker.ModeImports, "testdata/nosuchmodule"},
vulndb: "testdata/vulndb",
want: "no such file",
},
diff --git a/internal/worker/vulncheck_enqueue.go b/internal/worker/vulncheck_enqueue.go
index 6f80a36..96ab8c2 100644
--- a/internal/worker/vulncheck_enqueue.go
+++ b/internal/worker/vulncheck_enqueue.go
@@ -100,8 +100,8 @@
func vulncheckMode(mode string) (string, error) {
if mode == "" {
- // VTAStacks is the default mode
- return ModeVTAStacks, nil
+ // ModeGovulncheck is the default mode.
+ return ModeGovulncheck, nil
}
mode = strings.ToUpper(mode)
if _, ok := modes[mode]; !ok {
diff --git a/internal/worker/vulncheck_enqueue_test.go b/internal/worker/vulncheck_enqueue_test.go
index befea8b..b5e18ac 100644
--- a/internal/worker/vulncheck_enqueue_test.go
+++ b/internal/worker/vulncheck_enqueue_test.go
@@ -59,14 +59,14 @@
}
params := &ivulncheck.EnqueueQueryParams{Min: 8, File: "testdata/modules.txt"}
- gotTasks, err := createVulncheckQueueTasks(context.Background(), &config.Config{}, params, []string{ModeVTAStacks})
+ gotTasks, err := createVulncheckQueueTasks(context.Background(), &config.Config{}, params, []string{ModeGovulncheck})
if err != nil {
t.Fatal(err)
}
wantTasks := []queue.Task{
- vreq("github.com/pkg/errors", "v0.9.1", ModeVTAStacks, 10),
- vreq("golang.org/x/net", "v0.4.0", ModeVTAStacks, 20),
+ vreq("github.com/pkg/errors", "v0.9.1", ModeGovulncheck, 10),
+ vreq("golang.org/x/net", "v0.4.0", ModeGovulncheck, 20),
}
if diff := cmp.Diff(wantTasks, gotTasks, cmp.AllowUnexported(ivulncheck.Request{})); diff != "" {
t.Errorf("mismatch (-want, +got):\n%s", diff)
@@ -82,7 +82,7 @@
}
wantTasks = nil
// cfg.BinaryBucket is empty, so no binary-mode tasks are created.
- for _, mode := range []string{ModeGovulncheck, ModeImports, ModeVTAStacks} {
+ for _, mode := range []string{ModeGovulncheck, ModeImports} {
wantTasks = append(wantTasks,
vreq("github.com/pkg/errors", "v0.9.1", mode, 10),
vreq("golang.org/x/net", "v0.4.0", mode, 20))
@@ -100,8 +100,8 @@
want []string
wantErr bool
}{
- {"", true, []string{ModeBinary, ModeGovulncheck, ModeImports, ModeVTAStacks}, false},
- {"", false, []string{ModeVTAStacks}, false},
+ {"", true, []string{ModeBinary, ModeGovulncheck, ModeImports}, false},
+ {"", false, []string{ModeGovulncheck}, false},
{"imports", false, []string{ModeImports}, false},
{"imports", true, nil, true},
} {
diff --git a/internal/worker/vulncheck_scan.go b/internal/worker/vulncheck_scan.go
index 10bc700..a71050c 100644
--- a/internal/worker/vulncheck_scan.go
+++ b/internal/worker/vulncheck_scan.go
@@ -37,14 +37,6 @@
)
const (
- // ModeVTAStacks computes vulnerability call graph
- // and representative call stacks for each
- // vulnerability. Closely resembles the actual logic
- // of govulncheck.
- //
- // ModeVTAStacks is default vulncheck mode.
- ModeVTAStacks string = "VTASTACKS"
-
// ModeImports only computes import-level analysis.
ModeImports string = "IMPORTS"
@@ -58,7 +50,6 @@
// modes is a set of supported vulncheck modes
var modes = map[string]bool{
ModeImports: true,
- ModeVTAStacks: true,
ModeBinary: true,
ModeGovulncheck: true,
}
@@ -88,7 +79,7 @@
return fmt.Errorf("%w: %v", derrors.InvalidArgument, err)
}
if sreq.Mode == "" {
- sreq.Mode = ModeVTAStacks
+ sreq.Mode = ModeGovulncheck
}
if shouldSkip[sreq.Module] {
log.Infof(ctx, "skipping %s (module in shouldSkip list)", sreq.Path())
@@ -553,11 +544,6 @@
if err != nil {
return res, err
}
- if mode == ModeVTAStacks {
- log.Debugf(ctx, "running vulncheck.CallStacks: %s@%s", modulePath, version)
- vulncheck.CallStacks(res)
- log.Debugf(ctx, "completed run for vulncheck.CallStacks: %s@%s, err=%v", modulePath, version, err)
- }
return res, nil
})
// scanMemory is peak heap memory used during vulncheck + pkgs.
diff --git a/internal/worker/vulncheck_scan_test.go b/internal/worker/vulncheck_scan_test.go
index 8a4c7dd..4e8caaa 100644
--- a/internal/worker/vulncheck_scan_test.go
+++ b/internal/worker/vulncheck_scan_test.go
@@ -54,7 +54,7 @@
stats := &vulncheckStats{}
vulns, err := s.runScanModule(ctx,
"golang.org/x/exp/event", "v0.0.0-20220929112958-4a82f8963a65",
- "", ModeVTAStacks, stats)
+ "", ModeGovulncheck, stats)
if err != nil {
t.Fatal(err)
}
@@ -79,7 +79,7 @@
t.Run("memoryLimit", func(t *testing.T) {
s := &scanner{proxyClient: proxyClient, dbClient: dbClient, insecure: true, goMemLimit: 2000}
_, err := s.runScanModule(ctx, "golang.org/x/mod", "v0.5.1",
- "", ModeVTAStacks, &vulncheckStats{})
+ "", ModeGovulncheck, &vulncheckStats{})
if !errors.Is(err, derrors.ScanModuleMemoryLimitExceeded) {
t.Errorf("got %v, want MemoryLimitExceeded", err)
}