Also redact vars ending with 'secret' or 'key'

This commit is contained in:
Alexandre Aubin 2019-07-06 19:33:57 +02:00
parent a1c228930f
commit 0d2a9b0a98

View file

@ -310,7 +310,7 @@ class RedactingFormatter(Formatter):
try:
# This matches stuff like db_pwd=the_secret or admin_password=other_secret
# (the secret part being at least 3 chars to avoid catching some lines like just "db_pwd=")
match = re.search(r'(pwd|pass|password)=(\S{3,})$', record.strip())
match = re.search(r'(pwd|pass|password|secret|key)=(\S{3,})$', record.strip())
if match and match.group(2) not in self.data_to_redact:
self.data_to_redact.append(match.group(2))
except Exception as e: