fix whitelist commits, added test (#390)

This commit is contained in:
Zachary Rice authored and GitHub committed 2020-05-31 10:25:58 -04:00
1 parent e0f6399d5c
commit bdc688dd53
4 files changed
+59 -4

No files matched your search

+10
View File
@@ -356,6 +356,16 @@ func TestAudit(t *testing.T) {
},
wantPath: "../test_data/test_local_repo_four_leaks_commit_timerange.json",
},
{
description: "test local repo two whitelist commit config",
opts: options.Options{
RepoPath: "../test_data/test_repos/test_repo_2",
Report: "../test_data/test_local_repo_two_whitelist_commits.json.got",
Config: "../test_data/test_configs/whitelist_commit.toml",
ReportFormat: "json",
},
wantPath: "../test_data/test_local_repo_two_whitelist_commits.json",
},
}
for _, test := range tests {
+8 -4
View File
@@ -282,6 +282,12 @@ func (repo *Repo) Audit() error {
return storer.ErrStop
}
// Check if commit is whitelisted
if isCommitWhiteListed(c.Hash.String(), repo.config.Whitelist.Commits) {
return nil
}
// Check if at root
if len(c.ParentHashes) == 0 {
cc++
err = inspectFilesAtCommit(c, repo)
@@ -291,11 +297,9 @@ func (repo *Repo) Audit() error {
return nil
}
if isCommitWhiteListed(c.Hash.String(), repo.config.Whitelist.Commits) {
return nil
}
// increase commit counter
cc++
err = c.Parents().ForEach(func(parent *object.Commit) error {
defer func() {
if err := recover(); err != nil {