From b200a13c8d6f69db4e13a7615392ca899bc367c7 Mon Sep 17 00:00:00 2001 From: zricethezav Date: Sun, 19 Jan 2020 11:49:56 -0500 Subject: [PATCH] bug fix: use manager pointers instead of value for gitleaks hosts... this was causing an issue with metadata logging --- hosts/github.go | 8 ++++---- hosts/gitlab.go | 6 +++--- hosts/host.go | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hosts/github.go b/hosts/github.go index a42b7134..1051293a 100644 --- a/hosts/github.go +++ b/hosts/github.go @@ -21,13 +21,13 @@ import ( // Github wraps a github client and manager. This struct implements what the Host interface defines. type Github struct { client *github.Client - manager manager.Manager + manager *manager.Manager wg sync.WaitGroup } // NewGithubClient accepts a manager struct and returns a Github host pointer which will be used to // perform a github audit on an organization, user, or PR. -func NewGithubClient(m manager.Manager) (*Github, error) { +func NewGithubClient(m *manager.Manager) (*Github, error) { var err error ctx := context.Background() token := oauth2.StaticTokenSource( @@ -91,7 +91,7 @@ func (g *Github) Audit() { } for _, repo := range githubRepos { - r := audit.NewRepo(&g.manager) + r := audit.NewRepo(g.manager) r.Name = *repo.Name err := r.Clone(&git.CloneOptions{ URL: *repo.CloneURL, @@ -123,7 +123,7 @@ func (g *Github) AuditPR() { owner := splits[len(splits)-4] repoName := splits[len(splits)-3] prNum, err := strconv.Atoi(splits[len(splits)-1]) - repo := audit.NewRepo(&g.manager) + repo := audit.NewRepo(g.manager) repo.Name = repoName log.Infof("auditing pr %s\n", g.manager.Opts.PullRequest) diff --git a/hosts/gitlab.go b/hosts/gitlab.go index 8762a6aa..8cbb79d8 100644 --- a/hosts/gitlab.go +++ b/hosts/gitlab.go @@ -15,14 +15,14 @@ import ( // Gitlab wraps a gitlab client and manager. This struct implements what the Host interface defines. type Gitlab struct { client *gitlab.Client - manager manager.Manager + manager *manager.Manager ctx context.Context wg sync.WaitGroup } // NewGitlabClient accepts a manager struct and returns a Gitlab host pointer which will be used to // perform a gitlab audit on an group or user. -func NewGitlabClient(m manager.Manager) (*Gitlab, error) { +func NewGitlabClient(m *manager.Manager) (*Gitlab, error) { var err error gitlabClient := &Gitlab{ @@ -82,7 +82,7 @@ func (g *Gitlab) Audit() { // iterate of gitlab projects for _, p := range projects { - r := audit.NewRepo(&g.manager) + r := audit.NewRepo(g.manager) cloneOpts := g.manager.CloneOptions cloneOpts.URL = p.HTTPURLToRepo err := r.Clone(cloneOpts) diff --git a/hosts/host.go b/hosts/host.go index 866a0171..57c9830c 100644 --- a/hosts/host.go +++ b/hosts/host.go @@ -23,9 +23,9 @@ func Run(m *manager.Manager) error { var err error switch getHost(m.Opts.Host) { case _github: - host, err = NewGithubClient(*m) + host, err = NewGithubClient(m) case _gitlab: - host, err = NewGitlabClient(*m) + host, err = NewGitlabClient(m) default: return nil }