Private GIT

Skip to content
Snippets Groups Projects
Commit 6f134dfe authored by Thraxis's avatar Thraxis
Browse files

FIX#1292 Masking NZB API Keys in logs

* Modified Regex substitution to account for 3 possible keys that the
API can be attached to
* Modified Regex to account for API Key being at the end of the string
or followed by an & or a space
* Used capture groups to only mask out the API Key, matched prefix and
ending are kept
parent 057137c4
No related branches found
No related tags found
No related merge requests found
...@@ -62,7 +62,7 @@ class CensoredFormatter(logging.Formatter, object): ...@@ -62,7 +62,7 @@ class CensoredFormatter(logging.Formatter, object):
if v and len(v) > 0 and v in msg: if v and len(v) > 0 and v in msg:
msg = msg.replace(v, len(v) * '*') msg = msg.replace(v, len(v) * '*')
# Needed because Newznab apikey isn't stored as key=value in a section. # Needed because Newznab apikey isn't stored as key=value in a section.
msg = re.sub('apikey\=[^\&]*\&','apikey\=**********\&', msg) msg = re.sub(r'(r|apikey|api_key)=[^&]*([&\w]?)',r'\1=**********\2', msg)
return msg return msg
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment