mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 05:04:22 +01:00
add --max-target-megabytes : maximum size for a file/blob to be scanned (#1003)
* add --max-target-megabytes : maximum size for a file/blob to be scanned * add --max-target-megabytes : maximum size for a file/blob to be scanned * add --max-target-megabytes : maximum size for a file/blob to be scanned * adjust readme comment * fix on prem
This commit is contained in:
1 parent
81c92c78ca
commit
c0caab0355
4 files changed
+24
-3
No files matched your search
@@ -49,6 +49,9 @@ type Detector struct {
|
||||
// verbose is a flag to print findings
|
||||
Verbose bool
|
||||
|
||||
// files larger than this will be skipped
|
||||
MaxTargetMegaBytes int
|
||||
|
||||
// commitMap is used to keep track of commits that have been scanned.
|
||||
// This is only used for logging purposes and git scans.
|
||||
commitMap map[string]bool
|
||||
@@ -211,6 +214,15 @@ func (d *Detector) detectRule(fragment Fragment, rule config.Rule) []report.Find
|
||||
return findings
|
||||
}
|
||||
|
||||
// If flag configure and raw data size bigger then the flag
|
||||
if d.MaxTargetMegaBytes > 0 {
|
||||
rawLength := len(fragment.Raw) / 1000000
|
||||
if rawLength > d.MaxTargetMegaBytes {
|
||||
log.Debug().Msgf("skipping file: %s scan due to size: %d", fragment.FilePath, rawLength)
|
||||
return findings
|
||||
}
|
||||
}
|
||||
|
||||
matchIndices := rule.Regex.FindAllStringIndex(fragment.Raw, -1)
|
||||
for _, matchIndex := range matchIndices {
|
||||
// extract secret from match
|
||||
|
||||
Reference in new issue
Block a user