Checkov
Checkov is a static code analysis tool for infrastructure-as-code (IaC) that scans cloud infrastructure provisioned using Terraform, CloudFormation, Kubernetes, Helm, ARM Templates and Serverless framework.
Installation
Using pip
pip install checkovUsing Homebrew
brew install checkovUsing Docker
docker pull bridgecrew/checkovBasic Usage
Scan a Directory
checkov -d /path/to/terraform/codeScan a Specific File
checkov -f /path/to/terraform/file.tfOutput Formats
Configuration
Skip Checks
Create .checkov.yaml in your project root:
Policy Categories
Security
Access Control
Encryption
Network Security
IAM
Compliance
HIPAA
PCI DSS
SOC2
NIST
Operational Excellence
Backups
Monitoring
High Availability
CI/CD Integration
GitHub Actions
Azure DevOps Pipeline
Pre-commit Hook
Add to .pre-commit-config.yaml:
Common Security Checks
1. S3 Bucket Security
2. Security Group Rules
Custom Policies
Create custom_policies.py:
Best Practices
Regular Scanning
Integrate with CI/CD
Use pre-commit hooks
Schedule periodic scans
Policy Management
Document skip decisions
Review skipped checks regularly
Maintain custom policies
Remediation
Prioritize findings
Track fixes
Validate fixes
Checklist
Last updated