mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-12-01 13:34:23 +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"
|
"sync"
|
||||||
|
|
||||||
"github.com/gitleaks/go-gitdiff/gitdiff"
|
"github.com/gitleaks/go-gitdiff/gitdiff"
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/zricethezav/gitleaks/v8/config"
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
"github.com/zricethezav/gitleaks/v8/report"
|
"github.com/zricethezav/gitleaks/v8/report"
|
||||||
godocutil "golang.org/x/tools/godoc/util"
|
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
|
var findings []*report.Finding
|
||||||
mu := sync.Mutex{}
|
mu := sync.Mutex{}
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
|
commitMap := make(map[string]bool)
|
||||||
for f := range files {
|
for f := range files {
|
||||||
|
// keep track of commits for logging
|
||||||
|
if f.PatchHeader != nil {
|
||||||
|
commitMap[f.PatchHeader.SHA] = true
|
||||||
|
}
|
||||||
|
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(f *gitdiff.File) {
|
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
|
// Check if commit is allowed
|
||||||
if f.PatchHeader != nil {
|
if f.PatchHeader != nil {
|
||||||
commitSHA = f.PatchHeader.SHA
|
commitSHA = f.PatchHeader.SHA
|
||||||
|
|
||||||
if cfg.Allowlist.CommitAllowed(f.PatchHeader.SHA) {
|
if cfg.Allowlist.CommitAllowed(f.PatchHeader.SHA) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -85,5 +90,6 @@ func FromGit(files <-chan *gitdiff.File, cfg config.Config, outputOptions Option
|
|||||||
}
|
}
|
||||||
|
|
||||||
wg.Wait()
|
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
|
return findings
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user