mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 12:44:22 +01:00
limit number of goroutines for historic scanning as well (#761)
This commit is contained in:
1 parent
44d7d89e19
commit
801d44a6e4
3 files changed
+13
-7
No files matched your search
+6
-2
@@ -19,16 +19,20 @@ func FromGit(files <-chan *gitdiff.File, cfg config.Config, outputOptions Option
|
||||
var findings []report.Finding
|
||||
mu := sync.Mutex{}
|
||||
wg := sync.WaitGroup{}
|
||||
concurrentGoroutines := make(chan struct{}, MAXGOROUTINES)
|
||||
commitMap := make(map[string]bool)
|
||||
for f := range files {
|
||||
// keep track of commits for logging
|
||||
if f.PatchHeader != nil {
|
||||
commitMap[f.PatchHeader.SHA] = true
|
||||
}
|
||||
|
||||
wg.Add(1)
|
||||
concurrentGoroutines <- struct{}{}
|
||||
go func(f *gitdiff.File) {
|
||||
defer wg.Done()
|
||||
defer func() {
|
||||
wg.Done()
|
||||
<-concurrentGoroutines
|
||||
}()
|
||||
if f.IsBinary {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user