diff options
author | Marko Kreen | 2011-12-07 11:33:30 +0000 |
---|---|---|
committer | Marko Kreen | 2011-12-07 11:33:30 +0000 |
commit | 826b73a48c2e3549d880a790d4bf5bf005b00edf (patch) | |
tree | 00142798f9c64a1018a0f1d6cc91bfc92f3ca96d /python/skytools/scripting.py | |
parent | a1d3d0cc7d2cb4a067d7262c1519d1926dce37de (diff) |
DBScript: simpler removal of password info
PG connect strings can be quite free-form.
So remove everything after 'password'.
Diffstat (limited to 'python/skytools/scripting.py')
-rw-r--r-- | python/skytools/scripting.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/python/skytools/scripting.py b/python/skytools/scripting.py index 4d9b1f8f..558998c2 100644 --- a/python/skytools/scripting.py +++ b/python/skytools/scripting.py @@ -3,7 +3,7 @@ """ -import sys, os, signal, optparse, time, errno, select, re +import sys, os, signal, optparse, time, errno, select import logging, logging.handlers, logging.config import skytools @@ -722,8 +722,13 @@ class DBScript(BaseScript): else: if not connstr: connstr = self.cf.get(dbname) + # connstr might contain password, it is not a good idea to log it - filtered_connstr = re.sub(' password=\S+', ' password=***HIDDEN***', connstr) + filtered_connstr = connstr + pos = connstr.lower().find('password') + if pos >= 0: + filtered_connstr = connstr[:pos] + ' [...]' + self.log.debug("Connect '%s' to '%s'" % (cache, filtered_connstr)) dbc = DBCachedConn(cache, connstr, params['max_age'], setup_func = self.connection_hook) self.db_cache[cache] = dbc |