Skip to content

Commit 57ab7ad

Browse files
authored
Updated Checkov (#24)
* Updated agent * Updated script Added @bobheadxi changes. * Update ci-checkov.sh
1 parent 7f90d6f commit 57ab7ad

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

.buildkite/ci-checkov.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
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..."
1616
echo "Note: If there is no output below here then no terraform code was found to scan. All good!"
1717
echo "==========================================================================================="
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
3133
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'
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"
3337
fi

.buildkite/pipeline.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
steps:
22
- label: ":lipstick:"
33
command: .buildkite/shfmt.sh
4+
agents: { queue: standard }
45
- label: ":lipstick:"
56
command: .buildkite/terraform-fmt.sh
7+
agents: { queue: standard }
68
- label: ":lint-roller:"
79
command: .buildkite/shellcheck.sh
10+
agents: { queue: standard }
811
- label: ":terraform:"
912
command: .buildkite/terraform-validate.sh
13+
agents: { queue: standard }
1014
- label: ":lint-roller:"
1115
command: .buildkite/check-latest-tag.sh
16+
agents: { queue: standard }
1217
- label: ":lock: security - checkov"
1318
command: .buildkite/ci-checkov.sh
19+
agents: { queue: standard }

0 commit comments

Comments
 (0)