mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-12-01 13:34:23 +01:00
reworking logic
This commit is contained in:
1 parent
15dedda59a
commit
230a52e3e3
2 files changed
+7
-9
No files matched your search
+1
-1
@@ -614,7 +614,7 @@ func TestAuditRepo(t *testing.T) {
|
|||||||
description: "Audit until specific commit",
|
description: "Audit until specific commit",
|
||||||
numLeaks: 2,
|
numLeaks: 2,
|
||||||
testOpts: Options{
|
testOpts: Options{
|
||||||
Commit: "f6839959b7bbdcd23008f1fb16f797f35bcd3a0c",
|
CommitStop: "f6839959b7bbdcd23008f1fb16f797f35bcd3a0c",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math"
|
"math"
|
||||||
@@ -25,6 +24,7 @@ import (
|
|||||||
|
|
||||||
diffType "gopkg.in/src-d/go-git.v4/plumbing/format/diff"
|
diffType "gopkg.in/src-d/go-git.v4/plumbing/format/diff"
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
||||||
|
"gopkg.in/src-d/go-git.v4/plumbing/storer"
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
|
"gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
|
||||||
"gopkg.in/src-d/go-git.v4/storage/memory"
|
"gopkg.in/src-d/go-git.v4/storage/memory"
|
||||||
|
|
||||||
@@ -550,8 +550,7 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
|
|||||||
}
|
}
|
||||||
err = cIter.ForEach(func(c *object.Commit) error {
|
err = cIter.ForEach(func(c *object.Commit) error {
|
||||||
if c == nil || (opts.Depth != 0 && commitCount == opts.Depth) {
|
if c == nil || (opts.Depth != 0 && commitCount == opts.Depth) {
|
||||||
cIter.Close()
|
return storer.ErrStop
|
||||||
return errors.New("ErrStop")
|
|
||||||
}
|
}
|
||||||
commitCount = commitCount + 1
|
commitCount = commitCount + 1
|
||||||
if whiteListCommits[c.Hash.String()] {
|
if whiteListCommits[c.Hash.String()] {
|
||||||
@@ -567,7 +566,6 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
|
|||||||
cMutex.Lock()
|
cMutex.Lock()
|
||||||
commitMap[c.Hash.String()] = true
|
commitMap[c.Hash.String()] = true
|
||||||
cMutex.Unlock()
|
cMutex.Unlock()
|
||||||
|
|
||||||
totalCommits = totalCommits + 1
|
totalCommits = totalCommits + 1
|
||||||
|
|
||||||
fIter, err := c.Files()
|
fIter, err := c.Files()
|
||||||
@@ -691,14 +689,14 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak {
|
|||||||
}
|
}
|
||||||
}(c, parent)
|
}(c, parent)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
// stop audit if we are at commitStop
|
// stop audit if we are at commitStop
|
||||||
if c.Hash.String() == opts.CommitStop {
|
if c.Hash.String() == opts.CommitStop {
|
||||||
cIter.Close()
|
return storer.ErrStop
|
||||||
return errors.New("ErrStop")
|
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
|
|
||||||
})
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
commitWg.Wait()
|
commitWg.Wait()
|
||||||
|
|||||||
Reference in new issue
Block a user