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

1030 Коммитов

Автор SHA1 Сообщение Дата
Zvonimir Pavlinovic 76bde25551 internal/vulncheck: simplify vulnerability detection
We do not need to remember which symbols are imported, only packages.
This simplifies code and future CLs. It also avoids mutating Result,
which is anyhow mostly a structure used for testing.

Change-Id: I7412785dc56c9b330138e9e8519f7d8cb79e0cd8
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/556675
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-23 19:57:50 +00:00
Zvonimir Pavlinovic 8fb35e0f9d internal/scan: add binary extract mode
The extract mode spits out a json blob representing the minimal
representation of a Go binary needed for govulncheck vulnerability
detection. binary mode accepts both a Go binary and this representation
as an input.

The contents of extract should be regarded as a blob. The users of this
flag should not rely on its representation. It might change in the
future.

Change-Id: I81027062d34609fed7541ad2092d4cbe5df0d118
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/542035
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-01-22 17:47:54 +00:00
Maceo Thompson 3072335def 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>
2024-01-22 17:36:21 +00:00
Zvonimir Pavlinovic 0047a1615e internal/govulncheck: briefly explain streaming JSON
Fixes golang/go#65132

Change-Id: I627902b737d699f9d52060dcc56219a6f3104b22
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/556116
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>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
2024-01-19 14:28:38 +00:00
Maceo Thompson 4b54a8b06d internal/vulncheck: remove -mod=mod flag from LoadModules
This change is a hotfix removing the -mod=mod flag from the go list
call in LoadModules. A proper fix to support vendor directories will
be coming shortly.

Fixes golang/go#65155
Fixes golang/go#65130

Change-Id: I3faf90227154e019ab70201c9e04a1b185bc5f3a
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/556775
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-01-18 21:35:44 +00:00
Dmitri Shuralyov e313109e39 cmd/govulncheck: update test data
Generated with 'go test -update' for changes introduced by CL 555515.

For golang/go#65084.

Change-Id: I05938ce2755b6acdd42efc3fe9f51a485d8ca405
Cq-Include-Trybots: luci.golang.try:x_vuln-gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/555655
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2024-01-16 17:02:44 +00:00
Gopher Robot d8d123b8cd go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I163d4d41996a98980d7837fa49a6bd9f4b61fdfb
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/555515
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-01-12 13:27:17 +00:00
cui fliter 7335627909 internal/osv: fix type name in comment
Change-Id: I348d3c315b69cf6ac2f8536414d41d4b9bf44bd0
GitHub-Last-Rev: a3d8dad670
GitHub-Pull-Request: golang/vuln#8
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/551135
Reviewed-by: Tim King <taking@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
2023-12-20 04:11:29 +00:00
Zvonimir Pavlinovic 701bd5fa06 internal/scan: remove informational header for package and module mode
It might be confusing and is really not adding any value to the output.

Change-Id: Icb65714f5dd111aa875bd88c4e5925a2cab74a19
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/551378
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-12-19 21:38:56 +00:00
Zvonimir Pavlinovic ae31108ea7 internal/scan: remove redundant newline for package and module mode
Change-Id: If35e3951c20ad3c98f8a940172933acce665e7bd
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/551377
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>
2023-12-19 21:28:02 +00:00
Zvonimir Pavlinovic 9be1a0dbf6 cmd/govulncheck/integration/stackrox: update vuln expectation
This is due to new vuln db entry
https://go-review.git.corp.google.com/c/vulndb/+/550858.

Change-Id: I8859deab4b16c172dbc448946492937915536c9e
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/551136
TryBot-Result: Gopher Robot <gobot@golang.org>
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>
2023-12-19 18:46:41 +00:00
Zvonimir Pavlinovic 58c180b66e all: update tools to pick up bug fixes
Fixes golang/go#64112

Change-Id: Ifc1ab6dc91af02bf42d7ebb113bea4061c58831c
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/549377
Reviewed-by: Tim King <taking@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>
2023-12-14 18:10:03 +00:00
Zvonimir Pavlinovic 53a5385d13 internal/vulncheck: compute proper db names for generic functions
These should not include the type parameter/argument.

Updates golang/go#63535

Change-Id: Iaae0e587d365f7e26e2361c9814fa1d288d8ad86
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/548016
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>
2023-12-13 18:11:15 +00:00
Zvonimir Pavlinovic 864243bd05 internal/vulncheck: improve error message for fetching vulns
Fixes golang/go#64681

Change-Id: Ie65279bd557d9477b62e7aedcf6ec620536e1e18
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/549375
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>
2023-12-13 18:07:00 +00:00
Maceo Thompson bcd8b923d2 testdata: Add more package/mod level tests
Adds package level json tests as well as text output testing fro module
and package level scans.

Change-Id: Idad6ae2214c752fef5750963e1a6c36de7717a97
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/545639
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-13 15:38:03 +00:00
Maceo Thompson 65a36416c4 internal/scan: change text based on scan level
This change modifies the text output of govulncheck depending on the
scan level - specifically omitting assumptions about callstack
information when govulncheck never ran callstack analysis. 

Change-Id: Id3ba3a1c97edb6140f0f00d58d9ae76737fc0ce1
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/545638
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-13 15:37:57 +00:00
Maceo Thompson 7827b5dcb5 internal/scan: update show help message
The help message for the -show flag was incorrect. It now outputs the
correct supported values for -show.

Change-Id: Ib53562f5a663e56fe9972cba75b41b8bda87e1f3
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/549315
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-13 15:37:20 +00:00
Zvonimir Pavlinovic c27f855e01 internal/sarif: add sarif types
Updates golang/go#61347

Change-Id: Ia7690a83b3476d4de843c8d90060812f2d9d0432
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/543875
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
2023-12-05 20:09:30 +00:00
Zvonimir Pavlinovic 244182bca4 internal/scan: enable module scan mode
Source scanning does not accept patterns but we jump out early if
patterns are not present. We change this here.

Change-Id: I48557f6f8202b1e8409cbb5f8c91b3d48e1edaee
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/546575
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>
2023-12-01 19:54:08 +00:00
Maceo Thompson 5d9f62b9ff internal/scan: add scan_level to text tests
This change adds scan_level to the config of the json input to the
textHandler tests. This more closely mirrors the actual JSON that the
govulncheck text handler receives.

Change-Id: Ie7438572dffe75cb3c1e94b40c3fbc8a27715755
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/545637
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2023-11-30 19:26:27 +00:00
Maceo Thompson a5e767d85a internal/scan: add scan level to textHandler
This change adds scan level to the text handler, which will allow us to
change messages depending on the amount of information govulncheck has
available to it. For example, it will allow govulncheck to not mention
callstacks if it never ran callstack analysis.

Change-Id: I9dccd5b0445dddfd8c071bf266ab9eecb0bd0d5e
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/545636
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-30 19:25:56 +00:00
Maceo Thompson 75c1acc71f cmd/govulncheck: rearrange test files
Though this is slightly less organized (no longer dividing certain test
dirs into spearate json/text directories), it fixes a bug where those
tests weren't being ran. This is because `cmdtest.Read` globs on files
matching the pattern *.ct, meaning it doesn't search recursively for .ct
files. It also doesn't allow appending more tests to the test suite, so
it isn't possible to scan both a single directory wildcard (dir/*) and
the multiple directory case (dir/*/*).

This isn't the most ideal change, but all JSON tests end with _json.ct,
so they're still relatively human readable.

Change-Id: Ib0d55a3591535c3bb973af391359b1071722c4a0
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/545635
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-30 19:25:46 +00:00
Zvonimir Pavlinovic d953cce8a3 all: add logging to TestGovulncheck
Fixes golang/go#64254

Change-Id: If3b5280fbb239981dec38035c5e2f0ad5f5c6fd7
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/545335
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-30 17:20:57 +00:00
Maceo Thompson 25985ceb20 internal/scan: disallow package input in mod level
Throws an error when the user attempts to input a package path when
running govulncheck with -scan=module.

Change-Id: I97c6dd32c027a42e1bd4b3edd8e1bea90b447888
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/544595
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-28 21:12:38 +00:00
Gopher Robot 008d02098f go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: Icc611c62cc55217bc0e07d64f6e89cb2a45ef274
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/545180
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-27 19:07:27 +00:00
Maceo Thompson d51afa664d cmd/govulncheck: fix mod level behavior
Fixes a bug where govulncheck would incorrectly state that there were no
packages found matching the provided pattern when ran with the
-scan=module flag.
Additionally, this change adds base regression tests to ensure that:
1. Module level scanning short circuits before emitting more granular
   findings
2. Module level scanning still emits the same osvs as source level

Adds tests to ensure that module level scans behave as
expected. Further tests will be added for edge cases.

Change-Id: I144a785c416501e84c0f089c40456cebd7738456
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/543162
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2023-11-22 17:16:58 +00:00
Tim King 286bb05c5f all: update to x/tools@v.15.0
go get golang.org/x/tools@v0.15.0
go mod tidy

Change-Id: Ie77e7c0519d22e4a5d1b6d1402a64e3859f2cd87
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/544295
Run-TryBot: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-21 20:23:18 +00:00
Zvonimir Pavlinovic 4ce2d83134 internal/vulncheck: define Binary over Bin
This simplifies tests for binary and forces us to move other tests to
more appropriate places. Further, internal/scan will use it to load
inputs from a new binary extract mode. For the same reason, also make
the stdlib runtime copies available in internal. This also makes them
more visible.

Change-Id: If01cbdd59112609ff16f712d3968e25f4544189c
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/540355
TryBot-Result: Gopher Robot <gobot@golang.org>
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>
2023-11-20 16:29:00 +00:00
Zvonimir Pavlinovic 8fa5789029 internal/vulncheck: add binary abstraction data structure
This is minimal information needed for govulncheck to analyze binaries.
This will be jsonized into the follow-up CLs.

Change-Id: I52f71ad66ea7e5004d4ced388c488eff5e686fd6
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/540235
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
2023-11-14 19:01:33 +00:00
Maceo Thompson fcf7dff7b2 cmd/govulncheck: organize tests into subdirs
This change does not modify any tests, but organizes the preexisting
tests into subdirectories.

Change-Id: Id0634f646eae0aa9eceb98269acec2a76bbb2a6c
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/539662
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2023-11-08 20:07:54 +00:00
Maceo Thompson 26305ce587 internal/scan: Improve "Informational" text output
This change changes the text output to only include messages relating to
vulnerabilities that actually appear. This means that if there is a
package level vuln but no module level vulnerabilities, govulncheck will
no longer say "There are also 0 vulnerabilities in modules that you
import".

Additionally, this change cleans up how the informational section
actually builds the string, using strings.Builder and automatically
wrapping text with handler.wrap() instead of manually wrapping the text.

Change-Id: Ia933ee777d87004ec94918954619e916ec307dd7
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/540315
Reviewed-by: Ian Cottrell <iancottrell@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2023-11-07 19:54:48 +00:00
Maceo Thompson c8f88df03b internal/scan: properly "genericify" choose
The choose function previously returned an "any" type. It will now
return the type of the inputs.

Change-Id: I6d6bd1e02d0b184ba4916ff53960ca1930e367eb
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/540275
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2023-11-07 18:50:06 +00:00
Zvonimir Pavlinovic 94af419e51 internal/vulncheck: emit package findings all at once
Emitting one by one does not provide much benefits as traversal of
package import graphs is done fast. Emitting all at once makes the code
more consistent.

Change-Id: I9cb2617aeb60efa85c584bb41286d247af4d78c1
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/539735
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Maceo Thompson <maceothompson@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-06 19:48:24 +00:00
Zvonimir Pavlinovic d9895b7aff internal/vulncheck: update logic for package level analysis
We are not computing a proper slice of vulnerable imports graph, so we
update the documentation to reflect that. Also, we never don't really
have a need to maintain package entry points, so we get rid of them.

Some related cleaning and renaming is done as well.

This CL is part of a series of changes cleaning up the code a bit.

Change-Id: I3b530c0a74b65933ec0c20f6f86a0a9c11b66929
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/539340
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>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
2023-11-06 19:48:15 +00:00
Zvonimir Pavlinovic a916ed9ccd internal/vulncheck: remove obsolete tests and helpers
This CL is part of a series of changes cleaning up the code a bit.

Change-Id: Id5a2d644a5b3a2f8a79994ad270d4ee4c9b69e67
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/539037
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>
2023-11-06 16:41:44 +00:00
Maceo Thompson 494f7b9de9 internal/scan: remove obsolete function
Removes the "fileExists" function which is no longer used.

Fixes golang/go#63967

Change-Id: I7ac9eb5537f4419c22774a43ba955d2191c2fe84
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/540195
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Maceo Thompson <maceothompson@google.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2023-11-06 16:32:44 +00:00
Maceo Thompson 95059e5917 internal/scan: check for go mod before running
Previously, govulncheck would check for the existence of a go.mod file
using os.Stat only after loading packages or modules failed. Instead,
this change has govulncheck check using go env GOMOD, which returns a
specific string if no go mod is found. This allows us to also check
for a go mod file before attempting to load modules/packages.

Change-Id: I6302f226e1e7641e805838d959959170a442e0d3
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/538765
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2023-11-03 16:21:31 +00:00
Zvonimir Pavlinovic 1628303e78 cmd/govulncheck/integration: add new expectations
This is due to https://go-review.googlesource.com/c/vulndb/+/538778

Change-Id: Idf7114ab49c1f42fc699c8c7912d5312a0716928
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/539336
Reviewed-by: Maceo Thompson <maceothompson@google.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-02 20:31:07 +00:00
Maceo Thompson 227475cc4b cmd/govulncheck: Fix no go mod tests
This change copies the nogomod "module" to a temp dir. This allows us to
change how we check for a god mod file existing without worrying about
the file structure of our test suite.

Change-Id: I0cc2b24c6cbd6631abde37809a4e976397f8fc2a
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/538764
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-11-02 19:37:42 +00:00
Zvonimir Pavlinovic ff7757756c internal/vulncheck: rename moduleVulnerabilities
The new name is affectingVulns which more closely resembles what this
type contains. The main purpose is to differentiate between the vulns
that affect the current program+platform from those that are actually
pulled from the db and emitted to handler.OSV.

Some other cleaning is also performed related to the tests.

This CL is part of a series of changes cleaning up the code a bit.

Change-Id: I68619f31f7b0e6082d14334cd2bce02d193ea59b
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/539036
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>
2023-11-02 16:40:21 +00:00
Zvonimir Pavlinovic e30e74312c internal/vulncheck: add documentation and propagate errors
This CL is part of a series of changes cleaning up the code a bit.

Change-Id: Ica5890efe0ff46d4afe651355baec147d0557cc1
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/538789
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>
2023-11-02 16:36:33 +00:00
Zvonimir Pavlinovic aca0fd4fb1 internal/vulncheck: emit OSVs in their raw form asap
We omit raw unfiltered OSVs the moment we fetch them from the database.
In practice, findings will be linked to a proper subset of these, making
more explicit govulncheck strengths of taking into account:
 - module versions
 - platform information
 - symbols and their reachability via call graph

Change-Id: I3330535938ac037ccc9fae84562fa4270fd00d0e
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/538788
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>
2023-11-01 22:21:11 +00:00
Zvonimir Pavlinovic b7bbfa0e7d internal/scan: move emit logic for findings to internal/vulncheck
Some emit logic for findings is already in vulncheck and more will be
added. Might as well keep everything in the same place.

This also moves some call stack computation code for binaries to
vulncheck where anyhow call stack computation for source is located.

Finally, this also gets rid of redundant code and reduce API surface of
vulncheck.

Change-Id: I23317680369a14115b4c928c8a5445c696ca33e8
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/538875
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>
2023-11-01 17:30:26 +00:00
Maceo Thompson 61b4508dba internal: properly fetch modules in source mode
Loads modules using go list instead of inferring through packages. This
fixes a few module-level edge cases where a vuln wouldn't be counted.

Change-Id: I24e0ffa73f47451806d88aa672ca8ef7a72fc2bb
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/529278
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2023-10-31 19:13:44 +00:00
Maceo Thompson cc39747b1d internal/scan: verify scan level flag
When the provided scan level is invalid, govulncheck now errors before
attempting to analyze the given pattern. Previously, it would run with
the default scan level (source).

Change-Id: I3d73aaede55ec6cd58a04b3e128732316726affb
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/538677
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-31 17:25:23 +00:00
Maceo Thompson 441c6de8e0 internal/govulncheck: update Finding docstring
Updates the documentation for the Finding struct to better reflect
govulncheck's behavior.

Change-Id: I66b1f0aa7725697980d67623e84c220be1c311d0
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/538757
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-31 16:38:13 +00:00
Zvonimir Pavlinovic 0f3617a92d internal/vulncheck: remove file set computation
Source function is internal so it can make certain assumptions about how
it is called. This assumptions (now documented) allow us to avoid
computing and validating file sets, resulting in simplified code.

Fixes golang/go#59729

Change-Id: Iea7e5c91d51a8243451f13a3d13fa0672cca77cd
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/532215
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>
2023-10-30 20:54:14 +00:00
Zvonimir Pavlinovic be8c7020aa internal/scan: generate better message when patterns matches no packages
When a provided pattern is invalid, govulncheck returns the error
produced by Go. But when the pattern is valid and no packages match,
govulncheck proceeds to analyze 0 packages and produces usual progress
messages. This can be confusing. We hence generate a better progress
message.

Fixes golang/go#59623

Change-Id: Ida8cd61635dc1a2082ce428f5c1ae48f1715e4ce
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/532056
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>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-10-30 20:44:53 +00:00
Maceo Thompson 33c23e2343 internal/scan, vulncheck: emit vulns as found
This change updates govulncheck to emit findings and osvs as they are
found, which allows for quicker short circuiting depending on scan
level. It will also simplify implementing module level scanning.

Change-Id: I8cdc7492d76a9a21d5a0e9d9355ff4407d5f3864
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/528216
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
2023-10-18 15:02:40 +00:00
Maceo Thompson 1d6687b38e internal/scan: use modVersion for mod version
Fixes a case where (in emit result) modPath was passed as the mod
version arg to a call to fixedVersion() instead of modVersion.

Change-Id: Ib77046739b6b9c32ae593971b9a7422fa0db39ca
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/534860
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-10-13 18:01:20 +00:00