mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-28 20:24:22 +01:00
Commit debug log (#716)
* adding debug log for number of commits scanned * change debug text * readd commitsha
This commit is contained in:
1 parent
8eabfd614e
commit
f498b1d308
1 file changed
+7
-1
+7
-1
@@ -5,6 +5,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/gitleaks/go-gitdiff/gitdiff"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/zricethezav/gitleaks/v8/config"
|
||||
"github.com/zricethezav/gitleaks/v8/report"
|
||||
godocutil "golang.org/x/tools/godoc/util"
|
||||
@@ -17,7 +18,12 @@ func FromGit(files <-chan *gitdiff.File, cfg config.Config, outputOptions Option
|
||||
var findings []*report.Finding
|
||||
mu := sync.Mutex{}
|
||||
wg := sync.WaitGroup{}
|
||||
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)
|
||||
go func(f *gitdiff.File) {
|
||||
@@ -35,7 +41,6 @@ func FromGit(files <-chan *gitdiff.File, cfg config.Config, outputOptions Option
|
||||
// Check if commit is allowed
|
||||
if f.PatchHeader != nil {
|
||||
commitSHA = f.PatchHeader.SHA
|
||||
|
||||
if cfg.Allowlist.CommitAllowed(f.PatchHeader.SHA) {
|
||||
return
|
||||
}
|
||||
@@ -85,5 +90,6 @@ func FromGit(files <-chan *gitdiff.File, cfg config.Config, outputOptions Option
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
log.Debug().Msgf("%d commits scanned. Note: this number might be smaller than expected due to commits with no additions", len(commitMap))
|
||||
return findings
|
||||
}
|
||||
Reference in new issue
Block a user