Bylaw

Gallery › Security Center › Azure built-in policies

Azure registry container images should have vulnerabilities resolved (powered by Microsoft Defender Vulnerability Management)

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.1

Container image vulnerability assessment scans your registry for commonly known vulnerabilities (CVEs) and provides a detailed vulnerability report for each image. Resolving vulnerabilities can greatly improve your security posture, ensuring images are safe to use prior to deployment.

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONMDC_AzureContainerRegistryVulnerabilityAssessment_Audit.json · 53 lines
{
  "properties": {
    "displayName": "Azure registry container images should have vulnerabilities resolved (powered by Microsoft Defender Vulnerability Management)",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Container image vulnerability assessment scans your registry for commonly known vulnerabilities (CVEs) and provides a detailed vulnerability report for each image. Resolving vulnerabilities can greatly improve your security posture, ensuring images are safe to use prior to deployment.",
    "metadata": {
      "version": "1.0.1",
      "category": "Security Center"
    },
    "version": "1.0.1",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "defaultValue": "AuditIfNotExists"
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.ContainerRegistry/registries"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/assessments",
          "name": "c0b7cfc6-3172-465a-b378-53c7ff2cc0d5",
          "existenceCondition": {
            "field": "Microsoft.Security/assessments/status.code",
            "in": [
              "NotApplicable",
              "Healthy"
            ]
          }
        }
      }
    },
    "versions": [
      "1.0.1",
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/090c7b07-b4ed-4561-ad20-e9075f3ccaff",
  "name": "090c7b07-b4ed-4561-ad20-e9075f3ccaff"
}
Bylaw090c7b07-b4ed-4561-ad20-e9075f3ccaff.bylaw.ps1 · 27 lines
# Converted from MDC_AzureContainerRegistryVulnerabilityAssessment_Audit.json by ConvertTo-Bylaw.
Policy '090c7b07-b4ed-4561-ad20-e9075f3ccaff' {

    Properties @{
        DisplayName   = 'Azure registry container images should have vulnerabilities resolved (powered by Microsoft Defender Vulnerability Management)'
        Description   = 'Container image vulnerability assessment scans your registry for commonly known vulnerabilities (CVEs) and provides a detailed vulnerability report for each image. Resolving vulnerabilities can greatly improve your security posture, ensuring images are safe to use prior to deployment.'
        Version       = '1.0.1'
        Category      = 'Security Center'
        PolicyVersion = '1.0.1'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('AuditIfNotExists', 'Disabled')
        Default       = 'AuditIfNotExists'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.ContainerRegistry/registries'

    AuditIfNotExists 'Microsoft.Security/assessments' -Name 'c0b7cfc6-3172-465a-b378-53c7ff2cc0d5' -Effect (Param Effect) {
        Require 'status.code is one of 2 values' {
            Field status.code | Must -BeIn @('NotApplicable', 'Healthy')
        }
    }
}

Source: built-in-policies/policyDefinitions/Security Center/MDC_AzureContainerRegistryVulnerabilityAssessment_Audit.json in Azure/azure-policy, under the MIT licence.