From f95a270177250666f1ac53f7bd01aff3255b8802 Mon Sep 17 00:00:00 2001 From: JHCD Date: Mon, 27 Jul 2015 20:55:50 +0200 Subject: [PATCH] replace passwords and apikeys with "***" in logging #69 --- boswatch.py | 23 ++++++----------------- includes/globals.py | 4 ++-- includes/helper/configHandler.py | 2 ++ 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/boswatch.py b/boswatch.py index a2cb7bb..5242c5f 100755 --- a/boswatch.py +++ b/boswatch.py @@ -29,6 +29,7 @@ from includes import MyTimedRotatingFileHandler # extension of TimedRotatingFil from includes import converter # converter functions from includes import signalHandler # TERM-Handler for use script as a daemon from includes import checkSubprocesses # check startup of the subprocesses +from includes.helper import configHandler # @@ -206,18 +207,10 @@ try: globals.config.read(globals.script_path+"/config/config.ini") # if given loglevel is debug: if globals.config.getint("BOSWatch","loglevel") == 10: - logging.debug(" - BOSWatch:") - for key,val in globals.config.items("BOSWatch"): - logging.debug(" -- %s = %s", key, val) - logging.debug(" - FMS:") - for key,val in globals.config.items("FMS"): - logging.debug(" -- %s = %s", key, val) - logging.debug(" - ZVEI:") - for key,val in globals.config.items("ZVEI"): - logging.debug(" -- %s = %s", key, val) - logging.debug(" - POC:") - for key,val in globals.config.items("POC"): - logging.debug(" -- %s = %s", key, val) + configHandler.checkConfig("BOSWatch") + configHandler.checkConfig("FMS") + configHandler.checkConfig("ZVEI") + configHandler.checkConfig("POC") except: # we couldn't work without config -> exit logging.critical("cannot read config file") @@ -244,11 +237,7 @@ try: # Add NMA logging handler # try: - if globals.config.has_section("NMAHandler"): - if globals.config.getint("BOSWatch","loglevel") == 10: - logging.debug(" - NMAHandler:") - for key,val in globals.config.items("NMAHandler"): - logging.debug(" -- %s = %s", key, val) + if configHandler.checkConfig("NMAHandler"): # is NMAHandler enabled? if globals.config.getboolean("NMAHandler", "enableHandler") == True: # we only could do something, if an APIKey is given: diff --git a/includes/globals.py b/includes/globals.py index 0ca275f..0e46a9a 100644 --- a/includes/globals.py +++ b/includes/globals.py @@ -31,6 +31,6 @@ ricDescribtionList = {} # function -> read only in script def getVers(mode="vers"): if mode == "vers": - return "2.0" + return "2.1-dev" elif mode == "date": - return " 2015/07/13" + return "2015/07/27" diff --git a/includes/helper/configHandler.py b/includes/helper/configHandler.py index 2a21b4b..9a6cf59 100644 --- a/includes/helper/configHandler.py +++ b/includes/helper/configHandler.py @@ -28,6 +28,8 @@ def checkConfig(section=""): logging.debug("read [%s] from config file", section) for key,val in globals.config.items(section): + if ("password" in key) or ("apikey" in key): + val = "***" logging.debug(" - %s = %s", key, val) return True