Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: support whitelist for xml #152

Merged
merged 2 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
('<!--[# \t]*', ' *-->'), # e.g. xml
KevinHock marked this conversation as resolved.
Show resolved Hide resolved
# 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