Skip to content

Commit

Permalink
Secret regex bug correction
Browse files Browse the repository at this point in the history
  • Loading branch information
pablosnt committed Apr 1, 2021
1 parent 4659023 commit d76d53c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions detect_secrets/plugins/keyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
OPTIONAL_NON_WHITESPACE = r'[^\s]{0,50}?'
QUOTE = r'[\'"`]'
# Secret regex details:
# [^\v\'"]* -> this section match with every character except line breaks and quotes. This
# allows to find secrets that starts with symbols or alphanumeric characters.
# (?=[^\v\'"]*) -> this section match with every character except line breaks and quotes. This
# allows to find secrets that starts with symbols or alphanumeric characters.
#
# \w+ -> this section match only with words (letters, numbers or _ are allowed), and at
# (?=\w+) -> this section match only with words (letters, numbers or _ are allowed), and at
# least one character is required. This allows to reduce the false positives
# number.
#
Expand All @@ -83,7 +83,7 @@
# [^\v,\'"`] -> this section match with the last secret character that can be everything except
# line breaks, comma, backticks or quotes. This allows to reduce the false
# positives number and to prevent errors in the code snippet highlighting.
SECRET = r'[^\v\'\"]*\w+[^\v\'\"]*[^\v,\'\"`]'
SECRET = r'(?=[^\v\'\"]*)(?=\w+)[^\v\'\"]*[^\v,\'\"`]'
SQUARE_BRACKETS = r'(\[\])'

FOLLOWED_BY_COLON_EQUAL_SIGNS_REGEX = re.compile(
Expand Down

0 comments on commit d76d53c

Please sign in to comment.