Skip to content
This repository was archived by the owner on Jun 7, 2022. It is now read-only.

Commit 5816421

Browse files
authored
Created file to run checkov
1 parent a7db2ea commit 5816421

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

ci-checkov.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
# In case it reports already installed
4+
asdf shell python 3.10.0
5+
6+
# Install and run the plugin for checkov
7+
# Use the full path to run pip3.10
8+
/root/.asdf/installs/python/3.10.0/bin/pip3.10 install checkov
9+
10+
# List of checks we do not want to run here
11+
# 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"
13+
14+
# In case no terraform code is present
15+
echo "[+] Starting Checkov..."
16+
echo "Note: If there is no output below here then no terraform code was found to scan. All good!"
17+
echo "==========================================================================================="
18+
19+
# Run checkov
20+
/root/.asdf/installs/python/3.10.0/bin/checkov --skip-check $SKIP_CHECKS --quiet --framework terraform --compact -d .
21+
22+
# Options
23+
# --quiet: Only show failing tests
24+
# --compact: Do not show code snippets
25+
# --framework: Only scan terraform code
26+
27+
# Capture the error code
28+
CHECKOV_EXIT_CODE="$?"
29+
30+
# We check the exit code and display a warning if anything was found
31+
if [[ "$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'
33+
fi

0 commit comments

Comments
 (0)