From 4c9bc87437467f54d5b6c27f43d70ce864c63aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Magalh=C3=A3es?= Date: Tue, 23 Aug 2022 22:36:31 -0300 Subject: [PATCH 1/2] Using settings from config file in diagnostic.py Also fixed a typo in a return from exception --- diagnostic.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/diagnostic.py b/diagnostic.py index 0368256..da915a9 100755 --- a/diagnostic.py +++ b/diagnostic.py @@ -121,7 +121,7 @@ def check_virtual_environment_and_packages(spinner): @add_spinner def check_configuration(spinner): - global configuration_file, port + global configuration_file, PORT, HOST configfile = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'config/config.cfg') cfg = configparser.ConfigParser() cfg.read(configfile) @@ -135,7 +135,14 @@ def check_configuration(spinner): # Check if all fields from config.default exists in config result, faulties = diagnostic_util.dict_compare(cfg_default, cfg) if result: - port = configuration_file.get("Server", "port") + PORT = configuration_file.get("Server", "port") + host = configuration_file.get("Server", "host") + if not (host == "localhost" or host == "127.0.0.1"): + if configuration_file.getboolean("Server", "ssl"): + http = "https://" + else: + http = "http://" + HOST = http+host return (True, '') else: return_text = '''Configuration incomplete. @@ -388,7 +395,7 @@ def check_server_listening(spinner): try: r = requests.get(url) except requests.exceptions.ConnectionError: - return (False, 'Can\'t connect to {}').format(url) + return (False, 'Can\'t connect to {}'.format(url)) if '/error_page' in r.url: o = urlparse(r.url) From 06dc9761602968750866c4e8db6572f9ea2f5277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Magalh=C3=A3es?= Date: Wed, 24 Aug 2022 11:07:50 -0300 Subject: [PATCH 2/2] MISP user and password are now easier to set in diagnostic.py --- diagnostic.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/diagnostic.py b/diagnostic.py index da915a9..476e36c 100755 --- a/diagnostic.py +++ b/diagnostic.py @@ -40,6 +40,8 @@ Steps: - check log dynamic endpoint ''' +MISP_USER = 'admin@admin.test' +MISP_PASSWD = 'Password1234' HOST = 'http://127.0.0.1' PORT = 8001 # overriden by configuration file configuration_file = {} @@ -417,8 +419,8 @@ def check_server_listening(spinner): @add_spinner def check_server_dynamic_enpoint(spinner): payload = { - 'username': 'admin@admin.test', - 'password': 'Password1234', + 'username': MISP_USER, + 'password': MISP_PASSWD, 'submit': 'Sign In' } sleep_max = 15