Merge "Raise Exception when the paramter is invalid"

This commit is contained in:
Jenkins
2016-02-20 03:48:15 +00:00
committed by Gerrit Code Review
10 changed files with 180 additions and 32 deletions

View File

@@ -68,6 +68,10 @@ class ActionController(wsgi.Controller):
consts.PARAM_SORT: 'single',
consts.PARAM_GLOBAL_PROJECT: 'single',
}
for key in req.params.keys():
if (key not in param_whitelist.keys() and key not in
filter_whitelist.keys()):
raise exc.HTTPBadRequest(_('Invalid parameter %s') % key)
params = util.get_allowed_params(req.params, param_whitelist)
filters = util.get_allowed_params(req.params, filter_whitelist)

View File

@@ -139,6 +139,10 @@ class ClusterController(wsgi.Controller):
consts.PARAM_SORT: 'single',
consts.PARAM_GLOBAL_PROJECT: 'single',
}
for key in req.params.keys():
if (key not in param_whitelist.keys() and key not in
filter_whitelist.keys()):
raise exc.HTTPBadRequest(_('Invalid parameter %s') % key)
params = util.get_allowed_params(req.params, param_whitelist)
filters = util.get_allowed_params(req.params, filter_whitelist)

View File

@@ -13,10 +13,12 @@
"""
Event endpoint for Senlin v1 ReST API.
"""
from webob import exc
from senlin.api.common import util
from senlin.api.common import wsgi
from senlin.common import consts
from senlin.common.i18n import _
from senlin.common import utils
@@ -42,6 +44,10 @@ class EventController(wsgi.Controller):
consts.PARAM_SORT: 'single',
consts.PARAM_GLOBAL_PROJECT: 'single',
}
for key in req.params.keys():
if (key not in param_whitelist.keys() and key not in
filter_whitelist.keys()):
raise exc.HTTPBadRequest(_('Invalid parameter %s') % key)
params = util.get_allowed_params(req.params, param_whitelist)
filters = util.get_allowed_params(req.params, filter_whitelist)

View File

@@ -77,6 +77,10 @@ class NodeController(wsgi.Controller):
consts.PARAM_SORT: 'single',
consts.PARAM_GLOBAL_PROJECT: 'single',
}
for key in req.params.keys():
if (key not in param_whitelist.keys() and key not in
filter_whitelist.keys()):
raise exc.HTTPBadRequest(_('Invalid parameter %s') % key)
params = util.get_allowed_params(req.params, param_whitelist)
filters = util.get_allowed_params(req.params, filter_whitelist)

View File

@@ -79,6 +79,10 @@ class ReceiverController(wsgi.Controller):
consts.PARAM_SORT: 'single',
consts.PARAM_GLOBAL_PROJECT: 'single',
}
for key in req.params.keys():
if (key not in param_whitelist.keys() and key not in
filter_whitelist.keys()):
raise exc.HTTPBadRequest(_('Invalid parameter %s') % key)
params = util.get_allowed_params(req.params, param_whitelist)
filters = util.get_allowed_params(req.params, filter_whitelist)