-
Notifications
You must be signed in to change notification settings - Fork 114
Feature Request: file-by-file checks for Pull Requests #31
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
base: master
Are you sure you want to change the base?
Changes from all commits
2df0148
2c7c24b
036dd23
81ec058
4ec5e53
52d7e87
3cb4015
293c1f0
eb6a5b7
605a1a7
a143a06
959976f
2dc4b61
486ed42
06748d3
c8e9549
c3a97d9
8ec3979
7cefda6
f4545a5
6f97797
be5e4c9
ea086b6
43b03c1
63d7773
5137a76
c8f916e
70e7237
796c7ec
af707aa
71d1ac4
20de5fd
bf43547
dc85f1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
|
|
@@ -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 ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it be more efficient to copy the |
||
| RC=$? | ||
| fi | ||
|
|
||
| fi | ||
|
|
||
| echo "exiting script: $RC" | ||
| exit $RC | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| checkov==1.0.833 | ||
| checkov==1.0.865 |
There was a problem hiding this comment.
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
authorfor making singular changes.