Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(arm): unsupported module soft fail #6775

Merged
merged 3 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion checkov/common/bridgecrew/platform_errors.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from typing import List


class PlatformConnectionError(Exception):
def __init__(self, message: str) -> None:
self.message = message
Expand All @@ -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}"
7 changes: 4 additions & 3 deletions checkov/common/runners/runner_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions checkov/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading