mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-12-01 05:24:22 +01:00
Adding baseurl flag to allow self-hosted GitLab/GitHub servers
This commit is contained in:
1 parent
ef38b69c39
commit
c5e1e8abc0
3 files changed
+25
-2
No files matched your search
+14
-1
@@ -33,9 +33,22 @@ func NewGithubClient(m manager.Manager) *Github {
|
|||||||
&oauth2.Token{AccessToken: options.GetAccessToken(m.Opts)},
|
&oauth2.Token{AccessToken: options.GetAccessToken(m.Opts)},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var githubClient *github.Client
|
||||||
|
httpClient := oauth2.NewClient(ctx, token)
|
||||||
|
|
||||||
|
if m.Opts.BaseURL == "" {
|
||||||
|
githubClient = github.NewClient(httpClient)
|
||||||
|
} else {
|
||||||
|
var err error
|
||||||
|
githubClient, err = github.NewEnterpriseClient(m.Opts.BaseURL, m.Opts.BaseURL, httpClient)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &Github{
|
return &Github{
|
||||||
manager: m,
|
manager: m,
|
||||||
client: github.NewClient(oauth2.NewClient(ctx, token)),
|
client: githubClient,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -23,11 +23,20 @@ type Gitlab struct {
|
|||||||
// NewGitlabClient accepts a manager struct and returns a Gitlab host pointer which will be used to
|
// 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.
|
// perform a gitlab audit on an group or user.
|
||||||
func NewGitlabClient(m manager.Manager) *Gitlab {
|
func NewGitlabClient(m manager.Manager) *Gitlab {
|
||||||
return &Gitlab{
|
gitlabClient := &Gitlab{
|
||||||
manager: m,
|
manager: m,
|
||||||
ctx: context.Background(),
|
ctx: context.Background(),
|
||||||
client: gitlab.NewClient(nil, options.GetAccessToken(m.Opts)),
|
client: gitlab.NewClient(nil, options.GetAccessToken(m.Opts)),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if m.Opts.BaseURL != "" {
|
||||||
|
err := gitlabClient.client.SetBaseURL(m.Opts.BaseURL)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return gitlabClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audit will audit a github user or organization's repos.
|
// Audit will audit a github user or organization's repos.
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ type Options struct {
|
|||||||
|
|
||||||
// Hosts
|
// Hosts
|
||||||
Host string `long:"host" description:"git hosting service like gitlab or github. Supported hosts include: Github, Gitlab"`
|
Host string `long:"host" description:"git hosting service like gitlab or github. Supported hosts include: Github, Gitlab"`
|
||||||
|
BaseURL string `long:"baseurl" description:"Base URL for API requests. Defaults to the public GitLab or GitHub API, but can be set to a domain endpoint to use with a self hosted server."`
|
||||||
Organization string `long:"org" description:"organization to audit"`
|
Organization string `long:"org" description:"organization to audit"`
|
||||||
User string `long:"user" description:"user to audit"` //work
|
User string `long:"user" description:"user to audit"` //work
|
||||||
PullRequest string `long:"pr" description:"pull/merge request url"`
|
PullRequest string `long:"pr" description:"pull/merge request url"`
|
||||||
|
|||||||
Reference in new issue
Block a user