fix(general): Allow specifying files in a github actions config file #6813
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
User description
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Description
If you want to run checkov on multiple files or directories from a github action, you have to hack in the list of input directory or files like:
This technically works but has a few downsides. It'll fail if an file has a space in it, and if you're using
DOWNLOAD_EXTERNAL_MODULES
it will delete things you did not expect.A much more robust alternative is using the
.checkov.yaml
with:In the github action, directory defaults to
.
but you can pass indirectory: ''
. As the code is now, this will still callcheckov -d --output=...
which causes an error.This is probably not a breaking change because: if both
$INPUT_FILE
and$INPUT_DIRECTORY
are empty (directory
has explicitly been set to empty string in bridgecrewio/checkov-action, or a custom github action has been used):checkov: error: argument -d/--directory: expected one argument
and exit 2.INPUT_CONFIG_FILE
or print the logo / version and exit 0.Fixes bridgecrewio/checkov-action#22
Checklist:
Generated description
Below is a concise technical summary of the changes proposed in this PR:
Enhances the Checkov GitHub Action to support specifying files in a configuration file. Modifies the
entrypoint.sh
script to handle input from a.checkov.yaml
file, improving flexibility and robustness when scanning multiple files or directories. Adds error handling for empty input scenarios and refines the cleanup process for external modules.Modified files (1)
Latest Contributors(2)
.checkov.yaml
configuration fileModified files (1)
Latest Contributors(2)
Modified files (1)
Latest Contributors(2)