Skip to content

Commit

Permalink
Simplify and improve performance of the keyword plugin
Browse files Browse the repository at this point in the history
As per @domanchi comments for the PR #83, doing `lower()` once
is enough, and should also be faster.
  • Loading branch information
Jerzy Kozera committed Oct 8, 2018
1 parent 081f3d8 commit 191bbb5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions detect_secrets/plugins/keyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@


BLACKLIST = (
'PASS =',
# NOTE all values here should be lowercase,
# otherwise _secret_generator can fail to match them
'pass =',
'password',
'passwd',
'pwd',
Expand Down Expand Up @@ -66,7 +68,10 @@ def analyze_string(self, string, line_num, filename):

return output

def secret_generator(self, string):
def _secret_generator(self, lowercase_string):
for line in BLACKLIST:
if line.lower() in string.lower():
if line in lowercase_string:
yield line

def secret_generator(self, string):
return self._secret_generator(string.lower())

0 comments on commit 191bbb5

Please sign in to comment.