diff --git a/gopls/internal/regtest/misc/vuln_test.go b/gopls/internal/regtest/misc/vuln_test.go index 78c193efa0..91fef3f88b 100644 --- a/gopls/internal/regtest/misc/vuln_test.go +++ b/gopls/internal/regtest/misc/vuln_test.go @@ -109,7 +109,7 @@ func main() { Arguments: lens.Command.Arguments, }, nil) env.Await( - CompletedWork("Checking vulnerability", 1, true), + CompletedWork("govulncheck", 1, true), // TODO(hyangah): once the diagnostics are published, wait for diagnostics. ShownMessage("Found GO-0000-001"), ) diff --git a/gopls/internal/vulncheck/command.go b/gopls/internal/vulncheck/command.go index b84daa5d9f..60d582ca31 100644 --- a/gopls/internal/vulncheck/command.go +++ b/gopls/internal/vulncheck/command.go @@ -70,29 +70,30 @@ type cmd struct { // Run runs the govulncheck after loading packages using the provided packages.Config. func (c *cmd) Run(ctx context.Context, cfg *packages.Config, patterns ...string) (_ []Vuln, err error) { + logger := log.New(log.Default().Writer(), "", 0) cfg.Mode |= packages.NeedModule | packages.NeedName | packages.NeedFiles | packages.NeedCompiledGoFiles | packages.NeedImports | packages.NeedTypes | packages.NeedTypesSizes | packages.NeedSyntax | packages.NeedTypesInfo | packages.NeedDeps - log.Println("loading packages...") + logger.Println("loading packages...") loadedPkgs, err := gvc.LoadPackages(cfg, patterns...) if err != nil { - log.Printf("package load failed: %v", err) + logger.Printf("package load failed: %v", err) return nil, err } - log.Printf("analyzing %d packages...\n", len(loadedPkgs)) + logger.Printf("analyzing %d packages...\n", len(loadedPkgs)) r, err := vulncheck.Source(ctx, loadedPkgs, &vulncheck.Config{Client: c.Client, SourceGoVersion: goVersion()}) if err != nil { return nil, err } - log.Printf("selecting affecting vulnerabilities from %d findings...\n", len(r.Vulns)) + logger.Printf("selecting affecting vulnerabilities from %d findings...\n", len(r.Vulns)) unaffectedMods := filterUnaffected(r.Vulns) r.Vulns = filterCalled(r) - log.Printf("found %d vulnerabilities.\n", len(r.Vulns)) + logger.Printf("found %d vulnerabilities.\n", len(r.Vulns)) callInfo := gvc.GetCallInfo(r, loadedPkgs) return toVulns(callInfo, unaffectedMods) // TODO: add import graphs. diff --git a/internal/lsp/command.go b/internal/lsp/command.go index 1d6c973212..35bc0e4328 100644 --- a/internal/lsp/command.go +++ b/internal/lsp/command.go @@ -807,7 +807,7 @@ func (c *commandHandler) RunVulncheckExp(ctx context.Context, args command.Vulnc } err := c.run(ctx, commandConfig{ async: true, // need to be async to be cancellable - progress: "Checking vulnerability", + progress: "govulncheck", requireSave: true, forURI: args.URI, }, func(ctx context.Context, deps commandDeps) error {