From 93380ad86a12e0e1cf828fd14aceaa9b1781397c Mon Sep 17 00:00:00 2001 From: Shawn Smith Date: Sun, 25 Feb 2018 14:15:19 -0500 Subject: [PATCH] Do lowercase checks in stopwords This reduces the number of loops we need to do when checking. --- checks.go | 3 +++ main.go | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/checks.go b/checks.go index b11559cb..4357f163 100644 --- a/checks.go +++ b/checks.go @@ -89,6 +89,9 @@ func checkShannonEntropy(target string) bool { // containsStopWords checks if there are any stop words in target func containsStopWords(target string) bool { + // Convert to lowercase to reduce the number of loops needed. + target = strings.ToLower(target) + for _, stopWord := range stopWords { if strings.Contains(target, stopWord) { return true diff --git a/main.go b/main.go index 3b0b2ba6..e65f0bbd 100644 --- a/main.go +++ b/main.go @@ -37,8 +37,7 @@ func init() { base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" hexChars = "1234567890abcdefABCDEF" - stopWords = []string{"setting", "Setting", "SETTING", "info", - "Info", "INFO", "env", "Env", "ENV", "environment", "Environment", "ENVIRONMENT"} + stopWords = []string{"setting", "info", "env", "environment"} regexes = map[string]*regexp.Regexp{ "PKCS8": regexp.MustCompile("-----BEGIN PRIVATE KEY-----"),