Enable mask_password to handle byte code strings
Byte code strings passed into mask_password cause the coersion to six.text_type to fail with a UnicodeDecodeError. The code can work with the byte code string, but the incoming message may be an i18n object that has to be coerced. The temporary fix is to ignore the UnicodeDecodeError on the coersion. A better solution will be provided for Kilo. This is related to cinder bug #1368527 Change-Id: Ifb60942b7cdfe4d184f59012c29caa9fa71fb053 Closes-bug: #1366189 Closes-bug: #1368527
This commit is contained in:
parent
f79497e2c9
commit
e54a359733
@ -221,7 +221,13 @@ def mask_password(message, secret="***"):
|
||||
>>> mask_password("u'original_password' : u'aaaaa'")
|
||||
"u'original_password' : u'***'"
|
||||
"""
|
||||
message = six.text_type(message)
|
||||
|
||||
try:
|
||||
message = six.text_type(message)
|
||||
except UnicodeDecodeError:
|
||||
# NOTE(jecarey): Temporary fix to handle cases where message is a
|
||||
# byte string. A better solution will be provided in Kilo.
|
||||
pass
|
||||
|
||||
# NOTE(ldbragst): Check to see if anything in message contains any key
|
||||
# specified in _SANITIZE_KEYS, if not then just return the message since
|
||||
|
@ -546,3 +546,7 @@ class MaskPasswordTestCase(test_base.BaseTestCase):
|
||||
payload = ("test = node.session.auth.password --password mypassword")
|
||||
expected = ("test = node.session.auth.password --password ***")
|
||||
self.assertEqual(expected, strutils.mask_password(payload))
|
||||
|
||||
payload = "test = cmd --password my\xe9\x80\x80pass"
|
||||
expected = ("test = cmd --password ***")
|
||||
self.assertEqual(expected, strutils.mask_password(payload))
|
||||
|
Loading…
x
Reference in New Issue
Block a user