mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 13:14:22 +01:00
v3 work... lots of things
This commit is contained in:
1 parent
f3360cbf66
commit
b55d88dc15
215 files changed
+5513
-4218
No files matched your search
@@ -0,0 +1,55 @@
|
||||
package audit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/zricethezav/gitleaks-ng/manager"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
)
|
||||
|
||||
func Run(m *manager.Manager) error {
|
||||
if m.Opts.OwnerPath != "" {
|
||||
files, err := ioutil.ReadDir(m.Opts.OwnerPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, f := range files {
|
||||
if !f.IsDir() {
|
||||
continue
|
||||
}
|
||||
m.Opts.RepoPath = fmt.Sprintf("%s/%s",m.Opts.OwnerPath, f.Name())
|
||||
if err := runHelper(NewRepo(m)); err != nil {
|
||||
// TODO or send to errchan?
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return runHelper(NewRepo(m))
|
||||
}
|
||||
|
||||
func runHelper(r *Repo) error {
|
||||
// Check if gitleaks will perform a local audit.
|
||||
if r.Manager.Opts.OpenLocal() {
|
||||
r.Name = path.Base(r.Manager.Opts.RepoPath)
|
||||
if err := r.Open(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Check if we are checking uncommitted files. This is the default behavior
|
||||
// for a "$gitleaks" command with no options set
|
||||
if r.Manager.Opts.CheckUncommitted() {
|
||||
if err := r.AuditLocal(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
if err := r.Clone(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return r.Audit()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user