Skip to content

Commit cb89fbb

Browse files
authored
refactor(secret): add warning about large files (#7085)
1 parent 03ac93d commit cb89fbb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pkg/fanal/analyzer/secret/secret.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/aquasecurity/trivy/pkg/fanal/secret"
1818
"github.com/aquasecurity/trivy/pkg/fanal/types"
1919
"github.com/aquasecurity/trivy/pkg/fanal/utils"
20+
"github.com/aquasecurity/trivy/pkg/log"
2021
)
2122

2223
// To make sure SecretAnalyzer implements analyzer.Initializer
@@ -165,6 +166,9 @@ func (a *SecretAnalyzer) Required(filePath string, fi os.FileInfo) bool {
165166
return false
166167
}
167168

169+
if size := fi.Size(); size > 10485760 { // 10MB
170+
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))
171+
}
168172
return true
169173
}
170174

0 commit comments

Comments
 (0)