Bylaw

Gallery › Security Center › Azure built-in policies

SQL databases should have vulnerability findings resolved

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 4.1.0

Monitor vulnerability assessment scan results and recommendations for how to remediate database vulnerabilities.

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

Azure Policy JSONASC_SQLDbVulnerabilities_Audit.json · 63 lines
{
  "properties": {
    "displayName": "SQL databases should have vulnerability findings resolved",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Monitor vulnerability assessment scan results and recommendations for how to remediate database vulnerabilities.",
    "metadata": {
      "version": "4.1.0",
      "category": "Security Center"
    },
    "version": "4.1.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "AuditIfNotExists",
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "in": [
              "Microsoft.Sql/servers",
              "Microsoft.Sql/managedinstances"
            ]
          },
          {
            "field": "kind",
            "notContains": "analytics"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/assessments",
          "name": "82e20e14-edc5-4373-bfc4-f13121257c37",
          "existenceCondition": {
            "field": "Microsoft.Security/assessments/status.code",
            "in": [
              "NotApplicable",
              "Healthy"
            ]
          }
        }
      }
    },
    "versions": [
      "4.1.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/feedbf84-6b99-488c-acc2-71c829aa5ffc",
  "name": "feedbf84-6b99-488c-acc2-71c829aa5ffc"
}
Bylawfeedbf84-6b99-488c-acc2-71c829aa5ffc.bylaw.ps1 · 37 lines
# Converted from ASC_SQLDbVulnerabilities_Audit.json by ConvertTo-Bylaw.
Policy 'feedbf84-6b99-488c-acc2-71c829aa5ffc' {

    Properties @{
        DisplayName   = 'SQL databases should have vulnerability findings resolved'
        Description   = 'Monitor vulnerability assessment scan results and recommendations for how to remediate database vulnerabilities.'
        Version       = '4.1.0'
        Category      = 'Security Center'
        PolicyVersion = '4.1.0'
        Mode          = 'Indexed'
    }

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

    Resource * {

        When {
            Field type | Must -BeIn @('Microsoft.Sql/servers', 'Microsoft.Sql/managedinstances')
        }

        Require 'kind contains analytics' {
            Field kind | Must -ContainText 'analytics'
        }
    }

    AuditIfNotExists 'Microsoft.Security/assessments' -Name '82e20e14-edc5-4373-bfc4-f13121257c37' -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/ASC_SQLDbVulnerabilities_Audit.json in Azure/azure-policy, under the MIT licence.