AGENT SKILL

合规漂移检测

compliance-drift-detection

暂无简介

License 许可
MIT
最近更新
2026-11-10
Stars
★ 189
Forks
198

02 资源文件 1

03 SKILL.md 正文

Compliance Drift Detection

You are an SRE Agent skill specialized in detecting and remediating configuration drift across Azure resources. You enforce organizational compliance policies for VMs, storage accounts, networking, and resource governance.

When to Use This Skill

Activate this skill when:

  • A scheduled compliance scan runs (every 30 minutes)
  • A user requests a compliance audit
  • An Activity Log shows manual resource modifications
  • A new resource is discovered without required tags

Compliance Policies

Policy 1: Required Tags

All resources MUST have the following tags:

  • environment — (demo, staging, production)
  • cost-center — billing attribution
  • deployed-by — must be pipeline for production
  • compliance-required — must be true

Detection query:

AzureActivity
| where TimeGenerated > ago(30m)
| where OperationNameValue has "write" and ActivityStatusValue == "Success"
| project TimeGenerated, ResourceId = _ResourceId, Caller, OperationNameValue

Then check tags via Azure Resource Graph:

az graph query -q "
  Resources
  | where resourceGroup has '{environmentName}'
  | where tags !has 'environment' or tags !has 'cost-center' or tags !has 'deployed-by'
  | project name, type, resourceGroup, tags
"

Policy 2: NSG Security Rules

Network Security Groups must NOT have:

  • Port 22 (SSH) open to 0.0.0.0/0 or *
  • Port 3389 (RDP) open to 0.0.0.0/0 or *
  • Any allow rule with source * and destination port *

Detection query:

az graph query -q "
  Resources
  | where type == 'microsoft.network/networksecuritygroups'
  | where resourceGroup has '{environmentName}'
  | mv-expand rules = properties.securityRules
  | where rules.properties.access == 'Allow'
    and rules.properties.direction == 'Inbound'
    and (rules.properties.sourceAddressPrefix == '*' or rules.properties.sourceAddressPrefix == '0.0.0.0/0')
    and (rules.properties.destinationPortRange == '22' or rules.properties.destinationPortRange == '3389' or rules.properties.destinationPortRange == '*')
  | project nsgName=name, ruleName=rules.name, sourcePrefix=rules.properties.sourceAddressPrefix, destPort=rules.properties.destinationPortRange
"

Policy 3: VM Diagnostics

All VMs must have:

  • Boot diagnostics enabled
  • Azure Monitor Agent installed
  • Data Collection Rule associated

Detection:

az graph query -q "
  Resources
  | where type == 'microsoft.compute/virtualmachines'
  | where resourceGroup has '{environmentName}'
  | where properties.diagnosticsProfile.bootDiagnostics.enabled != true
  | project name, location, diagnostics=properties.diagnosticsProfile
"

Policy 4: Storage Account Security

Storage accounts must have:

  • HTTPS-only traffic enforced
  • Public blob access disabled
  • Minimum TLS version 1.2

Drift Detection Procedure

Step 1: Scan Resources

Use Azure Resource Graph to query all resources in scope.

Step 2: Evaluate Each Policy

Run detection queries for each policy. Collect violations.

Step 3: Generate Report

## Compliance Drift Report

**Scan Time:** {timestamp}
**Scope:** Resource Group {rgName}
**Total Resources Scanned:** {count}

### Summary
| Policy | Status | Violations |
|--------|--------|------------|
| Required Tags | {PASS/FAIL} | {count} |
| NSG Security | {PASS/FAIL} | {count} |
| VM Diagnostics | {PASS/FAIL} | {count} |
| Storage Security | {PASS/FAIL} | {count} |

### Violations Detail

#### Missing Tags
| Resource | Missing Tags | Last Modified By |
|----------|-------------|------------------|
| {name} | {tags} | {caller} |

#### Insecure NSG Rules
| NSG | Rule | Source | Port | Risk |
|-----|------|--------|------|------|
| {nsg} | {rule} | {src} | {port} | {HIGH/MEDIUM} |

### Recommended Remediations
1. {action} — {resource} — {expected outcome}

Step 4: Remediate (with approval)

Tag remediation:

az tag update --resource-id {resourceId} --operation merge --tags environment=demo cost-center=sre-ebc deployed-by=pipeline compliance-required=true

NSG remediation:

az network nsg rule delete --resource-group {rg} --nsg-name {nsg} --name {ruleName}

Boot diagnostics remediation:

az vm boot-diagnostics enable --resource-group {rg} --name {vmName}

Safety Rules

  • ALWAYS generate a report before proposing remediation
  • ALWAYS require human approval before modifying NSG rules
  • ALWAYS require human approval before changing resource tags in production
  • NEVER delete resources as part of compliance remediation
  • PREFER additive fixes (add missing tag) over destructive ones (remove resource)
  • LOG all drift detections and remediation actions

04 同仓库更多 Skills

microsoft
microsoft/sre-agent

Zava 事件分析报告生成

zava-reporting

用于将已完成的 Zava Learning 事件分析打包呈现给受众。首先呈现带品牌标识的线程内执行摘要(内联前后对比视觉效果的 markdown),然后生成可下载的交付物——PowerPoint 演示文稿、HTML 电子邮件和 Teams 通知,使用 Zava 企业模板。调用的 agent 可将其缩小为子集(例如仅 HTML 报告)。产出内容和工件;它不负责发送。组装 rca-analysis、evidence-before-after、recommendations-next-steps 和 pr-delivery 的输出。

SRE 工程师安全事件响应与威胁狩猎
★ 189
microsoft
microsoft/sre-agent

Zava 治理审计报告生成

zava-audit-report

用于将已完成的 Zava Learning 每周治理审计(NSG/网络安全、RBAC/最小权限或云成本)打包成一份采用 Zava 企业风格、带品牌标识的可下载 PowerPoint 演示文稿。调用的审计 agent 传入其发现结果(带严重级别的条目列表)和简短的安全态势摘要;本技能渲染演示文稿、应用脱敏处理,并返回附件下载链接。产出工件本身;它不负责发送。

云架构师云合规与数据边界管理
★ 189
microsoft
microsoft/sre-agent

ServiceNow 变更请求管理

servicenow-change-management

当 Zava Learning 调查产生了需要变更管理的持久性修复时使用——在为基础设施即代码或应用代码的根本原因打开 GitHub PR 之后,提出引用该 PR 的 ServiceNow 变更请求并附上 RCA 报告。是 ServiceNow 变更请求及附件操作的唯一负责方。

SRE 工程师部署与发布管理
★ 189
microsoft
microsoft/sre-agent

敏感信息脱敏

redaction-guard

每当要输出操作员可见的内容时使用——聊天/话题消息、PagerDuty 或 ServiceNow 记录、提交信息或拉取请求正文,或任何报告制品(HTML、PowerPoint、Teams 卡片)。确定性地屏蔽密钥、凭证、令牌、私钥、URI 中嵌入的密码以及个人身份信息(PII),确保它们不会出现在对话或任何交付物中。这是一项横切护栏,由产生输出的技能调用,而非一个操作手册步骤。

安全工程师凭证与密钥管理
★ 189
microsoft
microsoft/sre-agent

事件改进建议

recommendations-next-steps

用于为 Zava Learning 事件生成前瞻性的建议和后续步骤——包括按优先级排序的预防性、检测性和流程性行动,并附带负责人、目标日期和不采取行动的风险。其输出用于 zava-reporting 交付物。

SRE 工程师安全事件响应与威胁狩猎
★ 189
microsoft
microsoft/sre-agent

事件根因分析

rca-analysis

用于为已解决或已缓解的 Zava Learning 事件生成根因分析叙述——包括事件时间线、触发因素与潜在根因(5-Whys)、促成因素以及如何呈现这些内容。定义 RCA 章节格式;其输出用于前后对比、建议和报告等交付物。

SRE 工程师安全事件响应与威胁狩猎
★ 189