summaryrefslogtreecommitdiffstats
path: root/deluge/ui
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2022-02-05 09:23:11 +0000
committerCalum Lind <calumlind+deluge@gmail.com>2022-02-06 16:15:34 +0000
commitbf97bec994cce7b68e2de9713a1e58e75a5d87d2 (patch)
tree328e78901649d7e6667df545b8daed946b8521f4 /deluge/ui
parenta27a77f8c110907be034543f1456f4d4defe63fc (diff)
downloaddeluge-bf97bec994cce7b68e2de9713a1e58e75a5d87d2.tar.gz
deluge-bf97bec994cce7b68e2de9713a1e58e75a5d87d2.tar.bz2
deluge-bf97bec994cce7b68e2de9713a1e58e75a5d87d2.zip
[Config] Add mask_funcs to help mask passwords in logs
Added a new Config class parameter `log_mask_funcs` to enable config instances hide sensitive information that would normally appear in config debug logs. Added mask password function to hostlist to replace passwords with '*'s in logs. Closes: https://github.com/deluge-torrent/deluge/pull/363
Diffstat (limited to 'deluge/ui')
-rw-r--r--deluge/ui/hostlist.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/deluge/ui/hostlist.py b/deluge/ui/hostlist.py
index 7e2f397d0..cfd7e2e59 100644
--- a/deluge/ui/hostlist.py
+++ b/deluge/ui/hostlist.py
@@ -84,6 +84,14 @@ def migrate_config_2_to_3(config):
return config
+def mask_hosts_password(hosts):
+ """Replace passwords in hosts list with *'s for log output"""
+ if not hosts:
+ return hosts
+
+ return [list(host)[:-1] + ['*' * 10] for host in hosts]
+
+
class HostList:
"""This class contains methods for adding, removing and looking up hosts in hostlist.conf."""
@@ -94,6 +102,7 @@ class HostList:
default_hostlist(),
config_dir=get_config_dir(),
file_version=3,
+ log_mask_funcs={'hosts': mask_hosts_password},
)
self.config.run_converter((1, 2), 3, migrate_config_2_to_3)
self.config.save()