计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
implementing-cloud-security-posture-management【效率与协作】实施云安全态势管理(CSPM),使用 Prowler、ScoutSuite、AWS Security Hub、Azure Defender 和 GCP Security Command Center 对多云环境中的错误配置、合规违规和安全风险进行持续监控。
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
不适用于:运行时工作负载保护(使用 Falco 或 Aqua 等 CWPP 工具)、应用安全测试(使用 DAST/SAST 工具),或网络入侵检测(使用 GuardDuty 或 Network Watcher 等云原生 IDS)。
pip install prowler)pip install scoutsuite)在每个云提供商中启用内置 CSPM 功能,用于基线态势评估。
# AWS:启用带 FSBP 和 CIS 标准的 Security Hub
aws securityhub enable-security-hub --enable-default-standards
aws securityhub batch-enable-standards --standards-subscription-requests \
'[{"StandardsArn":"arn:aws:securityhub:::standards/cis-aws-foundations-benchmark/v/1.4.0"}]'
# Azure:启用 Microsoft Defender for Cloud(CSPM 层)
az security pricing create --name CloudPosture --tier standard
az security auto-provisioning-setting update --name default --auto-provision on
# GCP:启用 Security Command Center Premium
gcloud services enable securitycenter.googleapis.com
gcloud scc settings update --organization=ORG_ID \
--enable-asset-discovery
执行 Prowler,对所有三个云提供商进行全面安全检查。
# AWS 评估,执行所有 CIS 检查
prowler aws \
--profile production \
-M json-ocsf csv html \
-o ./prowler-results/aws/ \
--compliance cis_1.4_aws cis_1.5_aws
# Azure 评估
prowler azure \
--subscription-ids SUB_ID_1 SUB_ID_2 \
-M json-ocsf csv html \
-o ./prowler-results/azure/ \
--compliance cis_2.0_azure
# GCP 评估
prowler gcp \
--project-ids project-1 project-2 \
-M json-ocsf csv html \
-o ./prowler-results/gcp/ \
--compliance cis_2.0_gcp
# 查看跨所有提供商的摘要
prowler aws --list-compliance
使用 ScoutSuite 进行统一的多云安全评估,并生成可视化报告。
# 扫描 AWS
python3 -m ScoutSuite aws --profile production \
--report-dir ./scoutsuite/aws/
# 扫描 Azure
python3 -m ScoutSuite azure --cli \
--all-subscriptions \
--report-dir ./scoutsuite/azure/
# 扫描 GCP
python3 -m ScoutSuite gcp --user-account \
--all-projects \
--report-dir ./scoutsuite/gcp/
# 每次均生成包含风险评分发现结果的 HTML 报告
创建每日运行 CSPM 检查并将发现结果路由到相应渠道的定期管道。
# 通过 EventBridge + CodeBuild 创建每日 Prowler 扫描(AWS)
cat > buildspec.yml << 'EOF'
version: 0.2
phases:
install:
commands:
- pip install prowler
build:
commands:
- prowler aws -M json-ocsf -o s3://security-findings-bucket/prowler/$(date +%Y%m%d)/
- prowler aws --compliance cis_1.5_aws -M csv -o s3://security-findings-bucket/prowler/compliance/
post_build:
commands:
- |
CRITICAL=$(cat output/*.json | grep -c '"CRITICAL"')
if [ "$CRITICAL" -gt 0 ]; then
aws sns publish --topic-arn arn:aws:sns:us-east-1:ACCOUNT:security-alerts \
--subject "Prowler: 发现 $CRITICAL 个严重问题" \
--message "请查看 s3://security-findings-bucket/prowler/$(date +%Y%m%d)/"
fi
EOF
# 使用 EventBridge 设置定时任务
aws events put-rule \
--name daily-prowler-scan \
--schedule-expression "cron(0 6 * * ? *)" \
--state ENABLED
将来自多个 CSPM 工具和云提供商的发现结果聚合到统一视图。
# findings_aggregator.py - 规范化和去重 CSPM 发现结果
import json
import hashlib
from datetime import datetime
def normalize_finding(finding, source):
"""将来自不同 CSPM 工具的发现结果规范化为通用格式。"""
normalized = {
'id': hashlib.sha256(f"{finding.get('ResourceId','')}{finding.get('CheckId','')}".encode()).hexdigest()[:16],
'source': source,
'cloud': finding.get('Provider', 'unknown'),
'account': finding.get('AccountId', finding.get('SubscriptionId', '')),
'region': finding.get('Region', ''),
'resource_type': finding.get('ResourceType', ''),
'resource_id': finding.get('ResourceId', ''),
'severity': finding.get('Severity', 'INFO').upper(),
'status': finding.get('Status', 'FAIL'),
'title': finding.get('CheckTitle', finding.get('Title', '')),
'description': finding.get('StatusExtended', ''),
'compliance': finding.get('Compliance', {}),
'remediation': finding.get('Remediation', {}).get('Recommendation', {}).get('Text', ''),
'timestamp': datetime.utcnow().isoformat()
}
return normalized
def aggregate_findings(prowler_file, scoutsuite_file):
findings = {}
for file_path, source in [(prowler_file, 'prowler'), (scoutsuite_file, 'scoutsuite')]:
with open(file_path) as f:
for line in f:
raw = json.loads(line)
normalized = normalize_finding(raw, source)
if normalized['status'] == 'FAIL':
findings[normalized['id']] = normalized
return sorted(findings.values(), key=lambda x: {'CRITICAL':0,'HIGH':1,'MEDIUM':2,'LOW':3}.get(x['severity'],4))
为违反安全基线的配置漂移设置自动响应。
# AWS Config 自动修复不合规 S3 存储桶
aws configservice put-remediation-configurations --remediation-configurations '[{
"ConfigRuleName": "s3-bucket-public-read-prohibited",
"TargetType": "SSM_DOCUMENT",
"TargetId": "AWS-DisableS3BucketPublicReadWrite",
"Parameters": {
"S3BucketName": {"ResourceValue": {"Value": "RESOURCE_ID"}}
},
"Automatic": true,
"MaximumAutomaticAttempts": 3,
"RetryAttemptSeconds": 60
}]'
# Azure Policy 自动修复
az policy assignment create \
--name "enforce-storage-encryption" \
--policy "/providers/Microsoft.Authorization/policyDefinitions/404c3081-a854-4457-ae30-26a93ef643f9" \
--scope "/subscriptions/SUB_ID" \
--enforcement-mode Default
# GCP 组织策略约束
gcloud resource-manager org-policies set-policy policy.yaml --organization=ORG_ID
# policy.yaml: constraint: constraints/storage.publicAccessPrevention, enforcement: true
| 术语 | 定义 |
|---|---|
| CSPM(云安全态势管理) | 持续监控云基础设施错误配置和合规违规的实践 |
| 配置漂移(Configuration Drift) | 云资源配置随时间偏离已批准安全基线的意外变更 |
| 安全基线(Security Baseline) | 记录了所有云资源必须满足的最低安全配置要求的文档 |
| 合规框架(Compliance Framework) | 用于评估云配置的结构化安全控制和要求集(CIS、SOC 2、PCI DSS、NIST) |
| 发现结果严重程度(Finding Severity) | 基于可利用性和潜在影响的错误配置风险分类(严重、高、中、低、信息) |
| 自动修复(Auto-Remediation) | 无需人工干预即可将不合规资源恢复到所需配置的自动纠正操作 |
场景背景:一家企业在 AWS(主要)、Azure(身份和 Microsoft 服务)和 GCP(数据分析)上运行生产工作负载。安全团队需要统一的态势可见性。
方法:
常见陷阱:使用权限过宽运行 CSPM 工具会创建高价值目标。使用具有只读权限的专用服务账户并定期轮换凭据。不同 CSPM 工具可能以不同方式报告同一错误配置,因此去重逻辑必须考虑不同工具之间不同的资源 ID 格式和发现结果标题。
云安全态势管理仪表盘
==============================================
组织: Acme Corp
评估日期: 2026-02-23
环境: AWS(12 个账户)、Azure(8 个订阅)、GCP(5 个项目)
态势评分:
AWS: 82/100(比上周+3)
Azure: 76/100(比上周-1)
GCP: 79/100(比上周+5)
总体: 79/100
按严重程度划分的发现结果:
严重: 18(AWS: 7, Azure: 8, GCP: 3)
高: 67(AWS: 28, Azure: 24, GCP: 15)
中: 234(AWS: 98, Azure: 87, GCP: 49)
低: 412(AWS: 178, Azure: 134, GCP: 100)
失败类别 TOP 排行:
1. IAM 权限过宽策略 (43 个发现结果)
2. 静态加密未启用 (38 个发现结果)
3. 公开网络暴露 (29 个发现结果)
4. 日志和监控缺口 (24 个发现结果)
5. 未使用的凭据和密钥 (19 个发现结果)
自动修复(过去 7 天):
已自动修复的发现结果: 34
待手动修复: 51
已批准豁免: 8