bug fix: use manager pointers instead of value for gitleaks hosts... this was causing an issue with metadata logging

This commit is contained in:
zricethezav committed 2020-01-19 11:51:52 -05:00
1 parent e6fabdbb31
commit b200a13c8d
3 files changed
+9 -9

No files matched your search

+4 -4
View File
@@ -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)
+3 -3
View File
@@ -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)
+2 -2
View File
@@ -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
}