mirror of https://github.com/golang/go.git
internal/lsp: polish vulncheck progress messages
gopls.run_vulncheck_exp runs `gopls vulncheck` (fork of govulncheck) and pipes its stderr (logs) as progress messages. The default log format includes timestamp and that is too long for progress message. Tell gopls vulncheck to omit timestamp in the log message. Use "govulncheck" as the progress message prefix, instead of the long "Checking vulnerabilities". Change-Id: I92fe9958b20d0260711a42af9b5f9f399e267587 Reviewed-on: https://go-review.googlesource.com/c/tools/+/420998 Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Suzy Mueller <suzmue@golang.org> Reviewed-by: Jamal Carvalho <jamal@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
af2a0a8167
commit
81c7dc4e4e
|
|
@ -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"),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue