Skip to content

Commit 29e9ff7

Browse files
authored
refactor(secret): clarify secret scanner messages (#9409)
Signed-off-by: nikpivkin <[email protected]>
1 parent 46ab76a commit 29e9ff7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pkg/commands/artifact/run.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"os"
88
"slices"
9+
"strings"
910

1011
"github.com/hashicorp/go-multierror"
1112
"github.com/samber/lo"
@@ -35,6 +36,7 @@ import (
3536
"github.com/aquasecurity/trivy/pkg/types"
3637
"github.com/aquasecurity/trivy/pkg/version/doc"
3738
xhttp "github.com/aquasecurity/trivy/pkg/x/http"
39+
xstrings "github.com/aquasecurity/trivy/pkg/x/strings"
3840
)
3941

4042
// TargetKind represents what kind of artifact Trivy scans
@@ -578,9 +580,13 @@ func (r *runner) initScannerConfig(ctx context.Context, opts flag.Options) (Scan
578580
if opts.Scanners.Enabled(types.SecretScanner) {
579581
logger := log.WithPrefix(log.PrefixSecret)
580582
logger.Info("Secret scanning is enabled")
581-
logger.Info("If your scanning is slow, please try '--scanners vuln' to disable secret scanning")
583+
if nonSecrets := lo.Without(opts.Scanners, types.SecretScanner, types.SBOMScanner); len(nonSecrets) > 0 {
584+
logger.Info(fmt.Sprintf(
585+
"If your scanning is slow, please try '--scanners %s' to disable secret scanning",
586+
strings.Join(xstrings.ToStringSlice(nonSecrets), ",")))
587+
}
582588
// e.g. https://trivy.dev/latest/docs/scanner/secret/#recommendation
583-
logger.Info(fmt.Sprintf("Please see also %s for faster secret detection", doc.URL("/docs/scanner/secret/", "recommendation")))
589+
logger.Info(fmt.Sprintf("Please see %s for faster secret detection", doc.URL("/docs/scanner/secret/", "recommendation")))
584590
} else {
585591
opts.SecretConfigPath = ""
586592
}

0 commit comments

Comments
 (0)