[API]: Don't allow invalid port numbers
Change-Id: I40041f764272c7e30e92b27b75a9890212104739
This commit is contained in:
@@ -185,6 +185,11 @@ class LoadBalancersController(RestController):
|
||||
raise ClientSideError(
|
||||
'Node {0} is missing a port'.format(node.address)
|
||||
)
|
||||
if node.port < 1 or node.port > 65535:
|
||||
raise ClientSideError(
|
||||
'Node {0} port number {1} is invalid'
|
||||
.format(node.address, node.port)
|
||||
)
|
||||
try:
|
||||
node.address = ipfilter(node.address, conf.ip_filters)
|
||||
except IPOutOfRange:
|
||||
@@ -238,6 +243,10 @@ class LoadBalancersController(RestController):
|
||||
lb.protocol = 'HTTP'
|
||||
|
||||
if body.port:
|
||||
if body.port < 1 or body.port > 65535:
|
||||
raise ClientSideError(
|
||||
'Port number {0} is invalid'.format(body.port)
|
||||
)
|
||||
lb.port = body.port
|
||||
else:
|
||||
if lb.protocol == 'HTTP':
|
||||
|
||||
@@ -130,6 +130,11 @@ class NodesController(RestController):
|
||||
raise ClientSideError(
|
||||
'Node {0} is missing a port'.format(node.address)
|
||||
)
|
||||
if node.port < 1 or node.port > 65535:
|
||||
raise ClientSideError(
|
||||
'Node {0} port number {1} is invalid'
|
||||
.format(node.address, node.port)
|
||||
)
|
||||
try:
|
||||
node.address = ipfilter(node.address, conf.ip_filters)
|
||||
except IPOutOfRange:
|
||||
|
||||
Reference in New Issue
Block a user