From bb9c459a1a68011be77d612f4141db4b3f4e6ecd Mon Sep 17 00:00:00 2001 From: Milo Minderbinder Date: Mon, 31 Dec 2018 12:49:49 -0500 Subject: [PATCH] check whiteListFiles for root commit & GitHub PRs add missing checks against `whiteListFiles` regexes for files in the root/initial commit and in GitHub PRs (in `auditGithubPR` function) --- github.go | 11 +++++++++++ main.go | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/github.go b/github.go index b3b7c5e3..091439a6 100644 --- a/github.go +++ b/github.go @@ -51,9 +51,20 @@ func auditGithubPR() ([]Leak, error) { } files := commit.Files for _, f := range files { + skipFile := false if f.Patch == nil || f.Filename == nil { continue } + for _, re := range whiteListFiles { + if re.FindString(f.GetFilename()) != "" { + log.Infof("skipping whitelisted file (matched regex '%s'): %s", re.String(), f.GetFilename()) + skipFile = true + break + } + } + if skipFile { + continue + } diff := gitDiff{ sha: commit.GetSHA(), diff --git a/main.go b/main.go index a843804e..cda203f4 100644 --- a/main.go +++ b/main.go @@ -509,6 +509,12 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak { if bin || err != nil { return nil } + for _, re := range whiteListFiles { + if re.FindString(f.Name) != "" { + log.Infof("skipping whitelisted file (matched regex '%s'): %s", re.String(), f.Name) + return nil + } + } content, err := f.Contents() if err != nil { return nil @@ -578,7 +584,9 @@ func auditGitReference(repo *RepoDescriptor, ref *plumbing.Reference) []Leak { } for _, re := range whiteListFiles { if re.FindString(filePath) != "" { + log.Infof("skipping whitelisted file (matched regex '%s'): %s", re.String(), filePath) skipFile = true + break } } if skipFile {