diff --git a/.buildkite/ci-checkov.sh b/.buildkite/ci-checkov.sh new file mode 100644 index 0000000..1ee1c9b --- /dev/null +++ b/.buildkite/ci-checkov.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# In case it reports already installed +asdf shell python 3.10.0 + +# Install and run the plugin for checkov +# Use the full path to run pip3.10 +/root/.asdf/installs/python/3.10.0/bin/pip3.10 install checkov + +# List of checks we do not want to run here +# This is a living list and will see additions and mostly removals over time. +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" + +# In case no terraform code is present +echo "[+] Starting Checkov..." +echo "Note: If there is no output below here then no terraform code was found to scan. All good!" +echo "===========================================================================================" + +# Run checkov +/root/.asdf/installs/python/3.10.0/bin/checkov --skip-check $SKIP_CHECKS --quiet --framework terraform --compact -d . + +# Options +# --quiet: Only show failing tests +# --compact: Do not show code snippets +# --framework: Only scan terraform code + +# Capture the error code +CHECKOV_EXIT_CODE="$?" + +# We check the exit code and display a warning if anything was found +if [[ "$CHECKOV_EXIT_CODE" != 0 ]]; then + buildkite-agent annotate 'Possible Terraform security issues found. Please refer to the Sourcegraph handbook for guidance here.' --style 'warning' --context 'ctx-warn' +fi diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml index 10f20a8..fedef46 100644 --- a/.buildkite/pipeline.yaml +++ b/.buildkite/pipeline.yaml @@ -1,30 +1,36 @@ -$schema: 'http://json.schemastore.org/buildkite' +$schema: "http://json.schemastore.org/buildkite" env: - IMAGE: 'e2e-2e61d9153-2021-06-22t15-18-00z' - VAGRANT_RUN_ENV: 'CI' + IMAGE: "e2e-2e61d9153-2021-06-22t15-18-00z" + VAGRANT_RUN_ENV: "CI" steps: - - label: ':docker:' + - label: ":docker:" command: .buildkite/validate-docker-compose.sh - agents: { queue: 'vagrant' } + agents: { queue: "vagrant" } - - label: ':lipstick:' + - label: ":lipstick:" command: .buildkite/prettier-check.sh - agents: { queue: 'vagrant' } + agents: { queue: "vagrant" } - label: ":git: :sleuth_or_spy:" command: .buildkite/verify-release/verify-release.sh agents: { queue: standard } - - label: ':rice: pure-docker-test' + - label: ":rice: pure-docker-test" command: .buildkite/vagrant-run.sh docker-test artifact_paths: ./*.log env: - TEST_TYPE: 'pure-docker-test' - agents: { queue: 'vagrant' } + TEST_TYPE: "pure-docker-test" + agents: { queue: "vagrant" } - - label: ':rice: docker-compose-test' + - label: ":rice: docker-compose-test" command: .buildkite/vagrant-run.sh docker-test artifact_paths: ./*.log env: - TEST_TYPE: 'docker-compose-test' - agents: { queue: 'vagrant' } + TEST_TYPE: "docker-compose-test" + agents: { queue: "vagrant" } + + # This runs the Checkov Terraform Code scanner + # https://www.checkov.io/ + - command: .buildkite/ci-checkov.sh + label: ":lock: security - checkov" + agents: { queue: "standard" } diff --git a/.tool-versions b/.tool-versions index 32ecbf2..badc2a0 100644 --- a/.tool-versions +++ b/.tool-versions @@ -2,3 +2,4 @@ yarn 1.19.2 shellcheck 0.7.1 nodejs 13.12.0 golang 1.16 +python 3.10.0