Mercurial > kallithea
changeset 2882:12fce5e499d5 beta
obfuscate password in logs for engine connection string
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 29 Sep 2012 19:16:00 +0200 |
parents | 6b79e96f6ecd |
children | b1822f4a85ca |
files | rhodecode/lib/utils2.py rhodecode/model/__init__.py |
diffstat | 2 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/lib/utils2.py Sat Sep 29 14:32:26 2012 +0200 +++ b/rhodecode/lib/utils2.py Sat Sep 29 19:16:00 2012 +0200 @@ -497,3 +497,11 @@ cur_path = os.path.split(sys.executable)[0] if not os.environ['PATH'].startswith(cur_path): os.environ['PATH'] = '%s:%s' % (cur_path, os.environ['PATH']) + + +def obfuscate_url_pw(engine): + from sqlalchemy.engine import url + url = url.make_url(engine) + if url.password: + url.password = 'XXXXX' + return str(url) \ No newline at end of file
--- a/rhodecode/model/__init__.py Sat Sep 29 14:32:26 2012 +0200 +++ b/rhodecode/model/__init__.py Sat Sep 29 19:16:00 2012 +0200 @@ -43,7 +43,7 @@ import logging from rhodecode.model import meta -from rhodecode.lib.utils2 import safe_str +from rhodecode.lib.utils2 import safe_str, obfuscate_url_pw log = logging.getLogger(__name__) @@ -56,7 +56,8 @@ :param engine: engine to bind to """ - log.info("initializing db for %s" % engine) + engine_str = obfuscate_url_pw(str(engine.url)) + log.info("initializing db for %s" % engine_str) meta.Base.metadata.bind = engine