Add UUID syntax validation
This commit is contained in:
parent
95038a060c
commit
a51b499cb3
10
main.py
10
main.py
|
@ -7,6 +7,7 @@ import configparser
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
|
import uuid as uuid_module
|
||||||
from ipaddress import AddressValueError, IPv4Address, IPv6Address
|
from ipaddress import AddressValueError, IPv4Address, IPv6Address
|
||||||
from os import access, R_OK
|
from os import access, R_OK
|
||||||
|
|
||||||
|
@ -33,10 +34,17 @@ class CloudInitRequest:
|
||||||
self.remoteip = None
|
self.remoteip = None
|
||||||
self.hostinfo = ('localhost', )
|
self.hostinfo = ('localhost', )
|
||||||
self.request = request
|
self.request = request
|
||||||
self.uuid = uuid
|
|
||||||
self.meta_data = None
|
self.meta_data = None
|
||||||
self.meta_data_loaded = False
|
self.meta_data_loaded = False
|
||||||
self.user_data = None
|
self.user_data = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.uuid = str(uuid_module.UUID('{' + uuid + '}'))
|
||||||
|
# ValueError is wrong UUID syntax
|
||||||
|
# TypeError is None
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
self.uuid = None
|
||||||
|
|
||||||
self._init_ip()
|
self._init_ip()
|
||||||
self._generate_default_meta_data()
|
self._generate_default_meta_data()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user