From f498b1d308a0a11bd0ac1111d23d7b37f256469d Mon Sep 17 00:00:00 2001 From: Zachary Rice Date: Thu, 25 Nov 2021 10:46:47 -0600 Subject: [PATCH] Commit debug log (#716) * adding debug log for number of commits scanned * change debug text * readd commitsha --- detect/git.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/detect/git.go b/detect/git.go index e427f8ba..8b88b87c 100644 --- a/detect/git.go +++ b/detect/git.go @@ -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 }