Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

Commit

Permalink
Fix sanitize basic auth urls same line bug
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Sep 29, 2016
1 parent 54ccf51 commit a2787e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion badwolf/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import six

BASIC_AUTH_URL_RE = re.compile(
r'(?P<protocol>\S+?//)(?P<username>[^:]+?):(?P<password>[^@]+?)@(?P<address>\S+?)',
r'(?P<protocol>\S+?//)(?P<username>[^:\s]+?):(?P<password>[^@\s]+?)@(?P<address>\S+?)',
re.I | re.U
)

Expand Down
13 changes: 13 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ def test_sanitize_basic_auth_urls():
assert 'pwd' not in sanitized
assert 'http://example.com' in sanitized
assert 'git+https://***:***@example.com' in sanitized


def test_sanitize_basic_auth_urls_same_line():
text = '''abc
http://example.com -e git+https://user:pwd@example.com/
def
'''
sanitized = sanitize_sensitive_data(text)
assert 'user' not in sanitized
assert 'pwd' not in sanitized
assert 'http://example.com' in sanitized
assert 'git+https://***:***@example.com' in sanitized

0 comments on commit a2787e4

Please sign in to comment.