Ensure config regexes match the entire string

Oslo.config uses re.search() to check config values against the allowed
regex. This checks if the regex matches anywhere in the string, rather
than checking if the entire string matches the regex.

Make sure config options where the entire string should match the given
regex actually do so.

Change-Id: I9e30a24a4c0640f282f507d0a96640d3cdefe43c
Closes-Bug: #1815763
This commit is contained in:
Jim Rollenhagen 2019-02-13 08:16:45 -05:00
parent 104d79d8dd
commit 9cb825b014
3 changed files with 4 additions and 4 deletions

View File

@ -26,7 +26,7 @@ base_options = [
cfg.StrOpt(
'instance_usage_audit_period',
default='month',
regex='(hour|month|day|year)(@([0-9]+))?',
regex='^(hour|month|day|year)(@([0-9]+))?$',
help='''
Time period to generate instance usages for. It is possible to define optional
offset to given period by appending @ character followed by a number defining

View File

@ -24,7 +24,7 @@ cinder_group = cfg.OptGroup(
cinder_opts = [
cfg.StrOpt('catalog_info',
default='volumev3::publicURL',
regex='(\w+):(\w*):(.*?)',
regex='^(\w+):(\w*):(.*?)$',
help="""
Info to match when looking for cinder in the service catalog.

View File

@ -35,7 +35,7 @@ This service is typically executed on the controller node.
"""),
cfg.StrOpt('port_range',
default=DEFAULT_PORT_RANGE,
regex="\d+:\d+",
regex="^\d+:\d+$",
help="""
A range of TCP ports a guest can use for its backend.
@ -45,7 +45,7 @@ instance won't get launched.
Possible values:
* Each string which passes the regex ``\d+:\d+`` For example ``10000:20000``.
* Each string which passes the regex ``^\d+:\d+$`` For example ``10000:20000``.
Be sure that the first port number is lower than the second port number
and that both are in range from 0 to 65535.
"""),