Merge pull request #184 from JCofman/feature/gitlabTokenSupport

Feature/gitlab token support
This commit is contained in:
Zachary Rice authored and GitHub committed 2019-08-01 17:13:44 -05:00
commit 91406b0c4c
3 files changed
+23 -1

No files matched your search

+4
View File
@@ -1,5 +1,9 @@
CHANGELOG
=========
x.xx.x
---
- uses the `GITLAB_TOKEN` to clone GitLab repos.
2.0.0
----
- rules introduced in the gitleaks configurationn
+10 -1
View File
@@ -8,6 +8,7 @@ import (
log "github.com/sirupsen/logrus"
"github.com/xanzy/go-gitlab"
"gopkg.in/src-d/go-git.v4"
gitHttp "gopkg.in/src-d/go-git.v4/plumbing/transport/http"
"gopkg.in/src-d/go-git.v4/storage/memory"
)
@@ -131,6 +132,9 @@ func cloneGitlabRepo(tempDir string, p *gitlab.Project) (*Repo, error) {
repo *git.Repository
err error
)
gitLabToken := os.Getenv("GITLAB_TOKEN")
if opts.ExcludeForks && p.ForkedFromProject != nil {
return nil, fmt.Errorf("skipping %s, excluding forks", p.Name)
}
@@ -145,9 +149,14 @@ func cloneGitlabRepo(tempDir string, p *gitlab.Project) (*Repo, error) {
URL: p.HTTPURLToRepo,
}
if config.sshAuth != nil {
if config.sshAuth != nil && gitLabToken == "" {
opt.URL = p.SSHURLToRepo
opt.Auth = config.sshAuth
} else if gitLabToken != "" {
opt.Auth = &gitHttp.BasicAuth{
Username: "fakeUsername", // yes, this can be anything except an empty string
Password: gitLabToken,
}
}
log.Infof("cloning: %s", p.Name)
+9
View File
@@ -0,0 +1,9 @@
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9 h1:lkiLiLBHGoH3XnqSLUIaBsilGMUjI+Uy2Xu2JLUtTas=
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=