opts guard and removing severity

This commit is contained in:
zach rice committed 2019-11-12 15:18:13 -05:00
1 parent e446ba0738
commit 315ee56024
17 files changed
+99 -121

No files matched your search

+1 -3
View File
@@ -20,7 +20,6 @@ func Run(m *manager.Manager) error {
}
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
}
}
@@ -31,7 +30,6 @@ func Run(m *manager.Manager) error {
}
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 {
@@ -41,7 +39,7 @@ func runHelper(r *Repo) error {
// 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 {
if err := r.AuditUncommitted(); err != nil {
return err
}
return nil
+1 -1
View File
@@ -151,7 +151,7 @@ func TestAudit(t *testing.T) {
Report: "../test_data/test_local_repo_four_alt_config_entropy.json.got",
RepoConfig: true,
},
wantPath: "../test_data/test_local_repo_four_alt_config_entropy.json.got",
wantPath: "../test_data/test_local_repo_four_alt_config_entropy.json",
},
}
+4 -2
View File
@@ -17,6 +17,7 @@ import (
"gopkg.in/src-d/go-git.v4/storage/memory"
"io"
"os"
"path"
"sync"
"time"
)
@@ -76,9 +77,9 @@ func (repo *Repo) Clone(cloneOption *git.CloneOptions) error {
return nil
}
// AuditLocal will do a `git diff` and scan changed files that are being tracked. This is useful functionality
// AuditUncommitted will do a `git diff` and scan changed files that are being tracked. This is useful functionality
// for a pre-commit hook so you can make sure your code does not have any leaks before committing.
func (repo *Repo) AuditLocal() error {
func (repo *Repo) AuditUncommitted() error {
auditTimeStart := time.Now()
r, err := repo.Head()
@@ -277,6 +278,7 @@ func (repo *Repo) Open() error {
return err
}
repo.Repository = repository
repo.Name = path.Base(dir)
}
return nil
}