Skip to content

Commit 244182b

Browse files
committed
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>
1 parent 5d9f62b commit 244182b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

cmd/govulncheck/testdata/testfiles/source-module/module_short_curcuits.ct

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#####
22
# Test that findings with callstacks or packages are not emitted in module mode
3-
$ govulncheck -json -scan module -C ${moddir}/multientry .
3+
$ govulncheck -json -scan module -C ${moddir}/multientry
44
{
55
"config": {
66
"protocol_version": "v1.0.0",

internal/scan/source.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import (
2323
func runSource(ctx context.Context, handler govulncheck.Handler, cfg *config, client *client.Client, dir string) (err error) {
2424
defer derrors.Wrap(&err, "govulncheck")
2525

26-
if len(cfg.patterns) == 0 {
27-
return nil
26+
if cfg.ScanLevel.WantPackages() && len(cfg.patterns) == 0 {
27+
return nil // don't throw an error here
2828
}
2929
if !gomodExists(dir) {
3030
return errNoGoMod

0 commit comments

Comments
 (0)