Skip to content

Commit

Permalink
Merge pull request #125 from killuazhu/contribute-relax-whitelist-token
Browse files Browse the repository at this point in the history
feat: relax check on whitelist string
  • Loading branch information
KevinHock authored Feb 7, 2019
2 parents 8a14e43 + 7e43b91 commit 8e4190f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions detect_secrets/plugins/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
WHITELIST_REGEXES = [
re.compile(r)
for r in [
r'[ \t]+{} ?pragma: ?whitelist[ -]secret{}[ \t]*$'.format(start, end)
r'[ \t]+{} *pragma: ?whitelist[ -]secret{}[ \t]*$'.format(start, end)
for start, end in (
('#', ''), # e.g. python or yaml
('//', ''), # e.g. golang
(r'/\*', r' ?\*/'), # e.g. c
(r'/\*', r' *\*/'), # e.g. c
('\'', ''), # e.g. visual basic .net
('--', ''), # e.g. sql
# many other inline comment syntaxes are not included,
Expand Down
5 changes: 5 additions & 0 deletions tests/plugins/high_entropy_strings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,15 @@ def test_analyze_multiple_strings_same_line(self, content_to_format, expected_re
[
# Test inline annotation for whitelisting
"'{secret}' # pragma: whitelist secret",
"'{secret}' # pragma: whitelist secret",
"'{secret}' // pragma: whitelist secret",
"'{secret}' // pragma: whitelist secret",
"'{secret}' /* pragma: whitelist secret */",
"'{secret}' /* pragma: whitelist secret */",
"'{secret}' ' pragma: whitelist secret",
"'{secret}' ' pragma: whitelist secret",
"'{secret}' -- pragma: whitelist secret",
"'{secret}' -- pragma: whitelist secret",
# Test high entropy exclude regex
'"CanonicalUser": "{secret}"',
# Not a string
Expand Down

0 comments on commit 8e4190f

Please sign in to comment.