Configures Checkov for IaC security scanning across Terraform, CloudFormation, Kubernetes, Helm, ARM, Serverless, AWS CDK - `pip install checkov`, custom Python checks, SARIF / JUnit output, and `--baseline` gating so CI fails only on new findings in legacy code. Use for the broadest built-in rule set with Python custom checks; for Terraform-only scanning use tfsec-policy, for wider platform breadth (OpenAPI / Pulumi / Crossplane) use kics-policy, and for a consolidated new-project scanner use trivy-config.
80
100%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
# .checkov/custom_checks/cost_center_tag.py
from checkov.common.models.enums import CheckCategories, CheckResult
from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck
class CostCenterTagPresent(BaseResourceCheck):
def __init__(self):
super().__init__(
name="Ensure all EC2 instances have a cost_center tag",
id="CKV_CUSTOM_001",
categories=[CheckCategories.GENERAL_SECURITY],
supported_resources=['aws_instance'],
)
def scan_resource_conf(self, conf):
tags = conf.get('tags', [{}])[0]
if 'cost_center' in tags:
return CheckResult.PASSED
return CheckResult.FAILED
check = CostCenterTagPresent()checkov -d . --external-checks-dir .checkov/custom_checksFor custom YAML policies (no Python required), use the graph-based
policies/ directory (Checkov supports YAML rules).
jobs:
iac-security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v5
with: { python-version: '3.13' }
- run: pip install checkov
- name: Run Checkov
run: checkov -d . --output sarif --output-file-path checkov.sarif --baseline .checkov.baseline
- uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: checkov.sarifThe SARIF upload to GitHub Code Scanning surfaces findings as PR comments + the Security tab.