Files
Anthropic-Cybersecurity-Skills/skills/auditing-terraform-infrastructure-for-security/references/api-reference.md
T
mukul975 27c6414ca5 Add folder anatomy (scripts/agent.py + references/api-reference.md) for 648 cybersecurity skills
Complete skill folder anatomy across all cybersecurity skills:
- scripts/agent.py: 80-150 line Python agents using real libraries (impacket,
  boto3, azure-mgmt-*, kubernetes, pefile, yara, scapy, shodan, stix2, etc.)
- references/api-reference.md: real API documentation with method signatures
- LICENSE: MIT license for all skill folders
2026-03-10 21:02:12 +01:00

76 lines
1.8 KiB
Markdown

# API Reference: Auditing Terraform Infrastructure for Security
## Checkov CLI
```bash
# Scan directory
checkov -d ./terraform/ --framework terraform --output json
# Scan plan file
terraform plan -out=tfplan && terraform show -json tfplan > tfplan.json
checkov -f tfplan.json --framework terraform_plan
# Skip specific checks
checkov -d ./terraform/ --skip-check CKV_AWS_145
# List all checks
checkov --list --framework terraform | grep CKV_AWS
```
## tfsec CLI
```bash
# Scan with minimum severity
tfsec ./terraform/ --minimum-severity HIGH --format json
# Generate SARIF for GitHub
tfsec ./terraform/ --format sarif > tfsec.sarif
```
## Checkov Python API
```python
from checkov.runner_registry import RunnerRegistry
from checkov.terraform.runner import Runner
runner = Runner()
report = runner.run(root_folder="./terraform/")
for check in report.failed_checks:
print(check.check_id, check.resource, check.file_path)
```
## Common CKV Check IDs
| Check ID | Description |
|----------|-------------|
| CKV_AWS_18 | S3 access logging |
| CKV_AWS_19 | S3 server-side encryption |
| CKV_AWS_20 | S3 Block Public Access |
| CKV_AWS_24 | Security group allows SSH from 0.0.0.0/0 |
| CKV_AWS_1 | IAM policy with wildcard actions |
| CKV_AWS_145 | RDS encryption |
| CKV_AWS_41 | Secrets in Lambda environment variables |
## OPA/Conftest
```bash
# Evaluate plan against Rego policies
conftest test tfplan.json --policy ./policy/ --output json
```
```rego
package terraform.aws.s3
deny[msg] {
resource := input.resource.aws_s3_bucket[name]
not resource.server_side_encryption_configuration
msg := sprintf("S3 bucket '%s' missing encryption", [name])
}
```
### References
- Checkov: https://www.checkov.io/
- tfsec: https://aquasecurity.github.io/tfsec/
- Terrascan: https://runterrascan.io/
- Conftest: https://www.conftest.dev/