jenkins-bot has submitted this change and it was merged.
Change subject: Do not print passwords to console
......................................................................
Do not print passwords to console
The config parser can be run on the command line to print all values.
This routine is useful for debugging, however as a general rule passwords
should never be printed to the console.
Change-Id: I41bd9d91bc5a858cf7eadbf43b79df850dcb658c
---
M pywikibot/config2.py
1 file changed, 14 insertions(+), 1 deletion(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 7193aef..9fa0a6a 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -21,6 +21,8 @@
# variables that are intended only for internal use and not to be exported
# to other modules.
+_private_values = ['authenticate', 'proxy', 'db_password']
+
# ############# ACCOUNT SETTINGS ##############
# The family of sites we are working on. wikipedia.py will import
@@ -759,7 +761,18 @@
if not type(globals()[_name]) in [types.FunctionType,
types.ModuleType]:
if _all or _glv[_name] != globals()[_name]:
- print("%s=%s" % (_name, repr(globals()[_name])))
+ _value = globals()[_name]
+ if _name in _private_values and _value:
+ if isinstance(_value, dict):
+ _value = '{ ...xxxxxxxx... }'
+ elif hasattr(_value, '__dict__'):
+ _value = '%s( ...xxxxxxxx... )' % \
+ _value.__class__.__name__
+ else:
+ _value = repr('xxxxxxxx')
+ else:
+ _value = repr(_value)
+ print("%s=%s" % (_name, _value))
# cleanup all locally-defined variables
for __var in list(globals().keys()):
--
To view, visit
https://gerrit.wikimedia.org/r/141432
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I41bd9d91bc5a858cf7eadbf43b79df850dcb658c
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Betacommand <betacommand(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>