mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 21:24:21 +01:00
update to V7 (#469)
This commit is contained in:
1 parent
40545fb680
commit
c50906373c
88 files changed
+2633
-2698
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package scan
|
||||
|
||||
import (
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/zricethezav/gitleaks/v7/report"
|
||||
)
|
||||
|
||||
// CommitsScanner is a commit scanner
|
||||
type CommitsScanner struct {
|
||||
BaseScanner
|
||||
|
||||
repo *git.Repository
|
||||
repoName string
|
||||
commits []string
|
||||
}
|
||||
|
||||
// NewCommitsScanner creates and returns a commits scanner, notice the 's' in commits
|
||||
func NewCommitsScanner(base BaseScanner, repo *git.Repository, commits []string) *CommitsScanner {
|
||||
return &CommitsScanner{
|
||||
BaseScanner: base,
|
||||
repo: repo,
|
||||
commits: commits,
|
||||
repoName: getRepoName(base.opts),
|
||||
}
|
||||
}
|
||||
|
||||
// Scan kicks off a CommitsScanner Scan
|
||||
func (css *CommitsScanner) Scan() (report.Report, error) {
|
||||
var scannerReport report.Report
|
||||
for _, c := range css.commits {
|
||||
c, err := obtainCommit(css.repo, c)
|
||||
if err != nil {
|
||||
return scannerReport, nil
|
||||
}
|
||||
cs := NewCommitScanner(css.BaseScanner, css.repo, c)
|
||||
commitReport, err := cs.Scan()
|
||||
if err != nil {
|
||||
return scannerReport, err
|
||||
}
|
||||
scannerReport.Leaks = append(scannerReport.Leaks, commitReport.Leaks...)
|
||||
scannerReport.Commits++
|
||||
}
|
||||
return scannerReport, nil
|
||||
}
|
||||
Reference in new issue
Block a user