diff --git a/checkov/common/bridgecrew/platform_errors.py b/checkov/common/bridgecrew/platform_errors.py index e5c3031ae93..39a124b8254 100644 --- a/checkov/common/bridgecrew/platform_errors.py +++ b/checkov/common/bridgecrew/platform_errors.py @@ -1,3 +1,6 @@ +from typing import List + + class PlatformConnectionError(Exception): def __init__(self, message: str) -> None: self.message = message @@ -16,8 +19,9 @@ def __str__(self) -> str: class ModuleNotEnabledError(Exception): - def __init__(self, message: str) -> None: + def __init__(self, message: str, unsupported_frameworks: List[str]) -> None: self.message = message + self.unsupported_frameworks = unsupported_frameworks def __str__(self) -> str: return f"ModuleNotEnabledError: {self.message}" diff --git a/checkov/common/runners/runner_registry.py b/checkov/common/runners/runner_registry.py index ca533464f7a..5bad08c31a4 100644 --- a/checkov/common/runners/runner_registry.py +++ b/checkov/common/runners/runner_registry.py @@ -128,7 +128,8 @@ def run( collect_skip_comments=collect_skip_comments)] else: # This is the only runner, so raise a clear indication of failure - raise ModuleNotEnabledError(f'The framework "{runner_check_type}" is part of the "{self.licensing_integration.get_subscription_for_runner(runner_check_type).name}" module, which is not enabled in the platform') + raise ModuleNotEnabledError(f'The framework "{runner_check_type}" is part of the "{self.licensing_integration.get_subscription_for_runner(runner_check_type).name}" module, which is not enabled in the platform', + unsupported_frameworks=[runner_check_type]) else: valid_runners = [] invalid_runners = [] @@ -150,11 +151,11 @@ def run( # if some frameworks are disabled and the user used --framework, log a warning so they see it # if some frameworks are disabled and the user did not use --framework, then log at a lower level so that we have it for troubleshooting if not valid_runners: + check_types = [runner.check_type for runner in self.runners] runners_categories = os.linesep.join([f'{runner.check_type}: {self.licensing_integration.get_subscription_for_runner(runner.check_type).name}' for runner in invalid_runners]) error_message = f'All the frameworks are disabled because they are not enabled in the platform. ' \ f'You must subscribe to one or more of the categories below to get results for these frameworks.{os.linesep}{runners_categories}' - logging.error(error_message) - raise ModuleNotEnabledError(error_message) + raise ModuleNotEnabledError(error_message, unsupported_frameworks=check_types) elif invalid_runners: for runner in invalid_runners: level = logging.INFO diff --git a/checkov/main.py b/checkov/main.py index 797e9ca1110..7046e8e6398 100755 --- a/checkov/main.py +++ b/checkov/main.py @@ -693,8 +693,8 @@ def run(self, banner: str = checkov_banner, tool: str = default_tool, source_typ print(f"{banner}") return None except ModuleNotEnabledError as m: - logging.error(m) - self.exit_run() + if all(framework in self.config.framework for framework in m.unsupported_frameworks): + logging.warning(m) return None except PlatformConnectionError: # we don't want to print all of these stack traces in normal output, as these could be user error