yahoo-eng-team team mailing list archive
-
yahoo-eng-team team
-
Mailing list archive
-
Message #60683
[Bug 1653899] Re: The 500 returns for invalid regex in the pattern match query parameters
Reviewed: https://review.openstack.org/420494
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=841916daf78e740172da8f8b671069e81ae9a735
Submitter: Jenkins
Branch: master
commit 841916daf78e740172da8f8b671069e81ae9a735
Author: Kevin_Zheng <zhengzhenyu@xxxxxxxxxx>
Date: Mon Jan 16 12:02:30 2017 +0800
Strict pattern match query parameters
We have a lot of filters are pattern match.
There is list for exact match
https://github.com/openstack/nova/blob/df2fd4a252cecc1e1ef471c071e57526ddf65499/nova/db/sqlalchemy/api.py#L2221
Out of that list will be pattern match
https://github.com/openstack/nova/blob/df2fd4a252cecc1e1ef471c071e57526ddf65499/nova/db/sqlalchemy/api.py#L2231
HTTP 500 raises if invalid regex provided for
those filters, strict there format to be regex
in JSON schema to avoid this.
partial implement of bp add-whitelist-for-server-list-filter-sort-parameters
Closes-Bug: #1653899
Change-Id: I4cf38407c20284dee7127edfe312da81caac9272
** Changed in: nova
Status: In Progress => Fix Released
--
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1653899
Title:
The 500 returns for invalid regex in the pattern match query
parameters
Status in OpenStack Compute (nova):
Fix Released
Bug description:
We have a lot of filters are pattern match.
There is list for exact match
https://github.com/openstack/nova/blob/df2fd4a252cecc1e1ef471c071e57526ddf65499/nova/db/sqlalchemy/api.py#L2221
Out of that list will be pattern match
https://github.com/openstack/nova/blob/df2fd4a252cecc1e1ef471c071e57526ddf65499/nova/db/sqlalchemy/api.py#L2231
When I input a invalid regex pattern, I will get 500 returned.
For example:
curl -g -i -X GET http://hp-pc:8774/v2.1/servers?node=[[[ -H
"OpenStack-API-Version: compute 2.39" -H "User-Agent: python-
novaclient" -H "Accept: application/json" -H "X-OpenStack-Nova-API-
Version: 2.39" -H "X-Auth-Token:
gAAAAABYbKbto9BeEG31MtaiSCtIc43YKQCclVRJBklKMTv010fyB9jUgjmgvFSLCj8TyYfwJyIKiMduDesKNweCqnjcfLNlkMOsiNsHb4AyYrk0OlvZMwJ5I2rS1x_3kjyP2zbEUEJEKU1WrIY7QvjRBXQ7-r8AoI2QBCqolZjhtm2ckfoULTA"
There is traceback in the log:
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters Traceback (most recent call last):
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters context)
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 450, in do_execute
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters cursor.execute(statement, parameters)
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters File "/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 166, in execute
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters result = self._query(query)
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters File "/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 322, in _query
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters conn.query(q)
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 835, in query
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters self._affected_rows = self._read_query_result(unbuffered=unbuffered)
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1019, in _read_query_result
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters result.read()
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1302, in read
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters first_packet = self.connection._read_packet()
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 981, in _read_packet
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters packet.check_error()
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 393, in check_error
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters err.raise_mysql_exception(self._data)
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters File "/usr/local/lib/python2.7/dist-packages/pymysql/err.py", line 107, in raise_mysql_exception
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters raise errorclass(errno, errval)
2017-01-04 15:43:49.113 TRACE oslo_db.sqlalchemy.exc_filters InternalError: (1139, u"Got error 'brackets ([ ]) not balanced' from regexp"
To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1653899/+subscriptions
References