internal/scan, vulncheck: use packages.load for mod info

Govulncheck previously used go list to get mod info, which does not work
in modules with a vendor directory. Therefore, module information needs
to be extracted from package information instead.

There is one change to the behavior of govulncheck ran in module mode in
a certain edge case: if one runs govulncheck with the ./... package
pattern in a subdirectory of a module, govulncheck will only show the
vulnerabilities affecting that subdirectory as opposed to the entire
module. This does not affect govulncheck default behavior nor the
behavior of govulncheck when ran from the root of a module at any scan
level.

Fixes golang/go#65124

Change-Id: Ie3b0cb0b9486fb94efeb05ee0c76d19c9f595877
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/557495
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
10 files changed
tree: 8e6fb2ccb0b5cdd840195b51f8b2ae646cb2df1c
  1. cmd/
  2. devtools/
  3. doc/
  4. internal/
  5. scan/
  6. .gitignore
  7. all_test.go
  8. checks.bash
  9. CONTRIBUTING.md
  10. go.mod
  11. go.sum
  12. LICENSE
  13. PATENTS
  14. README.md
README.md

Go Vulnerability Management

Go Reference

Go's support for vulnerability management includes tooling for analyzing your codebase and binaries to surface known vulnerabilities in your dependencies. This tooling is backed by the Go vulnerability database, which is curated by the Go security team. Go’s tooling reduces noise in your results by only surfacing vulnerabilities in functions that your code is actually calling.

You can install the latest version of govulncheck using go install

go install golang.org/x/vuln/cmd/govulncheck@latest

Then, run govulncheck inside your module:

govulncheck ./...

See the govulncheck tutorial to get started, and https://go.dev/security/vuln for more information about Go's support for vulnerability management. The API documentation can be found at https://pkg.go.dev/golang.org/x/vuln/scan.

Privacy Policy

The privacy policy for govulncheck can be found at https://vuln.go.dev/privacy.

License

Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.

Database entries available at https://vuln.go.dev are distributed under the terms of the CC-BY 4.0 license.