mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 05:04:22 +01:00
Fix files whitelisting when checking Github PRs
Files whitelisting code was not executed when running the tool against a Github PR so the config was ignored. To avoid duplication, the whitelist files check has been moved to the `inspect` function which is always executed.
This commit is contained in:
1 parent
35531233d9
commit
169a137e7f
2 files changed
+27
-13
No files matched your search
@@ -176,6 +176,7 @@ func TestRun(t *testing.T) {
|
||||
description string
|
||||
expectedErrMsg string
|
||||
whiteListRepos []string
|
||||
whiteListFiles []*regexp.Regexp
|
||||
numLeaks int
|
||||
configPath string
|
||||
commitPerPage int
|
||||
@@ -290,6 +291,18 @@ func TestRun(t *testing.T) {
|
||||
expectedErrMsg: "",
|
||||
commitPerPage: 1,
|
||||
},
|
||||
{
|
||||
testOpts: Options{
|
||||
GithubPR: "https://github.com/gitleakstest/gronit/pull/1",
|
||||
},
|
||||
description: "test github pr with whitelisted files",
|
||||
numLeaks: 0,
|
||||
expectedErrMsg: "",
|
||||
commitPerPage: 1,
|
||||
whiteListFiles: []*regexp.Regexp{
|
||||
regexp.MustCompile("main.go"),
|
||||
},
|
||||
},
|
||||
}
|
||||
g := goblin.Goblin(t)
|
||||
for _, test := range tests {
|
||||
@@ -301,6 +314,11 @@ func TestRun(t *testing.T) {
|
||||
if test.commitPerPage != 0 {
|
||||
githubPages = test.commitPerPage
|
||||
}
|
||||
if test.whiteListFiles != nil {
|
||||
whiteListFiles = test.whiteListFiles
|
||||
} else {
|
||||
whiteListFiles = nil
|
||||
}
|
||||
opts = test.testOpts
|
||||
leaks, err := run()
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user