Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2df0148
Merge pull request #1 from bridgecrewio/master
libertyy Sep 1, 2020
2c7c24b
scan only changed files
libertyy Sep 1, 2020
036dd23
allow this to be published for testing purposes
libertyy Sep 1, 2020
81ec058
Update action.yml
libertyy Sep 1, 2020
4ec5e53
Update action.yml
libertyy Sep 1, 2020
52d7e87
undo change to action.yml
libertyy Sep 1, 2020
3cb4015
GITHUB_HEAD_REF is empty, then not a PR. do dir check
libertyy Sep 9, 2020
293c1f0
debug flag
libertyy Sep 9, 2020
eb6a5b7
cd into the directory before running git commands
libertyy Sep 10, 2020
605a1a7
debug
libertyy Sep 10, 2020
a143a06
debug
libertyy Sep 10, 2020
959976f
tr line endings into spaces
libertyy Sep 10, 2020
2dc4b61
munge git output into a bash array
libertyy Sep 10, 2020
486ed42
cleanup on git output
libertyy Sep 10, 2020
06748d3
remove debug
libertyy Sep 10, 2020
c8e9549
use INPUT_DIRECTORY in both PR or full scan mode
libertyy Sep 10, 2020
c3a97d9
default's with input_directory
libertyy Sep 10, 2020
8ec3979
try this
libertyy Sep 10, 2020
7cefda6
Merge remote-tracking branch 'upstream/master'
libertyy Oct 15, 2020
f4545a5
Merge branch 'master' into feat/pr_only_scans_changed_files
libertyy Oct 15, 2020
6f97797
upgrade checkov to latest
libertyy Nov 9, 2020
be5e4c9
remove set -x and add version check
libertyy Nov 9, 2020
ea086b6
git diff to exclude deleted files
libertyy Nov 9, 2020
43b03c1
debug
libertyy Nov 9, 2020
63d7773
flip the git diff references to properly exclude deletes
libertyy Nov 9, 2020
5137a76
remove debug
libertyy Nov 9, 2020
c8f916e
flip references to correct order
libertyy Nov 9, 2020
70e7237
bump up version
libertyy Nov 24, 2020
796c7ec
Merge pull request #2 from libertyy/feat/pr_only_scans_changed_files
libertyy Nov 24, 2020
af707aa
Updated checkov version in requirement.txt
conuigwe Jan 25, 2021
71d1ac4
updated checkov version in requirements.txt
conuigwe Feb 2, 2021
20de5fd
Merge pull request #3 from libertyy/fix/update_checkov_version
libertyy Feb 2, 2021
bf43547
Merge remote-tracking branch 'upstream/master'
Mar 9, 2021
dc85f1c
Update requirements.txt
libertyy Apr 7, 2021
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
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# action.yml
name: 'Checkov Github Action'
author: 'Chris Mavrakis'
description: 'Run Checkov against Terraform/CloudFormation infrastructure code, as a pre-packaged Github Action.'
author: 'Chris Mavrakis, Libertyy'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contributors should not add themselves as author for making singular changes.

description: 'TEST: DO NOT USE: Run Checkov against Terraform/CloudFormation infrastructure code, as a pre-packaged Github Action.'
inputs:
directory:
description: 'directory with infrastructure code to scan'
Expand Down
46 changes: 44 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ if [ ! -z "$INPUT_SOFT_FAIL" ] && [ "$INPUT_SOFT_FAIL" = "true" ]; then
SOFT_FAIL_FLAG="--soft-fail"
fi

RC=0 #return code

CHECKOV_REPORT=${INPUT_CHECKOV_REPORT:-"$HOME/report.out"}

EXTCHECK_DIRS_FLAG=""
if [ ! -z "$INPUT_EXTERNAL_CHECKS_DIRS" ]; then
IFS=', ' read -r -a extchecks_dir <<< "$INPUT_EXTERNAL_CHECKS_DIRS"
Expand Down Expand Up @@ -41,5 +45,43 @@ if [ ! -z "$INPUT_SOFT_FAIL" ]; then
fi

echo "::add-matcher::checkov-problem-matcher.json"
echo "running checkov on directory: $1"
checkov -d $INPUT_DIRECTORY $CHECK_FLAG $SKIP_CHECK_FLAG $QUIET_FLAG $SOFT_FAIL_FLAG $FRAMEWORK_FLAG $EXTCHECK_DIRS_FLAG $EXTCHECK_REPOS_FLAG $OUTPUT_FLAG

echo $(checkov --version )
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you arbitrarily echoing the version here with no added context. If this was intended for debugging, it is best to remove it.


if [ -z "$GITHUB_HEAD_REF" ]; then
# No different commits, not a PR
# Check everything, not just a PR diff (there is no PR diff in this context).
# NOTE: this file scope may need to be expanded or refined further.
echo "running checkov on directory: $1"
checkov -d $INPUT_DIRECTORY $CHECK_FLAG $SKIP_CHECK_FLAG $QUIET_FLAG $SOFT_FAIL_FLAG $FRAMEWORK_FLAG $EXTCHECK_DIRS_FLAG $EXTCHECK_REPOS_FLAG $OUTPUT_FLAG
RC=$?
else
pushd $GITHUB_WORKSPACE/$INPUT_DIRECTORY #&>/dev/null

git fetch ${GITHUB_BASE_REF/#/'origin '} #&>/dev/null
git fetch ${GITHUB_HEAD_REF/#/'origin '} #&>/dev/null
BASE_REF=$(git rev-parse ${GITHUB_BASE_REF/#/'origin/'})
HEAD_REF=$(git rev-parse ${GITHUB_HEAD_REF/#/'origin/'})
DIFF_FILES=$(git diff --diff-filter=d --name-only $BASE_REF $HEAD_REF | tr '\n' ' ')

IFS=' ' read -r -a files2scan <<< "$DIFF_FILES"

SCAN_FILES_FLAG=""
if [ -z "$DIFF_FILES" ]; then
echo "No files to scan"
RC=0
else
echo "running checkov on files: $DIFF_FILES"
for f in "${files2scan[@]}"
do
SCAN_FILES_FLAG="$SCAN_FILES_FLAG -f $f"
done
checkov $SCAN_FILES_FLAG $CHECK_FLAG $SKIP_CHECK_FLAG $QUIET_FLAG $SOFT_FAIL_FLAG $FRAMEWORK_FLAG $EXTCHECK_DIRS_FLAG $EXTCHECK_REPOS_FLAG $OUTPUT_FLAG
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be more efficient to copy the $DIFF_FILES to a temporary directory and scan all of them at once instead of individually? For mono-repos this could be a very time consuming (and thus costly) change.

RC=$?
fi

fi

echo "exiting script: $RC"
exit $RC

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
checkov==1.0.833
checkov==1.0.865