We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Feature Request: another flag to display failed checks
**Is your feature request related to a problem? Please describe.**

it seems that  -o github_failed_only only returns failed but with plain text. if I use -o json then I get all checks(failed and success). 
**Describe the solution you'd like**

Apart from  json and github_failed_only parameters.  It might be good to have  to  another flag to display failed only reports.  It can be used with json output. Something like to see failed checks in json format.
```
$ checkov --display-failed-checks -o json -d .
```



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `checkov/common/output/report.py`
Content:
```
1 import json
2 from collections import defaultdict
3 
4 from colorama import init
5 from junit_xml import TestCase, TestSuite
6 from termcolor import colored
7 
8 from checkov.common.models.enums import CheckResult
9 from checkov.version import version
10 from tabulate import tabulate
11 
12 init(autoreset=True)
13 
14 
15 class Report:
16 
17     def __init__(self, check_type):
18         self.check_type = check_type
19         self.passed_checks = []
20         self.failed_checks = []
21         self.skipped_checks = []
22         self.parsing_errors = []
23 
24     def add_parsing_errors(self, errors):
25         for file in errors:
26             self.add_parsing_error(file)
27 
28     def add_parsing_error(self, file):
29         if file:
30             self.parsing_errors.append(file)
31 
32     def add_record(self, record):
33         if record.check_result['result'] == CheckResult.PASSED:
34             self.passed_checks.append(record)
35         if record.check_result['result'] == CheckResult.FAILED:
36             self.failed_checks.append(record)
37         if record.check_result['result'] == CheckResult.SKIPPED:
38             self.skipped_checks.append(record)
39 
40     def get_summary(self):
41         return {
42             "passed": len(self.passed_checks),
43             "failed": len(self.failed_checks),
44             "skipped": len(self.skipped_checks),
45             "parsing_errors": len(self.parsing_errors),
46             "checkov_version": version
47         }
48 
49     def get_json(self):
50         return json.dumps(self.get_dict(), indent=4)
51 
52     def get_dict(self):
53         return {
54             "check_type": self.check_type,
55             "results": {
56                 "passed_checks": [check.__dict__ for check in self.passed_checks],
57                 "failed_checks": [check.__dict__ for check in self.failed_checks],
58                 "skipped_checks": [check.__dict__ for check in self.skipped_checks],
59                 "parsing_errors": list(self.parsing_errors)
60             },
61             "summary": self.get_summary()
62         }
63 
64     def get_exit_code(self, soft_fail):
65         if soft_fail:
66             return 0
67         elif len(self.failed_checks) > 0:
68             return 1
69         return 0
70 
71     def is_empty(self):
72         return len(self.passed_checks) + len(self.failed_checks) + len(self.skipped_checks) + len(self.parsing_errors) == 0
73 
74     def print_console(self, is_quiet=False, is_compact=False):
75         summary = self.get_summary()
76         print(colored(f"{self.check_type} scan results:", "blue"))
77         if self.parsing_errors:
78             message = "\nPassed checks: {}, Failed checks: {}, Skipped checks: {}, Parsing errors: {}\n".format(
79                 summary["passed"], summary["failed"], summary["skipped"], summary["parsing_errors"])
80         else:
81             message = "\nPassed checks: {}, Failed checks: {}, Skipped checks: {}\n".format(
82                 summary["passed"], summary["failed"], summary["skipped"])
83         print(colored(message, "cyan"))
84         if not is_quiet:
85             for record in self.passed_checks:
86                 print(record.to_string(compact=is_compact))
87         for record in self.failed_checks:
88             print(record.to_string(compact=is_compact))
89         if not is_quiet:
90             for record in self.skipped_checks:
91                 print(record.to_string(compact=is_compact))
92 
93         if not is_quiet:
94             for file in self.parsing_errors:
95                 Report._print_parsing_error_console(file)
96 
97     @staticmethod
98     def _print_parsing_error_console(file):
99         print(colored(f'Error parsing file {file}', 'red'))
100 
101     def print_junit_xml(self):
102         ts = self.get_test_suites()
103         print(TestSuite.to_xml_string(ts))
104 
105     def print_failed_github_md(self):
106         result = []
107         for record in self.failed_checks:
108             result.append([record.check_id, record.file_path ,record.resource, record.check_name, record.guideline])
109         print(tabulate(result, headers=["check_id", "file" ,"resource", "check_name", "guideline"], tablefmt="github", showindex=True))
110         print("\n\n---\n\n")
111 
112     def get_test_suites(self):
113         test_cases = defaultdict(list)
114         test_suites = []
115         records = self.passed_checks + self.failed_checks + self.skipped_checks
116         for record in records:
117             check_name = record.check_name
118 
119             test_name = "{} {} {}".format(self.check_type, check_name, record.resource)
120             test_case = TestCase(name=test_name, file=record.file_path, classname=record.check_class)
121             if record.check_result['result'] == CheckResult.FAILED:
122                 test_case.add_failure_info(
123                     "Resource \"{}\" failed in check \"{}\"".format(record.resource, check_name))
124             if record.check_result['result'] == CheckResult.SKIPPED:
125                 test_case.add_skipped_info(
126                     "Resource \"{}\" skipped in check \"{}\"\n Suppress comment: {}".format(record.resource, check_name,
127                                                                                             record.check_result[
128                                                                                                 'suppress_comment']))
129             test_cases[check_name].append(test_case)
130         for key in test_cases.keys():
131             test_suites.append(
132                 TestSuite(name=key, test_cases=test_cases[key], package=test_cases[key][0].classname))
133         return test_suites
134 
135     def print_json(self):
136         print(self.get_json())
137 
138
```

Path: `checkov/common/runners/runner_registry.py`
Content:
```
1 import json
2 import logging
3 from abc import abstractmethod
4 
5 from checkov.common.bridgecrew.integration_features.integration_feature_registry import integration_feature_registry
6 from checkov.common.output.report import Report
7 
8 OUTPUT_CHOICES = ['cli', 'json', 'junitxml', 'github_failed_only']
9 
10 from checkov.common.bridgecrew.platform_integration import BcPlatformIntegration
11 
12 
13 class RunnerRegistry(object):
14     runners = []
15     scan_reports = []
16     banner = ""
17 
18     def __init__(self, banner, runner_filter, *runners):
19         self.logger = logging.getLogger(__name__)
20         self.runner_filter = runner_filter
21         self.runners = runners
22         self.banner = banner
23         self.scan_reports = []
24         self.filter_runner_framework()
25         self.bc_platform = BcPlatformIntegration()
26 
27     @abstractmethod
28     def extract_entity_details(self, entity):
29         raise NotImplementedError()
30 
31     def run(self, root_folder=None, external_checks_dir=None, files=None, guidelines=None, collect_skip_comments=True, bc_integration=None):
32         for runner in self.runners:
33             integration_feature_registry.run_pre_scan()
34             scan_report = runner.run(root_folder, external_checks_dir=external_checks_dir, files=files,
35                                      runner_filter=self.runner_filter, collect_skip_comments=collect_skip_comments)
36             integration_feature_registry.run_post_scan(scan_report)
37             if guidelines:
38                 RunnerRegistry.enrich_report_with_guidelines(scan_report, guidelines)
39             self.scan_reports.append(scan_report)
40         return self.scan_reports
41 
42     def print_reports(self, scan_reports, args, url=None):
43         if args.output == 'cli':
44             print(f"{self.banner}\n")
45         exit_codes = []
46         report_jsons = []
47         junit_reports = []
48         for report in scan_reports:
49             if not report.is_empty():
50                 if args.output == "json":
51                     report_jsons.append(report.get_dict())
52                 elif args.output == "junitxml":
53                     junit_reports.append(report)
54                     # report.print_junit_xml()
55                 elif args.output == 'github_failed_only':
56                     report.print_failed_github_md()
57                 else:
58                     report.print_console(is_quiet=args.quiet, is_compact=args.compact)
59                     if url:
60                         print("More details: {}".format(url))
61             exit_codes.append(report.get_exit_code(args.soft_fail))
62         if args.output == "junitxml":
63             if len(junit_reports) == 1:
64                 junit_reports[0].print_junit_xml()
65             else:
66                 master_report = Report(None)
67                 for report in junit_reports:
68                     master_report.skipped_checks += report.skipped_checks
69                     master_report.passed_checks += report.passed_checks
70                     master_report.failed_checks += report.failed_checks
71                 master_report.print_junit_xml()
72         if args.output == "json":
73             if len(report_jsons) == 1:
74                 print(json.dumps(report_jsons[0], indent=4))
75             else:
76                 print(json.dumps(report_jsons, indent=4))
77         if args.output == "cli":
78             self.bc_platform.get_report_to_platform(args,scan_reports)
79 
80         exit_code = 1 if 1 in exit_codes else 0
81         exit(exit_code)
82 
83     def filter_runner_framework(self):
84         if not self.runner_filter:
85             return
86         if self.runner_filter.framework == 'all':
87             return
88         for runner in self.runners:
89             if runner.check_type == self.runner_filter.framework:
90                 self.runners = [runner]
91                 return
92 
93     @staticmethod
94     def enrich_report_with_guidelines(scan_report, guidelines):
95         for record in scan_report.failed_checks + scan_report.passed_checks + scan_report.skipped_checks:
96             if record.check_id in guidelines:
97                 record.set_guideline(guidelines[record.check_id])
98
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/checkov/common/output/report.py b/checkov/common/output/report.py
--- a/checkov/common/output/report.py
+++ b/checkov/common/output/report.py
@@ -49,17 +49,26 @@
     def get_json(self):
         return json.dumps(self.get_dict(), indent=4)
 
-    def get_dict(self):
-        return {
-            "check_type": self.check_type,
-            "results": {
-                "passed_checks": [check.__dict__ for check in self.passed_checks],
-                "failed_checks": [check.__dict__ for check in self.failed_checks],
-                "skipped_checks": [check.__dict__ for check in self.skipped_checks],
-                "parsing_errors": list(self.parsing_errors)
-            },
-            "summary": self.get_summary()
+    def get_dict(self, is_quiet=False):
+        if is_quiet:
+            return {
+                "check_type": self.check_type,
+                "results": {
+                    "failed_checks": [check.__dict__ for check in self.failed_checks]
+                },
+                "summary": self.get_summary()
         }
+        else: 
+            return {
+                "check_type": self.check_type,
+                "results": {
+                    "passed_checks": [check.__dict__ for check in self.passed_checks],
+                    "failed_checks": [check.__dict__ for check in self.failed_checks],
+                    "skipped_checks": [check.__dict__ for check in self.skipped_checks],
+                    "parsing_errors": list(self.parsing_errors)
+                },
+                "summary": self.get_summary()
+            }
 
     def get_exit_code(self, soft_fail):
         if soft_fail:
diff --git a/checkov/common/runners/runner_registry.py b/checkov/common/runners/runner_registry.py
--- a/checkov/common/runners/runner_registry.py
+++ b/checkov/common/runners/runner_registry.py
@@ -48,7 +48,7 @@
         for report in scan_reports:
             if not report.is_empty():
                 if args.output == "json":
-                    report_jsons.append(report.get_dict())
+                    report_jsons.append(report.get_dict(is_quiet=args.quiet))
                 elif args.output == "junitxml":
                     junit_reports.append(report)
                     # report.print_junit_xml()

{"golden_diff": "diff --git a/checkov/common/output/report.py b/checkov/common/output/report.py\n--- a/checkov/common/output/report.py\n+++ b/checkov/common/output/report.py\n@@ -49,17 +49,26 @@\n     def get_json(self):\n         return json.dumps(self.get_dict(), indent=4)\n \n-    def get_dict(self):\n-        return {\n-            \"check_type\": self.check_type,\n-            \"results\": {\n-                \"passed_checks\": [check.__dict__ for check in self.passed_checks],\n-                \"failed_checks\": [check.__dict__ for check in self.failed_checks],\n-                \"skipped_checks\": [check.__dict__ for check in self.skipped_checks],\n-                \"parsing_errors\": list(self.parsing_errors)\n-            },\n-            \"summary\": self.get_summary()\n+    def get_dict(self, is_quiet=False):\n+        if is_quiet:\n+            return {\n+                \"check_type\": self.check_type,\n+                \"results\": {\n+                    \"failed_checks\": [check.__dict__ for check in self.failed_checks]\n+                },\n+                \"summary\": self.get_summary()\n         }\n+        else: \n+            return {\n+                \"check_type\": self.check_type,\n+                \"results\": {\n+                    \"passed_checks\": [check.__dict__ for check in self.passed_checks],\n+                    \"failed_checks\": [check.__dict__ for check in self.failed_checks],\n+                    \"skipped_checks\": [check.__dict__ for check in self.skipped_checks],\n+                    \"parsing_errors\": list(self.parsing_errors)\n+                },\n+                \"summary\": self.get_summary()\n+            }\n \n     def get_exit_code(self, soft_fail):\n         if soft_fail:\ndiff --git a/checkov/common/runners/runner_registry.py b/checkov/common/runners/runner_registry.py\n--- a/checkov/common/runners/runner_registry.py\n+++ b/checkov/common/runners/runner_registry.py\n@@ -48,7 +48,7 @@\n         for report in scan_reports:\n             if not report.is_empty():\n                 if args.output == \"json\":\n-                    report_jsons.append(report.get_dict())\n+                    report_jsons.append(report.get_dict(is_quiet=args.quiet))\n                 elif args.output == \"junitxml\":\n                     junit_reports.append(report)\n                     # report.print_junit_xml()\n", "issue": "Feature Request: another flag to display failed checks\n**Is your feature request related to a problem? Please describe.**\r\n\r\nit seems that  -o github_failed_only only returns failed but with plain text. if I use -o json then I get all checks(failed and success). \r\n**Describe the solution you'd like**\r\n\r\nApart from  json and github_failed_only parameters.  It might be good to have  to  another flag to display failed only reports.  It can be used with json output. Something like to see failed checks in json format.\r\n```\r\n$ checkov --display-failed-checks -o json -d .\r\n```\r\n\r\n\n", "before_files": [{"content": "import json\nfrom collections import defaultdict\n\nfrom colorama import init\nfrom junit_xml import TestCase, TestSuite\nfrom termcolor import colored\n\nfrom checkov.common.models.enums import CheckResult\nfrom checkov.version import version\nfrom tabulate import tabulate\n\ninit(autoreset=True)\n\n\nclass Report:\n\n    def __init__(self, check_type):\n        self.check_type = check_type\n        self.passed_checks = []\n        self.failed_checks = []\n        self.skipped_checks = []\n        self.parsing_errors = []\n\n    def add_parsing_errors(self, errors):\n        for file in errors:\n            self.add_parsing_error(file)\n\n    def add_parsing_error(self, file):\n        if file:\n            self.parsing_errors.append(file)\n\n    def add_record(self, record):\n        if record.check_result['result'] == CheckResult.PASSED:\n            self.passed_checks.append(record)\n        if record.check_result['result'] == CheckResult.FAILED:\n            self.failed_checks.append(record)\n        if record.check_result['result'] == CheckResult.SKIPPED:\n            self.skipped_checks.append(record)\n\n    def get_summary(self):\n        return {\n            \"passed\": len(self.passed_checks),\n            \"failed\": len(self.failed_checks),\n            \"skipped\": len(self.skipped_checks),\n            \"parsing_errors\": len(self.parsing_errors),\n            \"checkov_version\": version\n        }\n\n    def get_json(self):\n        return json.dumps(self.get_dict(), indent=4)\n\n    def get_dict(self):\n        return {\n            \"check_type\": self.check_type,\n            \"results\": {\n                \"passed_checks\": [check.__dict__ for check in self.passed_checks],\n                \"failed_checks\": [check.__dict__ for check in self.failed_checks],\n                \"skipped_checks\": [check.__dict__ for check in self.skipped_checks],\n                \"parsing_errors\": list(self.parsing_errors)\n            },\n            \"summary\": self.get_summary()\n        }\n\n    def get_exit_code(self, soft_fail):\n        if soft_fail:\n            return 0\n        elif len(self.failed_checks) > 0:\n            return 1\n        return 0\n\n    def is_empty(self):\n        return len(self.passed_checks) + len(self.failed_checks) + len(self.skipped_checks) + len(self.parsing_errors) == 0\n\n    def print_console(self, is_quiet=False, is_compact=False):\n        summary = self.get_summary()\n        print(colored(f\"{self.check_type} scan results:\", \"blue\"))\n        if self.parsing_errors:\n            message = \"\\nPassed checks: {}, Failed checks: {}, Skipped checks: {}, Parsing errors: {}\\n\".format(\n                summary[\"passed\"], summary[\"failed\"], summary[\"skipped\"], summary[\"parsing_errors\"])\n        else:\n            message = \"\\nPassed checks: {}, Failed checks: {}, Skipped checks: {}\\n\".format(\n                summary[\"passed\"], summary[\"failed\"], summary[\"skipped\"])\n        print(colored(message, \"cyan\"))\n        if not is_quiet:\n            for record in self.passed_checks:\n                print(record.to_string(compact=is_compact))\n        for record in self.failed_checks:\n            print(record.to_string(compact=is_compact))\n        if not is_quiet:\n            for record in self.skipped_checks:\n                print(record.to_string(compact=is_compact))\n\n        if not is_quiet:\n            for file in self.parsing_errors:\n                Report._print_parsing_error_console(file)\n\n    @staticmethod\n    def _print_parsing_error_console(file):\n        print(colored(f'Error parsing file {file}', 'red'))\n\n    def print_junit_xml(self):\n        ts = self.get_test_suites()\n        print(TestSuite.to_xml_string(ts))\n\n    def print_failed_github_md(self):\n        result = []\n        for record in self.failed_checks:\n            result.append([record.check_id, record.file_path ,record.resource, record.check_name, record.guideline])\n        print(tabulate(result, headers=[\"check_id\", \"file\" ,\"resource\", \"check_name\", \"guideline\"], tablefmt=\"github\", showindex=True))\n        print(\"\\n\\n---\\n\\n\")\n\n    def get_test_suites(self):\n        test_cases = defaultdict(list)\n        test_suites = []\n        records = self.passed_checks + self.failed_checks + self.skipped_checks\n        for record in records:\n            check_name = record.check_name\n\n            test_name = \"{} {} {}\".format(self.check_type, check_name, record.resource)\n            test_case = TestCase(name=test_name, file=record.file_path, classname=record.check_class)\n            if record.check_result['result'] == CheckResult.FAILED:\n                test_case.add_failure_info(\n                    \"Resource \\\"{}\\\" failed in check \\\"{}\\\"\".format(record.resource, check_name))\n            if record.check_result['result'] == CheckResult.SKIPPED:\n                test_case.add_skipped_info(\n                    \"Resource \\\"{}\\\" skipped in check \\\"{}\\\"\\n Suppress comment: {}\".format(record.resource, check_name,\n                                                                                            record.check_result[\n                                                                                                'suppress_comment']))\n            test_cases[check_name].append(test_case)\n        for key in test_cases.keys():\n            test_suites.append(\n                TestSuite(name=key, test_cases=test_cases[key], package=test_cases[key][0].classname))\n        return test_suites\n\n    def print_json(self):\n        print(self.get_json())\n\n", "path": "checkov/common/output/report.py"}, {"content": "import json\nimport logging\nfrom abc import abstractmethod\n\nfrom checkov.common.bridgecrew.integration_features.integration_feature_registry import integration_feature_registry\nfrom checkov.common.output.report import Report\n\nOUTPUT_CHOICES = ['cli', 'json', 'junitxml', 'github_failed_only']\n\nfrom checkov.common.bridgecrew.platform_integration import BcPlatformIntegration\n\n\nclass RunnerRegistry(object):\n    runners = []\n    scan_reports = []\n    banner = \"\"\n\n    def __init__(self, banner, runner_filter, *runners):\n        self.logger = logging.getLogger(__name__)\n        self.runner_filter = runner_filter\n        self.runners = runners\n        self.banner = banner\n        self.scan_reports = []\n        self.filter_runner_framework()\n        self.bc_platform = BcPlatformIntegration()\n\n    @abstractmethod\n    def extract_entity_details(self, entity):\n        raise NotImplementedError()\n\n    def run(self, root_folder=None, external_checks_dir=None, files=None, guidelines=None, collect_skip_comments=True, bc_integration=None):\n        for runner in self.runners:\n            integration_feature_registry.run_pre_scan()\n            scan_report = runner.run(root_folder, external_checks_dir=external_checks_dir, files=files,\n                                     runner_filter=self.runner_filter, collect_skip_comments=collect_skip_comments)\n            integration_feature_registry.run_post_scan(scan_report)\n            if guidelines:\n                RunnerRegistry.enrich_report_with_guidelines(scan_report, guidelines)\n            self.scan_reports.append(scan_report)\n        return self.scan_reports\n\n    def print_reports(self, scan_reports, args, url=None):\n        if args.output == 'cli':\n            print(f\"{self.banner}\\n\")\n        exit_codes = []\n        report_jsons = []\n        junit_reports = []\n        for report in scan_reports:\n            if not report.is_empty():\n                if args.output == \"json\":\n                    report_jsons.append(report.get_dict())\n                elif args.output == \"junitxml\":\n                    junit_reports.append(report)\n                    # report.print_junit_xml()\n                elif args.output == 'github_failed_only':\n                    report.print_failed_github_md()\n                else:\n                    report.print_console(is_quiet=args.quiet, is_compact=args.compact)\n                    if url:\n                        print(\"More details: {}\".format(url))\n            exit_codes.append(report.get_exit_code(args.soft_fail))\n        if args.output == \"junitxml\":\n            if len(junit_reports) == 1:\n                junit_reports[0].print_junit_xml()\n            else:\n                master_report = Report(None)\n                for report in junit_reports:\n                    master_report.skipped_checks += report.skipped_checks\n                    master_report.passed_checks += report.passed_checks\n                    master_report.failed_checks += report.failed_checks\n                master_report.print_junit_xml()\n        if args.output == \"json\":\n            if len(report_jsons) == 1:\n                print(json.dumps(report_jsons[0], indent=4))\n            else:\n                print(json.dumps(report_jsons, indent=4))\n        if args.output == \"cli\":\n            self.bc_platform.get_report_to_platform(args,scan_reports)\n\n        exit_code = 1 if 1 in exit_codes else 0\n        exit(exit_code)\n\n    def filter_runner_framework(self):\n        if not self.runner_filter:\n            return\n        if self.runner_filter.framework == 'all':\n            return\n        for runner in self.runners:\n            if runner.check_type == self.runner_filter.framework:\n                self.runners = [runner]\n                return\n\n    @staticmethod\n    def enrich_report_with_guidelines(scan_report, guidelines):\n        for record in scan_report.failed_checks + scan_report.passed_checks + scan_report.skipped_checks:\n            if record.check_id in guidelines:\n                record.set_guideline(guidelines[record.check_id])\n", "path": "checkov/common/runners/runner_registry.py"}], "after_files": [{"content": "import json\nfrom collections import defaultdict\n\nfrom colorama import init\nfrom junit_xml import TestCase, TestSuite\nfrom termcolor import colored\n\nfrom checkov.common.models.enums import CheckResult\nfrom checkov.version import version\nfrom tabulate import tabulate\n\ninit(autoreset=True)\n\n\nclass Report:\n\n    def __init__(self, check_type):\n        self.check_type = check_type\n        self.passed_checks = []\n        self.failed_checks = []\n        self.skipped_checks = []\n        self.parsing_errors = []\n\n    def add_parsing_errors(self, errors):\n        for file in errors:\n            self.add_parsing_error(file)\n\n    def add_parsing_error(self, file):\n        if file:\n            self.parsing_errors.append(file)\n\n    def add_record(self, record):\n        if record.check_result['result'] == CheckResult.PASSED:\n            self.passed_checks.append(record)\n        if record.check_result['result'] == CheckResult.FAILED:\n            self.failed_checks.append(record)\n        if record.check_result['result'] == CheckResult.SKIPPED:\n            self.skipped_checks.append(record)\n\n    def get_summary(self):\n        return {\n            \"passed\": len(self.passed_checks),\n            \"failed\": len(self.failed_checks),\n            \"skipped\": len(self.skipped_checks),\n            \"parsing_errors\": len(self.parsing_errors),\n            \"checkov_version\": version\n        }\n\n    def get_json(self):\n        return json.dumps(self.get_dict(), indent=4)\n\n    def get_dict(self, is_quiet=False):\n        if is_quiet:\n            return {\n                \"check_type\": self.check_type,\n                \"results\": {\n                    \"failed_checks\": [check.__dict__ for check in self.failed_checks]\n                },\n                \"summary\": self.get_summary()\n        }\n        else: \n            return {\n                \"check_type\": self.check_type,\n                \"results\": {\n                    \"passed_checks\": [check.__dict__ for check in self.passed_checks],\n                    \"failed_checks\": [check.__dict__ for check in self.failed_checks],\n                    \"skipped_checks\": [check.__dict__ for check in self.skipped_checks],\n                    \"parsing_errors\": list(self.parsing_errors)\n                },\n                \"summary\": self.get_summary()\n            }\n\n    def get_exit_code(self, soft_fail):\n        if soft_fail:\n            return 0\n        elif len(self.failed_checks) > 0:\n            return 1\n        return 0\n\n    def is_empty(self):\n        return len(self.passed_checks) + len(self.failed_checks) + len(self.skipped_checks) + len(self.parsing_errors) == 0\n\n    def print_console(self, is_quiet=False, is_compact=False):\n        summary = self.get_summary()\n        print(colored(f\"{self.check_type} scan results:\", \"blue\"))\n        if self.parsing_errors:\n            message = \"\\nPassed checks: {}, Failed checks: {}, Skipped checks: {}, Parsing errors: {}\\n\".format(\n                summary[\"passed\"], summary[\"failed\"], summary[\"skipped\"], summary[\"parsing_errors\"])\n        else:\n            message = \"\\nPassed checks: {}, Failed checks: {}, Skipped checks: {}\\n\".format(\n                summary[\"passed\"], summary[\"failed\"], summary[\"skipped\"])\n        print(colored(message, \"cyan\"))\n        if not is_quiet:\n            for record in self.passed_checks:\n                print(record.to_string(compact=is_compact))\n        for record in self.failed_checks:\n            print(record.to_string(compact=is_compact))\n        if not is_quiet:\n            for record in self.skipped_checks:\n                print(record.to_string(compact=is_compact))\n\n        if not is_quiet:\n            for file in self.parsing_errors:\n                Report._print_parsing_error_console(file)\n\n    @staticmethod\n    def _print_parsing_error_console(file):\n        print(colored(f'Error parsing file {file}', 'red'))\n\n    def print_junit_xml(self):\n        ts = self.get_test_suites()\n        print(TestSuite.to_xml_string(ts))\n\n    def print_failed_github_md(self):\n        result = []\n        for record in self.failed_checks:\n            result.append([record.check_id, record.file_path ,record.resource, record.check_name, record.guideline])\n        print(tabulate(result, headers=[\"check_id\", \"file\" ,\"resource\", \"check_name\", \"guideline\"], tablefmt=\"github\", showindex=True))\n        print(\"\\n\\n---\\n\\n\")\n\n    def get_test_suites(self):\n        test_cases = defaultdict(list)\n        test_suites = []\n        records = self.passed_checks + self.failed_checks + self.skipped_checks\n        for record in records:\n            check_name = record.check_name\n\n            test_name = \"{} {} {}\".format(self.check_type, check_name, record.resource)\n            test_case = TestCase(name=test_name, file=record.file_path, classname=record.check_class)\n            if record.check_result['result'] == CheckResult.FAILED:\n                test_case.add_failure_info(\n                    \"Resource \\\"{}\\\" failed in check \\\"{}\\\"\".format(record.resource, check_name))\n            if record.check_result['result'] == CheckResult.SKIPPED:\n                test_case.add_skipped_info(\n                    \"Resource \\\"{}\\\" skipped in check \\\"{}\\\"\\n Suppress comment: {}\".format(record.resource, check_name,\n                                                                                            record.check_result[\n                                                                                                'suppress_comment']))\n            test_cases[check_name].append(test_case)\n        for key in test_cases.keys():\n            test_suites.append(\n                TestSuite(name=key, test_cases=test_cases[key], package=test_cases[key][0].classname))\n        return test_suites\n\n    def print_json(self):\n        print(self.get_json())\n\n", "path": "checkov/common/output/report.py"}, {"content": "import json\nimport logging\nfrom abc import abstractmethod\n\nfrom checkov.common.bridgecrew.integration_features.integration_feature_registry import integration_feature_registry\nfrom checkov.common.output.report import Report\n\nOUTPUT_CHOICES = ['cli', 'json', 'junitxml', 'github_failed_only']\n\nfrom checkov.common.bridgecrew.platform_integration import BcPlatformIntegration\n\n\nclass RunnerRegistry(object):\n    runners = []\n    scan_reports = []\n    banner = \"\"\n\n    def __init__(self, banner, runner_filter, *runners):\n        self.logger = logging.getLogger(__name__)\n        self.runner_filter = runner_filter\n        self.runners = runners\n        self.banner = banner\n        self.scan_reports = []\n        self.filter_runner_framework()\n        self.bc_platform = BcPlatformIntegration()\n\n    @abstractmethod\n    def extract_entity_details(self, entity):\n        raise NotImplementedError()\n\n    def run(self, root_folder=None, external_checks_dir=None, files=None, guidelines=None, collect_skip_comments=True, bc_integration=None):\n        for runner in self.runners:\n            integration_feature_registry.run_pre_scan()\n            scan_report = runner.run(root_folder, external_checks_dir=external_checks_dir, files=files,\n                                     runner_filter=self.runner_filter, collect_skip_comments=collect_skip_comments)\n            integration_feature_registry.run_post_scan(scan_report)\n            if guidelines:\n                RunnerRegistry.enrich_report_with_guidelines(scan_report, guidelines)\n            self.scan_reports.append(scan_report)\n        return self.scan_reports\n\n    def print_reports(self, scan_reports, args, url=None):\n        if args.output == 'cli':\n            print(f\"{self.banner}\\n\")\n        exit_codes = []\n        report_jsons = []\n        junit_reports = []\n        for report in scan_reports:\n            if not report.is_empty():\n                if args.output == \"json\":\n                    report_jsons.append(report.get_dict(is_quiet=args.quiet))\n                elif args.output == \"junitxml\":\n                    junit_reports.append(report)\n                    # report.print_junit_xml()\n                elif args.output == 'github_failed_only':\n                    report.print_failed_github_md()\n                else:\n                    report.print_console(is_quiet=args.quiet, is_compact=args.compact)\n                    if url:\n                        print(\"More details: {}\".format(url))\n            exit_codes.append(report.get_exit_code(args.soft_fail))\n        if args.output == \"junitxml\":\n            if len(junit_reports) == 1:\n                junit_reports[0].print_junit_xml()\n            else:\n                master_report = Report(None)\n                for report in junit_reports:\n                    master_report.skipped_checks += report.skipped_checks\n                    master_report.passed_checks += report.passed_checks\n                    master_report.failed_checks += report.failed_checks\n                master_report.print_junit_xml()\n        if args.output == \"json\":\n            if len(report_jsons) == 1:\n                print(json.dumps(report_jsons[0], indent=4))\n            else:\n                print(json.dumps(report_jsons, indent=4))\n        if args.output == \"cli\":\n            self.bc_platform.get_report_to_platform(args,scan_reports)\n\n        exit_code = 1 if 1 in exit_codes else 0\n        exit(exit_code)\n\n    def filter_runner_framework(self):\n        if not self.runner_filter:\n            return\n        if self.runner_filter.framework == 'all':\n            return\n        for runner in self.runners:\n            if runner.check_type == self.runner_filter.framework:\n                self.runners = [runner]\n                return\n\n    @staticmethod\n    def enrich_report_with_guidelines(scan_report, guidelines):\n        for record in scan_report.failed_checks + scan_report.passed_checks + scan_report.skipped_checks:\n            if record.check_id in guidelines:\n                record.set_guideline(guidelines[record.check_id])\n", "path": "checkov/common/runners/runner_registry.py"}]}