← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1653899] [NEW] The 500 returns for invalid regex in the pattern match query parameters

 

Public bug reported:

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"

** Affects: nova
     Importance: Undecided
         Status: New

-- 
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):
  New

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


Follow ups