mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-28 20:24:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7fbcf5333 | ||
|
|
2810eccc82 | ||
|
|
baff419091 | ||
|
|
d13e0fdfde | ||
|
|
5a300c3c64 | ||
|
|
d8ddb9630a | ||
|
|
1537eeb5fa | ||
|
|
1a492537dd | ||
|
|
bd4107b002 | ||
|
|
7b48cadf6d | ||
|
|
6eab8a7a0a | ||
|
|
c6d14e5b7d | ||
|
|
ce95cafd54 | ||
|
|
4024faceab | ||
|
|
1afa931248 | ||
|
|
2474c39311 | ||
|
|
f6460a7365 | ||
|
|
b47e00858e | ||
|
|
b200a13c8d | ||
|
|
e6fabdbb31 | ||
|
|
cdd654eab7 | ||
|
|
2f07b96333 | ||
|
|
62e74b2b18 | ||
|
|
e75693b131 | ||
|
|
3cd14d4696 | ||
|
|
d29cc9892c | ||
|
|
d996882f4e | ||
|
|
17b6aa856d |
No files matched your search
@@ -0,0 +1,29 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: bug
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Basic Info (please complete the following information):**
|
||||||
|
- OS:
|
||||||
|
- Gitleaks Version:
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
||||||
|
|
||||||
|
cc @zricethezav
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: enhancement
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
|
|
||||||
|
cc @zricethezav
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
### Description:
|
||||||
|
Explain the purpose of the PR.
|
||||||
|
|
||||||
|
### Checklist:
|
||||||
|
|
||||||
|
* [ ] Does your PR pass tests?
|
||||||
|
* [ ] Have you written new tests for your changes?
|
||||||
|
* [ ] Have you lint your code locally prior to submission?
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
*.DS_STORE
|
*.DS_STORE
|
||||||
*.idea
|
*.idea
|
||||||
gitleaks
|
gitleaks
|
||||||
|
build
|
||||||
|
|
||||||
# Test binary
|
# Test binary
|
||||||
*.out
|
*.out
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
VERSION := `git fetch --tags && git tag | sort -V | tail -1`
|
VERSION := `git fetch --tags && git tag | sort -V | tail -1`
|
||||||
PKG=github.com/zricethezav/gitleaks
|
PKG=github.com/zricethezav/gitleaks
|
||||||
LDFLAGS=-ldflags "-X=github.com/zricethezav/gitleaks/version.Version=$(VERSION)"
|
LDFLAGS=-ldflags "-X=github.com/zricethezav/gitleaks/v3/version.Version=$(VERSION)"
|
||||||
_LDFLAGS="github.com/zricethezav/gitleaks/version.Version=$(VERSION)"
|
_LDFLAGS="github.com/zricethezav/gitleaks/v3/version.Version=$(VERSION)"
|
||||||
COVER=--cover --coverprofile=cover.out
|
COVER=--cover --coverprofile=cover.out
|
||||||
|
|
||||||
test-cover:
|
test-cover:
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ docker pull zricethezav/gitleaks
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### Go
|
#### Go
|
||||||
|
Ensure `GO111MODULE=on` is set as an env var
|
||||||
```bash
|
```bash
|
||||||
go get -u github.com/zricethezav/gitleaks
|
go get github.com/zricethezav/gitleaks/v3@latest
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@@ -55,39 +55,42 @@ Usage:
|
|||||||
gitleaks [OPTIONS]
|
gitleaks [OPTIONS]
|
||||||
|
|
||||||
Application Options:
|
Application Options:
|
||||||
-v, --verbose Show verbose output from audit
|
-v, --verbose Show verbose output from audit
|
||||||
-r, --repo= Target repository
|
-r, --repo= Target repository
|
||||||
--config= config path
|
--config= config path
|
||||||
--disk Clones repo(s) to disk
|
--disk Clones repo(s) to disk
|
||||||
--version version number
|
--version version number
|
||||||
--timeout= Timeout (s)
|
--username= Username for git repo
|
||||||
--username= Username for git repo
|
--password= Password for git repo
|
||||||
--password= Password for git repo
|
--access-token= Access token for git repo
|
||||||
--access-token= Access token for git repo
|
--commit= sha of commit to audit
|
||||||
--commit= sha of commit to audit
|
--files-at-commit= sha of commit to audit all files at commit
|
||||||
--threads= Maximum number of threads gitleaks spawns
|
--threads= Maximum number of threads gitleaks spawns
|
||||||
--ssh-key= path to ssh key used for auth
|
--ssh-key= path to ssh key used for auth
|
||||||
--uncommitted run gitleaks on uncommitted code
|
--uncommitted run gitleaks on uncommitted code
|
||||||
--repo-path= Path to repo
|
--repo-path= Path to repo
|
||||||
--owner-path= Path to owner directory (repos discovered)
|
--owner-path= Path to owner directory (repos discovered)
|
||||||
--branch= Branch to audit
|
--branch= Branch to audit
|
||||||
--report= path to write json leaks file
|
--report= path to write json leaks file
|
||||||
--report-format= json or csv (default: json)
|
--report-format= json or csv (default: json)
|
||||||
--redact redact secrets from log messages and leaks
|
--redact redact secrets from log messages and leaks
|
||||||
--debug log debug messages
|
--debug log debug messages
|
||||||
--repo-config Load config from target repo. Config file must be ".gitleaks.toml" or "gitleaks.toml"
|
--repo-config Load config from target repo. Config file must be ".gitleaks.toml" or "gitleaks.toml"
|
||||||
--pretty Pretty print json if leaks are present
|
--pretty Pretty print json if leaks are present
|
||||||
--commit-from= Commit to start audit from
|
--commit-from= Commit to start audit from
|
||||||
--commit-to= Commit to stop audit
|
--commit-to= Commit to stop audit
|
||||||
--host= git hosting service like gitlab or github. Supported hosts include: Github, Gitlab
|
--timeout= Time allowed per audit. Ex: 10us, 30s, 1m, 1h10m1s
|
||||||
--baseurl= 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.
|
--depth= Number of commits to audit
|
||||||
--org= organization to audit
|
|
||||||
--user= user to audit
|
--host= git hosting service like gitlab or github. Supported hosts include: Github, Gitlab
|
||||||
--pr= pull/merge request url
|
--baseurl= 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.
|
||||||
|
--org= organization to audit
|
||||||
|
--user= user to audit
|
||||||
|
--pr= pull/merge request url
|
||||||
|
--exclude-forks audit excludes forks
|
||||||
|
|
||||||
Help Options:
|
Help Options:
|
||||||
-h, --help Show this help message
|
-h, --help Show this help message
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Docker usage examples
|
### Docker usage examples
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
"github.com/zricethezav/gitleaks/v3/manager"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|||||||
+53
-3
@@ -10,9 +10,9 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/config"
|
"github.com/zricethezav/gitleaks/v3/config"
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
"github.com/zricethezav/gitleaks/v3/manager"
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/v3/options"
|
||||||
|
|
||||||
"github.com/sergi/go-diff/diffmatchpatch"
|
"github.com/sergi/go-diff/diffmatchpatch"
|
||||||
)
|
)
|
||||||
@@ -213,6 +213,56 @@ func TestAudit(t *testing.T) {
|
|||||||
},
|
},
|
||||||
wantEmpty: true,
|
wantEmpty: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
description: "test local repo one aws leak timeout",
|
||||||
|
opts: options.Options{
|
||||||
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
|
Report: "../test_data/test_local_repo_one_aws_leak.json.got",
|
||||||
|
ReportFormat: "json",
|
||||||
|
Timeout: "10ns",
|
||||||
|
},
|
||||||
|
wantEmpty: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "test local repo one aws leak long timeout",
|
||||||
|
opts: options.Options{
|
||||||
|
RepoPath: "../test_data/test_repos/test_repo_1",
|
||||||
|
Report: "../test_data/test_local_repo_one_aws_leak.json.got",
|
||||||
|
ReportFormat: "json",
|
||||||
|
Timeout: "2m",
|
||||||
|
},
|
||||||
|
wantPath: "../test_data/test_local_repo_one_aws_leak.json",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "test owner path depth=2",
|
||||||
|
opts: options.Options{
|
||||||
|
OwnerPath: "../test_data/test_repos/",
|
||||||
|
Report: "../test_data/test_local_owner_aws_leak_depth_2.json.got",
|
||||||
|
ReportFormat: "json",
|
||||||
|
Depth: 2,
|
||||||
|
},
|
||||||
|
wantPath: "../test_data/test_local_owner_aws_leak_depth_2.json",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "test local repo five files at commit",
|
||||||
|
opts: options.Options{
|
||||||
|
RepoPath: "../test_data/test_repos/test_repo_5",
|
||||||
|
Report: "../test_data/test_local_repo_five_files_at_commit.json.got",
|
||||||
|
FilesAtCommit: "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||||
|
ReportFormat: "json",
|
||||||
|
},
|
||||||
|
wantPath: "../test_data/test_local_repo_five_files_at_commit.json",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
description: "test local repo five at commit",
|
||||||
|
opts: options.Options{
|
||||||
|
RepoPath: "../test_data/test_repos/test_repo_5",
|
||||||
|
Report: "../test_data/test_local_repo_five_commit.json.got",
|
||||||
|
Commit: "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||||
|
ReportFormat: "json",
|
||||||
|
},
|
||||||
|
wantPath: "../test_data/test_local_repo_five_commit.json",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|||||||
+71
-16
@@ -2,6 +2,7 @@ package audit
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@@ -11,8 +12,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/config"
|
"github.com/zricethezav/gitleaks/v3/config"
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
"github.com/zricethezav/gitleaks/v3/manager"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
"github.com/sergi/go-diff/diffmatchpatch"
|
"github.com/sergi/go-diff/diffmatchpatch"
|
||||||
@@ -39,6 +40,10 @@ type Repo struct {
|
|||||||
// for those repo audits.
|
// for those repo audits.
|
||||||
config config.Config
|
config config.Config
|
||||||
|
|
||||||
|
// ctx is used to signal timeouts to running goroutines
|
||||||
|
ctx context.Context
|
||||||
|
cancel context.CancelFunc
|
||||||
|
|
||||||
Name string
|
Name string
|
||||||
Manager *manager.Manager
|
Manager *manager.Manager
|
||||||
}
|
}
|
||||||
@@ -48,6 +53,7 @@ func NewRepo(m *manager.Manager) *Repo {
|
|||||||
return &Repo{
|
return &Repo{
|
||||||
Manager: m,
|
Manager: m,
|
||||||
config: m.Config,
|
config: m.Config,
|
||||||
|
ctx: context.Background(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,6 +99,10 @@ func (repo *Repo) AuditUncommitted() error {
|
|||||||
repo.config = cfg
|
repo.config = cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := repo.setupTimeout(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
auditTimeStart := time.Now()
|
auditTimeStart := time.Now()
|
||||||
|
|
||||||
r, err := repo.Head()
|
r, err := repo.Head()
|
||||||
@@ -204,6 +214,13 @@ func (repo *Repo) AuditUncommitted() error {
|
|||||||
// git repo. Options that can change the behavior of this function include: --commit, --depth, --branch.
|
// git repo. Options that can change the behavior of this function include: --commit, --depth, --branch.
|
||||||
// See options/options.go for an explanation on these options.
|
// See options/options.go for an explanation on these options.
|
||||||
func (repo *Repo) Audit() error {
|
func (repo *Repo) Audit() error {
|
||||||
|
if err := repo.setupTimeout(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if repo.cancel != nil {
|
||||||
|
defer repo.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
if repo.Repository == nil {
|
if repo.Repository == nil {
|
||||||
return fmt.Errorf("%s repo is empty", repo.Name)
|
return fmt.Errorf("%s repo is empty", repo.Name)
|
||||||
}
|
}
|
||||||
@@ -219,19 +236,12 @@ func (repo *Repo) Audit() error {
|
|||||||
|
|
||||||
auditTimeStart := time.Now()
|
auditTimeStart := time.Now()
|
||||||
|
|
||||||
// audit single Commit
|
// audit commit patches OR all files at commit. See https://github.com/zricethezav/gitleaks/issues/326
|
||||||
|
// TODO having --commit= and --files-at-commit= set should probably be guarded against
|
||||||
if repo.Manager.Opts.Commit != "" {
|
if repo.Manager.Opts.Commit != "" {
|
||||||
h := plumbing.NewHash(repo.Manager.Opts.Commit)
|
return inspectCommit(repo.Manager.Opts.Commit, repo, inspectCommitPatches)
|
||||||
c, err := repo.CommitObject(h)
|
} else if repo.Manager.Opts.FilesAtCommit != "" {
|
||||||
if err != nil {
|
return inspectCommit(repo.Manager.Opts.FilesAtCommit, repo, inspectFilesAtCommit)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = inspectCommit(c, repo)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logOpts, err := getLogOptions(repo)
|
logOpts, err := getLogOptions(repo)
|
||||||
@@ -247,13 +257,14 @@ func (repo *Repo) Audit() error {
|
|||||||
semaphore := make(chan bool, howManyThreads(repo.Manager.Opts.Threads))
|
semaphore := make(chan bool, howManyThreads(repo.Manager.Opts.Threads))
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
err = cIter.ForEach(func(c *object.Commit) error {
|
err = cIter.ForEach(func(c *object.Commit) error {
|
||||||
if c == nil || c.Hash.String() == repo.Manager.Opts.CommitTo {
|
if c == nil || c.Hash.String() == repo.Manager.Opts.CommitTo ||
|
||||||
|
repo.timeoutReached() || repo.depthReached(cc) {
|
||||||
return storer.ErrStop
|
return storer.ErrStop
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(c.ParentHashes) == 0 {
|
if len(c.ParentHashes) == 0 {
|
||||||
cc++
|
cc++
|
||||||
err = inspectCommit(c, repo)
|
err = inspectFilesAtCommit(c, repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -274,6 +285,9 @@ func (repo *Repo) Audit() error {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
if repo.timeoutReached() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
patch, err := c.Patch(parent)
|
patch, err := c.Patch(parent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -344,3 +358,44 @@ func (repo *Repo) loadRepoConfig() (config.Config, error) {
|
|||||||
_, err = toml.DecodeReader(f, &tomlLoader)
|
_, err = toml.DecodeReader(f, &tomlLoader)
|
||||||
return tomlLoader.Parse()
|
return tomlLoader.Parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// timeoutReached returns true if the timeout deadline has been met. This function should be used
|
||||||
|
// at the top of loops and before potentially long running goroutines (like checking inefficient regexes)
|
||||||
|
func (repo *Repo) timeoutReached() bool {
|
||||||
|
if repo.ctx.Err() == context.DeadlineExceeded {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// setupTimeout parses the --timeout option and assigns a context with timeout to the manager
|
||||||
|
// which will exit early if the timeout has been met.
|
||||||
|
func (repo *Repo) setupTimeout() error {
|
||||||
|
if repo.Manager.Opts.Timeout == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
timeout, err := time.ParseDuration(repo.Manager.Opts.Timeout)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
repo.ctx, repo.cancel = context.WithTimeout(context.Background(), timeout)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
select {
|
||||||
|
case <-repo.ctx.Done():
|
||||||
|
if repo.timeoutReached() {
|
||||||
|
log.Warnf("Timeout deadline (%s) exceeded for %s", timeout.String(), repo.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repo *Repo) depthReached(i int) bool {
|
||||||
|
if repo.Manager.Opts.Depth != 0 && repo.Manager.Opts.Depth == i {
|
||||||
|
log.Warnf("Exceeded depth limit (%d)", i)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
+66
-5
@@ -8,8 +8,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/config"
|
"github.com/zricethezav/gitleaks/v3/config"
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
"github.com/zricethezav/gitleaks/v3/manager"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"gopkg.in/src-d/go-git.v4"
|
"gopkg.in/src-d/go-git.v4"
|
||||||
@@ -25,6 +25,9 @@ import (
|
|||||||
// After that, file chunks are created which are then inspected by InspectString()
|
// After that, file chunks are created which are then inspected by InspectString()
|
||||||
func inspectPatch(patch *object.Patch, c *object.Commit, repo *Repo) {
|
func inspectPatch(patch *object.Patch, c *object.Commit, repo *Repo) {
|
||||||
for _, f := range patch.FilePatches() {
|
for _, f := range patch.FilePatches() {
|
||||||
|
if repo.timeoutReached() {
|
||||||
|
return
|
||||||
|
}
|
||||||
if f.IsBinary() {
|
if f.IsBinary() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -119,6 +122,9 @@ func InspectString(content string, c *object.Commit, repo *Repo, filename string
|
|||||||
// an optimization would be to switch the regex from FindAllIndex to FindString
|
// an optimization would be to switch the regex from FindAllIndex to FindString
|
||||||
// since we are iterating on the lines if entropy rules exist...
|
// since we are iterating on the lines if entropy rules exist...
|
||||||
for _, line := range strings.Split(content, "\n") {
|
for _, line := range strings.Split(content, "\n") {
|
||||||
|
if repo.timeoutReached() {
|
||||||
|
return
|
||||||
|
}
|
||||||
entropyTripped := trippedEntropy(line, rule)
|
entropyTripped := trippedEntropy(line, rule)
|
||||||
if entropyTripped && !ruleContainRegex(rule) {
|
if entropyTripped && !ruleContainRegex(rule) {
|
||||||
repo.Manager.SendLeaks(manager.Leak{
|
repo.Manager.SendLeaks(manager.Leak{
|
||||||
@@ -135,6 +141,9 @@ func InspectString(content string, c *object.Commit, repo *Repo, filename string
|
|||||||
File: filename,
|
File: filename,
|
||||||
})
|
})
|
||||||
} else if entropyTripped {
|
} else if entropyTripped {
|
||||||
|
if repo.timeoutReached() {
|
||||||
|
return
|
||||||
|
}
|
||||||
// entropy has been tripped which means if there is a regex specified in the same
|
// entropy has been tripped which means if there is a regex specified in the same
|
||||||
// rule, we need to inspect the line for a regex match. In otherwords, the current rule has
|
// rule, we need to inspect the line for a regex match. In otherwords, the current rule has
|
||||||
// both entropy and regex set which work in combination. This helps narrow down false positives
|
// both entropy and regex set which work in combination. This helps narrow down false positives
|
||||||
@@ -179,6 +188,9 @@ func InspectString(content string, c *object.Commit, repo *Repo, filename string
|
|||||||
if rule.Regex.String() == "" {
|
if rule.Regex.String() == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if repo.timeoutReached() {
|
||||||
|
return
|
||||||
|
}
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
locs := rule.Regex.FindAllIndex([]byte(content), -1)
|
locs := rule.Regex.FindAllIndex([]byte(content), -1)
|
||||||
if len(locs) != 0 {
|
if len(locs) != 0 {
|
||||||
@@ -243,11 +255,60 @@ func InspectString(content string, c *object.Commit, repo *Repo, filename string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// inspectCommit accepts a commit object and a repo. This function is only called when the --commit=
|
type commitInspector func(c *object.Commit, repo *Repo) error
|
||||||
|
|
||||||
|
// inspectCommit accepts a commit hash, repo, and commit inspecting function. A new commit
|
||||||
|
// object will be created from the hash which will be passed into either inspectCommitPatches
|
||||||
|
// or inspectFilesAtCommit depending on the options set.
|
||||||
|
func inspectCommit(hash string, repo *Repo, f commitInspector) error {
|
||||||
|
h := plumbing.NewHash(hash)
|
||||||
|
c, err := repo.CommitObject(h)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return f(c, repo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// inspectCommitPatches accepts a commit object and a repo. This function is only called when the --commit=
|
||||||
// option has been set. That option tells gitleaks to look only at a single commit and check the contents
|
// option has been set. That option tells gitleaks to look only at a single commit and check the contents
|
||||||
// of said commit. Similar to inspectPatch(), if the files contained in the commit are a binaries or if they are
|
// of said commit. Similar to inspectPatch(), if the files contained in the commit are a binaries or if they are
|
||||||
// whitelisted then those files will be skipped.
|
// whitelisted then those files will be skipped.
|
||||||
func inspectCommit(c *object.Commit, repo *Repo) error {
|
func inspectCommitPatches(c *object.Commit, repo *Repo) error {
|
||||||
|
if len(c.ParentHashes) == 0 {
|
||||||
|
err := inspectFilesAtCommit(c, repo)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.Parents().ForEach(func(parent *object.Commit) error {
|
||||||
|
defer func() {
|
||||||
|
if err := recover(); err != nil {
|
||||||
|
// sometimes the patch generation will fail due to a known bug in
|
||||||
|
// sergi's go-diff: https://github.com/sergi/go-diff/issues/89.
|
||||||
|
// Once a fix has been merged I will remove this recover.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if repo.timeoutReached() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
start := time.Now()
|
||||||
|
patch, err := c.Patch(parent)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not generate patch")
|
||||||
|
}
|
||||||
|
repo.Manager.RecordTime(manager.PatchTime(howLong(start)))
|
||||||
|
inspectPatch(patch, c, repo)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// inspectFilesAtCommit accepts a commit object and a repo. This function is only called when the --files-at-commit=
|
||||||
|
// option has been set. That option tells gitleaks to look only at ALL the files at a commit and check the contents
|
||||||
|
// of said commit. Similar to inspectPatch(), if the files contained in the commit are a binaries or if they are
|
||||||
|
// whitelisted then those files will be skipped.
|
||||||
|
func inspectFilesAtCommit(c *object.Commit, repo *Repo) error {
|
||||||
fIter, err := c.Files()
|
fIter, err := c.Files()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -255,7 +316,7 @@ func inspectCommit(c *object.Commit, repo *Repo) error {
|
|||||||
|
|
||||||
err = fIter.ForEach(func(f *object.File) error {
|
err = fIter.ForEach(func(f *object.File) error {
|
||||||
bin, err := f.IsBinary()
|
bin, err := f.IsBinary()
|
||||||
if bin {
|
if bin || repo.timeoutReached() {
|
||||||
return nil
|
return nil
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/v3/options"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/v3/options"
|
||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
module github.com/zricethezav/gitleaks
|
module github.com/zricethezav/gitleaks/v3
|
||||||
|
|
||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
|
|||||||
+16
-8
@@ -6,9 +6,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/audit"
|
"github.com/zricethezav/gitleaks/v3/audit"
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
"github.com/zricethezav/gitleaks/v3/manager"
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/v3/options"
|
||||||
|
|
||||||
"github.com/google/go-github/github"
|
"github.com/google/go-github/github"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@@ -21,13 +21,13 @@ import (
|
|||||||
// Github wraps a github client and manager. This struct implements what the Host interface defines.
|
// Github wraps a github client and manager. This struct implements what the Host interface defines.
|
||||||
type Github struct {
|
type Github struct {
|
||||||
client *github.Client
|
client *github.Client
|
||||||
manager manager.Manager
|
manager *manager.Manager
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewGithubClient accepts a manager struct and returns a Github host pointer which will be used to
|
// 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.
|
// 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
|
var err error
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
token := oauth2.StaticTokenSource(
|
token := oauth2.StaticTokenSource(
|
||||||
@@ -72,7 +72,15 @@ func (g *Github) Audit() {
|
|||||||
_githubRepos, resp, err = g.client.Repositories.ListByOrg(ctx, g.manager.Opts.Organization,
|
_githubRepos, resp, err = g.client.Repositories.ListByOrg(ctx, g.manager.Opts.Organization,
|
||||||
&github.RepositoryListByOrgOptions{ListOptions: listOptions})
|
&github.RepositoryListByOrgOptions{ListOptions: listOptions})
|
||||||
}
|
}
|
||||||
githubRepos = append(githubRepos, _githubRepos...)
|
|
||||||
|
for _, r := range _githubRepos {
|
||||||
|
if g.manager.Opts.ExcludeForks && r.GetFork() {
|
||||||
|
log.Debugf("excluding forked repo: %s", *r.Name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
githubRepos = append(githubRepos, r)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if resp == nil {
|
if resp == nil {
|
||||||
break
|
break
|
||||||
@@ -91,7 +99,7 @@ func (g *Github) Audit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, repo := range githubRepos {
|
for _, repo := range githubRepos {
|
||||||
r := audit.NewRepo(&g.manager)
|
r := audit.NewRepo(g.manager)
|
||||||
r.Name = *repo.Name
|
r.Name = *repo.Name
|
||||||
err := r.Clone(&git.CloneOptions{
|
err := r.Clone(&git.CloneOptions{
|
||||||
URL: *repo.CloneURL,
|
URL: *repo.CloneURL,
|
||||||
@@ -123,7 +131,7 @@ func (g *Github) AuditPR() {
|
|||||||
owner := splits[len(splits)-4]
|
owner := splits[len(splits)-4]
|
||||||
repoName := splits[len(splits)-3]
|
repoName := splits[len(splits)-3]
|
||||||
prNum, err := strconv.Atoi(splits[len(splits)-1])
|
prNum, err := strconv.Atoi(splits[len(splits)-1])
|
||||||
repo := audit.NewRepo(&g.manager)
|
repo := audit.NewRepo(g.manager)
|
||||||
repo.Name = repoName
|
repo.Name = repoName
|
||||||
log.Infof("auditing pr %s\n", g.manager.Opts.PullRequest)
|
log.Infof("auditing pr %s\n", g.manager.Opts.PullRequest)
|
||||||
|
|
||||||
|
|||||||
+16
-9
@@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/audit"
|
"github.com/zricethezav/gitleaks/v3/audit"
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
"github.com/zricethezav/gitleaks/v3/manager"
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/v3/options"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/xanzy/go-gitlab"
|
"github.com/xanzy/go-gitlab"
|
||||||
@@ -15,14 +15,14 @@ import (
|
|||||||
// Gitlab wraps a gitlab client and manager. This struct implements what the Host interface defines.
|
// Gitlab wraps a gitlab client and manager. This struct implements what the Host interface defines.
|
||||||
type Gitlab struct {
|
type Gitlab struct {
|
||||||
client *gitlab.Client
|
client *gitlab.Client
|
||||||
manager manager.Manager
|
manager *manager.Manager
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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, error) {
|
func NewGitlabClient(m *manager.Manager) (*Gitlab, error) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
gitlabClient := &Gitlab{
|
gitlabClient := &Gitlab{
|
||||||
@@ -57,19 +57,26 @@ func (g *Gitlab) Audit() {
|
|||||||
glOpts := &gitlab.ListProjectsOptions{
|
glOpts := &gitlab.ListProjectsOptions{
|
||||||
ListOptions: listOpts,
|
ListOptions: listOpts,
|
||||||
}
|
}
|
||||||
projects, resp, err = g.client.Projects.ListUserProjects(g.manager.Opts.User, glOpts)
|
_projects, resp, err = g.client.Projects.ListUserProjects(g.manager.Opts.User, glOpts)
|
||||||
|
|
||||||
} else if g.manager.Opts.Organization != "" {
|
} else if g.manager.Opts.Organization != "" {
|
||||||
glOpts := &gitlab.ListGroupProjectsOptions{
|
glOpts := &gitlab.ListGroupProjectsOptions{
|
||||||
ListOptions: listOpts,
|
ListOptions: listOpts,
|
||||||
}
|
}
|
||||||
projects, resp, err = g.client.Groups.ListGroupProjects(g.manager.Opts.Organization, glOpts)
|
_projects, resp, err = g.client.Groups.ListGroupProjects(g.manager.Opts.Organization, glOpts)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
projects = append(projects, _projects...)
|
for _, p := range _projects {
|
||||||
|
if g.manager.Opts.ExcludeForks && p.ForkedFromProject != nil {
|
||||||
|
log.Debugf("excluding forked repo: %s", p.Name)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
projects = append(projects, p)
|
||||||
|
}
|
||||||
|
|
||||||
if resp == nil {
|
if resp == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -82,7 +89,7 @@ func (g *Gitlab) Audit() {
|
|||||||
|
|
||||||
// iterate of gitlab projects
|
// iterate of gitlab projects
|
||||||
for _, p := range projects {
|
for _, p := range projects {
|
||||||
r := audit.NewRepo(&g.manager)
|
r := audit.NewRepo(g.manager)
|
||||||
cloneOpts := g.manager.CloneOptions
|
cloneOpts := g.manager.CloneOptions
|
||||||
cloneOpts.URL = p.HTTPURLToRepo
|
cloneOpts.URL = p.HTTPURLToRepo
|
||||||
err := r.Clone(cloneOpts)
|
err := r.Clone(cloneOpts)
|
||||||
|
|||||||
+3
-3
@@ -1,7 +1,7 @@
|
|||||||
package hosts
|
package hosts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
"github.com/zricethezav/gitleaks/v3/manager"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -23,9 +23,9 @@ func Run(m *manager.Manager) error {
|
|||||||
var err error
|
var err error
|
||||||
switch getHost(m.Opts.Host) {
|
switch getHost(m.Opts.Host) {
|
||||||
case _github:
|
case _github:
|
||||||
host, err = NewGithubClient(*m)
|
host, err = NewGithubClient(m)
|
||||||
case _gitlab:
|
case _gitlab:
|
||||||
host, err = NewGitlabClient(*m)
|
host, err = NewGitlabClient(m)
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -3,9 +3,9 @@ package hosts
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/zricethezav/gitleaks/config"
|
"github.com/zricethezav/gitleaks/v3/config"
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
"github.com/zricethezav/gitleaks/v3/manager"
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/v3/options"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/audit"
|
"github.com/zricethezav/gitleaks/v3/audit"
|
||||||
"github.com/zricethezav/gitleaks/config"
|
"github.com/zricethezav/gitleaks/v3/config"
|
||||||
"github.com/zricethezav/gitleaks/hosts"
|
"github.com/zricethezav/gitleaks/v3/hosts"
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
"github.com/zricethezav/gitleaks/v3/manager"
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/v3/options"
|
||||||
|
|
||||||
"github.com/hako/durafmt"
|
"github.com/hako/durafmt"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|||||||
+2
-2
@@ -13,8 +13,8 @@ import (
|
|||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/config"
|
"github.com/zricethezav/gitleaks/v3/config"
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/v3/options"
|
||||||
|
|
||||||
"github.com/hako/durafmt"
|
"github.com/hako/durafmt"
|
||||||
"github.com/mattn/go-colorable"
|
"github.com/mattn/go-colorable"
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package manager
|
|||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/zricethezav/gitleaks/config"
|
"github.com/zricethezav/gitleaks/v3/config"
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/v3/options"
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|||||||
+29
-26
@@ -7,7 +7,7 @@ import (
|
|||||||
"os/user"
|
"os/user"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/version"
|
"github.com/zricethezav/gitleaks/v3/version"
|
||||||
|
|
||||||
"github.com/jessevdk/go-flags"
|
"github.com/jessevdk/go-flags"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@@ -27,37 +27,40 @@ const (
|
|||||||
|
|
||||||
// Options stores values of command line options
|
// Options stores values of command line options
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Verbose bool `short:"v" long:"verbose" description:"Show verbose output from audit"`
|
Verbose bool `short:"v" long:"verbose" description:"Show verbose output from audit"`
|
||||||
Repo string `short:"r" long:"repo" description:"Target repository"`
|
Repo string `short:"r" long:"repo" description:"Target repository"`
|
||||||
Config string `long:"config" description:"config path"`
|
Config string `long:"config" description:"config path"`
|
||||||
Disk bool `long:"disk" description:"Clones repo(s) to disk"`
|
Disk bool `long:"disk" description:"Clones repo(s) to disk"`
|
||||||
Version bool `long:"version" description:"version number"`
|
Version bool `long:"version" description:"version number"`
|
||||||
Timeout int `long:"timeout" description:"Timeout (s)"`
|
Username string `long:"username" description:"Username for git repo"`
|
||||||
Username string `long:"username" description:"Username for git repo"`
|
Password string `long:"password" description:"Password for git repo"`
|
||||||
Password string `long:"password" description:"Password for git repo"`
|
AccessToken string `long:"access-token" description:"Access token for git repo"`
|
||||||
AccessToken string `long:"access-token" description:"Access token for git repo"`
|
Commit string `long:"commit" description:"sha of commit to audit"`
|
||||||
Commit string `long:"commit" description:"sha of commit to audit"`
|
FilesAtCommit string `long:"files-at-commit" description:"sha of commit to audit all files at commit"`
|
||||||
Threads int `long:"threads" description:"Maximum number of threads gitleaks spawns"`
|
Threads int `long:"threads" description:"Maximum number of threads gitleaks spawns"`
|
||||||
SSH string `long:"ssh-key" description:"path to ssh key used for auth"`
|
SSH string `long:"ssh-key" description:"path to ssh key used for auth"`
|
||||||
Uncommited bool `long:"uncommitted" description:"run gitleaks on uncommitted code"`
|
Uncommited bool `long:"uncommitted" description:"run gitleaks on uncommitted code"`
|
||||||
RepoPath string `long:"repo-path" description:"Path to repo"`
|
RepoPath string `long:"repo-path" description:"Path to repo"`
|
||||||
OwnerPath string `long:"owner-path" description:"Path to owner directory (repos discovered)"`
|
OwnerPath string `long:"owner-path" description:"Path to owner directory (repos discovered)"`
|
||||||
Branch string `long:"branch" description:"Branch to audit"`
|
Branch string `long:"branch" description:"Branch to audit"`
|
||||||
Report string `long:"report" description:"path to write json leaks file"`
|
Report string `long:"report" description:"path to write json leaks file"`
|
||||||
ReportFormat string `long:"report-format" default:"json" description:"json or csv"`
|
ReportFormat string `long:"report-format" default:"json" description:"json or csv"`
|
||||||
Redact bool `long:"redact" description:"redact secrets from log messages and leaks"`
|
Redact bool `long:"redact" description:"redact secrets from log messages and leaks"`
|
||||||
Debug bool `long:"debug" description:"log debug messages"`
|
Debug bool `long:"debug" description:"log debug messages"`
|
||||||
RepoConfig bool `long:"repo-config" description:"Load config from target repo. Config file must be \".gitleaks.toml\" or \"gitleaks.toml\""`
|
RepoConfig bool `long:"repo-config" description:"Load config from target repo. Config file must be \".gitleaks.toml\" or \"gitleaks.toml\""`
|
||||||
PrettyPrint bool `long:"pretty" description:"Pretty print json if leaks are present"`
|
PrettyPrint bool `long:"pretty" description:"Pretty print json if leaks are present"`
|
||||||
CommitFrom string `long:"commit-from" description:"Commit to start audit from"`
|
CommitFrom string `long:"commit-from" description:"Commit to start audit from"`
|
||||||
CommitTo string `long:"commit-to" description:"Commit to stop audit"`
|
CommitTo string `long:"commit-to" description:"Commit to stop audit"`
|
||||||
|
Timeout string `long:"timeout" description:"Time allowed per audit. Ex: 10us, 30s, 1m, 1h10m1s"`
|
||||||
|
Depth int `long:"depth" description:"Number of commits to audit"`
|
||||||
|
|
||||||
// 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."`
|
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"`
|
||||||
PullRequest string `long:"pr" description:"pull/merge request url"`
|
PullRequest string `long:"pr" description:"pull/merge request url"`
|
||||||
|
ExcludeForks bool `long:"exclude-forks" description:"audit excludes forks"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseOptions is responsible for parsing options passed in by cli. An Options struct
|
// ParseOptions is responsible for parsing options passed in by cli. An Options struct
|
||||||
|
|||||||
@@ -232,5 +232,44 @@
|
|||||||
"file": "secrets.md",
|
"file": "secrets.md",
|
||||||
"date": "2019-10-25T13:35:03-04:00",
|
"date": "2019-10-25T13:35:03-04:00",
|
||||||
"tags": "key, API, generic"
|
"tags": "key, API, generic"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "\nmore_secrets = '99432bfewaf823ec3294e231'",
|
||||||
|
"offender": "secrets = '99432bfewaf823ec3294e231'",
|
||||||
|
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||||
|
"repo": "test_repo_5",
|
||||||
|
"rule": "Generic Credential",
|
||||||
|
"commitMessage": "even more secrets\n",
|
||||||
|
"author": "Zach Rice",
|
||||||
|
"email": "zrice@gitlab.com",
|
||||||
|
"file": "secrets.py",
|
||||||
|
"date": "2020-02-01T10:30:22-05:00",
|
||||||
|
"tags": "key, API, generic"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "\naws_access_key_id='AKIAIO5FODNN7EXAMPL2'",
|
||||||
|
"offender": "AKIAIO5FODNN7EXAMPL2",
|
||||||
|
"commit": "ca71fcdeda15f25f0cc661d90e8785c255925c27",
|
||||||
|
"repo": "test_repo_5",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "introduce more secrets\n",
|
||||||
|
"author": "Zach Rice",
|
||||||
|
"email": "zrice@gitlab.com",
|
||||||
|
"file": "secrets.py",
|
||||||
|
"date": "2020-02-01T10:08:04-05:00",
|
||||||
|
"tags": "key, AWS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE'",
|
||||||
|
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||||
|
"commit": "1f2a4abc47dabf991e6af6f9770867ce0ac1f360",
|
||||||
|
"repo": "test_repo_5",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "introduce secrets\n",
|
||||||
|
"author": "Zach Rice",
|
||||||
|
"email": "zrice@gitlab.com",
|
||||||
|
"file": "secrets.py",
|
||||||
|
"date": "2020-02-01T10:07:34-05:00",
|
||||||
|
"tags": "key, AWS"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"line": " aws_access_key_id='AKIAIO5FODNN7EXAMPLE',",
|
||||||
|
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||||
|
"commit": "6557c92612d3b35979bd426d429255b3bf9fab74",
|
||||||
|
"repo": "test_repo_1",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "commit 1 with secrets\n",
|
||||||
|
"author": "zach rice",
|
||||||
|
"email": "zricer@protonmail.com",
|
||||||
|
"file": "server.test.py",
|
||||||
|
"date": "2019-10-24T09:29:27-04:00",
|
||||||
|
"tags": "key, AWS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||||
|
"offender": "AKIALALEMEL33243OLIB",
|
||||||
|
"commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263",
|
||||||
|
"repo": "test_repo_2",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "rm secrets again\n",
|
||||||
|
"author": "zach rice",
|
||||||
|
"email": "zricer@protonmail.com",
|
||||||
|
"file": "secrets.md",
|
||||||
|
"date": "2019-10-25T13:12:32-04:00",
|
||||||
|
"tags": "key, AWS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"",
|
||||||
|
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
|
||||||
|
"commit": "f61cd8587b7ac1d75a89a0c9af870a2f24c60263",
|
||||||
|
"repo": "test_repo_2",
|
||||||
|
"rule": "Generic Credential",
|
||||||
|
"commitMessage": "rm secrets again\n",
|
||||||
|
"author": "zach rice",
|
||||||
|
"email": "zricer@protonmail.com",
|
||||||
|
"file": "secrets.md",
|
||||||
|
"date": "2019-10-25T13:12:32-04:00",
|
||||||
|
"tags": "key, API, generic"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": " const AWSKEY = \"AKIALALEMEL33243OLIBE\"",
|
||||||
|
"offender": "AKIALALEMEL33243OLIB",
|
||||||
|
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||||
|
"repo": "test_repo_2",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "adding another one\n",
|
||||||
|
"author": "zach rice",
|
||||||
|
"email": "zricer@protonmail.com",
|
||||||
|
"file": "secrets.md",
|
||||||
|
"date": "2019-10-25T13:12:08-04:00",
|
||||||
|
"tags": "key, AWS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": " const AWSSECRET = \"99432bfewaf823ec3294e231\"",
|
||||||
|
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
|
||||||
|
"commit": "b2eb34a61c988afd9b4aaa9dd58c8dd7d5f14dba",
|
||||||
|
"repo": "test_repo_2",
|
||||||
|
"rule": "Generic Credential",
|
||||||
|
"commitMessage": "adding another one\n",
|
||||||
|
"author": "zach rice",
|
||||||
|
"email": "zricer@protonmail.com",
|
||||||
|
"file": "secrets.md",
|
||||||
|
"date": "2019-10-25T13:12:08-04:00",
|
||||||
|
"tags": "key, API, generic"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
|
||||||
|
"offender": "AKIALALEMEL33243OLIA",
|
||||||
|
"commit": "cd5eb8bef855f73c46b97b4c088badffdc40ebe9",
|
||||||
|
"repo": "test_repo_3",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "rm secrets\n",
|
||||||
|
"author": "zach rice",
|
||||||
|
"email": "zricer@protonmail.com",
|
||||||
|
"file": "secrets.md",
|
||||||
|
"date": "2019-10-25T13:54:26-04:00",
|
||||||
|
"tags": "key, AWS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "const AWSSECRET = \"99432bfewaf823ec3294e231\"",
|
||||||
|
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
|
||||||
|
"commit": "cd5eb8bef855f73c46b97b4c088badffdc40ebe9",
|
||||||
|
"repo": "test_repo_3",
|
||||||
|
"rule": "Generic Credential",
|
||||||
|
"commitMessage": "rm secrets\n",
|
||||||
|
"author": "zach rice",
|
||||||
|
"email": "zricer@protonmail.com",
|
||||||
|
"file": "secrets.md",
|
||||||
|
"date": "2019-10-25T13:54:26-04:00",
|
||||||
|
"tags": "key, API, generic"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "const AWSKEY = \"AKIALALEMEL33243OLIAE\"",
|
||||||
|
"offender": "AKIALALEMEL33243OLIA",
|
||||||
|
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
|
||||||
|
"repo": "test_repo_3",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "more secrets\n",
|
||||||
|
"author": "zach rice",
|
||||||
|
"email": "zricer@protonmail.com",
|
||||||
|
"file": "secrets.md",
|
||||||
|
"date": "2019-10-25T13:54:08-04:00",
|
||||||
|
"tags": "key, AWS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "const AWSSECRET = \"99432bfewaf823ec3294e231\"",
|
||||||
|
"offender": "SECRET = \"99432bfewaf823ec3294e231\"",
|
||||||
|
"commit": "84ac4e80d4dbf2c968b64e9d4005f5079795bb81",
|
||||||
|
"repo": "test_repo_3",
|
||||||
|
"rule": "Generic Credential",
|
||||||
|
"commitMessage": "more secrets\n",
|
||||||
|
"author": "zach rice",
|
||||||
|
"email": "zricer@protonmail.com",
|
||||||
|
"file": "secrets.md",
|
||||||
|
"date": "2019-10-25T13:54:08-04:00",
|
||||||
|
"tags": "key, API, generic"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "\nmore_secrets = '99432bfewaf823ec3294e231'",
|
||||||
|
"offender": "secrets = '99432bfewaf823ec3294e231'",
|
||||||
|
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||||
|
"repo": "test_repo_5",
|
||||||
|
"rule": "Generic Credential",
|
||||||
|
"commitMessage": "even more secrets\n",
|
||||||
|
"author": "Zach Rice",
|
||||||
|
"email": "zrice@gitlab.com",
|
||||||
|
"file": "secrets.py",
|
||||||
|
"date": "2020-02-01T10:30:22-05:00",
|
||||||
|
"tags": "key, API, generic"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "\naws_access_key_id='AKIAIO5FODNN7EXAMPL2'",
|
||||||
|
"offender": "AKIAIO5FODNN7EXAMPL2",
|
||||||
|
"commit": "ca71fcdeda15f25f0cc661d90e8785c255925c27",
|
||||||
|
"repo": "test_repo_5",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "introduce more secrets\n",
|
||||||
|
"author": "Zach Rice",
|
||||||
|
"email": "zrice@gitlab.com",
|
||||||
|
"file": "secrets.py",
|
||||||
|
"date": "2020-02-01T10:08:04-05:00",
|
||||||
|
"tags": "key, AWS"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"line": "\nmore_secrets = '99432bfewaf823ec3294e231'",
|
||||||
|
"offender": "secrets = '99432bfewaf823ec3294e231'",
|
||||||
|
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||||
|
"repo": "test_repo_5",
|
||||||
|
"rule": "Generic Credential",
|
||||||
|
"commitMessage": "even more secrets\n",
|
||||||
|
"author": "Zach Rice",
|
||||||
|
"email": "zrice@gitlab.com",
|
||||||
|
"file": "secrets.py",
|
||||||
|
"date": "2020-02-01T10:30:22-05:00",
|
||||||
|
"tags": "key, API, generic"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPLE'",
|
||||||
|
"offender": "AKIAIO5FODNN7EXAMPLE",
|
||||||
|
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||||
|
"repo": "test_repo_5",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "even more secrets\n",
|
||||||
|
"author": "Zach Rice",
|
||||||
|
"email": "zrice@gitlab.com",
|
||||||
|
"file": "secrets.py",
|
||||||
|
"date": "2020-02-01T10:30:22-05:00",
|
||||||
|
"tags": "key, AWS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "aws_access_key_id='AKIAIO5FODNN7EXAMPL2'",
|
||||||
|
"offender": "AKIAIO5FODNN7EXAMPL2",
|
||||||
|
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||||
|
"repo": "test_repo_5",
|
||||||
|
"rule": "AWS Manager ID",
|
||||||
|
"commitMessage": "even more secrets\n",
|
||||||
|
"author": "Zach Rice",
|
||||||
|
"email": "zrice@gitlab.com",
|
||||||
|
"file": "secrets.py",
|
||||||
|
"date": "2020-02-01T10:30:22-05:00",
|
||||||
|
"tags": "key, AWS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"line": "more_secrets = '99432bfewaf823ec3294e231'",
|
||||||
|
"offender": "secrets = '99432bfewaf823ec3294e231'",
|
||||||
|
"commit": "a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0",
|
||||||
|
"repo": "test_repo_5",
|
||||||
|
"rule": "Generic Credential",
|
||||||
|
"commitMessage": "even more secrets\n",
|
||||||
|
"author": "Zach Rice",
|
||||||
|
"email": "zrice@gitlab.com",
|
||||||
|
"file": "secrets.py",
|
||||||
|
"date": "2020-02-01T10:30:22-05:00",
|
||||||
|
"tags": "key, API, generic"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
even more secrets
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
ref: refs/heads/master
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[core]
|
||||||
|
repositoryformatversion = 0
|
||||||
|
filemode = true
|
||||||
|
bare = false
|
||||||
|
logallrefupdates = true
|
||||||
|
ignorecase = true
|
||||||
|
precomposeunicode = true
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Unnamed repository; edit this file 'description' to name the repository.
|
||||||
Binary file not shown.
@@ -0,0 +1,6 @@
|
|||||||
|
# git ls-files --others --exclude-from=.git/info/exclude
|
||||||
|
# Lines that start with '#' are comments.
|
||||||
|
# For a project mostly in C, the following would be a good set of
|
||||||
|
# exclude patterns (uncomment them if you want to use them):
|
||||||
|
# *.[oa]
|
||||||
|
# *~
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
0000000000000000000000000000000000000000 547bc0caa26ce3f20bea9ad9bb0f7e3e9dc749ec Zach Rice <zrice@gitlab.com> 1580490269 -0500 commit (initial): init
|
||||||
|
547bc0caa26ce3f20bea9ad9bb0f7e3e9dc749ec 1f2a4abc47dabf991e6af6f9770867ce0ac1f360 Zach Rice <zrice@gitlab.com> 1580569654 -0500 commit: introduce secrets
|
||||||
|
1f2a4abc47dabf991e6af6f9770867ce0ac1f360 ca71fcdeda15f25f0cc661d90e8785c255925c27 Zach Rice <zrice@gitlab.com> 1580569684 -0500 commit: introduce more secrets
|
||||||
|
ca71fcdeda15f25f0cc661d90e8785c255925c27 a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0 Zach Rice <zrice@gitlab.com> 1580571022 -0500 commit: even more secrets
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
0000000000000000000000000000000000000000 547bc0caa26ce3f20bea9ad9bb0f7e3e9dc749ec Zach Rice <zrice@gitlab.com> 1580490269 -0500 commit (initial): init
|
||||||
|
547bc0caa26ce3f20bea9ad9bb0f7e3e9dc749ec 1f2a4abc47dabf991e6af6f9770867ce0ac1f360 Zach Rice <zrice@gitlab.com> 1580569654 -0500 commit: introduce secrets
|
||||||
|
1f2a4abc47dabf991e6af6f9770867ce0ac1f360 ca71fcdeda15f25f0cc661d90e8785c255925c27 Zach Rice <zrice@gitlab.com> 1580569684 -0500 commit: introduce more secrets
|
||||||
|
ca71fcdeda15f25f0cc661d90e8785c255925c27 a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0 Zach Rice <zrice@gitlab.com> 1580571022 -0500 commit: even more secrets
|
||||||
BIN
Binary file not shown.
+2
@@ -0,0 +1,2 @@
|
|||||||
|
x•ŽM
|
||||||
|
Â0F]繀’ß&ĎŕŇÝĚdb¶•4ÝxzsW<xĽŹ¶e©]cN˝1˨�±™°” MA«ĽĆ’µˇ�0;ŚĹŻ]z��‰ŘŁ�!AN�޶ś2—�}Ţš|ÍňQ‰ĺőŰĆÜ_µż/´-7©}T~J“wň¬ĽRbĐń®óżž¨ko[>FfgjÜwń;ěH�
|
||||||
BIN
Binary file not shown.
+4
@@ -0,0 +1,4 @@
|
|||||||
|
x•�A
|
||||||
|
‚!F[{й@1ú«)Dt†–ítû…L�iÓéó
|
||||||
|
>xðÞG£÷& ½>Èd*¶š’3ç@hü‘μéZB$olEçL.dTúÈ>&<ípoÄpùÎ5·g“WÊ'ý
|
||||||
|
Ú´qe"Ñ!ªE×›ð¿žjï&êÚQ3–
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+2
@@ -0,0 +1,2 @@
|
|||||||
|
x•ŽA
|
||||||
|
Â0E]çse2Í$-ˆx—îÒéÄl#itáéÍ\=xŸ_òº.ˆèP‹*$%.29¥ë1«O®␍ê58ï�Ìæ‹n$›dÒ)ZNÄ E¼·Ó€Ú‡ž¥Å5ßuÎîQf¸-¢pþ–†ëc©Ï8ž$¯°Ü#‹DpDF4ͶwUÿíŒ~tƒ5…]¥hÝÍ\ïES
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
x•ŽAj1E»ö)t�yì‘l(¥gȲ;Y–“�N\g“Óg®ÐÕ‡�÷µïû6aYøc3Xk)![ñ)�ÊZ#'Zjð>ÇbèþdØ}‚o‹D)¹Ji9{#iÔ23&b5õ-:yÎ[ð#zƒË¦Ÿ¯qÌ÷u›¿RÎÚ÷/ðk•2¥'\ÝA�wÓþë¹í>G¯Ï#³÷að06î␍ÿGó
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
a4c9fb737d5552fd96fce5cc7eedb23353ba9ed0
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Init
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
aws_access_key_id='AKIAIO5FODNN7EXAMPLE'
|
||||||
|
print(aws_access_key_id)
|
||||||
|
|
||||||
|
aws_access_key_id='AKIAIO5FODNN7EXAMPL2'
|
||||||
|
print(aws_access_key_id)
|
||||||
|
|
||||||
|
more_secrets = '99432bfewaf823ec3294e231'
|
||||||
|
print(more_secrets)
|
||||||
|
|
||||||
Reference in new issue
Block a user