compliance-drift-detection
Skill187 starsChanged 6 months agoMITView on GitHub
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. 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 Detection query: Then check tags via Azure Resource Graph: Detection query: Tag remediation:
In this repository28 other files it gives its agents.
- labs/onboardinglab/AGENTS.mdAGENTS.md
- labs/zava-aks-postgres/AGENTS.mdAGENTS.md
- labs/zava-learning/AGENTS.mdAGENTS.md
- deployment-compliance-checkSkill
- onboarding-labSkill
- azure-monitor-rcaSkill
- email-incident-followupSkill
- github-issue-followupSkill
- proactive-health-checkSkill
- ticketing-pr-validationSkill
- vm-performance-diagnosticsSkill
- deploying-demoSkill
- managing-sre-agentSkill
- running-demoSkill
- connectivity-triageSkill
- cost-analysisSkill
- evidence-before-afterSkill
- nsg-auditSkill
- pagerduty-incident-updateSkill
- performance-investigationSkill
- pr-deliverySkill
- rbac-auditSkill
- rca-analysisSkill
- recommendations-next-stepsSkill
- redaction-guardSkill
- servicenow-change-managementSkill
- zava-audit-reportSkill
- zava-reportingSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 6 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
All resources MUST have the following tags:
- Distinctive: line 62
All VMs must have:
- Distinctive: line 87
Use Azure Resource Graph to query all resources in scope.
- Distinctive: line 90
Run detection queries for each policy.
- Distinctive: line 147
NEVER: delete resources as part of compliance remediation
- Distinctive: line 149
LOG: all drift detections and remediation actions
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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 attributiondeployed-by— must bepipelinefor productioncompliance-required— must betrue
Detection query:
AzureActivity
| where TimeGenerated > ago(30m)
| where OperationNameValue has "write" and ActivityStatusValue == "Success"
| project TimeGenerated, ResourceId = _ResourceId, Caller, OperationNameValueThen 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/0or* - Port 3389 (RDP) open to
0.0.0.0/0or* - 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=trueNSG 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
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

