[openstack-dev] [nova][oslo.utils] Bug-1680130 Check validation of UUID length

Jay Pipes jaypipes at gmail.com
Mon Apr 24 14:44:47 UTC 2017


On 04/24/2017 09:45 AM, Jadhav, Pooja wrote:
> Solution 3:
>
> We can check UUID in central place means in "is_uuid_like" method of
> oslo_utils [4].

This gets my vote. It's a bug in the is_uuid_like() function, IMHO, that 
is returns True for badly-formatted UUID values (like having two 
consecutive hyphens).

FTR, the fix would be pretty simple. Just change this [1] line from this:

return str(uuid.UUID(val)).replace('-', '') == _format_uuid_string(val)

to this:

# Disallow two consecutive hyphens
if '--' in val:
     raise TypeError
return str(uuid.UUID(val)).replace('-', '') == _format_uuid_string(val)

Fix it there and you fix this issue for all projects that use it.

Best,
-jay

[1] 
https://github.com/openstack/oslo.utils/blob/master/oslo_utils/uuidutils.py#L56



More information about the OpenStack-dev mailing list