Iac Checkov 标志

Iac Checkov

组织
AgentSecOps
iac-checkov

使用 Checkov 扫描基础设施即代码(IaC)的安全问题,内置 750 多项适用于 Terraform、CloudFormation、Kubernetes、Dockerfile 和 ARM 模板的策略。适用于:(1)扫描 IaC 文件中的安全配置错误和合规违规;(2)根据 CIS、PCI-DSS、HIPAA 和 SOC2 基准验证云基础设施;(3)检测 IaC 中的密钥和硬编码凭据;(4)在 CI/CD 流水线中实施策略即代码;(5)生成合规报告,并提供云安全态势管理的修复建议。

Add to TypingMind

概览

发布者AgentSecOps
代码仓库SecOpsAgentKit
技能名称iac-checkov
星标数
225
复刻数
44
附带文件
8
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 8 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 AgentSecOps 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Iac Checkov AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/AgentSecOps/SecOpsAgentKit/tree/main/skills/devsecops/iac-checkov
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/AgentSecOps/SecOpsAgentKit.git /tmp/SecOpsAgentKit
mkdir -p .claude/skills
cp -r /tmp/SecOpsAgentKit/skills/devsecops/iac-checkov .claude/skills/iac-checkov
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Iac Checkov,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Iac Checkov。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Iac Checkov 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Infrastructure as Code Security with Checkov

Overview

Checkov is a static code analysis tool that scans Infrastructure as Code (IaC) files for security misconfigurations and compliance violations before deployment. With 750+ built-in policies, Checkov helps prevent cloud security issues by detecting problems in Terraform, CloudFormation, Kubernetes, Dockerfiles, Helm charts, and ARM templates.

Checkov performs graph-based scanning to understand resource relationships and detect complex misconfigurations that span multiple resources, making it more powerful than simple pattern matching.

Quick Start

Install Checkov

bash
# Via pip
pip install checkov

# Via Homebrew (macOS)
brew install checkov

# Via Docker
docker pull bridgecrew/checkov

Scan Terraform Directory

bash
# Scan all Terraform files in directory
checkov -d ./terraform

# Scan specific file
checkov -f ./terraform/main.tf

# Scan with specific framework
checkov -d ./infrastructure --framework terraform

Scan Kubernetes Manifests

bash
# Scan Kubernetes YAML files
checkov -d ./k8s --framework kubernetes

# Scan Helm chart
checkov -d ./helm-chart --framework helm

Scan CloudFormation Template

bash
# Scan CloudFormation template
checkov -f ./cloudformation/template.yaml --framework cloudformation

Core Workflow

Step 1: Understand Scan Scope

Identify IaC files and frameworks to scan:

bash
# Supported frameworks
checkov --list-frameworks

# Output:
# terraform, cloudformation, kubernetes, dockerfile, helm,
# serverless, arm, secrets, ansible, github_actions, gitlab_ci

Scope Considerations:

  • Scan entire infrastructure directory for comprehensive coverage
  • Focus on specific frameworks during initial adoption
  • Exclude generated or vendor files
  • Include both production and non-production configurations

Step 2: Run Basic Scan

Execute Checkov with appropriate output format:

bash
# CLI output (human-readable)
checkov -d ./terraform

# JSON output (for automation)
checkov -d ./terraform -o json

# Multiple output formats
checkov -d ./terraform -o cli -o json -o sarif

# Save output to file
checkov -d ./terraform -o json --output-file-path ./reports

What Checkov Detects:

  • Security misconfigurations (unencrypted resources, public access)
  • Compliance violations (CIS benchmarks, industry standards)
  • Secrets and hardcoded credentials
  • Missing security controls (logging, monitoring, encryption)
  • Insecure network configurations
  • Resource relationship issues (via graph analysis)

Step 3: Filter and Prioritize Findings

Focus on critical issues first:

bash
# Show only high severity issues
checkov -d ./terraform --check CKV_AWS_*

# Skip specific checks (false positives)
checkov -d ./terraform --skip-check CKV_AWS_8,CKV_AWS_21

# Check against specific compliance framework
checkov -d ./terraform --compact --framework terraform \
  --check CIS_AWS,CIS_AZURE

# Run only checks with specific severity
checkov -d ./terraform --check HIGH,CRITICAL

Severity Levels:

  • CRITICAL: Immediate security risks (public S3 buckets, unencrypted databases)
  • HIGH: Significant security concerns (missing MFA, weak encryption)
  • MEDIUM: Important security best practices (missing tags, logging disabled)
  • LOW: Recommendations and hardening (resource naming conventions)

Step 4: Suppress False Positives

Use inline suppression for legitimate exceptions:

hcl
# Terraform example
resource "aws_s3_bucket" "example" {
  # checkov:skip=CKV_AWS_18:This bucket is intentionally public for static website
  bucket = "my-public-website"
  acl    = "public-read"
}
yaml
# Kubernetes example
apiVersion: v1
kind: Pod
metadata:
  name: privileged-pod
  annotations:
    checkov.io/skip: CKV_K8S_16=Legacy application requires privileged mode
spec:
  containers:
  - name: app
    securityContext:
      privileged: true

See references/suppression_guide.md for comprehensive suppression strategies.

Step 5: Create Custom Policies

Define organization-specific policies:

python
# custom_checks/require_s3_versioning.py
from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck
from checkov.common.models.enums import CheckResult, CheckCategories

class S3BucketVersioning(BaseResourceCheck):
    def __init__(self):
        name = "Ensure S3 bucket has versioning enabled"
        id = "CKV_AWS_CUSTOM_001"
        supported_resources = ['aws_s3_bucket']
        categories = [CheckCategories.BACKUP_AND_RECOVERY]
        super().__init__(name=name, id=id, categories=categories,
                         supported_resources=supported_resources)

    def scan_resource_conf(self, conf):
        if 'versioning' in conf:
            if conf['versioning'][0].get('enabled') == [True]:
                return CheckResult.PASSED
        return CheckResult.FAILED

check = S3BucketVersioning()

Run with custom policies:

bash
checkov -d ./terraform --external-checks-dir ./custom_checks

See references/custom_policies.md for advanced policy development.

Step 6: Generate Compliance Reports

Create reports for audit and compliance:

bash
# Generate comprehensive report
checkov -d ./terraform \
  -o cli -o json -o junitxml \
  --output-file-path ./compliance-reports \
  --repo-id my-infrastructure \
  --branch main

# CycloneDX SBOM for IaC
checkov -d ./terraform -o cyclonedx

# SARIF for GitHub Security
checkov -d ./terraform -o sarif --output-file-path ./sarif-report.json

Report Types:

  • CLI: Human-readable console output
  • JSON: Machine-readable for automation
  • JUnit XML: CI/CD integration (Jenkins, GitLab)
  • SARIF: GitHub/Azure DevOps Security tab
  • CycloneDX: Software Bill of Materials for IaC

Map findings to compliance frameworks using references/compliance_mapping.md.

CI/CD Integration

GitHub Actions

Add Checkov scanning to pull request checks:

yaml
# .github/workflows/checkov.yml
name: Checkov IaC Security Scan
on: [push, pull_request]

jobs:
  checkov-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Run Checkov
        uses: bridgecrewio/checkov-action@master
        with:
          directory: infrastructure/
          framework: terraform
          output_format: sarif
          output_file_path: checkov-results.sarif
          soft_fail: false

      - name: Upload SARIF Report
        if: always()
        uses: github/codeql-action/upload-sarif@v2
        with:
          sarif_file: checkov-results.sarif

Pre-Commit Hook

Prevent committing insecure IaC:

yaml
# .pre-commit-config.yaml
repos:
  - repo: https://github.com/bridgecrewio/checkov
    rev: 2.5.0
    hooks:
      - id: checkov
        args: [--soft-fail]
        files: \.(tf|yaml|yml|json)$

Install pre-commit hooks:

bash
pip install pre-commit
pre-commit install

GitLab CI

yaml
# .gitlab-ci.yml
checkov_scan:
  image: bridgecrew/checkov:latest
  stage: security
  script:
    - checkov -d ./terraform -o json -o junitxml
      --output-file-path $CI_PROJECT_DIR/checkov-report
  artifacts:
    reports:
      junit: checkov-report/results_junitxml.xml
    paths:
      - checkov-report/
    when: always

Jenkins Pipeline

groovy
// Jenkinsfile
pipeline {
    agent any
    stages {
        stage('Checkov Scan') {
            steps {
                sh 'pip install checkov'
                sh '''
                    checkov -d ./terraform \
                      -o cli -o junitxml \
                      --output-file-path ./reports
                '''
            }
        }
    }
    post {
        always {
            junit 'reports/results_junitxml.xml'
        }
    }
}

See assets/ directory for complete CI/CD templates.

Framework-Specific Workflows

Terraform

Scan Terraform with Variable Files:

bash
# Scan with tfvars
checkov -d ./terraform --var-file ./terraform.tfvars

# Download and scan external modules
checkov -d ./terraform --download-external-modules true

# Skip Terraform plan files
checkov -d ./terraform --skip-path terraform.tfstate

Common Terraform Checks:

  • CKV_AWS_19: Ensure S3 bucket has server-side encryption
  • CKV_AWS_21: Ensure S3 bucket has versioning enabled
  • CKV_AWS_23: Ensure Security Group ingress is not open to 0.0.0.0/0
  • CKV_AWS_40: Ensure IAM policies don't use wildcard actions
  • CKV_AWS_61: Ensure RDS database has encryption at rest enabled

Kubernetes

Scan Kubernetes Manifests:

bash
# Scan all YAML manifests
checkov -d ./k8s --framework kubernetes

# Scan Helm chart
checkov -d ./helm-chart --framework helm

# Scan kustomize output
kustomize build ./overlay/prod | checkov -f - --framework kubernetes

Common Kubernetes Checks:

  • CKV_K8S_8: Ensure Liveness Probe is configured
  • CKV_K8S_10: Ensure CPU requests are set
  • CKV_K8S_11: Ensure CPU limits are set
  • CKV_K8S_14: Ensure container image is not latest
  • CKV_K8S_16: Ensure container is not privileged
  • CKV_K8S_22: Ensure read-only root filesystem
  • CKV_K8S_28: Ensure container capabilities are minimized

CloudFormation

Scan CloudFormation Templates:

bash
# Scan CloudFormation template
checkov -f ./cloudformation/stack.yaml --framework cloudformation

# Scan AWS SAM template
checkov -f ./sam-template.yaml --framework serverless

Dockerfile

Scan Dockerfiles for Security Issues:

bash
# Scan Dockerfile
checkov -f ./Dockerfile --framework dockerfile

# Common issues detected:
# - Running as root user
# - Using :latest tag
# - Missing HEALTHCHECK
# - Exposing sensitive ports

Baseline and Drift Detection

Create Security Baseline

Establish baseline for existing infrastructure:

bash
# Create baseline (first scan)
checkov -d ./terraform --create-baseline

# This creates .checkov.baseline file with current findings

Detect New Issues (Drift)

Compare subsequent scans against baseline:

bash
# Compare against baseline - only fail on NEW issues
checkov -d ./terraform --baseline .checkov.baseline

# This allows existing issues while preventing new ones

Use Cases:

  • Gradual remediation of legacy infrastructure
  • Focus on preventing new security debt
  • Phased compliance adoption

Secret Scanning

Detect hardcoded secrets in IaC:

bash
# Enable secrets scanning
checkov -d ./terraform --framework secrets

# Common secrets detected:
# - AWS access keys
# - API tokens
# - Private keys
# - Database passwords
# - Generic secrets (high entropy strings)

Security Considerations

  • Policy Suppression Governance: Require security team approval for suppressing CRITICAL/HIGH findings
  • CI/CD Failure Thresholds: Configure --hard-fail-on for severity levels that should block deployment
  • Custom Policy Management: Version control custom policies and review changes
  • Compliance Alignment: Map organizational requirements to Checkov policies
  • Secrets Management: Never commit secrets; use secret managers and rotation policies
  • Audit Logging: Log all scan results and policy suppressions for compliance audits
  • False Positive Review: Regularly review suppressed findings to ensure they remain valid
  • Policy Updates: Keep Checkov updated to receive new security policies

Bundled Resources

Scripts (scripts/)

  • checkov_scan.py - Comprehensive scanning script with multiple frameworks and output formats
  • checkov_terraform_scan.sh - Terraform-specific scanning with variable file support
  • checkov_k8s_scan.sh - Kubernetes manifest scanning with cluster comparison
  • checkov_baseline_create.sh - Baseline creation and drift detection workflow
  • checkov_compliance_report.py - Generate compliance reports (CIS, PCI-DSS, HIPAA, SOC2)
  • ci_integration.sh - CI/CD integration examples for multiple platforms

References (references/)

  • compliance_mapping.md - Mapping of Checkov checks to CIS, PCI-DSS, HIPAA, SOC2, NIST
  • custom_policies.md - Guide for writing custom Python and YAML policies
  • suppression_guide.md - Best practices for suppressing false positives
  • terraform_checks.md - Comprehensive list of Terraform checks with remediation
  • kubernetes_checks.md - Kubernetes security checks and pod security standards
  • cloudformation_checks.md - CloudFormation security checks with examples

Assets (assets/)

  • checkov_config.yaml - Checkov configuration file template
  • github_actions.yml - Complete GitHub Actions workflow
  • gitlab_ci.yml - Complete GitLab CI pipeline
  • jenkins_pipeline.groovy - Jenkins pipeline template
  • pre_commit_config.yaml - Pre-commit hook configuration
  • custom_policy_template.py - Template for custom Python policies
  • policy_metadata.yaml - Policy metadata for organization-specific policies

Common Patterns

Pattern 1: Progressive Compliance Adoption

Gradually increase security posture:

bash
# Phase 1: Scan without failing (awareness)
checkov -d ./terraform --soft-fail

# Phase 2: Fail only on CRITICAL issues
checkov -d ./terraform --hard-fail-on CRITICAL

# Phase 3: Fail on CRITICAL and HIGH
checkov -d ./terraform --hard-fail-on CRITICAL,HIGH

# Phase 4: Full enforcement with baseline
checkov -d ./terraform --baseline .checkov.baseline

Pattern 2: Multi-Framework Infrastructure

Scan complete infrastructure stack:

bash
# Use bundled script for comprehensive scanning
python3 scripts/checkov_scan.py \
  --infrastructure-dir ./infrastructure \
  --frameworks terraform,kubernetes,dockerfile \
  --output-dir ./security-reports \
  --compliance CIS,PCI-DSS

Pattern 3: Policy-as-Code Repository

Maintain centralized policy repository:

policies/
├── custom_checks/
│   ├── aws/
│   │   ├── require_encryption.py
│   │   └── require_tags.py
│   ├── kubernetes/
│   │   └── require_psp.py
├── .checkov.yaml          # Global config
└── suppression_list.txt   # Approved suppressions

Pattern 4: Compliance-Driven Scanning

Focus on specific compliance requirements:

bash
# CIS AWS Foundations Benchmark
checkov -d ./terraform --check CIS_AWS

# PCI-DSS compliance
checkov -d ./terraform --framework terraform \
  --check CKV_AWS_19,CKV_AWS_21,CKV_AWS_61 \
  -o json --output-file-path ./pci-dss-report

# HIPAA compliance
checkov -d ./terraform --framework terraform \
  --compact --check CKV_AWS_17,CKV_AWS_19,CKV_AWS_61,CKV_AWS_93

Integration Points

  • CI/CD: GitHub Actions, GitLab CI, Jenkins, Azure DevOps, CircleCI, Bitbucket Pipelines
  • Version Control: Pre-commit hooks, pull request checks, branch protection rules
  • Cloud Platforms: AWS, Azure, GCP, OCI, Alibaba Cloud
  • IaC Tools: Terraform, Terragrunt, CloudFormation, ARM, Pulumi
  • Container Orchestration: Kubernetes, OpenShift, EKS, GKE, AKS
  • Policy Engines: OPA (Open Policy Agent), Sentinel
  • Security Platforms: Prisma Cloud, Bridgecrew Platform
  • SIEM/Logging: Export findings to Splunk, Elasticsearch, CloudWatch

Troubleshooting

Issue: Too Many Findings Overwhelming Team

Solution: Use progressive adoption with baselines:

bash
# Create baseline with current state
checkov -d ./terraform --create-baseline

# Only fail on new issues
checkov -d ./terraform --baseline .checkov.baseline --soft-fail-on LOW,MEDIUM

Issue: False Positives for Legitimate Use Cases

Solution: Use inline suppressions with justification:

hcl
# Provide clear business justification
resource "aws_security_group" "allow_office" {
  # checkov:skip=CKV_AWS_23:Office IP range needs SSH access for developers
  ingress {
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = ["203.0.113.0/24"]  # Office IP range
  }
}

Issue: Scan Takes Too Long

Solution: Optimize scan scope:

bash
# Skip unnecessary paths
checkov -d ./terraform \
  --skip-path .terraform/ \
  --skip-path modules/vendor/ \
  --skip-framework secrets

# Use compact output
checkov -d ./terraform --compact --quiet

Issue: Custom Policies Not Loading

Solution: Verify policy structure and loading:

bash
# Check policy syntax
python3 custom_checks/my_policy.py

# Ensure proper directory structure
checkov -d ./terraform \
  --external-checks-dir ./custom_checks \
  --list

# Debug with verbose output
checkov -d ./terraform --external-checks-dir ./custom_checks -v

Issue: Integration with Private Terraform Modules

Solution: Configure module access:

bash
# Set up Terraform credentials
export TF_TOKEN_app_terraform_io="your-token"

# Download external modules
checkov -d ./terraform --download-external-modules true

# Or scan after terraform init
cd ./terraform && terraform init
checkov -d .

References

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Iac Checkov AI 技能有什么作用?

使用 Checkov 扫描基础设施即代码(IaC)的安全问题,内置 750 多项适用于 Terraform、CloudFormation、Kubernetes、Dockerfile 和 ARM 模板的策略。适用于:(1)扫描 IaC 文件中的安全配置错误和合规违规;(2)根据 CIS、PCI-DSS、HIPAA 和 SOC2 基准验证云基础设施;(3)检测 IaC 中的密钥和硬编码凭据;(4)在 CI/CD 流水线中实施策略即代码;(5)生成合规报告,并提供云安全态势管理的修复建议。

为什么在 TypingMind 中使用 Iac Checkov?

因为您只需安装一次,就能搭配任何模型使用。Iac Checkov 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Iac Checkov?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/AgentSecOps/SecOpsAgentKit/tree/main/skills/devsecops/iac-checkov。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Iac Checkov?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Iac Checkov 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Iac Checkov 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Iac Checkov AI 技能免费吗?

AgentSecOps 已在 GitHub 上发布了该技能。请查看代码仓库了解许可条款。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇