Skip to content

Commit

Permalink
↪️ Merge pull request #152 from killuazhu/contribute-xml-whitelist
Browse files Browse the repository at this point in the history
feature: support whitelist for xml
  • Loading branch information
KevinHock committed Apr 8, 2019
2 parents 8716e5b + 109a4eb commit 94c30be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 6 additions & 5 deletions detect_secrets/plugins/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
for r in [
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
('\'', ''), # e.g. visual basic .net
('--', ''), # e.g. sql
('#', ''), # e.g. python or yaml
('//', ''), # e.g. golang
(r'/\*', r' *\*/'), # e.g. c
('\'', ''), # e.g. visual basic .net
('--', ''), # e.g. sql
(r'<!--[# \t]*?', ' *?-->'), # e.g. xml
# many other inline comment syntaxes are not included,
# because we want to be performant for
# any(regex.search(line) for regex in WHITELIST_REGEXES)
Expand Down
4 changes: 4 additions & 0 deletions tests/plugins/high_entropy_strings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ def test_analyze_multiple_strings_same_line(self, content_to_format, expected_re
"'{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 94c30be

Please sign in to comment.