From bc5df671dddc2429171cda94b85e17648df629d4 Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Thu, 4 Aug 2022 16:09:30 +0200 Subject: [PATCH] feat(check): handle errors (#1318) --- lib/check/check.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/check/check.py b/lib/check/check.py index 72417bd7..59b913c0 100644 --- a/lib/check/check.py +++ b/lib/check/check.py @@ -3,7 +3,6 @@ from pkgutil import walk_packages from types import ModuleType from typing import Any -# import time from colorama import Fore, Style from config.config import groups_file @@ -195,9 +194,15 @@ def run_check(check, audit_info, output_options): f"\nCheck ID: {check.checkID} - {Fore.MAGENTA}{check.serviceName}{Fore.YELLOW} [{check.severity}]{Style.RESET_ALL}" ) logger.debug(f"Executing check: {check.checkID}") - findings = check.execute() - - report(findings, output_options, audit_info) + try: + findings = check.execute() + except Exception as error: + print(f"Something went wrong in {check.checkID}, please use --log-level ERROR") + logger.error(f"{check.checkID} -- {error.__class__.__name__}: {error}") + else: + report(findings, output_options, audit_info) + finally: + pass def import_check(check_path: str) -> ModuleType: