[geany/infrastructure] 0bf51a: Hide password when dumping the config for logging
Enrico Tröger
git-noreply at xxxxx
Tue Aug 13 21:58:16 UTC 2019
Branch: refs/heads/master
Author: Enrico Tröger <enrico.troeger at uvena.de>
Committer: Enrico Tröger <enrico.troeger at uvena.de>
Date: Tue, 13 Aug 2019 21:58:16 UTC
Commit: 0bf51a42ff08a0bbf88e5f51833a98ec17bf5fba
https://github.com/geany/infrastructure/commit/0bf51a42ff08a0bbf88e5f51833a98ec17bf5fba
Log Message:
-----------
Hide password when dumping the config for logging
Modified Paths:
--------------
scripts/git2irc/git2irc.py
Modified: scripts/git2irc/git2irc.py
9 lines changed, 7 insertions(+), 2 deletions(-)
===================================================================
@@ -45,7 +45,8 @@
'''
from cgi import FieldStorage
-from configparser import SafeConfigParser # py3
+from configparser import SafeConfigParser
+from copy import deepcopy
from json import dumps, loads
from urllib.request import Request, urlopen
import logging
@@ -89,7 +90,11 @@ def init_config(conf_filename):
config['shortener']['url'] = conf.get('shortener', 'url')
config['shortener']['username'] = conf.get('shortener', 'username')
config['shortener']['password'] = conf.get('shortener', 'password')
- logger.debug('Read configuration dict: {}'.format(str(config)))
+
+ # copy config and replace password before logging
+ config_for_logging = deepcopy(config)
+ config_for_logging['shortener']['password'] = '*******'
+ logger.debug('Read configuration dict: {}'.format(str(config_for_logging)))
# catch-all: will be for invalid config file/section/option, unknown
# filename, etc
except Exception as e:
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list