mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-15 01:32:57 -07:00
Update logger blacklist for newsleter/notifier configs
This commit is contained in:
parent
c19cc858bd
commit
44428cc6e5
5 changed files with 33 additions and 14 deletions
|
@ -42,6 +42,7 @@ import datafactory
|
|||
import libraries
|
||||
import logger
|
||||
import mobile_app
|
||||
import newsletters
|
||||
import newsletter_handler
|
||||
import notification_handler
|
||||
import notifiers
|
||||
|
@ -202,6 +203,7 @@ def initialize(config_file):
|
|||
logger.error(u"Could not perform upgrades: %s" % e)
|
||||
|
||||
# Add notifier configs to logger blacklist
|
||||
newsletters.blacklist_logger()
|
||||
notifiers.blacklist_logger()
|
||||
mobile_app.blacklist_logger()
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import traceback
|
|||
|
||||
import plexpy
|
||||
import helpers
|
||||
from plexpy.config import _BLACKLIST_KEYS, _WHITELIST_KEYS
|
||||
|
||||
# These settings are for file logging only
|
||||
FILENAME = "tautulli.log"
|
||||
|
@ -48,6 +49,20 @@ logger_plex_websocket = logging.getLogger("plex_websocket")
|
|||
# Global queue for multiprocessing logging
|
||||
queue = None
|
||||
|
||||
|
||||
def blacklist_config(config):
|
||||
blacklist = set()
|
||||
blacklist_keys = ['HOOK', 'APIKEY', 'KEY', 'PASSWORD', 'TOKEN']
|
||||
|
||||
for key, value in config.iteritems():
|
||||
if isinstance(value, basestring) and len(value.strip()) > 5 and \
|
||||
key.upper() not in _WHITELIST_KEYS and (key.upper() in blacklist_keys or
|
||||
any(bk in key.upper() for bk in _BLACKLIST_KEYS)):
|
||||
blacklist.add(value.strip())
|
||||
|
||||
_BLACKLIST_WORDS.update(blacklist)
|
||||
|
||||
|
||||
class NoThreadFilter(logging.Filter):
|
||||
"""
|
||||
Log filter for the current thread
|
||||
|
|
|
@ -138,7 +138,5 @@ def set_last_seen(device_token=None):
|
|||
|
||||
def blacklist_logger():
|
||||
devices = get_mobile_devices()
|
||||
|
||||
blacklist = set(d['device_token'] for d in devices)
|
||||
|
||||
logger._BLACKLIST_WORDS.update(blacklist)
|
||||
for d in devices:
|
||||
logger.blacklist_config(d)
|
||||
|
|
|
@ -196,6 +196,7 @@ def add_newsletter_config(agent_id=None, **kwargs):
|
|||
newsletter_id = db.last_insert_id()
|
||||
logger.info(u"Tautulli Newsletters :: Added new newsletter agent: %s (newsletter_id %s)."
|
||||
% (agent['label'], newsletter_id))
|
||||
blacklist_logger()
|
||||
return newsletter_id
|
||||
except Exception as e:
|
||||
logger.warn(u"Tautulli Newsletters :: Unable to add newsletter agent: %s." % e)
|
||||
|
@ -254,6 +255,7 @@ def set_newsletter_config(newsletter_id=None, agent_id=None, **kwargs):
|
|||
logger.info(u"Tautulli Newsletters :: Updated newsletter agent: %s (newsletter_id %s)."
|
||||
% (agent['label'], newsletter_id))
|
||||
newsletter_handler.schedule_newsletters(newsletter_id=newsletter_id)
|
||||
blacklist_logger()
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.warn(u"Tautulli Newsletters :: Unable to update newsletter agent: %s." % e)
|
||||
|
@ -274,6 +276,17 @@ def send_newsletter(newsletter_id=None, subject=None, body=None, message=None, n
|
|||
logger.debug(u"Tautulli Newsletters :: Notification requested but no newsletter_id received.")
|
||||
|
||||
|
||||
def blacklist_logger():
|
||||
db = database.MonitorDatabase()
|
||||
notifiers = db.select('SELECT newsletter_config, email_config FROM newsletters')
|
||||
|
||||
for n in notifiers:
|
||||
config = json.loads(n['newsletter_config'] or '{}')
|
||||
logger.blacklist_config(config)
|
||||
email_config = json.loads(n['email_config'] or '{}')
|
||||
logger.blacklist_config(email_config)
|
||||
|
||||
|
||||
def serve_template(templatename, **kwargs):
|
||||
if plexpy.CONFIG.NEWSLETTER_CUSTOM_DIR:
|
||||
template_dir = plexpy.CONFIG.NEWSLETTER_CUSTOM_DIR
|
||||
|
|
|
@ -62,7 +62,6 @@ import mobile_app
|
|||
import pmsconnect
|
||||
import request
|
||||
import users
|
||||
from plexpy.config import _BLACKLIST_KEYS, _WHITELIST_KEYS
|
||||
|
||||
|
||||
BROWSER_NOTIFIERS = {}
|
||||
|
@ -612,17 +611,9 @@ def blacklist_logger():
|
|||
db = database.MonitorDatabase()
|
||||
notifiers = db.select('SELECT notifier_config FROM notifiers')
|
||||
|
||||
blacklist = set()
|
||||
blacklist_keys = ['hook', 'key', 'password', 'token']
|
||||
|
||||
for n in notifiers:
|
||||
config = json.loads(n['notifier_config'] or '{}')
|
||||
for key, value in config.iteritems():
|
||||
if isinstance(value, basestring) and len(value.strip()) > 5 and \
|
||||
key.upper() not in _WHITELIST_KEYS and (key.upper() in blacklist_keys or any(bk in key.upper() for bk in _BLACKLIST_KEYS)):
|
||||
blacklist.add(value.strip())
|
||||
|
||||
logger._BLACKLIST_WORDS.update(blacklist)
|
||||
logger.blacklist_config(config)
|
||||
|
||||
|
||||
class PrettyMetadata(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue