Repository: bridgecrewio/checkov

Issue:
Delimiter in wrong position when using multi-output with empty error list
**Describe the bug**
The "--- OUTPUT DELIMITER ---" message appears below two outputs when running on a project without any errors to output. This causes problems when trying to use parsers to split the output.

**To Reproduce**
Steps to reproduce the behavior:
1. mkdir -p /tmp/checkov-bug
2. cd /tmp/checkov-bug
3. docker run -it -v $PWD:/app -w /app bridgecrew/checkov:2.0.591 -o cli -o junitxml -d .

Output is:
       _               _              
   ___| |__   ___  ___| | _______   __
  / __| '_ \ / _ \/ __| |/ / _ \ \ / /
 | (__| | | |  __/ (__|   < (_) \ V / 
  \___|_| |_|\___|\___|_|\_\___/ \_/  
                                      
By bridgecrew.io | version: 2.0.590 
Update available 2.0.590 -> 2.0.591
Run pip3 install -U checkov to update 

\<?xml version="1.0" ?\>
\<testsuites/\>

--- OUTPUT DELIMITER ---


**Expected behavior**

The expected behaviour would be for the XML snippet to be below "--- OUTPUT DELIMITER ---", since it was the second output option passed to checkov.

**Screenshots**

**Desktop (please complete the following information):**
 - OS: Docker image bridgecrew/checkov
 - Checkov Version 2.0.591

**Additional context**



Discussion:
Hi @tonikarppi thanks for raising this issue. This seems to be a bug and only happens, as you described it, when there is no violation. Just for your information, it doesn't matter, how the order of the output parameters are, they will always be printed out in a specific order and CLI should be first and then the other ones are followed up.

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
@@ -101,6 +101,7 @@ def print_reports(
         if "cli" in config.output and not config.quiet:
             print(f"{self.banner}\n")
         exit_codes = []
+        cli_reports = []
         report_jsons = []
         sarif_reports = []
         junit_reports = []
@@ -117,22 +118,25 @@ def print_reports(
                 if "sarif" in config.output:
                     sarif_reports.append(report)
                 if "cli" in config.output:
-                    report.print_console(
-                        is_quiet=config.quiet,
-                        is_compact=config.compact,
-                        created_baseline_path=created_baseline_path,
-                        baseline=baseline,
-                        use_bc_ids=config.output_bc_ids,
-                    )
-                    if url:
-                        print("More details: {}".format(url))
-                    output_formats.discard("cli")
-                    if output_formats:
-                        print(OUTPUT_DELIMITER)
+                    cli_reports.append(report)
                 if "cyclonedx" in config.output:
                     cyclonedx_reports.append(report)
             exit_codes.append(report.get_exit_code(config.soft_fail, config.soft_fail_on, config.hard_fail_on))
 
+        if "cli" in config.output:
+            for report in cli_reports:
+                report.print_console(
+                    is_quiet=config.quiet,
+                    is_compact=config.compact,
+                    created_baseline_path=created_baseline_path,
+                    baseline=baseline,
+                    use_bc_ids=config.output_bc_ids,
+                )
+            if url:
+                print("More details: {}".format(url))
+            output_formats.remove("cli")
+            if output_formats:
+                print(OUTPUT_DELIMITER)
         if "sarif" in config.output:
             master_report = Report("merged")
             print(self.banner)


Test patch: