Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
Add commitsScanned metrics (#1533)
Bill Richf39303495a46
diff --git a/pkg/sources/git/git.go b/pkg/sources/git/git.goindex 41e6a9376..b8d03a6dd 100644--- a/pkg/sources/git/git.go+++ b/pkg/sources/git/git.go@@ -51,9 +51,14 @@ type Git struct {jobID int64sourceMetadataFunc func(file, email, commit, timestamp, repository string, line int64) *source_metadatapb.MetaDataverify bool+ metrics metricsconcurrency *semaphore.Weighted}+type metrics struct {+ commitsScanned int+}+func NewGit(sourceType sourcespb.SourceType, jobID, sourceID int64, sourceName string, verify bool, concurrency int,sourceMetadataFunc func(file, email, commit, timestamp, repository string, line int64) *source_metadatapb.MetaData,) *Git {@@ -339,6 +344,10 @@ func CloneRepoUsingSSH(ctx context.Context, gitUrl string, args ...string) (strireturn CloneRepo(ctx, userInfo, gitUrl, args...)}+func (s *Git) CommitsScanned() int {+ return s.metrics.commitsScanned+}+func (s *Git) ScanCommits(ctx context.Context, repo *git.Repository, path string, scanOptions *ScanOptions, chunksChan chan *sources.Chunk) error {if err := GitCmdCheck(); err != nil {return err@@ -371,6 +380,7 @@ func (s *Git) ScanCommits(ctx context.Context, repo *git.Repository, path stringbreak}depth+++ s.metrics.commitsScanned++logger.V(5).Info("scanning commit", "commit", commit.Hash)for _, diff := range commit.Diffs {if !scanOptions.Filter.Pass(diff.PathB) {