11#! /usr/bin/env bash
2-
3- # In case it reports already installed
4- asdf shell python 3.10.0
2+ # Set this to fail on the install
3+ set -euxo pipefail
54
65# Install and run the plugin for checkov
76# Use the full path to run pip3.10
8- /root/.asdf/installs/python/3.10.0/bin/ pip3.10 install checkov
7+ pip3 install checkov
98
109# List of checks we do not want to run here
1110# This is a living list and will see additions and mostly removals over time.
12- SKIP_CHECKS=" CKV_GCP_22,CKV_GCP_66,CKV_GCP_13,CKV_GCP_71,CKV_GCP_61,CKV_GCP_21,CKV_GCP_65,CKV_GCP_67,CKV_GCP_20,CKV_GCP_69,CKV_GCP_12,CKV_GCP_24,CKV_GCP_25,CKV_GCP_64,CKV_GCP_68,CKV2_AWS_5,CKV2_GCP_3,CKV2_GCP_5,CKV_AWS_23,CKV_GCP_70,CKV_GCP_62,CKV_GCP_62,CKV_GCP_62,CKV_GCP_62,CKV_GCP_29,CKV_GCP_39"
11+ # SKIP_CHECKS="CKV_GCP_22,CKV_GCP_66,CKV_GCP_13,CKV_GCP_71,CKV_GCP_61,CKV_GCP_21,CKV_GCP_65,CKV_GCP_67,CKV_GCP_20,CKV_GCP_69,CKV_GCP_12,CKV_GCP_24,CKV_GCP_25,CKV_GCP_64,CKV_GCP_68,CKV2_AWS_5,CKV2_GCP_3,CKV2_GCP_5,CKV_AWS_23,CKV_GCP_70,CKV_GCP_62,CKV_GCP_62,CKV_GCP_62,CKV_GCP_62,CKV_GCP_29,CKV_GCP_39"
1312
13+ set +x
1414# In case no terraform code is present
15- echo " [+] Starting Checkov..."
15+ echo " --- Starting Checkov..."
1616echo " Note: If there is no output below here then no terraform code was found to scan. All good!"
1717echo " ==========================================================================================="
1818
19+ # Set not to fail on non-zero exit code
20+ set +e
1921# Run checkov
20- /root/.asdf/installs/python/3.10.0/bin/checkov --skip-check $SKIP_CHECKS --quiet --framework terraform --compact -d .
22+ python3 -m checkov.main --quiet --framework terraform --compact -d .
2123
2224# Options
2325# --quiet: Only show failing tests
@@ -29,5 +31,7 @@ CHECKOV_EXIT_CODE="$?"
2931
3032# We check the exit code and display a warning if anything was found
3133if [[ " $CHECKOV_EXIT_CODE " != 0 ]]; then
32- buildkite-agent annotate ' Possible Terraform security issues found. Please refer to the Sourcegraph handbook for guidance <a target="_blank" href="https://handbook.sourcegraph.com/product-engineering/engineering/cloud/security/checkov">here</a>.' --style ' warning' --context ' ctx-warn'
34+ echo " ^^^ +++"
35+ echo " Possible Terraform security issues found. "
36+ echo " Please refer to the Sourcegraph handbook for guidance: https://handbook.sourcegraph.com/product-engineering/engineering/cloud/security/checkov"
3337fi
0 commit comments