# HG changeset patch # User Marcin Kuzminski # Date 2012-09-29 17:16:00 # Node ID 12fce5e499d53c83d5aeeb7c0bfc7babf38c137a # Parent 6b79e96f6ecda216ce5edf3debc8169393564644 obfuscate password in logs for engine connection string diff --git a/rhodecode/lib/utils2.py b/rhodecode/lib/utils2.py --- a/rhodecode/lib/utils2.py +++ b/rhodecode/lib/utils2.py @@ -497,3 +497,11 @@ def fix_PATH(os_=None): 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 diff --git a/rhodecode/model/__init__.py b/rhodecode/model/__init__.py --- a/rhodecode/model/__init__.py +++ b/rhodecode/model/__init__.py @@ -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 @@ def init_model(engine): :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