Преглед изворни кода

Merge pull request #47 from Shawn-Smith/Stopwords-lowercase

Make stopwords lowercase
Zachary Rice пре 8 година
родитељ
комит
4b21bbef2e
2 измењених фајлова са 4 додато и 2 уклоњено
  1. 3 0
      checks.go
  2. 1 2
      main.go

+ 3 - 0
checks.go

@@ -107,6 +107,9 @@ func checkShannonEntropy(target string, opts *Options) 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

+ 1 - 2
main.go

@@ -46,8 +46,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-----"),