Fixing merge commit scans and large patch rule checking (#414)

* Fixing merge commit scans and large patch rule checking

* Adding tests for merge request scans
This commit is contained in:
Zachary Rice authored and GitHub committed 2020-07-25 14:55:59 -04:00
1 parent 1dc7569f95
commit eabc7b5c12
47 files changed
+278 -32

No files matched your search

+8
View File
@@ -200,7 +200,15 @@ func extractAndInjectLineNumber(leak *manager.Leak, bundle *Bundle, repo *Repo)
if bundle.Patch == "" {
return
}
// This is needed as some patches generate strings that are larger than
// scanners max size (MaxScanTokenSize = 64 * 1024)
// https://github.com/zricethezav/gitleaks/issues/413
buf := make([]byte, len(bundle.Patch))
scanner := bufio.NewScanner(strings.NewReader(bundle.Patch))
scanner.Buffer(buf, len(bundle.Patch))
scanner.Split(bufio.ScanLines)
currFile := ""
currLine := 0
currStartDiffLine := 0