mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-12-01 13:34:23 +01:00
Merge pull request #222 from martelo/modify-single-commit-audit
Modify single commit audit
This commit is contained in:
1 file changed
+17
-10
+17
-10
@@ -133,7 +133,21 @@ func (repoInfo *RepoInfo) audit() ([]Leak, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Branch != "" {
|
if opts.Commit != "" {
|
||||||
|
h := plumbing.NewHash(opts.Commit)
|
||||||
|
c, err := repoInfo.repository.CommitObject(h)
|
||||||
|
if err != nil {
|
||||||
|
return leaks, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
commitCount = commitCount + 1
|
||||||
|
totalCommits = totalCommits + 1
|
||||||
|
leaksFromSingleCommit := repoInfo.auditSingleCommit(c)
|
||||||
|
mutex.Lock()
|
||||||
|
leaks = append(leaksFromSingleCommit, leaks...)
|
||||||
|
mutex.Unlock()
|
||||||
|
return leaks, err
|
||||||
|
} else if opts.Branch != "" {
|
||||||
refs, err := repoInfo.repository.Storer.IterReferences()
|
refs, err := repoInfo.repository.Storer.IterReferences()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return leaks, err
|
return leaks, err
|
||||||
@@ -187,21 +201,14 @@ func (repoInfo *RepoInfo) audit() ([]Leak, error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// commits w/o parent (root of git the git ref) or option for single commit is not empty str
|
// commits w/o parent (root of git the git ref)
|
||||||
if (len(c.ParentHashes) == 0 && opts.Commit == "") || (len(c.ParentHashes) == 0 && opts.Commit == c.Hash.String()) {
|
if len(c.ParentHashes) == 0 {
|
||||||
commitCount = commitCount + 1
|
commitCount = commitCount + 1
|
||||||
totalCommits = totalCommits + 1
|
totalCommits = totalCommits + 1
|
||||||
leaksFromSingleCommit := repoInfo.auditSingleCommit(c)
|
leaksFromSingleCommit := repoInfo.auditSingleCommit(c)
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
leaks = append(leaksFromSingleCommit, leaks...)
|
leaks = append(leaksFromSingleCommit, leaks...)
|
||||||
mutex.Unlock()
|
mutex.Unlock()
|
||||||
if opts.Commit == c.Hash.String() {
|
|
||||||
return storer.ErrStop
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if opts.Commit != "" && opts.Commit != c.Hash.String() {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user