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

Commit

Permalink
Merge "Mask passwords included without quotes at the ends of commands"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jun 27, 2014
2 parents 5c835cf + 5e3d3a5 commit e9bb0b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion openstack/common/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
r'([\'"].*?%(key)s[\'"]\s*:\s*u?[\'"]).*?([\'"])',
r'([\'"].*?%(key)s[\'"]\s*,\s*\'--?[A-z]+\'\s*,\s*u?[\'"])'
'.*?([\'"])',
r'(%(key)s\s*--?[A-z]+\s*).*?([\s])']
r'(%(key)s\s*--?[A-z]+\s*)\S+(\s*)']

for key in _SANITIZE_KEYS:
for pattern in _FORMAT_PATTERNS:
Expand Down
10 changes: 10 additions & 0 deletions tests/unit/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,12 @@ def test_mask_password(self):
"'***', 'nomask'")
self.assertEqual(expected, log.mask_password(payload))

payload = ("test = 'node.session.auth.password', '--password', "
"'mypassword'")
expected = ("test = 'node.session.auth.password', '--password', "
"'***'")
self.assertEqual(expected, log.mask_password(payload))

payload = "test = node.session.auth.password -v mypassword nomask"
expected = "test = node.session.auth.password -v *** nomask"
self.assertEqual(expected, log.mask_password(payload))
Expand All @@ -916,3 +922,7 @@ def test_mask_password(self):
expected = ("test = node.session.auth.password --password *** "
"nomask")
self.assertEqual(expected, log.mask_password(payload))

payload = ("test = node.session.auth.password --password mypassword")
expected = ("test = node.session.auth.password --password ***")
self.assertEqual(expected, log.mask_password(payload))

0 comments on commit e9bb0b5

Please sign in to comment.