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(general): add flag for summary position #3497

Merged
merged 4 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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/output/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def print_console(
created_baseline_path: str | None = None,
baseline: Baseline | None = None,
use_bc_ids: bool = False,
summary_position_bottom: bool = False
) -> str:
summary = self.get_summary()
output_data = colored(f"{self.check_type} scan results:\n", "blue")
Expand All @@ -193,7 +194,8 @@ def print_console(
message = f"\nFailed checks: {summary['failed']}, Skipped checks: {summary['skipped']}\n\n"
else:
message = f"\nPassed checks: {summary['passed']}, Failed checks: {summary['failed']}, Skipped checks: {summary['skipped']}\n\n"
output_data += colored(message, "cyan")
if not summary_position_bottom:
output_data += colored(message, "cyan")
# output for vulnerabilities is different
if self.check_type in (CheckType.SCA_PACKAGE, CheckType.SCA_IMAGE):
if self.failed_checks or self.skipped_checks:
Expand Down Expand Up @@ -222,6 +224,8 @@ def print_console(
f"Baseline analysis report using {baseline.path} - only new failed checks with respect to the baseline are reported",
"blue",
)
if summary_position_bottom:
output_data += colored(message, "cyan")
return output_data

@staticmethod
Expand Down
2 changes: 2 additions & 0 deletions checkov/common/runners/runner_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ def print_reports(
created_baseline_path=created_baseline_path,
baseline=baseline,
use_bc_ids=config.output_bc_ids,
summary_position_bottom=config.summary_position_bottom
)
print(cli_output)
# Remove colors from the cli output
Expand All @@ -269,6 +270,7 @@ def print_reports(
created_baseline_path=created_baseline_path,
baseline=baseline,
use_bc_ids=config.output_bc_ids,
summary_position_bottom=config.summary_position_bottom
))
master_report.failed_checks += report.failed_checks
master_report.skipped_checks += report.skipped_checks
Expand Down
2 changes: 2 additions & 0 deletions checkov/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,8 @@ def add_parser_args(parser: ArgumentParser) -> None:
env_var='CKV_SECRETS_SCAN_BLACK_LIST',
action='append',
help='black file list to filter out from the secret scanner')
parser.add('--summary-position-bottom', action='store_true',
gruebel marked this conversation as resolved.
Show resolved Hide resolved
help='Change the summary to be appended in the bottom after the policy violations')


def get_external_checks_dir(config: Any) -> Any:
Expand Down