diff --git a/checkov/common/runners/runner_registry.py b/checkov/common/runners/runner_registry.py index a4ac0298e40..15f01632a92 100644 --- a/checkov/common/runners/runner_registry.py +++ b/checkov/common/runners/runner_registry.py @@ -108,8 +108,7 @@ def _merge_reports(self, reports: Iterable[Report | list[Report]]) -> list[Repor merge_reports(self._check_type_to_report_map[sub_report.check_type], sub_report) else: self._check_type_to_report_map[sub_report.check_type] = sub_report - - merged_reports.append(sub_report) + merged_reports.append(sub_report) return merged_reports diff --git a/tests/common/runner_registry/test_runner_registry.py b/tests/common/runner_registry/test_runner_registry.py index f2d8b87ee37..1c1171cbebf 100644 --- a/tests/common/runner_registry/test_runner_registry.py +++ b/tests/common/runner_registry/test_runner_registry.py @@ -8,6 +8,7 @@ from checkov.cloudformation.runner import Runner as cfn_runner from checkov.common.bridgecrew.check_type import CheckType from checkov.common.bridgecrew.code_categories import CodeCategoryMapping +from checkov.common.output.report import Report from checkov.common.runners.runner_registry import RunnerRegistry from checkov.common.util.banner import banner from checkov.kubernetes.runner import Runner as k8_runner @@ -238,6 +239,32 @@ def test_extract_git_info_from_account_id(self): self.assertEqual(expected_git_repo, result_git_repo) self.assertEqual(expected_git_org, result_git_org) + def test_merge_reports(self): + # given + runner_registry = RunnerRegistry(banner, RunnerFilter(), *DEFAULT_RUNNERS) + reports = [ + [ + Report(check_type=CheckType.TERRAFORM), + Report(check_type=CheckType.SCA_IMAGE), + ], + Report(check_type=CheckType.CLOUDFORMATION), + Report(check_type=CheckType.SCA_IMAGE), + ] + + # when + merged_reports = runner_registry._merge_reports(reports=reports) + + # then + merged_report_check_types = [ + report.check_type + for report in merged_reports + ] + self.assertCountEqual(merged_report_check_types,[ + CheckType.TERRAFORM, + CheckType.CLOUDFORMATION, + CheckType.SCA_IMAGE, + ]) + def test_non_compact_json_output(capsys): # given