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>
This commit is contained in:
Zvonimir Pavlinovic 2023-12-01 16:56:14 +00:00
Родитель 5d9f62b9ff
Коммит 244182bca4
2 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -1,6 +1,6 @@
#####
# Test that findings with callstacks or packages are not emitted in module mode
$ govulncheck -json -scan module -C ${moddir}/multientry .
$ govulncheck -json -scan module -C ${moddir}/multientry
{
"config": {
"protocol_version": "v1.0.0",

Просмотреть файл

@ -23,8 +23,8 @@ import (
func runSource(ctx context.Context, handler govulncheck.Handler, cfg *config, client *client.Client, dir string) (err error) {
defer derrors.Wrap(&err, "govulncheck")
if len(cfg.patterns) == 0 {
return nil
if cfg.ScanLevel.WantPackages() && len(cfg.patterns) == 0 {
return nil // don't throw an error here
}
if !gomodExists(dir) {
return errNoGoMod