Граф коммитов

1030 Коммитов

Автор SHA1 Сообщение Дата
Zvonimir Pavlinovic 6f169c6e54 cmd/govulncheck: add sarif test for binaries
Updates golang/go#61347

Change-Id: Iae039bb8dbe77cb984e425179bc39eaa2ddc3b8e
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/550736
Reviewed-by: Maceo Thompson <maceothompson@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-25 18:40:23 +00:00
Zvonimir Pavlinovic 3c9f0482c1 internal/sarif: add stacks
Location information will be added later.

Updates golang/go#61347

Change-Id: Ibd6a2f7f6dfd4ac6e333c5de070b76a68e8e462c
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/550735
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
2024-03-25 18:39:34 +00:00
Zvonimir Pavlinovic cb159d5dc4 internal/sarif: add result message
Updates golang/go#61347

Change-Id: Iffc71db2b1256db2a7294619be29a4a6e4ddfc5c
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/550015
Reviewed-by: Maceo Thompson <maceothompson@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-03-25 13:26:22 +00:00
Zvonimir Pavlinovic a06239cc8b internal/vulncheck: get correctly package for instantiated functions
Fixes golang/go#66139

Change-Id: I57812643c78e6cd17415e310567212587978a233
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/570616
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
2024-03-25 13:25:35 +00:00
Zvonimir Pavlinovic 8f863e2f0f internal/sarif: add result stubs to run object
Other information (message, location, and stacks) will be added in
future CLs.

Updates golang/go#61347

Change-Id: I3bb78594372038817e379c16d452ff5159b26efc
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/549995
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-22 18:56:11 +00:00
Zvonimir Pavlinovic c26f8bc516 internal/govulncheck: add scan mode to config
This makes config more self-contained and will help make sarif support
cleaner.

Also update help with default values for scan mode and level to be
consistent while at it.

Updates golang/go#61347

Change-Id: I6fc8d3dcd82f7843b54b704a9bdcc02352eeeeaa
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/567455
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
2024-03-22 16:28:16 +00:00
Zvonimir Pavlinovic d26ab060e8 internal/vulncheck: delete only synthetic nodes not related to generics
Change-Id: Ibbfae4da2156ed2153067eba8a526fdfed64ea35
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/570615
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-03-13 17:26:28 +00:00
Zvonimir Pavlinovic d04103f34c internal/scan: add more info to validation errors
Updates golang/go#66139

Change-Id: I3a7eb8ea6a653802740f6ccb2b6449f929da6e67
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/570575
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
2024-03-11 19:11:34 +00:00
Zvonimir Pavlinovic 563994f085 internal/sarif: add rules
Also add a summary to one of the vulndb entries. This actually improves
testing coverage for both govulncheck text and sarif.

Updates golang/go#61347

Change-Id: Id851d6015daf350908b433c56853daf75f1240fb
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/549815
Reviewed-by: Maceo Thompson <maceothompson@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-07 14:56:51 +00:00
Zvonimir Pavlinovic 7644235270 internal/scan: fix name of the error variable
So that staticcheck does not complain.

Change-Id: I6783ba93aabf627d9453e33604da5d29e05ac3df
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/569635
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Auto-Submit: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
2024-03-06 22:14:14 +00:00
Zvonimir Pavlinovic b51a8ac362 internal/sarif: add handler
The handler keeps track of the most precise findings for a
vulnerability.

Updates golang/go#61347

Change-Id: I8fe8183826f152d8d51d9e5b3117cd192012fdba
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/549775
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
2024-03-06 21:45:38 +00:00
Zvonimir Pavlinovic 334df71c24 internal/scan: add sarif flag
But don't document it.

Updates golang/go#61347

Change-Id: Iac4aef93c3e74a235f646b101feea2b1c62769ac
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/549376
Reviewed-by: Maceo Thompson <maceothompson@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-06 21:45:13 +00:00
Zvonimir Pavlinovic 0c4448e1ec internal/scan: add types for format, show, mode, and scan flags
This results in a better distribution of work since validation can be
done at the point when the flags are set. As a downside, it results in
printing usage message on parse failure.

Change-Id: I7befd7ad628e2f7587ee5185cab01068c2db4610
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/564895
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
2024-03-06 21:44:10 +00:00
Gopher Robot cc62404b8c go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I8e4bb8e01742bc0fbfe2d38ffec6906c5d44c03f
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/569016
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-03-05 16:02:16 +00:00
Zvonimir Pavlinovic 450a31aeb0 internal/vulncheck: use proper stdlib check when loading packages
Since we have IsStdPackage and we use it elsewhere, we should also use
it here. Moreover, this is a more complete check. Some stdlib packages
will have (vendor) copies of x repos and those packages will have a path
that contains a dot.

Change-Id: I029992042b4aaaf8567f0a92c0489bb4b93282da
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/568275
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
2024-03-04 20:48:18 +00:00
Zvonimir Pavlinovic 77c3f530c9 internal/vulncheck,internal/scan: sort messages where needed
JSON output does not promise the order of messages. Text output wants
some determinism in the output. This CL makes sure then that sorting of
relevant messages is only done when creating text output. This will make
things slightly faster, and more importantly, easier to maintain.
Before, the sorting was done at several different places which is hard
to understand.

Change-Id: I6de03b9d403f8a5fe1106b5e3bdc223401385c93
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/566095
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
2024-03-04 17:59:52 +00:00
Zvonimir Pavlinovic 685e27b965 internal/scan: introduce format flag
The current values are text and json. The latter is compatible with
-json flag that is designated as a legacy flag common to Go tools. This
CL is a precursor to sarif support.

Change-Id: I5a73b224e34c6c7f2798858c818f5f8d8e2437d0
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/564478
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
2024-02-26 19:52:18 +00:00
Zvonimir Pavlinovic bb775576a9 internal/vulncheck: manipulate packages from PackageGraph
Packages obtained by querying PackageGraph are fixed up. Most notably,
this means that stdlib packages will have stdlib module set. We should
then use these packages. We in fact do, at least for the parts that
matter, but this CL tries to refactor code so that is made explicit.

Change-Id: I194b819ec40eba6726a68be7766ec220b80ec2f8
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/564155
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-02-15 17:34:48 +00:00
Zvonimir Pavlinovic 27078ae2a1 internal/vulncheck: do not have stdlibModule as global
This creates races and is not needed. vulncheck.PackageGraph will add
stdlibModule as .Module field of packages. We hence do not need to save
it separately.

Change-Id: I9fe800d16586c31c2813c69dc1c6945e1148154a
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/564018
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
2024-02-15 16:03:44 +00:00
Zvonimir Pavlinovic 2dec233613 cmd/govulncheck: make sure filepath are cross-platform
As of recent changes, our tests will produce relative paths. They can be
different depending on the system. This will make builders fail and,
more importantly, make govulncheck JSON non-portable. This CL makes sure
all paths use slashes.

Change-Id: I16ef56cfbdd5d762a5dd3d5ca5d7f66bbad021b5
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/564095
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2024-02-15 14:28:05 +00:00
Zvonimir Pavlinovic 08ad966e7b internal/govulncheck: fix up some comments
Change-Id: I13b0dacfcd48d2bf71daeb39507dad34a764ee0d
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/563755
Reviewed-by: Maceo Thompson <maceothompson@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
2024-02-13 19:29:33 +00:00
Zvonimir Pavlinovic 06a69c43ff internal/vulncheck: add relative paths for vendored paths
packages.Load does not provide a path for a module if the module is
vendored. Vendored package and file paths are available so we
reconstruct the vendored module directory from them.

Change-Id: I75784a358e74c6c413b0e6d89e6bfc599a46efe0
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/559535
Reviewed-by: Maceo Thompson <maceothompson@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
2024-02-13 18:56:03 +00:00
Zvonimir Pavlinovic 26c8e26cfe internal/vulncheck: emit relative paths for call findings
The paths are relative subject to their module or standard library.

Change-Id: I780589c9cf1949cc4c9545246952116f0a52876b
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/558615
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2024-02-13 17:00:02 +00:00
Zvonimir Pavlinovic dcac2d7cab internal/vulncheck, internal/scan: improve stdlib reporting
This CL addresses several issues:
- stdlib findings were never emitted on module level. The Package field
  was always set. This is inconsistent and sometimes wrong. When ran in
  -scan=module mode, the Package would be set to a first package path
  that exists in OSV, although that package would might not even be
  imported.
- stdlib findings at package level were never presented in -scan=package
  mode. govulncheck text would say that the stdlib package is not
  imported although in fact it might be.

This CL also puts stdlib-specific test files in their own folder.

Change-Id: Ia496f64757da194aeb2fe0c0ecdd699e87e08e4b
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/562778
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-13 14:39:41 +00:00
Gopher Robot 1009a55b46 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: Ia5522ac82488daeba25cba3e863db9607bd307b5
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/563555
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-02-13 14:33:37 +00:00
Zvonimir Pavlinovic e17f629f30 all: remove bash checks
The only check left in checks.bash is now a check that performs static
analysis of shell scripts. But we don't really have any useful shell
scripts apart from checks.bash itself. The snapshot_vulndb.sh could be
useful but it has not been used in a long time and it does not really
need static analysis: its failure would reflect in unit tests.

We hence delete all shell scripts and code that invokes them.

Change-Id: I58570f0b65487ef31b3382ab76e110e1f2b53605
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/563055
Reviewed-by: Maceo Thompson <maceothompson@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-02-12 17:28:11 +00:00
Zvonimir Pavlinovic 60e1cce05e all: do go mod tidy test inside unit tests
Better to do it here, instead of shell.

Fixes golang/go#59871

Change-Id: I6e774715e7947f6e8134cf34e4c8c371ba633949
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/563035
Reviewed-by: Maceo Thompson <maceothompson@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-12 17:27:28 +00:00
Zvonimir Pavlinovic 5507063454 cmd/govulncheck: mask line numbers and columns
These can in principle change for stdlib. Although we always pretend we
are running against go1.18, the actual stdlib underneath can be
different. This could result in different line numbers and columns.
There currently does not exist a clean way of masking line position for
stdlib paths, so we mask everything with placeholders.

Change-Id: I08628acbf10aa3f36b969bac5745ae3b4d52f284
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/562215
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
2024-02-06 19:26:49 +00:00
Zvonimir Pavlinovic c154f6ab18 internal/scan: remove redundant new lines
An extra new line is added when either 1) there is no summary of "other"
vulnerabilities found or 2) no suggestion. This CL removes those lines.

Change-Id: Ic6ab8c3a4b8ab193fdcd88e4afe65ab42a9a1794
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/562055
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-02-06 16:30:10 +00:00
Zvonimir Pavlinovic 0b50c25208 internal/vulncheck: add position for sinks in findings' trace
The sink is the vulnerable function. Before, we wouldn't show anything
as we are only showing positions of calls. Now, we include the position
where the vulnerable symbol is defined.

This will not have effect on default text output. It will though on
-show traces output. The main beneficiary of this change are integration
points that will now be able to jump to the definition of the
vulnerable symbol.

Change-Id: Ie156bf5d05dc1c743f118f4d14dba6e2c263549b
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/559275
Reviewed-by: Maceo Thompson <maceothompson@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-02-06 16:18:28 +00:00
Zvonimir Pavlinovic f50d9a688b internal/scan: put -show <option> into single quotes
This establishes a convention where we wrap examples and mentions of
flag usage into single quotes to indicate proper usage. For instance,
this indicates that the verbose mode is triggered when both `-show`
and `verbose` are used at the same time one after another. The same goes
for other flags, such as scan.

Change-Id: I45cdc6499f9203d0ef73246cb8985c7b420cfacd
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/560815
Reviewed-by: Maceo Thompson <maceothompson@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
2024-02-05 23:42:38 +00:00
Zvonimir Pavlinovic c02416c8c7 internal/buildinfo: do module-level analysis with no PCLN table
No PCLN table means we just have buildinfo, which is exactly the same
scenario as when the binary is stripped. We should hence support it.

Fixes golang/go#59731

Change-Id: Ib6dd072f4827bc98bbbe5e686c81b5d72246a58b
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/560375
Reviewed-by: Maceo Thompson <maceothompson@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2024-02-05 19:55:16 +00:00
Zvonimir Pavlinovic 3b6ac80fe4 internal/scan: add a newline after summary
Otherwise, command prompt and the summary are at the same line.

Change-Id: Ic3f132d16b918e3ac37b1284c83672c2dd1fb3c8
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/560377
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-02-05 19:44:07 +00:00
Zvonimir Pavlinovic fadf1fa8c2 internal/test: add more info on GoBuild failures
Updates golang/go#59767

Change-Id: I314db4e5837031210fe7b52630898b88d044b7a6
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/560376
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-02-05 19:33:51 +00:00
Zvonimir Pavlinovic c28edb3d30 internal/scan: remove extra dot in a comment
Change-Id: I70cf7c23106578e40c3e344d21f5bf55869e219f
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/559538
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
2024-02-05 19:33:42 +00:00
Maceo Thompson 1c2c5f6965 cmd/govulncheck: fix vendor test
Fixes a capitalization error from some git weirdness, causing vendor
mode tests to break.

Change-Id: I1459391f17dfb73cfd1a6cb7e2d2f8a1f8e7f838
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/561475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2024-02-05 19:24:42 +00:00
Zvonimir Pavlinovic 95961a44ba internal/vulncheck: refactor a loop with an append
This makes staticcheck happy and resolves builders' failures.

Change-Id: I90c0aa18ee7ca35fd18879d1d4dd5b6c9b0bcfa1
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/560335
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-05 17:26:28 +00:00
Maceo Thompson 7c6930921d cmd/govulncheck: fix stripped bin test
This change fixes the stripped binary test - previously it was not
actually being run. The test is now updated to match the proper text
output.

Change-Id: I71d72c3eddf389a480fb2d3960e127ff5d672daf
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/559975
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2024-02-05 17:16:39 +00:00
Maceo Thompson 3e072daead cmd/govulncheck: update vendor tests
This change adds a private module to the vendored module, to better test
the edge case referenced in issue #65124

Change-Id: I54541bca826f99d609ba5801d23c3c801ee7056b
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/557858
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2024-01-31 22:15:42 +00:00
Zvonimir Pavlinovic 3fe4ad4114 cmd/govulncheck: add more tests and reorganize them
This is to make the test dir structure and naming more consistent.

Change-Id: I1a0602689c0c36eaf4863c174d104138837c1983
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/559175
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
2024-01-31 21:48:34 +00:00
Zvonimir Pavlinovic e215a3d102 internal/vulncheck: add package and module mode for binaries
The code for binary now is structuraly the same as for source.

Change-Id: I1601bb8ccb804a39dbfb28cfe5524e9462e2f5b4
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/558879
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
2024-01-31 21:29:26 +00:00
Zvonimir Pavlinovic a62a153a25 internal/scan: replace Source with Symbol in text output
This matches the agreed design where each text section is named after
the mode. Also, this makes more sense when printing results for
binaries.

Change-Id: Iaa950cf5eb1c4e07b07eb1e0f7f32b23f6b168e3
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/559537
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-01-31 19:40:09 +00:00
Zvonimir Pavlinovic 792b8f64b1 internal/scan: fix error statuses for scan={package|module}
The exit status should indicate that vulnerabilities are found if
govulncheck detects an import of a vulnerability in packages mode and
require of a vulnerability in modules mode.

Change-Id: If1e8b0c757875a2fc1bae1ed1eaa71a484dba9ef
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/558876
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
2024-01-31 15:05:22 +00:00
Maceo Thompson d5a21a7e09 internal/scan: add -show verbose flag
This change adds the -show verbose flag. This makes it so that by
default, govulncheck will only show vuln information for it's given scan
level. For example, by default it will only show information for called
vulnerabilities. See go/govulnchecktext for more info.

Change-Id: Ifb078780501c850f1f049278573733bbf302d752
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/557738
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2024-01-30 20:28:30 +00:00
Maceo Thompson 41c590b92d internal/scan: overhaul text output
This change updates the text output to be more organized and to better
differentiate between vulnerabilities that are definitely called and
vulnerabilities govulncheck thinks it can discard.
See go/govulnchecktext for more info

Change-Id: Ifcd25cf78447b5150cc77c49f753960ee644b6f0
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/557737
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-01-30 20:28:17 +00:00
Zvonimir Pavlinovic 4a6fd77d87 internal/scan: simplify redundant error checking
Change-Id: I9b5eabf84e97d2b4c1df1047cb232cfed529d433
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/558616
Reviewed-by: Maceo Thompson <maceothompson@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-01-29 17:50:36 +00:00
Maceo Thompson 37a5d4f246 internal/scan: add scan level to testdata
Adds scan_level to the config for the json in testdata to better reflect
the structure of the json that the text handler actually receives. This
will become necessary as the text handler uses scan level in its config.

Change-Id: Ifa26b94529899d3b0f9d344d2e38adf46a8e8683
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/557736
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2024-01-24 21:35:46 +00:00
Zvonimir Pavlinovic b8b5a5b575 cmd/govulncheck/integration: update expectations for stackrox
Vuln db added entries for go-git and stackrox is using is at version
5.6.1.

Change-Id: I69a975db87ec88d7ef280eea13f74575fac8aa4c
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/557955
Reviewed-by: Maceo Thompson <maceothompson@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-01-23 21:06:23 +00:00
Zvonimir Pavlinovic ad01a21008 internal/vulncheck: support osv entries with no pkg info
These are interpreted as if all symbols of the module are vulnerable.

Change-Id: I150d7a62bfdf76d1ab3de5c04c384d52484983c3
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/556736
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
2024-01-23 20:14:00 +00:00
Zvonimir Pavlinovic 0be6bb8254 internal/vulncheck: remove redundant symbol check
OSV applies to a vulnerable symbol if ecosystem specific contains an
entry for the symbol's package and the symbol is affected. ForSymbol
makes that connection. We don't need to check for this again later.

Change-Id: I63f9098b74a5b6243afeea8b53c9003bc48f565f
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/556735
Reviewed-by: Maceo Thompson <maceothompson@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-01-23 20:01:08 +00:00