internal/vulncheck: remove use of ssautil.AllFunctions
This function was used to prune out the forward slice of functions
starting from roots. There weren't a lot of functions being pruned.
Measured on a few large projects, at most 0.08% of functions were
pruned. Keeping those functions is not expected to affect precision
or performance. Calling VTA two times will very likely get rid of
these functions anyhow.
Updates golang/go#69231
Change-Id: Id57f9697c5a5550b4d15fbeb88de30b8bee220da
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/611216
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
diff --git a/internal/vulncheck/slicing.go b/internal/vulncheck/slicing.go
index 71fffc4..0bfa160 100644
--- a/internal/vulncheck/slicing.go
+++ b/internal/vulncheck/slicing.go
@@ -44,12 +44,3 @@
}
return seen
}
-
-// pruneSet removes functions in `set` that are in `toPrune`.
-func pruneSet(set, toPrune map[*ssa.Function]bool) {
- for f := range set {
- if !toPrune[f] {
- delete(set, f)
- }
- }
-}
diff --git a/internal/vulncheck/utils.go b/internal/vulncheck/utils.go
index dcfc9cd..e752f4a 100644
--- a/internal/vulncheck/utils.go
+++ b/internal/vulncheck/utils.go
@@ -16,7 +16,6 @@
"golang.org/x/tools/go/callgraph/cha"
"golang.org/x/tools/go/callgraph/vta"
"golang.org/x/tools/go/packages"
- "golang.org/x/tools/go/ssa/ssautil"
"golang.org/x/tools/go/types/typeutil"
"golang.org/x/vuln/internal"
"golang.org/x/vuln/internal/osv"
@@ -71,12 +70,8 @@
return nil, err
}
initial := cha.CallGraph(prog)
- allFuncs := ssautil.AllFunctions(prog)
fslice := forwardSlice(entrySlice, initial)
- // Keep only actually linked functions.
- pruneSet(fslice, allFuncs)
-
if err := ctx.Err(); err != nil { // cancelled?
return nil, err
}
@@ -85,8 +80,6 @@
// Repeat the process once more, this time using
// the produced VTA call graph as the base graph.
fslice = forwardSlice(entrySlice, vtaCg)
- pruneSet(fslice, allFuncs)
-
if err := ctx.Err(); err != nil { // cancelled?
return nil, err
}