Skip to content

fix(general): handle single and trailing-comma output file paths - #7653

Open
KaoKsn wants to merge 2 commits into
bridgecrewio:mainfrom
KaoKsn:fix/output_file_path
Open

fix(general): handle single and trailing-comma output file paths#7653
KaoKsn wants to merge 2 commits into
bridgecrewio:mainfrom
KaoKsn:fix/output_file_path

Conversation

@KaoKsn

@KaoKsn KaoKsn commented Aug 20, 2026

Copy link
Copy Markdown

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Fixes Issue: #7645

Description

Fix crashes caused by an empty file path in output_paths when a trailing comma is provided.

    checkov -f target.tf -o json -o junitxml --output-file-path result.json,

Ensure that a single --output-file-path value is treated as a file rather than a directory, so:

    checkov -f target.tf -o json --output-file-path result.json

creates result.json instead of result.json/results_json.json

Add tests covering single output paths and preventing nested output files.

Motivation: Usage lead to finding the bug.

Fixes #7645
Fixes all the problems that issue(#7645) states, expect the output is printed to the console since nothing was suggested for the second problem the issue states.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my feature, policy, or fix is effective and works
  • New and existing tests pass locally with my changes

Fixes Issue: bridgecrewio#7645

    Fix crashes caused by an empty file path in output_paths when a
    trailing comma is provided.
        checkov -f target.tf -o json -o junitxml --output-file-path result.json,
    Ensure that a single --output-file-path value is treated as a file
    rather than a directory, so:
        checkov -f target.tf -o json --output-file-path result.json
    creates result.json instead of result.json/results_json.json.

    Add tests covering single output paths and preventing
    nested output files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--output-file-path is treated as a directory for single-file output unlike multiple files or even single file suffixed with a comma.

1 participant