aquasecurity / trivy

Find vulnerabilities, misconfigurations, secrets, SBOM in containers, Kubernetes, code repositories, clouds and more
https://aquasecurity.github.io/trivy
Apache License 2.0
22.31k stars 2.2k forks source link

refactor(secret): move warning about file size after `IsBinary` check #7123

Closed DmitriyLewen closed 2 weeks ago

DmitriyLewen commented 2 weeks ago

Description

Fix problem that we write warning every each binary file larger than 10MB.

Before:

➜ ./trivy fs --scanners secret ./trivy 
2024-07-09T12:19:09+06:00       INFO    Secret scanning is enabled
2024-07-09T12:19:09+06:00       INFO    If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-07-09T12:19:09+06:00       INFO    Please see also https://aquasecurity.github.io/trivy/dev/docs/scanner/secret#recommendation for faster secret detection
2024-07-09T12:19:09+06:00       WARN    [secret] The size of the scanned file is too large. It is recommended to use `--skip-files` for this file to avoid high memory consumption.     file_path="trivy" size (MB)=240

After:

➜  ./trivy fs --scanners secret ./trivy
2024-07-09T12:21:13+06:00       INFO    Secret scanning is enabled
2024-07-09T12:21:13+06:00       INFO    If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2024-07-09T12:21:13+06:00       INFO    Please see also https://aquasecurity.github.io/trivy/dev/docs/scanner/secret#recommendation for faster secret detection

Checklist