mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 12:44:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67454d109e | ||
|
|
ce603c73b4 | ||
|
|
55218fc8f8 | ||
|
|
5d81c650e8 | ||
|
|
0726209172 | ||
|
|
bfec8aca51 | ||
|
|
a9b30edb06 | ||
|
|
cc6d698e63 | ||
|
|
2ba97d0fa3 |
No files matched your search
@@ -1,6 +1,23 @@
|
|||||||
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
|
1.7.0
|
||||||
-----
|
-----
|
||||||
- Exit code == 2 on error
|
- Exit code == 2 on error
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ Application Options:
|
|||||||
--csv report output to csv
|
--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
|
||||||
|
|||||||
+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)$"
|
||||||
|
|||||||
+85
-115
@@ -56,30 +56,41 @@ regexes= [
|
|||||||
]
|
]
|
||||||
`
|
`
|
||||||
|
|
||||||
var benchmarkRepo *Repo
|
const testWhitelistRepo = `
|
||||||
var benchmarkLeaksRepo *Repo
|
[[regexes]]
|
||||||
|
description = "AWS"
|
||||||
|
regex = '''AKIA[0-9A-Z]{16}'''
|
||||||
|
|
||||||
func getBenchmarkLeaksRepo() *Repo {
|
[whitelist]
|
||||||
|
repos = [
|
||||||
|
"gronit",
|
||||||
|
]
|
||||||
|
`
|
||||||
|
|
||||||
|
var benchmarkRepo *RepoDescriptor
|
||||||
|
var benchmarkLeaksRepo *RepoDescriptor
|
||||||
|
|
||||||
|
func getBenchmarkLeaksRepo() *RepoDescriptor {
|
||||||
if benchmarkLeaksRepo != nil {
|
if benchmarkLeaksRepo != nil {
|
||||||
return benchmarkLeaksRepo
|
return benchmarkLeaksRepo
|
||||||
}
|
}
|
||||||
leaksR, _ := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
leaksR, _ := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||||
URL: "https://github.com/gitleakstest/gronit.git",
|
URL: "https://github.com/gitleakstest/gronit.git",
|
||||||
})
|
})
|
||||||
benchmarkLeaksRepo = &Repo{
|
benchmarkLeaksRepo = &RepoDescriptor{
|
||||||
repository: leaksR,
|
repository: leaksR,
|
||||||
}
|
}
|
||||||
return benchmarkLeaksRepo
|
return benchmarkLeaksRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBenchmarkRepo() *Repo {
|
func getBenchmarkRepo() *RepoDescriptor {
|
||||||
if benchmarkRepo != nil {
|
if benchmarkRepo != nil {
|
||||||
return benchmarkRepo
|
return benchmarkRepo
|
||||||
}
|
}
|
||||||
bmRepo, _ := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
bmRepo, _ := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||||
URL: "https://github.com/apple/swift-package-manager.git",
|
URL: "https://github.com/apple/swift-package-manager.git",
|
||||||
})
|
})
|
||||||
benchmarkRepo = &Repo{
|
benchmarkRepo = &RepoDescriptor{
|
||||||
repository: bmRepo,
|
repository: bmRepo,
|
||||||
}
|
}
|
||||||
return benchmarkRepo
|
return benchmarkRepo
|
||||||
@@ -157,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)
|
||||||
}
|
}
|
||||||
@@ -165,10 +176,9 @@ func TestGetRepo(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func TestRunAudit(t *testing.T) {
|
func TestRun(t *testing.T) {
|
||||||
err := loadToml()
|
var err error
|
||||||
configsDir := testTomlLoader()
|
configsDir := testTomlLoader()
|
||||||
defer os.RemoveAll(configsDir)
|
|
||||||
|
|
||||||
dir, err = ioutil.TempDir("", "gitleaksTestOwner")
|
dir, err = ioutil.TempDir("", "gitleaksTestOwner")
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
@@ -185,7 +195,9 @@ func TestRunAudit(t *testing.T) {
|
|||||||
testOpts Options
|
testOpts Options
|
||||||
description string
|
description string
|
||||||
expectedErrMsg string
|
expectedErrMsg string
|
||||||
|
whiteListRepos []string
|
||||||
numLeaks int
|
numLeaks int
|
||||||
|
configPath string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
testOpts: Options{
|
testOpts: Options{
|
||||||
@@ -239,112 +251,49 @@ func TestRunAudit(t *testing.T) {
|
|||||||
numLeaks: 0,
|
numLeaks: 0,
|
||||||
expectedErrMsg: "unable to generate ssh key: open reallyreallyreallyreallywrongpath: no such file or directory",
|
expectedErrMsg: "unable to generate ssh key: open reallyreallyreallyreallywrongpath: no such file or directory",
|
||||||
},
|
},
|
||||||
}
|
|
||||||
g := goblin.Goblin(t)
|
|
||||||
for _, test := range tests {
|
|
||||||
g.Describe("TestRunAudit", func() {
|
|
||||||
g.It(test.description, func() {
|
|
||||||
opts = test.testOpts
|
|
||||||
leaks, err := run()
|
|
||||||
if err != nil {
|
|
||||||
g.Assert(err.Error()).Equal(test.expectedErrMsg)
|
|
||||||
}
|
|
||||||
g.Assert(len(leaks)).Equal(test.numLeaks)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestStartAudit(t *testing.T) {
|
|
||||||
err := loadToml()
|
|
||||||
configsDir := testTomlLoader()
|
|
||||||
defer os.RemoveAll(configsDir)
|
|
||||||
|
|
||||||
dir, err = ioutil.TempDir("", "gitleaksTestOwner")
|
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
git.PlainClone(dir+"/gronit", false, &git.CloneOptions{
|
|
||||||
URL: "https://github.com/gitleakstest/gronit",
|
|
||||||
})
|
|
||||||
git.PlainClone(dir+"/h1domains", false, &git.CloneOptions{
|
|
||||||
URL: "https://github.com/gitleakstest/h1domains",
|
|
||||||
})
|
|
||||||
var tests = []struct {
|
|
||||||
testOpts Options
|
|
||||||
description string
|
|
||||||
expectedErrMsg string
|
|
||||||
numLeaks int
|
|
||||||
}{
|
|
||||||
{
|
{
|
||||||
testOpts: Options{
|
testOpts: Options{
|
||||||
GithubUser: "gitleakstest",
|
Repo: "https://github.com/gitleakstest/gronit.git",
|
||||||
},
|
},
|
||||||
description: "test github user",
|
description: "test leak",
|
||||||
numLeaks: 2,
|
numLeaks: 2,
|
||||||
expectedErrMsg: "",
|
expectedErrMsg: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
testOpts: Options{
|
testOpts: Options{
|
||||||
GithubUser: "gitleakstest",
|
Repo: "https://github.com/gitleakstest/h1domains.git",
|
||||||
Disk: true,
|
|
||||||
},
|
},
|
||||||
description: "test github user on disk ",
|
description: "test clean",
|
||||||
numLeaks: 2,
|
numLeaks: 0,
|
||||||
expectedErrMsg: "",
|
expectedErrMsg: "",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
testOpts: Options{
|
||||||
|
Repo: "https://github.com/gitleakstest/empty.git",
|
||||||
|
},
|
||||||
|
description: "test empty",
|
||||||
|
numLeaks: 0,
|
||||||
|
expectedErrMsg: "reference not found",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
testOpts: Options{
|
testOpts: Options{
|
||||||
GithubOrg: "gitleakstestorg",
|
GithubOrg: "gitleakstestorg",
|
||||||
},
|
},
|
||||||
description: "test github org",
|
description: "test github org",
|
||||||
numLeaks: 2,
|
|
||||||
expectedErrMsg: "",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
testOpts: Options{
|
|
||||||
GithubOrg: "gitleakstestorg",
|
|
||||||
IncludePrivate: true,
|
|
||||||
},
|
|
||||||
description: "test private org no ssh",
|
|
||||||
numLeaks: 0,
|
numLeaks: 0,
|
||||||
expectedErrMsg: "no ssh auth available",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
testOpts: Options{
|
|
||||||
GithubOrg: "gitleakstestorg",
|
|
||||||
Disk: true,
|
|
||||||
},
|
|
||||||
description: "test org on disk",
|
|
||||||
numLeaks: 2,
|
|
||||||
expectedErrMsg: "",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
testOpts: Options{
|
|
||||||
GithubOrg: "gitleakstestorg",
|
|
||||||
IncludePrivate: true,
|
|
||||||
Disk: true,
|
|
||||||
},
|
|
||||||
description: "test private org on disk no ssh",
|
|
||||||
numLeaks: 0,
|
|
||||||
expectedErrMsg: "no ssh auth available",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
testOpts: Options{
|
|
||||||
OwnerPath: dir,
|
|
||||||
},
|
|
||||||
description: "test owner path",
|
|
||||||
numLeaks: 2,
|
|
||||||
expectedErrMsg: "",
|
expectedErrMsg: "",
|
||||||
|
configPath: path.Join(configsDir, "repo"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
g := goblin.Goblin(t)
|
g := goblin.Goblin(t)
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
g.Describe("TestStartAudit", 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
|
||||||
leaks, err := startAudits()
|
leaks, err := run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.Assert(err.Error()).Equal(test.expectedErrMsg)
|
g.Assert(err.Error()).Equal(test.expectedErrMsg)
|
||||||
}
|
}
|
||||||
@@ -419,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
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,7 +387,7 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
leaksRepo := Repo{
|
leaksRepo := &RepoDescriptor{
|
||||||
repository: leaksR,
|
repository: leaksR,
|
||||||
name: "gronit",
|
name: "gronit",
|
||||||
}
|
}
|
||||||
@@ -448,7 +398,7 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
cleanRepo := Repo{
|
cleanRepo := &RepoDescriptor{
|
||||||
repository: cleanR,
|
repository: cleanR,
|
||||||
name: "h1domains",
|
name: "h1domains",
|
||||||
}
|
}
|
||||||
@@ -458,10 +408,11 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
description string
|
description string
|
||||||
expectedErrMsg string
|
expectedErrMsg string
|
||||||
numLeaks int
|
numLeaks int
|
||||||
repo Repo
|
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
|
||||||
}{
|
}{
|
||||||
@@ -475,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,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -586,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)
|
||||||
@@ -615,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 != "" {
|
||||||
@@ -622,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")
|
||||||
@@ -814,7 +784,7 @@ func BenchmarkAuditRepo1Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 1
|
opts.MaxGoRoutines = 1
|
||||||
benchmarkRepo = getBenchmarkRepo()
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -823,7 +793,7 @@ func BenchmarkAuditRepo2Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 2
|
opts.MaxGoRoutines = 2
|
||||||
benchmarkRepo = getBenchmarkRepo()
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,7 +802,7 @@ func BenchmarkAuditRepo4Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 4
|
opts.MaxGoRoutines = 4
|
||||||
benchmarkRepo = getBenchmarkRepo()
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -841,7 +811,7 @@ func BenchmarkAuditRepo8Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 8
|
opts.MaxGoRoutines = 8
|
||||||
benchmarkRepo = getBenchmarkRepo()
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -850,7 +820,7 @@ func BenchmarkAuditRepo10Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 10
|
opts.MaxGoRoutines = 10
|
||||||
benchmarkRepo = getBenchmarkRepo()
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -859,7 +829,7 @@ func BenchmarkAuditRepo100Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 100
|
opts.MaxGoRoutines = 100
|
||||||
benchmarkRepo = getBenchmarkRepo()
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -868,7 +838,7 @@ func BenchmarkAuditRepo1000Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 1000
|
opts.MaxGoRoutines = 1000
|
||||||
benchmarkRepo = getBenchmarkRepo()
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func BenchmarkAuditRepo10000Proc(b *testing.B) {
|
func BenchmarkAuditRepo10000Proc(b *testing.B) {
|
||||||
@@ -876,7 +846,7 @@ func BenchmarkAuditRepo10000Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 10000
|
opts.MaxGoRoutines = 10000
|
||||||
benchmarkRepo = getBenchmarkRepo()
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func BenchmarkAuditRepo100000Proc(b *testing.B) {
|
func BenchmarkAuditRepo100000Proc(b *testing.B) {
|
||||||
@@ -884,7 +854,7 @@ func BenchmarkAuditRepo100000Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 100000
|
opts.MaxGoRoutines = 100000
|
||||||
benchmarkRepo = getBenchmarkRepo()
|
benchmarkRepo = getBenchmarkRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func BenchmarkAuditLeakRepo1Proc(b *testing.B) {
|
func BenchmarkAuditLeakRepo1Proc(b *testing.B) {
|
||||||
@@ -892,7 +862,7 @@ func BenchmarkAuditLeakRepo1Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 1
|
opts.MaxGoRoutines = 1
|
||||||
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkLeaksRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -901,7 +871,7 @@ func BenchmarkAuditLeakRepo2Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 2
|
opts.MaxGoRoutines = 2
|
||||||
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkLeaksRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -910,7 +880,7 @@ func BenchmarkAuditLeakRepo4Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 4
|
opts.MaxGoRoutines = 4
|
||||||
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkLeaksRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -919,7 +889,7 @@ func BenchmarkAuditLeakRepo8Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 8
|
opts.MaxGoRoutines = 8
|
||||||
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkLeaksRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -928,7 +898,7 @@ func BenchmarkAuditLeakRepo10Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 10
|
opts.MaxGoRoutines = 10
|
||||||
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkLeaksRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func BenchmarkAuditLeakRepo100Proc(b *testing.B) {
|
func BenchmarkAuditLeakRepo100Proc(b *testing.B) {
|
||||||
@@ -936,7 +906,7 @@ func BenchmarkAuditLeakRepo100Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 100
|
opts.MaxGoRoutines = 100
|
||||||
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkLeaksRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func BenchmarkAuditLeakRepo1000Proc(b *testing.B) {
|
func BenchmarkAuditLeakRepo1000Proc(b *testing.B) {
|
||||||
@@ -944,7 +914,7 @@ func BenchmarkAuditLeakRepo1000Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 1000
|
opts.MaxGoRoutines = 1000
|
||||||
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkLeaksRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -953,7 +923,7 @@ func BenchmarkAuditLeakRepo10000Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 10000
|
opts.MaxGoRoutines = 10000
|
||||||
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkLeaksRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -962,6 +932,6 @@ func BenchmarkAuditLeakRepo100000Proc(b *testing.B) {
|
|||||||
opts.MaxGoRoutines = 100000
|
opts.MaxGoRoutines = 100000
|
||||||
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
benchmarkLeaksRepo = getBenchmarkLeaksRepo()
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
auditRepo(*benchmarkLeaksRepo)
|
auditGitRepo(benchmarkRepo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,9 @@ import (
|
|||||||
git "gopkg.in/src-d/go-git.v4"
|
git "gopkg.in/src-d/go-git.v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Leak represents a leaked secret or regex match. This will be output to stdout and/or the report
|
// Leak represents a leaked secret or regex match.
|
||||||
|
// Output to stdout as json if the --verbose option is set or
|
||||||
|
// as a csv if the --csv and --report options are set.
|
||||||
type Leak struct {
|
type Leak struct {
|
||||||
Line string `json:"line"`
|
Line string `json:"line"`
|
||||||
Commit string `json:"commit"`
|
Commit string `json:"commit"`
|
||||||
@@ -47,23 +49,15 @@ type Leak struct {
|
|||||||
Repo string `json:"repo"`
|
Repo string `json:"repo"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Repo contains the actual git repository and meta data about the repo
|
// RepoDescriptor contains a src-d git repository and other data about the repo
|
||||||
type Repo struct {
|
type RepoDescriptor struct {
|
||||||
path string
|
path string
|
||||||
url string
|
url string
|
||||||
name string
|
name string
|
||||||
leaks []Leak
|
|
||||||
repository *git.Repository
|
repository *git.Repository
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Owner contains a collection of repos. This could represent an org or user.
|
|
||||||
type Owner struct {
|
|
||||||
path string
|
|
||||||
url string
|
|
||||||
repos []Repo
|
|
||||||
}
|
|
||||||
|
|
||||||
// Options for gitleaks
|
// Options for gitleaks
|
||||||
type Options struct {
|
type Options struct {
|
||||||
// remote target options
|
// remote target options
|
||||||
@@ -96,12 +90,13 @@ type Options struct {
|
|||||||
// TODO: IncludeMessages string `long:"messages" description:"include commit messages in audit"`
|
// TODO: IncludeMessages string `long:"messages" description:"include commit messages in audit"`
|
||||||
|
|
||||||
// Output options
|
// Output options
|
||||||
Log string `short:"l" long:"log" description:"log level"`
|
Log string `short:"l" long:"log" description:"log level"`
|
||||||
Verbose bool `short:"v" long:"verbose" description:"Show verbose output from gitleaks audit"`
|
Verbose bool `short:"v" long:"verbose" description:"Show verbose output from gitleaks audit"`
|
||||||
Report string `long:"report" description:"path to write report file"`
|
Report string `long:"report" description:"path to write report file"`
|
||||||
CSV bool `long:"csv" description:"report output to csv"`
|
CSV bool `long:"csv" description:"report output to csv"`
|
||||||
Redact bool `long:"redact" description:"redact secrets from log messages and report"`
|
Redact bool `long:"redact" description:"redact secrets from log messages and report"`
|
||||||
Version bool `long:"version" description:"version number"`
|
Version bool `long:"version" description:"version number"`
|
||||||
|
SampleConfig bool `long:"sample-config" description:"prints a sample config file"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config struct for regexes matching and whitelisting
|
// Config struct for regexes matching and whitelisting
|
||||||
@@ -115,14 +110,29 @@ type Config struct {
|
|||||||
Regexes []string
|
Regexes []string
|
||||||
Commits []string
|
Commits []string
|
||||||
Branches []string
|
Branches []string
|
||||||
|
Repos []string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type gitDiff struct {
|
||||||
|
content string
|
||||||
|
commit *object.Commit
|
||||||
|
filePath string
|
||||||
|
branchName string
|
||||||
|
repoName string
|
||||||
|
}
|
||||||
|
|
||||||
const defaultGithubURL = "https://api.github.com/"
|
const defaultGithubURL = "https://api.github.com/"
|
||||||
const version = "1.7.0"
|
const version = "1.8.0"
|
||||||
const errExit = 2
|
const errExit = 2
|
||||||
const leakExit = 1
|
const leakExit = 1
|
||||||
const defaultConfig = `
|
const defaultConfig = `
|
||||||
|
# This is a sample config file for gitleaks. You can configure gitleaks what to search for and what to whitelist.
|
||||||
|
# The output you are seeing here is the default gitleaks config. If GITLEAKS_CONFIG environment variable
|
||||||
|
# is set, gitleaks will load configurations from that path. If option --config-path is set, gitleaks will load
|
||||||
|
# configurations from that path. Gitleaks does not whitelist anything by default.
|
||||||
|
|
||||||
|
|
||||||
title = "gitleaks config"
|
title = "gitleaks config"
|
||||||
# add regexes to the regex table
|
# add regexes to the regex table
|
||||||
[[regexes]]
|
[[regexes]]
|
||||||
@@ -148,7 +158,6 @@ description = "Twitter"
|
|||||||
regex = '''(?i)twitter.*['\"][0-9a-zA-Z]{35,44}['\"]'''
|
regex = '''(?i)twitter.*['\"][0-9a-zA-Z]{35,44}['\"]'''
|
||||||
|
|
||||||
[whitelist]
|
[whitelist]
|
||||||
|
|
||||||
#regexes = [
|
#regexes = [
|
||||||
# "AKAIMYFAKEAWKKEY",
|
# "AKAIMYFAKEAWKKEY",
|
||||||
#]
|
#]
|
||||||
@@ -165,6 +174,10 @@ regex = '''(?i)twitter.*['\"][0-9a-zA-Z]{35,44}['\"]'''
|
|||||||
#branches = [
|
#branches = [
|
||||||
# "dev/STUPDIFKNFEATURE"
|
# "dev/STUPDIFKNFEATURE"
|
||||||
#]
|
#]
|
||||||
|
|
||||||
|
#repos = [
|
||||||
|
# "someYugeRepoWeKnowIsCLEAR"
|
||||||
|
#]
|
||||||
`
|
`
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -175,6 +188,7 @@ var (
|
|||||||
whiteListFiles []*regexp.Regexp
|
whiteListFiles []*regexp.Regexp
|
||||||
whiteListCommits map[string]bool
|
whiteListCommits map[string]bool
|
||||||
whiteListBranches []string
|
whiteListBranches []string
|
||||||
|
whiteListRepos []string
|
||||||
fileDiffRegex *regexp.Regexp
|
fileDiffRegex *regexp.Regexp
|
||||||
sshAuth *ssh.PublicKeys
|
sshAuth *ssh.PublicKeys
|
||||||
dir string
|
dir string
|
||||||
@@ -194,9 +208,9 @@ func main() {
|
|||||||
fmt.Println(version)
|
fmt.Println(version)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if opts.SampleConfig {
|
||||||
log.Error(err)
|
fmt.Println(defaultConfig)
|
||||||
os.Exit(errExit)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
leaks, err := run()
|
leaks, err := run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -215,6 +229,7 @@ func main() {
|
|||||||
|
|
||||||
// run parses options and kicks off the audit
|
// run parses options and kicks off the audit
|
||||||
func run() ([]Leak, error) {
|
func run() ([]Leak, error) {
|
||||||
|
var leaks []Leak
|
||||||
setLogs()
|
setLogs()
|
||||||
err := optsGuard()
|
err := optsGuard()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -239,46 +254,42 @@ func run() ([]Leak, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return startAudits()
|
|
||||||
}
|
|
||||||
|
|
||||||
func startAudits() ([]Leak, error) {
|
|
||||||
var leaks []Leak
|
|
||||||
// start audits
|
// start audits
|
||||||
if opts.OwnerPath != "" {
|
if opts.Repo != "" || opts.RepoPath != "" {
|
||||||
|
// Audit a single remote repo or a local repo.
|
||||||
|
repo, err := cloneRepo()
|
||||||
|
if err != nil {
|
||||||
|
return leaks, err
|
||||||
|
}
|
||||||
|
return auditGitRepo(repo)
|
||||||
|
} else if opts.OwnerPath != "" {
|
||||||
|
// Audit local repos. Gitleaks will look for all child directories of OwnerPath for
|
||||||
|
// git repos and perform an audit on said repos.
|
||||||
repos, err := discoverRepos(opts.OwnerPath)
|
repos, err := discoverRepos(opts.OwnerPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return leaks, err
|
return leaks, err
|
||||||
}
|
}
|
||||||
for _, repo := range repos {
|
for _, repo := range repos {
|
||||||
leaksFromRepo, err := auditRepo(repo)
|
leaksFromRepo, err := auditGitRepo(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return leaks, err
|
return leaks, err
|
||||||
}
|
}
|
||||||
leaks = append(leaksFromRepo, leaks...)
|
leaks = append(leaksFromRepo, leaks...)
|
||||||
}
|
}
|
||||||
} else if opts.GithubOrg != "" || opts.GithubUser != "" {
|
} else if opts.GithubOrg != "" || opts.GithubUser != "" {
|
||||||
githubRepos, err := getGithubRepos()
|
// Audit a github owner -- a user or organization. If you want to include
|
||||||
|
// private repos you must pass a --private/-p option and have your ssh keys set
|
||||||
|
leaks, err = auditGithubRepos()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return leaks, err
|
return leaks, err
|
||||||
}
|
}
|
||||||
for _, githubRepo := range githubRepos {
|
|
||||||
leaksFromRepo, err := auditGithubRepo(githubRepo)
|
|
||||||
if len(leaksFromRepo) == 0 {
|
|
||||||
log.Infof("no leaks found for repo %s", *githubRepo.Name)
|
|
||||||
} else {
|
|
||||||
log.Warnf("leaks found for repo %s", *githubRepo.Name)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
log.Warn(err)
|
|
||||||
}
|
|
||||||
leaks = append(leaks, leaksFromRepo...)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return leaks, nil
|
return leaks, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// writeReport writes a report to opts.Report in JSON.
|
// writeReport writes a report to a file specified in the --report= option.
|
||||||
|
// Default format for report is JSON. You can use the --csv option to write the report as a csv
|
||||||
func writeReport(leaks []Leak) error {
|
func writeReport(leaks []Leak) error {
|
||||||
var err error
|
var err error
|
||||||
log.Infof("writing report to %s", opts.Report)
|
log.Infof("writing report to %s", opts.Report)
|
||||||
@@ -301,14 +312,14 @@ func writeReport(leaks []Leak) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// getRepo is responsible for cloning a repo in-memory or to disk, or opening a local repo and creating
|
// cloneRepo clones a repo to memory(default) or to disk if the --disk option is set. If you want to
|
||||||
// a repo object
|
// clone a private repo you must set the --private/-p option, use a ssh target, and have your ssh keys
|
||||||
func getRepo() (Repo, error) {
|
// configured. If you want to audit a local repo, getRepo will load up a repo located at --repo-path
|
||||||
|
func cloneRepo() (*RepoDescriptor, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
repo *git.Repository
|
repo *git.Repository
|
||||||
)
|
)
|
||||||
|
|
||||||
if opts.Disk {
|
if opts.Disk {
|
||||||
log.Infof("cloning %s", opts.Repo)
|
log.Infof("cloning %s", opts.Repo)
|
||||||
cloneTarget := fmt.Sprintf("%s/%x", dir, md5.Sum([]byte(fmt.Sprintf("%s%s", opts.GithubUser, opts.Repo))))
|
cloneTarget := fmt.Sprintf("%s/%x", dir, md5.Sum([]byte(fmt.Sprintf("%s%s", opts.GithubUser, opts.Repo))))
|
||||||
@@ -325,7 +336,6 @@ func getRepo() (Repo, error) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if opts.RepoPath != "" {
|
} else if opts.RepoPath != "" {
|
||||||
// use existing repo
|
|
||||||
log.Infof("opening %s", opts.Repo)
|
log.Infof("opening %s", opts.Repo)
|
||||||
repo, err = git.PlainOpen(opts.RepoPath)
|
repo, err = git.PlainOpen(opts.RepoPath)
|
||||||
} else {
|
} else {
|
||||||
@@ -343,7 +353,7 @@ func getRepo() (Repo, error) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Repo{
|
return &RepoDescriptor{
|
||||||
repository: repo,
|
repository: repo,
|
||||||
path: opts.RepoPath,
|
path: opts.RepoPath,
|
||||||
url: opts.Repo,
|
url: opts.Repo,
|
||||||
@@ -352,24 +362,89 @@ func getRepo() (Repo, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// auditRef audits a git reference
|
// auditGitRepo beings an audit on a git repository by checking the default HEAD branch, all branches, or
|
||||||
// TODO: need to add a layer of parallelism here and a cache for parent+child commits so we don't
|
// a single branch depending on what gitleaks is configured to do. Note when I say branch I really
|
||||||
// double dip
|
// mean reference as these branches are read only.
|
||||||
func auditRef(repo Repo, ref *plumbing.Reference, commitWg *sync.WaitGroup, commitChan chan []Leak) error {
|
func auditGitRepo(repo *RepoDescriptor) ([]Leak, error) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
leaks []Leak
|
||||||
|
)
|
||||||
|
for _, repoName := range whiteListRepos {
|
||||||
|
if repoName == repo.name {
|
||||||
|
return nil, fmt.Errorf("skipping %s, whitelisted", repoName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ref, err := repo.repository.Head()
|
||||||
|
if err != nil {
|
||||||
|
return leaks, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if opts.AuditAllRefs {
|
||||||
|
skipBranch := false
|
||||||
|
refs, err := repo.repository.Storer.IterReferences()
|
||||||
|
if err != nil {
|
||||||
|
return leaks, err
|
||||||
|
}
|
||||||
|
err = refs.ForEach(func(ref *plumbing.Reference) error {
|
||||||
|
for _, b := range whiteListBranches {
|
||||||
|
if strings.HasSuffix(string(ref.Name()), b) {
|
||||||
|
skipBranch = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if skipBranch {
|
||||||
|
skipBranch = false
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
branchLeaks := auditGitReference(repo, ref)
|
||||||
|
for _, leak := range branchLeaks {
|
||||||
|
leaks = append(leaks, leak)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
if opts.Branch != "" {
|
||||||
|
foundBranch := false
|
||||||
|
refs, _ := repo.repository.Storer.IterReferences()
|
||||||
|
branch := strings.Split(opts.Branch, "/")[len(strings.Split(opts.Branch, "/"))-1]
|
||||||
|
err = refs.ForEach(func(refBranch *plumbing.Reference) error {
|
||||||
|
if strings.Split(refBranch.Name().String(), "/")[len(strings.Split(refBranch.Name().String(), "/"))-1] == branch {
|
||||||
|
foundBranch = true
|
||||||
|
ref = refBranch
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if foundBranch == false {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
leaks = auditGitReference(repo, ref)
|
||||||
|
}
|
||||||
|
return leaks, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// auditGitReference beings the audit for a git reference. This function will
|
||||||
|
// traverse the git reference and audit each line of each diff. Set maximum concurrency with
|
||||||
|
// the --max-go option (default is set to the number of cores on your cpu).
|
||||||
|
func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
prevCommit *object.Commit
|
prevCommit *object.Commit
|
||||||
semaphore chan bool
|
semaphore chan bool
|
||||||
repoName string
|
repoName string
|
||||||
|
leaks []Leak
|
||||||
|
commitWg sync.WaitGroup
|
||||||
|
mutex = &sync.Mutex{}
|
||||||
)
|
)
|
||||||
repoName = repo.name
|
repoName = repo.name
|
||||||
if opts.MaxGoRoutines != 0 {
|
if opts.MaxGoRoutines != 0 {
|
||||||
maxGo = opts.MaxGoRoutines
|
maxGo = opts.MaxGoRoutines
|
||||||
}
|
}
|
||||||
|
|
||||||
semaphore = make(chan bool, maxGo)
|
semaphore = make(chan bool, maxGo)
|
||||||
cIter, err := repo.repository.Log(&git.LogOptions{From: ref.Hash()})
|
cIter, err := repo.repository.Log(&git.LogOptions{From: ref.Hash()})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil
|
||||||
}
|
}
|
||||||
err = cIter.ForEach(func(c *object.Commit) error {
|
err = cIter.ForEach(func(c *object.Commit) error {
|
||||||
if c.Hash.String() == opts.Commit {
|
if c.Hash.String() == opts.Commit {
|
||||||
@@ -379,22 +454,25 @@ func auditRef(repo Repo, ref *plumbing.Reference, commitWg *sync.WaitGroup, comm
|
|||||||
log.Infof("skipping commit: %s\n", c.Hash.String())
|
log.Infof("skipping commit: %s\n", c.Hash.String())
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
semaphore <- true
|
|
||||||
commitWg.Add(1)
|
commitWg.Add(1)
|
||||||
|
semaphore <- true
|
||||||
go func(c *object.Commit, prevCommit *object.Commit) {
|
go func(c *object.Commit, prevCommit *object.Commit) {
|
||||||
var (
|
var (
|
||||||
leaks []Leak
|
|
||||||
filePath string
|
filePath string
|
||||||
skipFile bool
|
skipFile bool
|
||||||
)
|
)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
commitWg.Done()
|
||||||
<-semaphore
|
<-semaphore
|
||||||
commitChan <- leaks
|
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
log.Warnf("recoverying from panic on commit %s, likely large diff causing panic", c.Hash.String())
|
log.Warnf("recoverying from panic on commit %s, likely large diff causing panic", c.Hash.String())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
diff := gitDiff{
|
||||||
|
commit: prevCommit,
|
||||||
|
branchName: string(ref.Name()),
|
||||||
|
repoName: repoName,
|
||||||
|
}
|
||||||
|
|
||||||
if prevCommit == nil {
|
if prevCommit == nil {
|
||||||
t, _ := c.Tree()
|
t, _ := c.Tree()
|
||||||
@@ -404,7 +482,15 @@ func auditRef(repo Repo, ref *plumbing.Reference, commitWg *sync.WaitGroup, comm
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
leaks = append(leaks, checkDiff(content, c, file.Name, string(ref.Name()), repoName)...)
|
diff.filePath = file.Name
|
||||||
|
diff.content = content
|
||||||
|
diff.commit = c
|
||||||
|
chunkLeaks := inspect(diff)
|
||||||
|
for _, leak := range chunkLeaks {
|
||||||
|
mutex.Lock()
|
||||||
|
leaks = append(leaks, leak)
|
||||||
|
mutex.Unlock()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -426,6 +512,7 @@ func auditRef(repo Repo, ref *plumbing.Reference, commitWg *sync.WaitGroup, comm
|
|||||||
} else if to != nil {
|
} else if to != nil {
|
||||||
filePath = to.Path()
|
filePath = to.Path()
|
||||||
}
|
}
|
||||||
|
diff.filePath = filePath
|
||||||
for _, re := range whiteListFiles {
|
for _, re := range whiteListFiles {
|
||||||
if re.FindString(filePath) != "" {
|
if re.FindString(filePath) != "" {
|
||||||
skipFile = true
|
skipFile = true
|
||||||
@@ -438,8 +525,13 @@ func auditRef(repo Repo, ref *plumbing.Reference, commitWg *sync.WaitGroup, comm
|
|||||||
chunks := f.Chunks()
|
chunks := f.Chunks()
|
||||||
for _, chunk := range chunks {
|
for _, chunk := range chunks {
|
||||||
if chunk.Type() == 1 || chunk.Type() == 2 {
|
if chunk.Type() == 1 || chunk.Type() == 2 {
|
||||||
// only check if adding or removing
|
diff.content = chunk.Content()
|
||||||
leaks = append(leaks, checkDiff(chunk.Content(), prevCommit, filePath, string(ref.Name()), repoName)...)
|
chunkLeaks := inspect(diff)
|
||||||
|
for _, leak := range chunkLeaks {
|
||||||
|
mutex.Lock()
|
||||||
|
leaks = append(leaks, leak)
|
||||||
|
mutex.Unlock()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -448,84 +540,16 @@ func auditRef(repo Repo, ref *plumbing.Reference, commitWg *sync.WaitGroup, comm
|
|||||||
prevCommit = c
|
prevCommit = c
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// auditRepo performs an audit on a repository checking for regex matching and ignoring
|
|
||||||
// files and regexes that are whitelisted
|
|
||||||
func auditRepo(repo Repo) ([]Leak, error) {
|
|
||||||
var (
|
|
||||||
err error
|
|
||||||
leaks []Leak
|
|
||||||
commitWg sync.WaitGroup
|
|
||||||
)
|
|
||||||
|
|
||||||
ref, err := repo.repository.Head()
|
|
||||||
if err != nil {
|
|
||||||
return leaks, err
|
|
||||||
}
|
|
||||||
|
|
||||||
// leak messaging
|
|
||||||
commitChan := make(chan []Leak, 1)
|
|
||||||
|
|
||||||
if opts.AuditAllRefs {
|
|
||||||
skipBranch := false
|
|
||||||
refs, err := repo.repository.Storer.IterReferences()
|
|
||||||
if err != nil {
|
|
||||||
return leaks, err
|
|
||||||
}
|
|
||||||
err = refs.ForEach(func(ref *plumbing.Reference) error {
|
|
||||||
for _, b := range whiteListBranches {
|
|
||||||
if strings.HasSuffix(string(ref.Name()), b) {
|
|
||||||
skipBranch = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if skipBranch {
|
|
||||||
skipBranch = false
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
auditRef(repo, ref, &commitWg, commitChan)
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
if opts.Branch != "" {
|
|
||||||
foundBranch := false
|
|
||||||
refs, _ := repo.repository.Storer.IterReferences()
|
|
||||||
branch := strings.Split(opts.Branch, "/")[len(strings.Split(opts.Branch, "/"))-1]
|
|
||||||
err = refs.ForEach(func(refBranch *plumbing.Reference) error {
|
|
||||||
if strings.Split(refBranch.Name().String(), "/")[len(strings.Split(refBranch.Name().String(), "/"))-1] == branch {
|
|
||||||
foundBranch = true
|
|
||||||
ref = refBranch
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if foundBranch == false {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
auditRef(repo, ref, &commitWg, commitChan)
|
|
||||||
}
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
for commitLeaks := range commitChan {
|
|
||||||
if commitLeaks != nil {
|
|
||||||
for _, leak := range commitLeaks {
|
|
||||||
leaks = append(leaks, leak)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
commitWg.Done()
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
commitWg.Wait()
|
commitWg.Wait()
|
||||||
return leaks, err
|
return leaks
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkDiff accepts a string diff and commit object then performs a
|
// inspect will parse each line of the git diff's content against a set of regexes or
|
||||||
// regex check
|
// a set of regexes set by the config (see gitleaks.toml for example). This function
|
||||||
func checkDiff(diff string, commit *object.Commit, filePath string, branch string, repo string) []Leak {
|
// will skip lines that include a whitelisted regex. A list of leaks is returned.
|
||||||
lines := strings.Split(diff, "\n")
|
// If verbose mode (-v/--verbose) is set, then checkDiff will log leaks as they are discovered.
|
||||||
|
func inspect(diff gitDiff) []Leak {
|
||||||
|
lines := strings.Split(diff.content, "\n")
|
||||||
var (
|
var (
|
||||||
leaks []Leak
|
leaks []Leak
|
||||||
skipLine bool
|
skipLine bool
|
||||||
@@ -553,14 +577,14 @@ func checkDiff(diff string, commit *object.Commit, filePath string, branch strin
|
|||||||
|
|
||||||
leak := Leak{
|
leak := Leak{
|
||||||
Line: line,
|
Line: line,
|
||||||
Commit: commit.Hash.String(),
|
Commit: diff.commit.Hash.String(),
|
||||||
Offender: match,
|
Offender: match,
|
||||||
Type: leakType,
|
Type: leakType,
|
||||||
Message: commit.Message,
|
Message: diff.commit.Message,
|
||||||
Author: commit.Author.String(),
|
Author: diff.commit.Author.String(),
|
||||||
File: filePath,
|
File: diff.filePath,
|
||||||
Branch: branch,
|
Branch: diff.branchName,
|
||||||
Repo: repo,
|
Repo: diff.repoName,
|
||||||
}
|
}
|
||||||
if opts.Redact {
|
if opts.Redact {
|
||||||
leak.Offender = "REDACTED"
|
leak.Offender = "REDACTED"
|
||||||
@@ -575,16 +599,22 @@ func checkDiff(diff string, commit *object.Commit, filePath string, branch strin
|
|||||||
return leaks
|
return leaks
|
||||||
}
|
}
|
||||||
|
|
||||||
// auditOwner audits all of the owner's(user or org) repos
|
// auditGithubRepos kicks off audits if --github-user or --github-org options are set.
|
||||||
func getGithubRepos() ([]*github.Repository, error) {
|
// First, we gather all the github repositories from the github api (this doesnt actually clone the repo).
|
||||||
|
// After all the repos have been pulled from github's api we proceed to audit the repos by calling auditGithubRepo.
|
||||||
|
// If an error occurs during an audit of a repo, that error is logged but won't break the execution cycle.
|
||||||
|
func auditGithubRepos() ([]Leak, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
githubRepos []*github.Repository
|
githubRepos []*github.Repository
|
||||||
rs []*github.Repository
|
pagedGithubRepos []*github.Repository
|
||||||
resp *github.Response
|
resp *github.Response
|
||||||
githubClient *github.Client
|
githubClient *github.Client
|
||||||
githubOrgOptions *github.RepositoryListByOrgOptions
|
githubOrgOptions *github.RepositoryListByOrgOptions
|
||||||
githubOptions *github.RepositoryListOptions
|
githubOptions *github.RepositoryListOptions
|
||||||
|
done bool
|
||||||
|
leaks []Leak
|
||||||
|
ownerDir string
|
||||||
)
|
)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
@@ -613,56 +643,92 @@ func getGithubRepos() ([]*github.Repository, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
if done {
|
||||||
|
break
|
||||||
|
}
|
||||||
if opts.GithubUser != "" {
|
if opts.GithubUser != "" {
|
||||||
if opts.IncludePrivate {
|
if opts.IncludePrivate {
|
||||||
rs, resp, err = githubClient.Repositories.List(ctx, "", githubOptions)
|
pagedGithubRepos, resp, err = githubClient.Repositories.List(ctx, "", githubOptions)
|
||||||
} else {
|
} else {
|
||||||
rs, resp, err = githubClient.Repositories.List(ctx, opts.GithubUser, githubOptions)
|
pagedGithubRepos, resp, err = githubClient.Repositories.List(ctx, opts.GithubUser, githubOptions)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
done = true
|
||||||
}
|
}
|
||||||
githubOptions.Page = resp.NextPage
|
githubOptions.Page = resp.NextPage
|
||||||
githubRepos = append(githubRepos, rs...)
|
githubRepos = append(githubRepos, pagedGithubRepos...)
|
||||||
if resp.NextPage == 0 {
|
if resp.NextPage == 0 {
|
||||||
return githubRepos, err
|
done = true
|
||||||
}
|
}
|
||||||
} else if opts.GithubOrg != "" {
|
} else if opts.GithubOrg != "" {
|
||||||
rs, resp, err = githubClient.Repositories.ListByOrg(ctx, opts.GithubOrg, githubOrgOptions)
|
pagedGithubRepos, resp, err = githubClient.Repositories.ListByOrg(ctx, opts.GithubOrg, githubOrgOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
done = true
|
||||||
}
|
}
|
||||||
githubOrgOptions.Page = resp.NextPage
|
githubOrgOptions.Page = resp.NextPage
|
||||||
githubRepos = append(githubRepos, rs...)
|
githubRepos = append(githubRepos, pagedGithubRepos...)
|
||||||
if resp.NextPage == 0 {
|
if resp.NextPage == 0 {
|
||||||
return githubRepos, err
|
done = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if opts.Log == "Debug" || opts.Log == "debug" {
|
if opts.Log == "Debug" || opts.Log == "debug" {
|
||||||
for _, githubRepo := range rs {
|
for _, githubRepo := range pagedGithubRepos {
|
||||||
log.Debugf("staging repos %s", *githubRepo.Name)
|
log.Debugf("staging repos %s", *githubRepo.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if opts.Disk {
|
||||||
|
ownerDir, err = ioutil.TempDir(dir, opts.GithubUser)
|
||||||
|
os.RemoveAll(ownerDir)
|
||||||
|
}
|
||||||
|
for _, githubRepo := range githubRepos {
|
||||||
|
repo, err := cloneGithubRepo(githubRepo)
|
||||||
|
if err != nil {
|
||||||
|
log.Warn(err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
leaksFromRepo, err := auditGitRepo(repo)
|
||||||
|
if opts.Disk {
|
||||||
|
os.RemoveAll(fmt.Sprintf("%s/%s", ownerDir, *githubRepo.Name))
|
||||||
|
}
|
||||||
|
if len(leaksFromRepo) == 0 {
|
||||||
|
log.Infof("no leaks found for repo %s", *githubRepo.Name)
|
||||||
|
} else {
|
||||||
|
log.Warnf("leaks found for repo %s", *githubRepo.Name)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
log.Warn(err)
|
||||||
|
}
|
||||||
|
leaks = append(leaks, leaksFromRepo...)
|
||||||
|
}
|
||||||
|
return leaks, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// auditGithubRepo clones repos from github
|
// cloneGithubRepo clones a repo from the url parsed from a github repo. The repo
|
||||||
func auditGithubRepo(githubRepo *github.Repository) ([]Leak, error) {
|
// will be cloned to disk if --disk is set. If the repo is private, you must include the
|
||||||
|
// --private/-p option. After the repo is clone, an audit will begin.
|
||||||
|
func cloneGithubRepo(githubRepo *github.Repository) (*RepoDescriptor, error) {
|
||||||
var (
|
var (
|
||||||
leaks []Leak
|
repo *git.Repository
|
||||||
repo *git.Repository
|
err error
|
||||||
err error
|
|
||||||
)
|
)
|
||||||
|
for _, repoName := range whiteListRepos {
|
||||||
|
if repoName == *githubRepo.Name {
|
||||||
|
return nil, fmt.Errorf("skipping %s, whitelisted", repoName)
|
||||||
|
}
|
||||||
|
}
|
||||||
log.Infof("cloning: %s", *githubRepo.Name)
|
log.Infof("cloning: %s", *githubRepo.Name)
|
||||||
if opts.Disk {
|
if opts.Disk {
|
||||||
ownerDir, err := ioutil.TempDir(dir, opts.GithubUser)
|
ownerDir, err := ioutil.TempDir(dir, opts.GithubUser)
|
||||||
defer os.RemoveAll(fmt.Sprintf("%s/%s", ownerDir, *githubRepo.Name))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return leaks, fmt.Errorf("unable to generater owner temp dir: %v", err)
|
return nil, fmt.Errorf("unable to generater owner temp dir: %v", err)
|
||||||
}
|
}
|
||||||
if opts.IncludePrivate {
|
if opts.IncludePrivate {
|
||||||
if sshAuth == nil {
|
if sshAuth == nil {
|
||||||
return leaks, fmt.Errorf("no ssh auth available")
|
return nil, fmt.Errorf("no ssh auth available")
|
||||||
}
|
}
|
||||||
repo, err = git.PlainClone(fmt.Sprintf("%s/%s", ownerDir, *githubRepo.Name), false, &git.CloneOptions{
|
repo, err = git.PlainClone(fmt.Sprintf("%s/%s", ownerDir, *githubRepo.Name), false, &git.CloneOptions{
|
||||||
URL: *githubRepo.SSHURL,
|
URL: *githubRepo.SSHURL,
|
||||||
@@ -676,7 +742,7 @@ func auditGithubRepo(githubRepo *github.Repository) ([]Leak, error) {
|
|||||||
} else {
|
} else {
|
||||||
if opts.IncludePrivate {
|
if opts.IncludePrivate {
|
||||||
if sshAuth == nil {
|
if sshAuth == nil {
|
||||||
return leaks, fmt.Errorf("no ssh auth available")
|
return nil, fmt.Errorf("no ssh auth available")
|
||||||
}
|
}
|
||||||
repo, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
repo, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
|
||||||
URL: *githubRepo.SSHURL,
|
URL: *githubRepo.SSHURL,
|
||||||
@@ -689,15 +755,16 @@ func auditGithubRepo(githubRepo *github.Repository) ([]Leak, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return leaks, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return auditRepo(Repo{
|
return &RepoDescriptor{
|
||||||
repository: repo,
|
repository: repo,
|
||||||
name: *githubRepo.Name,
|
name: *githubRepo.Name,
|
||||||
})
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// githubToken returns a oauth2 client for the github api to consume
|
// githubToken returns an oauth2 client for the github api to consume. This token is necessary
|
||||||
|
// if you are running audits with --github-user or --github-org
|
||||||
func githubToken() *http.Client {
|
func githubToken() *http.Client {
|
||||||
githubToken := os.Getenv("GITHUB_TOKEN")
|
githubToken := os.Getenv("GITHUB_TOKEN")
|
||||||
if githubToken == "" {
|
if githubToken == "" {
|
||||||
@@ -710,11 +777,11 @@ func githubToken() *http.Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// discoverRepos walks all the children of `path`. If a child directory
|
// discoverRepos walks all the children of `path`. If a child directory
|
||||||
// contain a .git file then that repo will be added
|
// contain a .git file then that repo will be added to the list of repos returned
|
||||||
func discoverRepos(ownerPath string) ([]Repo, error) {
|
func discoverRepos(ownerPath string) ([]*RepoDescriptor, error) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
repos []Repo
|
repos []*RepoDescriptor
|
||||||
)
|
)
|
||||||
files, err := ioutil.ReadDir(ownerPath)
|
files, err := ioutil.ReadDir(ownerPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -727,7 +794,7 @@ func discoverRepos(ownerPath string) ([]Repo, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
repos = append(repos, Repo{
|
repos = append(repos, &RepoDescriptor{
|
||||||
repository: r,
|
repository: r,
|
||||||
name: f.Name(),
|
name: f.Name(),
|
||||||
path: repoPath,
|
path: repoPath,
|
||||||
@@ -798,9 +865,11 @@ func optsGuard() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// loadToml loads of the toml config containing regexes and whitelists
|
// loadToml loads of the toml config containing regexes and whitelists.
|
||||||
// 1. look for config path
|
// This function will first look if the configPath is set and load the config
|
||||||
// 2. two, look for gitleaks config env var
|
// from that file. Otherwise will then look for the path set by the GITHLEAKS_CONIFG
|
||||||
|
// env var. If that is not set, then gitleaks will continue with the default configs
|
||||||
|
// specified by the const var at the top `defaultConfig`
|
||||||
func loadToml() error {
|
func loadToml() error {
|
||||||
var (
|
var (
|
||||||
config Config
|
config Config
|
||||||
@@ -827,9 +896,7 @@ func loadToml() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// load up regexes
|
|
||||||
if singleSearchRegex != nil {
|
if singleSearchRegex != nil {
|
||||||
// single search takes precedence over default regex
|
|
||||||
regexes["singleSearch"] = singleSearchRegex
|
regexes["singleSearch"] = singleSearchRegex
|
||||||
} else {
|
} else {
|
||||||
for _, regex := range config.Regexes {
|
for _, regex := range config.Regexes {
|
||||||
@@ -837,6 +904,7 @@ func loadToml() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
whiteListBranches = config.Whitelist.Branches
|
whiteListBranches = config.Whitelist.Branches
|
||||||
|
whiteListRepos = config.Whitelist.Repos
|
||||||
whiteListCommits = make(map[string]bool)
|
whiteListCommits = make(map[string]bool)
|
||||||
for _, commit := range config.Whitelist.Commits {
|
for _, commit := range config.Whitelist.Commits {
|
||||||
whiteListCommits[commit] = true
|
whiteListCommits[commit] = true
|
||||||
@@ -851,7 +919,9 @@ func loadToml() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// getSSHAuth generates ssh auth
|
// getSSHAuth return an ssh auth use by go-git to clone repos behind authentication.
|
||||||
|
// If --ssh-key is set then it will attempt to load the key from that path. If not,
|
||||||
|
// gitleaks will use the default $HOME/.ssh/id_rsa key
|
||||||
func getSSHAuth() (*ssh.PublicKeys, error) {
|
func getSSHAuth() (*ssh.PublicKeys, error) {
|
||||||
var (
|
var (
|
||||||
sshKeyPath string
|
sshKeyPath string
|
||||||
@@ -869,7 +939,7 @@ func getSSHAuth() (*ssh.PublicKeys, error) {
|
|||||||
return sshAuth, err
|
return sshAuth, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (leak *Leak) log() {
|
func (leak Leak) log() {
|
||||||
b, _ := json.MarshalIndent(leak, "", " ")
|
b, _ := json.MarshalIndent(leak, "", " ")
|
||||||
fmt.Println(string(b))
|
fmt.Println(string(b))
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user