Skip to content

Commit

Permalink
refactor(secret): add warning about large files (#7085)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen authored Jul 3, 2024
1 parent 03ac93d commit cb89fbb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/fanal/analyzer/secret/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit cb89fbb

Please sign in to comment.