mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
Escape characters in username log filter
* Remove filter for friendly names
This commit is contained in:
parent
84a14c0f25
commit
35aca11feb
2 changed files with 3 additions and 6 deletions
|
@ -164,7 +164,7 @@
|
||||||
<input type="checkbox" id="log_blacklist_usernames" name="log_blacklist_usernames" value="1" ${config['log_blacklist_usernames']}> Mask Usernames in Logs
|
<input type="checkbox" id="log_blacklist_usernames" name="log_blacklist_usernames" value="1" ${config['log_blacklist_usernames']}> Mask Usernames in Logs
|
||||||
</label>
|
</label>
|
||||||
<p class="help-block">
|
<p class="help-block">
|
||||||
Enable to mask Plex usernames and Tautulli friendly names with asterisks (*) in the logs.<br />
|
Enable to mask Plex usernames with asterisks (*) in the logs.<br />
|
||||||
Note: Only logs from the time this setting is enabled will be masked.
|
Note: Only logs from the time this setting is enabled will be masked.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -130,20 +130,17 @@ class UsernameFilter(logging.Filter):
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
username = item['username']
|
username = item['username']
|
||||||
friendly_name = item['friendly_name']
|
|
||||||
|
|
||||||
if username == 'Local':
|
if username.lower() in ('local', 'guest'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
record.msg = self.replace(record.msg, username)
|
record.msg = self.replace(record.msg, username)
|
||||||
record.msg = self.replace(record.msg, friendly_name)
|
|
||||||
|
|
||||||
args = []
|
args = []
|
||||||
for arg in record.args:
|
for arg in record.args:
|
||||||
if isinstance(arg, str):
|
if isinstance(arg, str):
|
||||||
arg = self.replace(arg, username)
|
arg = self.replace(arg, username)
|
||||||
arg = self.replace(arg, friendly_name)
|
|
||||||
args.append(arg)
|
args.append(arg)
|
||||||
record.args = tuple(args)
|
record.args = tuple(args)
|
||||||
except:
|
except:
|
||||||
|
@ -154,7 +151,7 @@ class UsernameFilter(logging.Filter):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def replace(text, match):
|
def replace(text, match):
|
||||||
mask = match[:2] + 8 * '*' + match[-1]
|
mask = match[:2] + 8 * '*' + match[-1]
|
||||||
return re.sub(r'\b{}\b'.format(match), mask, text, flags=re.IGNORECASE)
|
return re.sub(re.escape(match), mask, text, flags=re.IGNORECASE)
|
||||||
|
|
||||||
|
|
||||||
class RegexFilter(logging.Filter):
|
class RegexFilter(logging.Filter):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue