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

Doug Hellmann doug at doughellmann.com
Mon Apr 24 15:15:47 UTC 2017


Excerpts from Jay Pipes's message of 2017-04-24 10:44:47 -0400:
> 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
> 

I think the point of that function was to be a little forgiving of
typos, since we use UUIDs so much in the command line interfaces.

Doug



More information about the OpenStack-dev mailing list