Repository: bridgecrewio/checkov

Issue:
Checkov crashed for "--compact" input parameter with "-o json -o junitxml" for multiple output
**Describe the issue**
Checkov is crashing when we use `--compact` input parameter with `-o json -o junitxml` for multiple output.

**Examples**
To create a sample `json` file, follow this documentation.
https://learn.hashicorp.com/tutorials/terraform/aws-build?in=terraform/aws-get-started
https://www.checkov.io/7.Scan%20Examples/Terraform%20Plan%20Scanning.html
```
mkdir checkov-results
checkov -f tfplan.json --framework terraform_plan --skip-download -o json -o junitxml --output-file-path checkov-results --compact
```

**Exception Trace**
```
    },
    "summary": {
        "passed": 2,
        "failed": 4,
        "skipped": 0,
        "parsing_errors": 0,
        "resource_count": 0,
        "checkov_version": "2.1.70"
    },
    "url": "Add an api key '--bc-api-key <api-key>' to see more detailed insights via https://bridgecrew.cloud"
}

--- OUTPUT DELIMITER ---

Traceback (most recent call last):
  File "/usr/local/bin/checkov", line 9, in <module>
    sys.exit(run())
  File "/usr/local/lib/python3.9/site-packages/checkov/main.py", line 337, in run
    exit_code = runner_registry.print_reports(scan_reports, config, url=url, created_baseline_path=created_baseline_path, baseline=baseline)
  File "/usr/local/lib/python3.9/site-packages/checkov/common/runners/runner_registry.py", line 211, in print_reports
    test_suites = [
  File "/usr/local/lib/python3.9/site-packages/checkov/common/runners/runner_registry.py", line 212, in <listcomp>
    report.get_test_suite(properties=properties, use_bc_ids=config.output_bc_ids)
  File "/usr/local/lib/python3.9/site-packages/checkov/common/output/report.py", line 449, in get_test_suite
    output=self._create_test_case_failure_output(record)
  File "/usr/local/lib/python3.9/site-packages/checkov/common/output/report.py", line 541, in _create_test_case_failure_output
    if record.code_block:
AttributeError: 'Record' object has no attribute 'code_block'
```

**Desktop (please complete the following information):**
 - OS: linux/mac
 - Checkov Version: 2.0.1223 & 2.1.70 (latest)



Discussion:
hey @pandey-mohit thanks for reaching out. Looks like a bug sneaked into the code 😄 it results from the combination of using json output + compact. I will come up with a fix for it.

Resolving patch:
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
@@ -436,5 +436,5 @@ def strip_code_blocks_from_json(report_jsons: List[Dict[str, Any]]) -> None:
             results = report.get('results', {})
             for result in results.values():
                 for result_dict in result:
-                    result_dict.pop('code_block', None)
-                    result_dict.pop('connected_node', None)
+                    result_dict["code_block"] = None
+                    result_dict["connected_node"] = None


Test patch:
diff --git a/tests/common/runner_registry/test_runner_registry.py b/tests/common/runner_registry/test_runner_registry.py
--- a/tests/common/runner_registry/test_runner_registry.py
+++ b/tests/common/runner_registry/test_runner_registry.py
@@ -1,5 +1,5 @@
 import argparse
-import csv
+import json
 import unittest
 
 import os
@@ -103,10 +103,14 @@ def test_compact_json_output(self):
         with patch('sys.stdout', new=io.StringIO()) as captured_output:
             runner_registry.print_reports(scan_reports=reports, config=config)
 
-        output = captured_output.getvalue()
+        output = json.loads(captured_output.getvalue())
+        passed_checks = output["results"]["passed_checks"]
+        failed_checks = output["results"]["failed_checks"]
 
-        assert 'code_block' not in output
-        assert 'connected_node' not in output
+        assert all(check["code_block"] is None for check in passed_checks)
+        assert all(check["connected_node"] is None for check in passed_checks)
+        assert all(check["code_block"] is None for check in failed_checks)
+        assert all(check["connected_node"] is None for check in failed_checks)
 
     def test_compact_csv_output(self):
         test_files_dir = os.path.dirname(os.path.realpath(__file__)) + "/example_s3_tf"