Sync strutils from oslo-incubator for mask_password fix

This sync pulls in:
   1131b56 Enable mask_password to handle byte code strings

This is needed because Nova commands are hitting the same
problem Cinder was hitting in bug 1368527 which was fixed
by this strutils update in bug 1366189.

This is not needed in kilo because in kilo Nova has moved
to using the oslo.utils library, which has this fix in it.

NOTE(jecarey):
This is now needed in stable/icehouse because of the backport of:
   f58d95c9 - Sync process and str utils from oslo
which was to address CVE-2014-7231 (bug #1345233)

Note that during icehouse mask_password was moved from
oslo-incubator log.py to strutils.py, however both still exist and
are used.  In order to minimize change, this patch also updates
the original nova/openstack/common/log.py.

Closes-bug: #1366189
Change-Id: I983feea4ac26e34032fa66a4b55f0ce42699ba6a
(cherry picked from commit 0bad3b14ab)
This commit is contained in:
James Carey 2014-10-23 13:24:27 -07:00 committed by James Carey
parent bbf65ab569
commit 1e03160eb2
2 changed files with 12 additions and 2 deletions

View File

@ -263,7 +263,12 @@ 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

View File

@ -271,7 +271,12 @@ 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