From cb89fbb124a2ea7c2c49adcf27b8a2bdebc895f7 Mon Sep 17 00:00:00 2001 From: DmitriyLewen <91113035+DmitriyLewen@users.noreply.github.com> Date: Wed, 3 Jul 2024 18:19:30 +0600 Subject: [PATCH] refactor(secret): add warning about large files (#7085) --- pkg/fanal/analyzer/secret/secret.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/fanal/analyzer/secret/secret.go b/pkg/fanal/analyzer/secret/secret.go index cad32e00ad8f..e26caaea5401 100644 --- a/pkg/fanal/analyzer/secret/secret.go +++ b/pkg/fanal/analyzer/secret/secret.go @@ -17,6 +17,7 @@ import ( "github.com/aquasecurity/trivy/pkg/fanal/secret" "github.com/aquasecurity/trivy/pkg/fanal/types" "github.com/aquasecurity/trivy/pkg/fanal/utils" + "github.com/aquasecurity/trivy/pkg/log" ) // To make sure SecretAnalyzer implements analyzer.Initializer @@ -165,6 +166,9 @@ func (a *SecretAnalyzer) Required(filePath string, fi os.FileInfo) bool { return false } + if size := fi.Size(); size > 10485760 { // 10MB + log.WithPrefix("secret").Warn("The size of the scanned file is too large. It is recommended to use `--skip-files` for this file to avoid high memory consumption.", log.FilePath(filePath), log.Int64("size (MB)", size/1048576)) + } return true }