glance/glance
Ian Wienand f601cfccf1 Support RFC1738 quoted chars in passwords
In the bug, a user tried setting a devstack password with a "@" in it.

As it turns out, sqlalchmey turns the connection-string into a
sqlalchemy.engine.url.URL object [1] which returns a RFC1738 quoted
string.

However, alembic's set_main_option [2] uses python
string-interpolation which interprets '%' characters.  This means you
end up with an interpolation traceback when using any quoted character
(':@/') in a user/password (more likely password).

Avoid this by ensuring the URL is safe for python interpolation in
set_main_option by replacing '%' -> '%%'.

I convinced myself this is safe because sqlalchemy correctly parses
the quoted and unquoted versions just the same

---
 >>> str(sqlalchemy.engine.url.make_url('mysql+pymysql://foo:crazy:@/pw@/moo'))
 'mysql+pymysql://foo:crazy%3A%40%2Fpw@/moo'
 >>> str(sqlalchemy.engine.url.make_url('mysql+pymysql://foo:crazy%3A%40%2Fpw@/moo'))
 'mysql+pymysql://foo:crazy%3A%40%2Fpw@/moo'
---

A test is added

[1] https://github.com/zzzeek/sqlalchemy/blob/master/lib/sqlalchemy/engine/url.py
[2] http://alembic.zzzcomputing.com/en/latest/api/config.html#alembic.config.Config.set_main_option

Change-Id: I3ef7e3e539e35ce040573f2044ab6eb3c990200a
Closes-Bug: #1695299
2018-08-13 14:44:32 +10:00
..
api Add API version 2.8 2018-08-07 16:39:06 +01:00
async Add multi-store support 2018-08-01 08:53:47 +00:00
cmd Remove Images API v1 entry points 2018-07-13 10:21:49 +01:00
common Correct typo in help text 2018-08-06 11:36:28 -04:00
db Support RFC1738 quoted chars in passwords 2018-08-13 14:44:32 +10:00
domain Add multi-store support 2018-08-01 08:53:47 +00:00
hacking Make i18n log translation functions as no-op 2017-06-21 16:14:15 +07:00
image_cache Remove Images API v1 entry points 2018-07-13 10:21:49 +01:00
locale Imported Translations from Zanata 2018-08-09 07:36:04 +00:00
quota Add multi-store support 2018-08-01 08:53:47 +00:00
registry Deprecate Registry and it's config opts 2017-10-13 16:09:06 +01:00
tests Support RFC1738 quoted chars in passwords 2018-08-13 14:44:32 +10:00
__init__.py Empty files shouldn't contain copyright nor license 2013-12-24 22:39:05 -06:00
context.py Use new oslo.context arg names 2017-11-27 10:20:10 -06:00
gateway.py Fix for Image members not generating notifications 2016-01-25 04:50:58 -08:00
i18n.py Make i18n log translation functions as no-op 2017-06-21 16:14:15 +07:00
location.py Add multi-store support 2018-08-01 08:53:47 +00:00
notifier.py Add multi-store support 2018-08-01 08:53:47 +00:00
opts.py Fix config group not found error 2018-02-18 14:18:29 -05:00
schema.py Import i18n functions directly 2015-12-07 18:20:43 +03:00
scrubber.py Add multi-store support 2018-08-01 08:53:47 +00:00
version.py Remove vim header 2014-01-14 16:03:28 +00:00