nuclei-templates/cloud/azure/virtualmachines/azure-vmss-empty-unattached...

56 lines
2.0 KiB
YAML

id: azure-vmss-empty-unattached
info:
name: Azure Virtual Machine Scale Sets Empty and Unattached
author: princechaddha
severity: low
description: |
Identify any empty virtual machine scale sets available within your Microsoft Azure cloud account and delete them in order to eliminate unnecessary costs and meet compliance requirements when it comes to unused resources. A Microsoft Azure virtual machine scale set is considered empty when it doesn't have any VM instances attached anymore and is no longer associated with a load balancer.
impact: |
Maintaining empty VM scale sets can incur unnecessary costs and occupy valuable resources that could be utilized elsewhere.
remediation: |
Regularly check and remove any VM scale sets that do not contain any VM instances and are not associated with any load balancers.
reference:
- https://docs.microsoft.com/en-us/azure/virtual-machine-scale-sets/
tags: cloud,devops,azure,microsoft,vmss,azure-cloud-config
flow: |
code(1);
for (let ScaleSetData of iterate(template.scaleSetList)) {
ScaleSetData = JSON.parse(ScaleSetData);
set("name", ScaleSetData.Name);
set("resourceGroup", ScaleSetData.ResourceGroup);
code(2);
}
self-contained: true
code:
- engine:
- sh
- bash
source: |
az vmss list --output json --query '[*].{"Name":name,"ResourceGroup":resourceGroup}'
extractors:
- type: json
name: scaleSetList
internal: true
json:
- '.[]'
- engine:
- sh
- bash
source: |
az vmss list-instances --name "$name" --resource-group "$resourceGroup" --query '[*].id'
matchers-condition: and
matchers:
- type: word
words:
- '[]'
extractors:
- type: dsl
dsl:
- 'name + " in " + resourceGroup + " is empty and unattached"'
# digest: 4a0a00473045022024d0ff4cc5d16d07160755f5e4e335d5de1ebb9bc1872832e49b3beedccb4523022100ad126340ec7d5c11100e9f718381d8632ae722051920334ac7e8995586633460:922c64590222798bb761d5b6d8e72950