IaC安全扫描器Skill iac-security-scanner

IaC安全扫描器是一款专注于基础设施即代码安全审计的自动化工具。它能对Terraform、CloudFormation、Kubernetes、Pulumi等主流IaC代码进行深度扫描,自动识别安全漏洞、错误配置和合规性问题,并支持自定义策略执行。该工具集成了Checkov、tfsec、OPA等业界领先的扫描引擎,可生成详细的合规性报告,映射CIS、NIST、PCI-DSS等标准,是DevSecOps流程中保障云原生架构安全、实现左移安全的关键组件。关键词:基础设施即代码安全,IaC安全扫描,云安全审计,DevSecOps,合规性检查,Terraform安全,Kubernetes安全,安全策略执行。

云安全 0 次安装 0 次浏览 更新于 2/26/2026

name: iac-security-scanner description: 针对 Terraform、CloudFormation、Kubernetes 和 Pulumi 的基础设施即代码安全扫描与策略执行 allowed-tools:

  • Bash
  • Read
  • Write
  • Glob
  • Grep
  • WebFetch

IaC 安全扫描技能

目的

在部署前,对云基础设施定义进行基础设施即代码安全扫描和策略执行,以识别错误配置、安全漏洞和合规性违规。

能力

Terraform 安全扫描

  • 扫描 Terraform 配置中的安全错误配置
  • 检查暴露的资源(公开的 S3 存储桶、开放的安全组)
  • 验证静态和传输中数据的加密设置
  • 检测 Terraform 文件中的硬编码密钥
  • 分析 Terraform 状态文件以查找敏感数据暴露

CloudFormation 分析

  • 扫描 CloudFormation 模板中的安全问题
  • 检查 IAM 策略配置是否符合最小权限原则
  • 验证网络配置安全性
  • 检测不安全的默认配置

Kubernetes 清单扫描

  • 分析 Kubernetes YAML 清单中的安全问题
  • 检查 Pod 安全标准合规性
  • 验证资源限制和配额
  • 检测特权容器和主机路径挂载

Pulumi 代码分析

  • 扫描 Pulumi TypeScript/Python 代码中的安全问题
  • 检查云资源配置
  • 验证安全最佳实践

策略执行

  • 使用 OPA/Rego 定义和执行自定义安全策略
  • 为云资源配置创建防护栏
  • 阻止违反安全策略的部署
  • 生成策略合规性报告

合规性映射

  • 将发现映射到合规性框架(CIS、NIST、SOC 2、PCI-DSS)
  • 生成合规性差距分析报告
  • 跟踪针对合规性要求的修复进度

集成

  • Checkov:Bridgecrew 的多云 IaC 扫描器
  • tfsec:Terraform 安全扫描器
  • KICS:保持基础设施即代码安全
  • Terrascan:IaC 安全扫描器
  • OPA/Rego:策略即代码引擎
  • Snyk IaC:基础设施即代码安全测试

目标流程

  • IaC 安全扫描流程
  • 云安全架构审查
  • DevSecOps 流水线集成
  • 基础设施部署流水线
  • 合规性持续监控

输入模式

{
  "type": "object",
  "properties": {
    "iacPath": {
      "type": "string",
      "description": "IaC 文件或目录的路径"
    },
    "iacType": {
      "type": "string",
      "enum": ["terraform", "cloudformation", "kubernetes", "pulumi", "arm", "ansible"],
      "description": "要扫描的 IaC 类型"
    },
    "scanners": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": ["checkov", "tfsec", "kics", "terrascan", "snyk"]
      },
      "description": "要使用的扫描器"
    },
    "complianceFrameworks": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": ["CIS", "NIST", "SOC2", "PCI-DSS", "HIPAA", "GDPR"]
      }
    },
    "customPolicies": {
      "type": "string",
      "description": "自定义 OPA/Rego 策略的路径"
    },
    "severityThreshold": {
      "type": "string",
      "enum": ["CRITICAL", "HIGH", "MEDIUM", "LOW"]
    },
    "excludePaths": {
      "type": "array",
      "items": { "type": "string" }
    }
  },
  "required": ["iacPath", "iacType"]
}

输出模式

{
  "type": "object",
  "properties": {
    "scanId": {
      "type": "string"
    },
    "iacPath": {
      "type": "string"
    },
    "scanTimestamp": {
      "type": "string",
      "format": "date-time"
    },
    "summary": {
      "type": "object",
      "properties": {
        "totalFiles": { "type": "integer" },
        "filesScanned": { "type": "integer" },
        "passedChecks": { "type": "integer" },
        "failedChecks": { "type": "integer" },
        "skippedChecks": { "type": "integer" }
      }
    },
    "findings": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "checkId": { "type": "string" },
          "severity": { "type": "string" },
          "resourceType": { "type": "string" },
          "resourceName": { "type": "string" },
          "filePath": { "type": "string" },
          "lineNumber": { "type": "integer" },
          "description": { "type": "string" },
          "remediation": { "type": "string" },
          "complianceMapping": { "type": "array" }
        }
      }
    },
    "complianceReport": {
      "type": "object"
    },
    "recommendations": {
      "type": "array",
      "items": { "type": "string" }
    }
  }
}

使用示例

skill: {
  name: 'iac-security-scanner',
  context: {
    iacPath: './infrastructure/terraform',
    iacType: 'terraform',
    scanners: ['checkov', 'tfsec'],
    complianceFrameworks: ['CIS', 'SOC2'],
    severityThreshold: 'MEDIUM'
  }
}