mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 04:34:46 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67454d109e | ||
|
|
ce603c73b4 | ||
|
|
55218fc8f8 | ||
|
|
5d81c650e8 | ||
|
|
0726209172 | ||
|
|
bfec8aca51 | ||
|
|
a9b30edb06 | ||
|
|
cc6d698e63 | ||
|
|
2ba97d0fa3 | ||
|
|
d299b5aa7f | ||
|
|
0a209b60a5 | ||
|
|
fe8c6271f2 | ||
|
|
42fb085684 | ||
|
|
3faec00bf9 | ||
|
|
93669f1ee8 |
No files matched your search
@@ -1,6 +1,44 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
1.8.0
|
||||||
|
-----
|
||||||
|
- whitelist repos
|
||||||
|
- sample config option
|
||||||
|
|
||||||
|
1.7.3
|
||||||
|
-----
|
||||||
|
- style points
|
||||||
|
|
||||||
|
1.7.2
|
||||||
|
-----
|
||||||
|
- Fixing dangling goroutines, removing channel messaging
|
||||||
|
|
||||||
|
1.7.1
|
||||||
|
-----
|
||||||
|
- Fixing bug where single repos were not being audited
|
||||||
|
|
||||||
|
1.7.0
|
||||||
|
-----
|
||||||
|
- Exit code == 2 on error
|
||||||
|
- Cleaning up some logs
|
||||||
|
- Removing some unreachable code
|
||||||
|
|
||||||
|
1.6.1
|
||||||
|
-----
|
||||||
|
- Recover from panic when diffing
|
||||||
|
|
||||||
|
1.6.0
|
||||||
|
-----
|
||||||
|
- Default maximum goroutines spawned is number of cores your cpu run with. See benchmarks in wiki.
|
||||||
|
- Cleanup after each repo audit for organizations rather than waiting for the entire organization to complete. Eliminates risk of running out of disk space.
|
||||||
|
|
||||||
|
|
||||||
|
1.5.0
|
||||||
|
-----
|
||||||
|
- Support for CSV reporting
|
||||||
|
- Refactoring github user/owner audits
|
||||||
|
|
||||||
1.4.0
|
1.4.0
|
||||||
-----
|
-----
|
||||||
- Support for single commit repos
|
- Support for single commit repos
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Contributing Guidelines
|
||||||
|
|
||||||
|
The gitleaks project is under [GNU General Public License v3.0](LICENSE.md) and accepts
|
||||||
|
contributions via GitHub pull requests.
|
||||||
|
|
||||||
|
## How to Contribute
|
||||||
|
|
||||||
|
Open a PR. Give the PR a descriptive title. Add some comments describing whats the purpose of the PR.
|
||||||
|
|
||||||
|
__BUT before you do that!__
|
||||||
|
|
||||||
|
Make sure you pass this list of requirements.
|
||||||
|
|
||||||
|
- You've ran `go fmt`.
|
||||||
|
- You've ran `golint`.
|
||||||
|
- Your Go changes are confined to `gitleaks_test.go` and `main.go`. This is subject to change as the project evolves. Stylistically, I like having a single go file considering the size of this project (its tiny).
|
||||||
|
- You've added test cases for your changes.
|
||||||
|
- You've updated [the changelog](CHANGELOG.md).
|
||||||
|
- Your tests pass.
|
||||||
|
|
||||||
@@ -4,13 +4,12 @@ test:
|
|||||||
go get github.com/golang/lint/golint
|
go get github.com/golang/lint/golint
|
||||||
go fmt
|
go fmt
|
||||||
golint
|
golint
|
||||||
go test --race -cover
|
go test --race --cover -run=Test$
|
||||||
deploy:
|
deploy:
|
||||||
@echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
|
@echo "$(DOCKER_PASSWORD)" | docker login -u "$(DOCKER_USERNAME)" --password-stdin
|
||||||
docker build -f Dockerfile -t $(REPO):$(TAG) .
|
docker build -f Dockerfile -t $(REPO):$(TAG) .
|
||||||
echo "Pushing $(REPO):$(COMMIT) $(REPO):$(TAG)"
|
echo "Pushing $(REPO):$(COMMIT) $(REPO):$(TAG)"
|
||||||
docker push $(REPO)
|
docker push $(REPO)
|
||||||
|
|
||||||
build-all:
|
build-all:
|
||||||
rm -rf build
|
rm -rf build
|
||||||
mkdir build
|
mkdir build
|
||||||
@@ -21,3 +20,8 @@ build-all:
|
|||||||
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips"
|
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips"
|
||||||
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips"
|
env GOOS="linux" GOARCH="mips" go build -o "build/gitleaks-linux-mips"
|
||||||
env GOOS="darwin" GOARCH="amd64" go build -o "build/gitleaks-darwin-amd64"
|
env GOOS="darwin" GOARCH="amd64" go build -o "build/gitleaks-darwin-amd64"
|
||||||
|
benchmark:
|
||||||
|
go test -run=Benchmark -bench=. -benchtime=5s
|
||||||
|
benchmark-fast:
|
||||||
|
go test -bench=BenchmarkAuditLeakRepo -run=BenchmarkAuditLeakRepo$
|
||||||
|
|
||||||
@@ -43,16 +43,19 @@ Application Options:
|
|||||||
-l, --log= log level
|
-l, --log= log level
|
||||||
-v, --verbose Show verbose output from gitleaks audit
|
-v, --verbose Show verbose output from gitleaks audit
|
||||||
--report= path to write report file
|
--report= path to write report file
|
||||||
|
--csv report output to csv
|
||||||
--redact redact secrets from log messages and report
|
--redact redact secrets from log messages and report
|
||||||
--version version number
|
--version version number
|
||||||
|
--sample-config prints a sample config file
|
||||||
|
|
||||||
Help Options:
|
Help Options:
|
||||||
-h, --help Show this help message
|
-h, --help Show this help message
|
||||||
```
|
```
|
||||||
#### Exit Codes
|
#### Exit Codes
|
||||||
```
|
```
|
||||||
1: leaks present
|
|
||||||
0: no leaks
|
0: no leaks
|
||||||
|
1: leaks present
|
||||||
|
2: error encountered
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Additional Examples and Explanations
|
#### Additional Examples and Explanations
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ regex = '''(?i)twitter.*['\"][0-9a-zA-Z]{35,44}['\"]'''
|
|||||||
|
|
||||||
[whitelist]
|
[whitelist]
|
||||||
regexes = [
|
regexes = [
|
||||||
"AKIA.*",
|
# "AKIA.*EXAMPLE",
|
||||||
]
|
]
|
||||||
files = [
|
files = [
|
||||||
"(.*?)(jpg|gif|doc|pdf|bin|go)$"
|
"(.*?)(jpg|gif|doc|pdf|bin|go)$"
|
||||||
|
|||||||
+306
-40
@@ -56,6 +56,46 @@ regexes= [
|
|||||||
]
|
]
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const testWhitelistRepo = `
|
||||||
|
[[regexes]]
|
||||||
|
description = "AWS"
|
||||||
|
regex = '''AKIA[0-9A-Z]{16}'''
|
||||||
|
|
||||||
|
[whitelist]
|
||||||
|
repos = [
|
||||||
|
"gronit",
|
||||||
|
]
|
||||||
|
`
|
||||||
|
|
||||||
|
var benchmarkRepo *RepoDescriptor
|
||||||
|
var benchmarkLeaksRepo *RepoDescriptor
|
||||||
|
|
||||||
|
func getBenchmarkLeaksRepo() *RepoDescriptor {
|
||||||
|
if benchmarkLeaksRepo != nil {
|
||||||
|
return benchmarkLeaksRepo
|
||||||
|
}
|
||||||
|
leaksR, _ := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||||
|
URL: "https://github.com/gitleakstest/gronit.git",
|
||||||
|
})
|
||||||
|
benchmarkLeaksRepo = &RepoDescriptor{
|
||||||
|
repository: leaksR,
|
||||||
|
}
|
||||||
|
return benchmarkLeaksRepo
|
||||||
|
}
|
||||||
|
|
||||||
|
func getBenchmarkRepo() *RepoDescriptor {
|
||||||
|
if benchmarkRepo != nil {
|
||||||
|
return benchmarkRepo
|
||||||
|
}
|
||||||
|
bmRepo, _ := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||||
|
URL: "https://github.com/apple/swift-package-manager.git",
|
||||||
|
})
|
||||||
|
benchmarkRepo = &RepoDescriptor{
|
||||||
|
repository: bmRepo,
|
||||||
|
}
|
||||||
|
return benchmarkRepo
|
||||||
|
}
|
||||||
|
|
||||||
func TestGetRepo(t *testing.T) {
|
func TestGetRepo(t *testing.T) {
|
||||||
var err error
|
var err error
|
||||||
dir, err = ioutil.TempDir("", "gitleaksTestRepo")
|
dir, err = ioutil.TempDir("", "gitleaksTestRepo")
|
||||||
@@ -128,7 +168,7 @@ func TestGetRepo(t *testing.T) {
|
|||||||
g.Describe("TestGetRepo", func() {
|
g.Describe("TestGetRepo", func() {
|
||||||
g.It(test.description, func() {
|
g.It(test.description, func() {
|
||||||
opts = test.testOpts
|
opts = test.testOpts
|
||||||
_, err := getRepo()
|
_, err := cloneRepo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.Assert(err.Error()).Equal(test.expectedErrMsg)
|
g.Assert(err.Error()).Equal(test.expectedErrMsg)
|
||||||
}
|
}
|
||||||
@@ -136,9 +176,9 @@ func TestGetRepo(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func TestRun(t *testing.T) {
|
||||||
func TestGetOwnerRepo(t *testing.T) {
|
|
||||||
var err error
|
var err error
|
||||||
|
configsDir := testTomlLoader()
|
||||||
|
|
||||||
dir, err = ioutil.TempDir("", "gitleaksTestOwner")
|
dir, err = ioutil.TempDir("", "gitleaksTestOwner")
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
@@ -155,14 +195,16 @@ func TestGetOwnerRepo(t *testing.T) {
|
|||||||
testOpts Options
|
testOpts Options
|
||||||
description string
|
description string
|
||||||
expectedErrMsg string
|
expectedErrMsg string
|
||||||
numRepos int
|
whiteListRepos []string
|
||||||
|
numLeaks int
|
||||||
|
configPath string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
testOpts: Options{
|
testOpts: Options{
|
||||||
GithubUser: "gitleakstest",
|
GithubUser: "gitleakstest",
|
||||||
},
|
},
|
||||||
description: "test github user",
|
description: "test github user",
|
||||||
numRepos: 2,
|
numLeaks: 2,
|
||||||
expectedErrMsg: "",
|
expectedErrMsg: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -171,7 +213,7 @@ func TestGetOwnerRepo(t *testing.T) {
|
|||||||
Disk: true,
|
Disk: true,
|
||||||
},
|
},
|
||||||
description: "test github user on disk ",
|
description: "test github user on disk ",
|
||||||
numRepos: 2,
|
numLeaks: 2,
|
||||||
expectedErrMsg: "",
|
expectedErrMsg: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -179,56 +221,83 @@ func TestGetOwnerRepo(t *testing.T) {
|
|||||||
GithubOrg: "gitleakstestorg",
|
GithubOrg: "gitleakstestorg",
|
||||||
},
|
},
|
||||||
description: "test github org",
|
description: "test github org",
|
||||||
numRepos: 2,
|
numLeaks: 2,
|
||||||
expectedErrMsg: "",
|
expectedErrMsg: "",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
testOpts: Options{
|
|
||||||
OwnerPath: dir,
|
|
||||||
},
|
|
||||||
description: "test plain clone remote repo",
|
|
||||||
numRepos: 2,
|
|
||||||
expectedErrMsg: "",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
testOpts: Options{
|
|
||||||
GithubOrg: "gitleakstestorg",
|
|
||||||
IncludePrivate: true,
|
|
||||||
},
|
|
||||||
description: "test private org no ssh",
|
|
||||||
numRepos: 0,
|
|
||||||
expectedErrMsg: "no ssh auth available",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
testOpts: Options{
|
testOpts: Options{
|
||||||
GithubOrg: "gitleakstestorg",
|
GithubOrg: "gitleakstestorg",
|
||||||
Disk: true,
|
Disk: true,
|
||||||
},
|
},
|
||||||
description: "test org on disk",
|
description: "test org on disk",
|
||||||
numRepos: 2,
|
numLeaks: 2,
|
||||||
|
expectedErrMsg: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testOpts: Options{
|
||||||
|
OwnerPath: dir,
|
||||||
|
},
|
||||||
|
description: "test owner path",
|
||||||
|
numLeaks: 2,
|
||||||
expectedErrMsg: "",
|
expectedErrMsg: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
testOpts: Options{
|
testOpts: Options{
|
||||||
GithubOrg: "gitleakstestorg",
|
GithubOrg: "gitleakstestorg",
|
||||||
IncludePrivate: true,
|
IncludePrivate: true,
|
||||||
Disk: true,
|
SSHKey: "reallyreallyreallyreallywrongpath",
|
||||||
},
|
},
|
||||||
description: "test private org on disk no ssh",
|
description: "test private org no ssh",
|
||||||
numRepos: 0,
|
numLeaks: 0,
|
||||||
expectedErrMsg: "no ssh auth available",
|
expectedErrMsg: "unable to generate ssh key: open reallyreallyreallyreallywrongpath: no such file or directory",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testOpts: Options{
|
||||||
|
Repo: "https://github.com/gitleakstest/gronit.git",
|
||||||
|
},
|
||||||
|
description: "test leak",
|
||||||
|
numLeaks: 2,
|
||||||
|
expectedErrMsg: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testOpts: Options{
|
||||||
|
Repo: "https://github.com/gitleakstest/h1domains.git",
|
||||||
|
},
|
||||||
|
description: "test clean",
|
||||||
|
numLeaks: 0,
|
||||||
|
expectedErrMsg: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testOpts: Options{
|
||||||
|
Repo: "https://github.com/gitleakstest/empty.git",
|
||||||
|
},
|
||||||
|
description: "test empty",
|
||||||
|
numLeaks: 0,
|
||||||
|
expectedErrMsg: "reference not found",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
testOpts: Options{
|
||||||
|
GithubOrg: "gitleakstestorg",
|
||||||
|
},
|
||||||
|
description: "test github org",
|
||||||
|
numLeaks: 0,
|
||||||
|
expectedErrMsg: "",
|
||||||
|
configPath: path.Join(configsDir, "repo"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
g := goblin.Goblin(t)
|
g := goblin.Goblin(t)
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
g.Describe("TestGetOwnerRepo", func() {
|
g.Describe("TestRun", func() {
|
||||||
g.It(test.description, func() {
|
g.It(test.description, func() {
|
||||||
|
if test.configPath != "" {
|
||||||
|
os.Setenv("GITLEAKS_CONFIG", test.configPath)
|
||||||
|
}
|
||||||
opts = test.testOpts
|
opts = test.testOpts
|
||||||
repos, err := getOwnerRepos()
|
leaks, err := run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.Assert(err.Error()).Equal(test.expectedErrMsg)
|
g.Assert(err.Error()).Equal(test.expectedErrMsg)
|
||||||
}
|
}
|
||||||
g.Assert(len(repos)).Equal(test.numRepos)
|
g.Assert(len(leaks)).Equal(test.numLeaks)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -236,7 +305,8 @@ func TestGetOwnerRepo(t *testing.T) {
|
|||||||
|
|
||||||
func TestWriteReport(t *testing.T) {
|
func TestWriteReport(t *testing.T) {
|
||||||
tmpDir, _ := ioutil.TempDir("", "reportDir")
|
tmpDir, _ := ioutil.TempDir("", "reportDir")
|
||||||
reportFile := path.Join(tmpDir, "report.json")
|
reportJSON := path.Join(tmpDir, "report.json")
|
||||||
|
reportCSV := path.Join(tmpDir, "report.csv")
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
leaks := []Leak{
|
leaks := []Leak{
|
||||||
{
|
{
|
||||||
@@ -260,11 +330,21 @@ func TestWriteReport(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
leaks: leaks,
|
leaks: leaks,
|
||||||
reportFile: reportFile,
|
reportFile: reportJSON,
|
||||||
fileName: "report.json",
|
fileName: "report.json",
|
||||||
description: "can we write a file",
|
description: "can we write a file",
|
||||||
testOpts: Options{
|
testOpts: Options{
|
||||||
Report: reportFile,
|
Report: reportJSON,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
leaks: leaks,
|
||||||
|
reportFile: reportCSV,
|
||||||
|
fileName: "report.csv",
|
||||||
|
description: "can we write a file",
|
||||||
|
testOpts: Options{
|
||||||
|
Report: reportCSV,
|
||||||
|
CSV: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -288,6 +368,7 @@ func testTomlLoader() string {
|
|||||||
ioutil.WriteFile(path.Join(tmpDir, "branch"), []byte(testWhitelistBranch), 0644)
|
ioutil.WriteFile(path.Join(tmpDir, "branch"), []byte(testWhitelistBranch), 0644)
|
||||||
ioutil.WriteFile(path.Join(tmpDir, "commit"), []byte(testWhitelistCommit), 0644)
|
ioutil.WriteFile(path.Join(tmpDir, "commit"), []byte(testWhitelistCommit), 0644)
|
||||||
ioutil.WriteFile(path.Join(tmpDir, "file"), []byte(testWhitelistFile), 0644)
|
ioutil.WriteFile(path.Join(tmpDir, "file"), []byte(testWhitelistFile), 0644)
|
||||||
|
ioutil.WriteFile(path.Join(tmpDir, "repo"), []byte(testWhitelistRepo), 0644)
|
||||||
return tmpDir
|
return tmpDir
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,29 +381,38 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
leaksRepo, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
leaksR, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||||
URL: "https://github.com/gitleakstest/gronit.git",
|
URL: "https://github.com/gitleakstest/gronit.git",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
leaksRepo := &RepoDescriptor{
|
||||||
|
repository: leaksR,
|
||||||
|
name: "gronit",
|
||||||
|
}
|
||||||
|
|
||||||
cleanRepo, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
cleanR, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||||
URL: "https://github.com/gitleakstest/h1domains.git",
|
URL: "https://github.com/gitleakstest/h1domains.git",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
cleanRepo := &RepoDescriptor{
|
||||||
|
repository: cleanR,
|
||||||
|
name: "h1domains",
|
||||||
|
}
|
||||||
|
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
testOpts Options
|
testOpts Options
|
||||||
description string
|
description string
|
||||||
expectedErrMsg string
|
expectedErrMsg string
|
||||||
numLeaks int
|
numLeaks int
|
||||||
repo *git.Repository
|
repo *RepoDescriptor
|
||||||
whiteListFiles []*regexp.Regexp
|
whiteListFiles []*regexp.Regexp
|
||||||
whiteListCommits map[string]bool
|
whiteListCommits map[string]bool
|
||||||
whiteListBranches []string
|
whiteListBranches []string
|
||||||
|
whiteListRepos []string
|
||||||
whiteListRegexes []*regexp.Regexp
|
whiteListRegexes []*regexp.Regexp
|
||||||
configPath string
|
configPath string
|
||||||
}{
|
}{
|
||||||
@@ -336,7 +426,7 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
description: "two leaks present limit goroutines",
|
description: "two leaks present limit goroutines",
|
||||||
numLeaks: 2,
|
numLeaks: 2,
|
||||||
testOpts: Options{
|
testOpts: Options{
|
||||||
MaxGoRoutines: 2,
|
MaxGoRoutines: 4,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -447,6 +537,20 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
configPath: path.Join(configsDir, "commit"),
|
configPath: path.Join(configsDir, "commit"),
|
||||||
numLeaks: 2,
|
numLeaks: 2,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
repo: leaksRepo,
|
||||||
|
description: "audit whitelist repo",
|
||||||
|
numLeaks: 0,
|
||||||
|
whiteListRepos: []string{
|
||||||
|
"gronit",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
repo: leaksRepo,
|
||||||
|
description: "toml whitelist repo",
|
||||||
|
numLeaks: 0,
|
||||||
|
configPath: path.Join(configsDir, "repo"),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
whiteListCommits = make(map[string]bool)
|
whiteListCommits = make(map[string]bool)
|
||||||
@@ -476,6 +580,11 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
whiteListRegexes = nil
|
whiteListRegexes = nil
|
||||||
}
|
}
|
||||||
|
if test.whiteListRepos != nil {
|
||||||
|
whiteListRepos = test.whiteListRepos
|
||||||
|
} else {
|
||||||
|
whiteListRepos = nil
|
||||||
|
}
|
||||||
|
|
||||||
// config paths
|
// config paths
|
||||||
if test.configPath != "" {
|
if test.configPath != "" {
|
||||||
@@ -483,7 +592,7 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
loadToml()
|
loadToml()
|
||||||
}
|
}
|
||||||
|
|
||||||
leaks, err = auditRepo(test.repo)
|
leaks, err = auditGitRepo(test.repo)
|
||||||
|
|
||||||
if opts.Redact {
|
if opts.Redact {
|
||||||
g.Assert(leaks[0].Offender).Equal("REDACTED")
|
g.Assert(leaks[0].Offender).Equal("REDACTED")
|
||||||
@@ -669,3 +778,160 @@ func TestLoadToml(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditRepo1Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 1
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditRepo2Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 2
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditRepo4Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 4
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditRepo8Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 8
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditRepo10Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 10
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditRepo100Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 100
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditRepo1000Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 1000
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func BenchmarkAuditRepo10000Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 10000
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func BenchmarkAuditRepo100000Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 100000
|
||||||
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func BenchmarkAuditLeakRepo1Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 1
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditLeakRepo2Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 2
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditLeakRepo4Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 4
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditLeakRepo8Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 8
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditLeakRepo10Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 10
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func BenchmarkAuditLeakRepo100Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 100
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func BenchmarkAuditLeakRepo1000Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 1000
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditLeakRepo10000Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 10000
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkAuditLeakRepo100000Proc(b *testing.B) {
|
||||||
|
loadToml()
|
||||||
|
opts.MaxGoRoutines = 100000
|
||||||
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
auditGitRepo(benchmarkRepo)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user