From 1ea773ddfb377598b182a950d1c00dd184a416e4 Mon Sep 17 00:00:00 2001 From: boris Date: Sun, 21 Oct 2018 20:17:32 +0300 Subject: [PATCH] support self hosted GitLab server --- README.md | 1 + gitlab.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index bddfb3a0..499643ff 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ The code return codes are: ### GitLab To audit public repositories for user on GitLab use `--gitlab-user=` and for group `--gitlab-org=`. For private repositories add `GITLAB_TOKEN` environment variable with your personal access token (is used to list all repositories via API) also add key `-p` with `--ssh-key=` for SSH key path (is used to clone repository). +If self hosted GitLab server add `GITLAB_URL` environment variable with your URL. #### Additional information * Additional documentation about how gitleaks functions can be found on the [wiki page](https://github.com/zricethezav/gitleaks/wiki) diff --git a/gitlab.go b/gitlab.go index b37c8234..7eb9e9f1 100644 --- a/gitlab.go +++ b/gitlab.go @@ -20,6 +20,11 @@ func auditGitlabRepos() ([]Leak, error) { page := 1 cl := gitlab.NewClient(nil, os.Getenv("GITLAB_TOKEN")) + // if self hosted GitLab server + if url := os.Getenv("GITLAB_URL"); url != "" { + cl.SetBaseURL(url) + } + var ( ps []*gitlab.Project resp *gitlab.Response