mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 13:14:22 +01:00
workin on tests
This commit is contained in:
1 parent
fa27d32bfe
commit
d4925443c8
2 files changed
+10
-6
No files matched your search
+8
-4
@@ -684,6 +684,7 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
whiteListRepos = nil
|
whiteListRepos = nil
|
||||||
}
|
}
|
||||||
skip := false
|
skip := false
|
||||||
|
totalCommits = 0
|
||||||
// config paths
|
// config paths
|
||||||
if test.configPath != "" {
|
if test.configPath != "" {
|
||||||
os.Setenv("GITLEAKS_CONFIG", test.configPath)
|
os.Setenv("GITLEAKS_CONFIG", test.configPath)
|
||||||
@@ -695,11 +696,14 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
if !skip {
|
if !skip {
|
||||||
leaks, err = auditGitRepo(test.repo)
|
leaks, err = auditGitRepo(test.repo)
|
||||||
|
if test.testOpts.Depth != 0 {
|
||||||
if opts.Redact {
|
g.Assert(totalCommits).Equal(test.testOpts.Depth)
|
||||||
g.Assert(leaks[0].Offender).Equal("REDACTED")
|
} else {
|
||||||
|
if opts.Redact {
|
||||||
|
g.Assert(leaks[0].Offender).Equal("REDACTED")
|
||||||
|
}
|
||||||
|
g.Assert(len(leaks)).Equal(test.numLeaks)
|
||||||
}
|
}
|
||||||
g.Assert(len(leaks)).Equal(test.numLeaks)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ type Options struct {
|
|||||||
|
|
||||||
CommitStop string `long:"commit-stop" description:"sha of commit to stop at"`
|
CommitStop string `long:"commit-stop" description:"sha of commit to stop at"`
|
||||||
Commit string `long:"commit" description:"sha of commit to investigate"`
|
Commit string `long:"commit" description:"sha of commit to investigate"`
|
||||||
Depth int `long:"depth" description:"maximum commit depth"`
|
Depth int64 `long:"depth" description:"maximum commit depth"`
|
||||||
|
|
||||||
// local target option
|
// local target option
|
||||||
RepoPath string `long:"repo-path" description:"Path to repo"`
|
RepoPath string `long:"repo-path" description:"Path to repo"`
|
||||||
@@ -509,7 +509,7 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
|
|||||||
err error
|
err error
|
||||||
repoName string
|
repoName string
|
||||||
leaks []Leak
|
leaks []Leak
|
||||||
commitCount int
|
commitCount int64
|
||||||
commitWg sync.WaitGroup
|
commitWg sync.WaitGroup
|
||||||
mutex = &sync.Mutex{}
|
mutex = &sync.Mutex{}
|
||||||
semaphore chan bool
|
semaphore chan bool
|
||||||
|
|||||||
Reference in new issue
Block a user