adding stopwords (#849)

* adding stopwords

* format readme, update default config
This commit is contained in:
Zachary Rice authored and GitHub committed 2022-04-21 08:31:58 -05:00
1 parent 82f7d61593
commit 8481f0e9cd
64 files changed
+181 -109

No files matched your search

+18 -1
View File
@@ -1,6 +1,9 @@
package config
import "regexp"
import (
"regexp"
"strings"
)
// Allowlist allows a rule to be ignored for specific
// regexes, paths, and/or commits
@@ -16,6 +19,11 @@ type Allowlist struct {
// Commits is a slice of commit SHAs that are allowed to be ignored.
Commits []string
// StopWords is a slice of stop words that are allowed to be ignored.
// This targets the _secret_, not the content of the regex match like the
// Regexes slice.
StopWords []string
}
// CommitAllowed returns true if the commit is allowed to be ignored.
@@ -40,3 +48,12 @@ func (a *Allowlist) PathAllowed(path string) bool {
func (a *Allowlist) RegexAllowed(s string) bool {
return anyRegexMatch(s, a.Regexes)
}
func (a *Allowlist) ContainsStopWord(s string) bool {
for _, stopWord := range a.StopWords {
if strings.Contains(s, stopWord) {
return true
}
}
return false
}