mcpField
I
implementing-azure-defender-for-cloud

implementing-azure-defender-for-cloud

github.com/mukul975安全35.2k37 次安装8 周前更新
代码仓库

关于 implementing-azure-defender-for-cloud

面向负责 Azure 云安全的团队,提供 Microsoft Defender for Cloud 的部署与配置指导,覆盖工作负载保护、合规评估和威胁响应。内容涉及安全建议、告警、JIT VM 访问及自动化。

主要功能

  1. 01启用工作负载防护计划
  2. 02自动部署安全监控代理
  3. 03评估安全建议与 Secure Score
  4. 04配置法规合规标准
  5. 05设置告警与响应自动化
  6. 06配置 JIT VM 访问

适用场景

  1. 01在多个订阅中部署云安全计划
  2. 02保护虚拟机、容器与 SQL 工作负载
  3. 03跟踪 CIS 等合规标准
  4. 04按告警自动触发事件响应

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill implementing-azure-defender-for-cloud

安装后在 Claude Code 中输入/implementing-azure-defender-for-cloud确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

LICENSE
references/
api-reference.md
scripts/
agent.py

详细介绍

实施 Azure Defender for Cloud

何时使用

  • 当需要在 Azure 订阅中启用全面的安全监控时
  • 当需要为 VM、容器、SQL、存储和 Key Vault 实施云工作负载保护时
  • 当合规要求需要对监管框架进行持续评估时
  • 当需要构建能够响应检测到的威胁的自适应安全控制时
  • 当需要集中管理来自 Azure 原生和混合工作负载的安全发现结果时

不要使用于仅针对非 Azure 工作负载的保护(请使用 AWS Security Hub 或 GCP SCC)、应用级安全测试(请使用 Azure DevOps DAST/SAST)或身份专属保护(请使用 Microsoft Defender for Identity)。

先决条件

  • 具有 Contributor 或 Security Admin 角色的 Azure 订阅
  • 为合规评估启用 Azure Policy
  • 用于诊断数据收集的 Log Analytics 工作区
  • 用于混合服务器保护的 Azure Arc 已连接计算机
  • Defender 计划的定价层设置为 Standard(免费层仅提供 CSPM)

工作流

步骤 1:启用 Defender for Cloud 计划

为每种需要保护的工作负载类型启用相应的 Defender 计划。

# Enable Defender for Cloud CSPM (foundational posture management)
az security pricing create --name CloudPosture --tier standard

# Enable Defender for Servers
az security pricing create --name VirtualMachines --tier standard \
  --subplan P2

# Enable Defender for Containers
az security pricing create --name Containers --tier standard

# Enable Defender for Storage
az security pricing create --name StorageAccounts --tier standard \
  --subplan PerStorageAccount

# Enable Defender for SQL
az security pricing create --name SqlServers --tier standard

# Enable Defender for Key Vault
az security pricing create --name KeyVaults --tier standard

# Enable Defender for App Service
az security pricing create --name AppServices --tier standard

# Verify all enabled plans
az security pricing list \
  --query "[].{Plan:name, Tier:pricingTier, SubPlan:subPlan}" -o table
步骤 2:配置安全 Agent 的自动预配

启用监控 Agent 向 VM 和容器的自动部署。

# Enable auto-provisioning of Log Analytics agent
az security auto-provisioning-setting update \
  --name default --auto-provision on

# Configure Log Analytics workspace for data collection
az security workspace-setting create \
  --name default \
  --target-workspace "/subscriptions/SUB_ID/resourceGroups/RG/providers/Microsoft.OperationalInsights/workspaces/SecurityWorkspace"

# Enable Defender for Containers auto-provisioning components
az security setting update \
  --name Sentinel \
  --setting-kind DataExportSettings

# Verify auto-provisioning status
az security auto-provisioning-setting list -o table
步骤 3:审查安全建议并确定优先级

检索安全建议,并根据安全分数影响确定修复的优先级。

# Get the current secure score
az security secure-score list \
  --query "[].{Name:displayName, Current:current, Max:max, Percentage:percentage}" -o table

# List all active security recommendations
az security assessment list \
  --query "[?status.code=='Unhealthy'].{Name:displayName, Severity:metadata.severity, Category:metadata.category, ResourceCount:status.cause}" \
  -o table

# Get recommendations sorted by severity
az security assessment list \
  --query "[?status.code=='Unhealthy'] | sort_by(@, &metadata.severity)" \
  -o table

# Get detailed recommendation with remediation steps
az security assessment show \
  --name ASSESSMENT_ID \
  --query "{Name:displayName, Description:metadata.description, Severity:metadata.severity, Remediation:metadata.remediationDescription}"

# List recommendations by control
az security secure-score-controls list \
  --query "[].{Control:displayName, CurrentScore:current, MaxScore:max, NotHealthy:notHealthyResourceCount}" \
  -o table
步骤 4:配置法规合规性仪表板

启用合规标准并监控各订阅的遵守情况。

# List available regulatory compliance standards
az security regulatory-compliance-standards list \
  --query "[].{Standard:name, State:state}" -o table

# Enable specific compliance standards
az security regulatory-compliance-standards update \
  --name "CIS-Azure-2.0" --state "Enabled"

az security regulatory-compliance-standards update \
  --name "PCI-DSS-4.0" --state "Enabled"

az security regulatory-compliance-standards update \
  --name "NIST-SP-800-53-R5" --state "Enabled"

# Get compliance status for a specific standard
az security regulatory-compliance-controls list \
  --standard-name "CIS-Azure-2.0" \
  --query "[].{Control:id, Description:displayName, State:state, PassedResources:passedResources, FailedResources:failedResources}" \
  -o table

# Get failing assessments for a control
az security regulatory-compliance-assessments list \
  --standard-name "CIS-Azure-2.0" \
  --control-name "2.1" \
  --query "[?state=='Failed'].{Assessment:id, State:state}" -o table
步骤 5:设置安全警报和自动化

配置警报通知和自动化响应工作流。

# Create security contact for alert notifications
az security contact create \
  --name "SecurityTeam" \
  --email "[email protected]" \
  --phone "+1-555-0199" \
  --alert-notifications on \
  --alerts-to-admins on

# List active security alerts
az security alert list \
  --query "[?status=='Active'].{Name:alertDisplayName, Severity:severity, Time:timeGeneratedUtc, Status:status}" \
  -o table

# Create workflow automation for high-severity alerts (Logic App trigger)
az security automation create \
  --name "high-severity-alert-response" \
  --resource-group "security-rg" \
  --scopes "[{\"description\":\"Full subscription\",\"scopePath\":\"/subscriptions/SUB_ID\"}]" \
  --sources "[{
    \"eventSource\":\"Alerts\",
    \"ruleSets\":[{
      \"rules\":[{
        \"propertyJPath\":\"Severity\",
        \"propertyType\":\"String\",
        \"expectedValue\":\"High\",
        \"operator\":\"Equals\"
      }]
    }]
  }]" \
  --actions "[{
    \"logicAppResourceId\":\"/subscriptions/SUB_ID/resourceGroups/security-rg/providers/Microsoft.Logic/workflows/alert-response\",
    \"actionType\":\"LogicApp\"
  }]"
步骤 6:实施自适应应用程序控制和 JIT VM 访问

配置用于运行时安全的高级工作负载保护功能。

# Enable Just-In-Time VM access
az security jit-policy create \
  --resource-group "production-rg" \
  --name "jit-policy" \
  --virtual-machines "[{
    \"id\":\"/subscriptions/SUB_ID/resourceGroups/production-rg/providers/Microsoft.Compute/virtualMachines/web-server-01\",
    \"ports\":[
      {\"number\":22,\"protocol\":\"TCP\",\"allowedSourceAddressPrefix\":\"*\",\"maxRequestAccessDuration\":\"PT3H\"},
      {\"number\":3389,\"protocol\":\"TCP\",\"allowedSourceAddressPrefix\":\"*\",\"maxRequestAccessDuration\":\"PT3H\"}
    ]
  }]"

# Request JIT access when needed
az security jit-policy initiate \
  --resource-group "production-rg" \
  --name "jit-policy" \
  --virtual-machines "[{
    \"id\":\"VM_ID\",
    \"ports\":[{\"number\":22,\"endTimeUtc\":\"2026-02-23T15:00:00Z\",\"allowedSourceAddressPrefix\":\"10.0.1.50\"}]
  }]"

# Review adaptive application control recommendations
az security adaptive-application-controls list \
  --query "[].{Group:displayName, Recommendation:recommendationAction, VMCount:vmRecommendations|length(@)}" \
  -o table

关键概念

术语定义
Microsoft Defender for CloudAzure 原生安全平台,在 Azure、混合和多云环境中提供 CSPM 和云工作负载保护(CWP)
安全分数基于已实施的安全建议百分比的组织安全态势的数值衡量指标
安全建议Defender for Cloud 提供的用于改善安全态势的可操作指导,按严重性和安全分数影响确定优先级
Defender 计划工作负载专属的保护层(服务器、容器、SQL、存储等),为特定资源类型启用高级威胁检测
实时 VM 访问通过默认阻止管理端口(SSH/RDP)并按需授予限时访问来减少攻击面的功能
自适应应用程序控制基于机器学习的允许列表,推荐允许在 VM 上运行的应用程序

工具与系统

  • Microsoft Defender for Cloud:具有 CSPM、CWP 和法规合规性功能的中央安全平台
  • Azure Policy:Defender for Cloud 用于评估和强制执行安全配置的治理服务
  • Log Analytics 工作区:用于存储 Defender Agent 收集的安全遥测数据的后端数据存储
  • Azure Logic Apps:由 Defender 警报触发的事件响应工作流自动化
  • Azure Arc:将 Defender for Cloud 保护扩展到混合和多云服务器及 Kubernetes 集群

常见场景

场景:在多订阅企业中推广 Defender for Cloud

背景:某企业拥有 20 个 Azure 订阅,需要启用 Defender for Cloud 的服务器、容器和 SQL 保护,同时建立符合 CIS Azure 2.0 的合规基线。

实施方法:

  1. 使用 Azure Policy 计划在所有订阅中启用 CSPM 方案(CloudPosture)
  2. 在生产订阅上启用 Defender for Servers P2、Containers 和 SQL
  3. 配置自动预配,向所有 VM 部署 Log Analytics 代理
  4. 启用 CIS Azure 2.0 和 PCI DSS 4.0 合规标准
  5. 创建安全联系人,并配置向 SOC 团队发送警报通知
  6. 通过 Logic Apps 为 High 严重性警报设置工作流自动化
  7. 为所有生产服务器启用 JIT VM 访问,以消除长期存在的 SSH/RDP 暴露风险
  8. 为高管相关方创建每周 Secure Score 报告

注意事项:Defender for Servers P2 按每台服务器每小时计费。对于拥有大量 VM 的环境,成本可能迅速攀升。开发订阅请使用 Defender for Servers P1,仅生产环境使用 P2。代理的自动预配可能与由 SCCM 或其他工具管理的现有代理部署发生冲突。

输出格式

Microsoft Defender for Cloud Deployment Report
=================================================
Organization: Acme Corp
Subscriptions: 20 (12 production, 8 non-production)
Deployment Date: 2026-02-23

DEFENDER PLANS ENABLED:
  CloudPosture (CSPM):     20 / 20 subscriptions
  Servers P2:              12 / 20 (production only)
  Containers:              12 / 20 (production only)
  SQL:                     12 / 20 (production only)
  Storage:                 20 / 20 all subscriptions
  Key Vault:               20 / 20 all subscriptions

SECURE SCORE:
  Current: 62% (baseline)
  Target: 80% within 90 days

COMPLIANCE STATUS (CIS Azure 2.0):
  Compliant controls:        78 / 142 (55%)
  Non-compliant controls:    52 / 142
  Not applicable:            12 / 142

RECOMMENDATIONS:
  Critical:    8 recommendations affecting 34 resources
  High:       24 recommendations affecting 89 resources
  Medium:     56 recommendations affecting 234 resources
  Low:        34 recommendations affecting 112 resources

SECURITY ALERTS (Last 7 Days):
  High severity:    3
  Medium severity:  12
  Low severity:     28

评论

支持 Markdown