Functioning --quiet for -o json.
* Functioning --quiet for -o json. Needs tests,
looking at for callable unit test and passing in cli params
* added integration test for -o json --quiet
MODIFY
.github/workflows/build.yml
.github/workflows/build.yml
@@ -46,6 +46,7 @@ jobs:
pipenv run checkov -s -d cfngoat/ -o json > checkov_report_cfngoat.json
pipenv run checkov -s -d kubernetes-goat/ -o json > checkov_report_kubernetes-goat.json
pipenv run checkov -s --skip-check CKV_AWS_33,CKV_AWS_41 -d terragoat/terraform/ -o json > checkov_report_terragoat_with_skip.json
+ pipenv run checkov -s -d cfngoat/ -o json --quiet > checkov_report_cfngoat_quiet.json
- name: Run integration tests
run: |

MODIFY
.github/workflows/pr-test.yml
.github/workflows/pr-test.yml
@@ -78,6 +78,7 @@ jobs:
pipenv run checkov -s -d cfngoat/ -o json > checkov_report_cfngoat.json
pipenv run checkov -s -d kubernetes-goat/ -o json > checkov_report_kubernetes-goat.json
pipenv run checkov -s --skip-check CKV_AWS_33,CKV_AWS_41 -d terragoat/terraform/ -o json > checkov_report_terragoat_with_skip.json
+ pipenv run checkov -s -d cfngoat/ -o json --quiet > checkov_report_cfngoat_quiet.json
- name: Run integration tests
run: |

MODIFY
checkov/common/output/report.py
checkov/common/output/report.py
@@ -49,7 +49,16 @@ class Report:
def get_json(self):
return json.dumps(self.get_dict(), indent=4)
- def get_dict(self):
+ 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": {

MODIFY
checkov/common/runners/runner_registry.py
checkov/common/runners/runner_registry.py
@@ -48,7 +48,7 @@ class RunnerRegistry(object):
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()

MODIFY
integration_tests/test_checkov_json_report.py
integration_tests/test_checkov_json_report.py
@@ -33,6 +33,13 @@ class TestCheckovJsonReport(unittest.TestCase):
self.assertEqual(data["summary"]["parsing_errors"], 0, "expecting 0 parsing errors")
self.assertGreater(data["summary"]["failed"], 1, "expecting more then 1 failed checks")
+ def validate_json_quiet(self):
+ report_path = current_dir + "/../checkov_report_cfngoat_quiet.json"
+ with open(report_path) as json_file:
+ data = json.load(json_file)
+ self.assertTrue(data["results"]["failed_checks"])
+ self.assertFalse(data["results"]["passed_checks"])
+ self.assertTrue(data["summary"])
if __name__ == '__main__':
unittest.main()

Functioning --quiet for -o json. (#854)

* Functioning --quiet for -o json. Needs tests,
looking at #774 for callable unit test and passing in cli params

* added integration test for -o json --quiet