Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
The quick answer
python3 -m venv ~/.venvs/checkov && ~/.venvs/checkov/bin/pip install checkov
~/.venvs/checkov/bin/checkov -d ./terraform --framework terraform --compactStep by step
- Install in a virtual environment (quick answer), or run the container:
docker run --rm -v "$PWD:/tf" bridgecrew/checkov -d /tf. - Scan the code — each finding shows the check ID (for example
CKV_AWS_18"S3 bucket access logging"), the resource and the file line.--compacthides the code snippets;--quietshows only failures. - Scan the plan too — the plan has the real values (variables, module outputs):
terraform plan -out=tfplan && terraform show -json tfplan > tfplan.json
~/.venvs/checkov/bin/checkov -f tfplan.json --framework terraform_plan- Fix, or skip with a reason — fix most findings. When a check does not fit, skip it in the code, next to the resource, with a reason a reviewer can judge:
resource "aws_s3_bucket" "logs" {
#checkov:skip=CKV_AWS_18:This is the access log bucket itself
bucket = "example-logs"
}- Team settings in a file — frameworks, skipped checks for the whole repo, output:
framework:
- terraform
compact: true
skip-check:
- CKV_AWS_144- In CI — fail the job on findings, and upload SARIF so findings show in the pull request (GitHub code scanning):
checkov -d ./terraform -o cli -o sarif --output-file-path console,results.sarif- Existing projects with many findings — create a baseline once (
--create-baseline), then CI fails only on new findings (--baseline terraform/.checkov.baseline); fix the old ones step by step.
Check that it worked
The scan ends with Passed checks: N, Failed checks: 0, Skipped checks: M; every skip in the code has a reason; a test change that opens port 22 to 0.0.0.0/0 makes the CI job fail with the check ID in the log.
Common problems
| Problem | Cause | Fix |
|---|---|---|
| Hundreds of findings in an old project | Never scanned before. | Baseline first; fix the high-risk ones; block new ones. |
| Finding in a module you do not own | Checkov scans downloaded modules. | --skip-path .terraform or --download-external-modules false; report upstream. |
| Variables shown as unknown | Static scan does not know the values. | Scan the plan JSON too. |
| Skip comment ignored | Wrong place or format. | #checkov:skip=ID:reason inside the resource block. |
| CI green despite findings | --soft-fail set. | Remove it (or use it only during the baseline phase). |
pip install breaks system Python | Installed globally. | Use a venv or the container. |
Go further
- Command pages: terraform, pip.
- Next how-tos: Plan and apply Terraform safely, Create a safe S3 bucket with Terraform, Find bugs in code with Semgrep, Create a CI pipeline in GitHub Actions.
- Learn it: Supply chain services — the pipeline, IaC tools at work — Terraform. Full guide: Checkov.
1Why scan the Terraform plan and not only the code?
The plan contains the real values of variables and modules, so checks can see settings that the code alone does not show.
2What makes a good Checkov skip?
It sits next to the resource with the check ID and a clear reason, so reviewers can judge it.