mirror of https://github.com/golang/go.git
gopls/internal/govulncheck: sync x/vuln@b9a3ad9
For golang/go#53869 Change-Id: I8cf795b792380596be306b2437e26faf990cff8b Reviewed-on: https://go-review.googlesource.com/c/tools/+/418537 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> Run-TryBot: Jamal Carvalho <jamal@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
a732e45cc7
commit
126ef8f864
|
|
@ -15,3 +15,5 @@ The `copy.sh` does the copying, after removing all .go files here. To use it:
|
|||
2. cd to this directory.
|
||||
|
||||
3. Run `copy.sh`.
|
||||
|
||||
4. Re-add build tags for go1.18
|
||||
|
|
@ -8,13 +8,11 @@
|
|||
package govulncheck
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/tools/go/packages"
|
||||
"golang.org/x/vuln/client"
|
||||
"golang.org/x/vuln/vulncheck"
|
||||
)
|
||||
|
||||
|
|
@ -57,26 +55,6 @@ func LoadPackages(cfg *packages.Config, patterns ...string) ([]*vulncheck.Packag
|
|||
return vpkgs, err
|
||||
}
|
||||
|
||||
// Source calls vulncheck.Source on the Go source in pkgs. It returns the result
|
||||
// with Vulns trimmed to those that are actually called.
|
||||
//
|
||||
// This function is being used by the Go IDE team.
|
||||
func Source(ctx context.Context, pkgs []*vulncheck.Package, c client.Client) (*vulncheck.Result, error) {
|
||||
r, err := vulncheck.Source(ctx, pkgs, &vulncheck.Config{Client: c})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Keep only the vulns that are called.
|
||||
var vulns []*vulncheck.Vuln
|
||||
for _, v := range r.Vulns {
|
||||
if v.CallSink != 0 {
|
||||
vulns = append(vulns, v)
|
||||
}
|
||||
}
|
||||
r.Vulns = vulns
|
||||
return r, nil
|
||||
}
|
||||
|
||||
// CallInfo is information about calls to vulnerable functions.
|
||||
type CallInfo struct {
|
||||
// CallStacks contains all call stacks to vulnerable functions.
|
||||
|
|
|
|||
Loading…
Reference in New Issue