Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow specifying files in a github actions config file #6813

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions github_action_resources/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,16 @@ if [ -n "$INPUT_DOCKER_IMAGE" ]; then
CHECKOV_RESULTS=$(checkov --bc-api-key $API_KEY_VARIABLE --branch $GIT_BRANCH --repo-id $GITHUB_REPOSITORY $DOCKER_IMAGE_FLAG $DOCKERFILE_PATH_FLAG $OUTPUT_FLAG $OUTPUT_FILE_PATH_FLAG)
# Else if File Variable exists then use -f flag to scan specific resources
else
RESOURCE_TO_SCAN=""
if [ -n "$INPUT_FILE" ]; then
RESOURCE_TO_SCAN="-f $INPUT_FILE"
echo "running checkov on file: $INPUT_FILE"
else
# Otherwise exists then use -d flag for directory scanning
elif [ -n "$INPUT_DIRECTORY" ]; then
# Use -d flag for directory scanning
RESOURCE_TO_SCAN="-d $INPUT_DIRECTORY"
echo "running checkov on directory: $INPUT_DIRECTORY"
elif [ -n "$INPUT_CONFIG_FILE" ]; then
echo "running checkov on files defined in configuration file: $INPUT_CONFIG_FILE"
fi
# Build command
if [ -n "$API_KEY_VARIABLE" ]; then
Expand All @@ -221,10 +224,10 @@ EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
{ echo "CHECKOV_RESULTS<<$EOF"; echo "${CHECKOV_RESULTS:0:65536}"; echo "$EOF"; } >> $GITHUB_ENV
{ echo "results<<$EOF"; echo "$CHECKOV_RESULTS"; echo "$EOF"; } >> $GITHUB_OUTPUT

if [ -n "$INPUT_DOWNLOAD_EXTERNAL_MODULES" ] && [ "$INPUT_DOWNLOAD_EXTERNAL_MODULES" = "true" ]; then
if [ -n "$INPUT_DOWNLOAD_EXTERNAL_MODULES" ] && [ "$INPUT_DOWNLOAD_EXTERNAL_MODULES" = "true" ] && [ -n "$INPUT_DIRECTORY" ]; then
echo "Cleaning up $INPUT_DIRECTORY/.external_modules directory"
#This directory must be removed here for the self hosted github runners run as non-root user.
rm -fr $INPUT_DIRECTORY/.external_modules
rm -fr "$INPUT_DIRECTORY/.external_modules"
exit $CHECKOV_EXIT_CODE
fi
exit $CHECKOV_EXIT_CODE