Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
add metrics for gitlab (#2190)
ahrav2a7813929b3a
diff --git a/pkg/sources/gitlab/gitlab.go b/pkg/sources/gitlab/gitlab.goindex 7851e7c6f..54893cc0b 100644--- a/pkg/sources/gitlab/gitlab.go+++ b/pkg/sources/gitlab/gitlab.go@@ -148,6 +148,8 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk, _ .if err != nil {return errors.New(err)}++ gitlabReposScanned.WithLabelValues(s.name).Set(0)// Get repo within target.repos, errs := normalizeRepos(s.repos)for _, repoErr := range errs {@@ -409,6 +411,8 @@ func (s *Source) getReposFromGitlab(ctx context.Context, apiClient *gitlab.Clienif len(repos) == 0 {return nil, errors.Errorf("unable to discover any repos"), true}++ gitlabReposEnumerated.WithLabelValues(s.name).Set(float64(len(repos)))return repos, nil, false}@@ -467,6 +471,7 @@ func (s *Source) scanRepos(ctx context.Context, chunksChan chan *sources.Chunk)scanErrs.Add(err)return nil}+ gitlabReposScanned.WithLabelValues(s.name).Inc()logger.V(2).Info(fmt.Sprintf("Completed scanning repo %d/%d", i+1, len(s.repos)))return nildiff --git a/pkg/sources/gitlab/metrics.go b/pkg/sources/gitlab/metrics.gonew file mode 100644index 000000000..927368225--- /dev/null+++ b/pkg/sources/gitlab/metrics.go@@ -0,0 +1,26 @@+package gitlab++import (+ "github.com/prometheus/client_golang/prometheus"+ "github.com/prometheus/client_golang/prometheus/promauto"++ "github.com/trufflesecurity/trufflehog/v3/pkg/common"+)++var (+ gitlabReposEnumerated = promauto.NewGaugeVec(prometheus.GaugeOpts{+ Namespace: common.MetricsNamespace,+ Subsystem: common.MetricsSubsystem,+ Name: "gitlab_repos_enumerated",+ Help: "Total number of Gitlab repositories enumerated.",+ },+ []string{"source_name"})++ gitlabReposScanned = promauto.NewGaugeVec(prometheus.GaugeOpts{+ Namespace: common.MetricsNamespace,+ Subsystem: common.MetricsSubsystem,+ Name: "gitlab_repos_scanned",+ Help: "Total number of Gitlab repositories scanned.",+ },+ []string{"source_name"})+)