Bylaw

Gallery › SQL › Azure built-in policies

[Deprecated]: Advanced Threat Protection types should be set to 'All' in SQL server Advanced Data Security settings

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0-deprecated Deprecated

It is recommended to enable all Advanced Threat Protection types on your SQL servers. Enabling all types protects against SQL injection, database vulnerabilities, and any other anomalous activities.

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

Azure Policy JSONSqlServer_EnsureThreatDetectionTypes_Audit.json · 50 lines
{
  "properties": {
    "displayName": "[Deprecated]: Advanced Threat Protection types should be set to 'All' in SQL server Advanced Data Security settings",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "It is recommended to enable all Advanced Threat Protection types on your SQL servers. Enabling all types protects against SQL injection, database vulnerabilities, and any other anomalous activities.",
    "metadata": {
      "version": "1.0.0-deprecated",
      "category": "SQL",
      "deprecated": true
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Disabled",
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.Sql/servers"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Sql/servers/securityAlertPolicies",
          "name": "default",
          "existenceCondition": {
            "field": "Microsoft.Sql/servers/securityAlertPolicies/disabledAlerts[*]",
            "equals": ""
          }
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/e756b945-1b1b-480b-8de8-9a0859d5f7ad",
  "name": "e756b945-1b1b-480b-8de8-9a0859d5f7ad"
}
Bylawe756b945-1b1b-480b-8de8-9a0859d5f7ad.bylaw.ps1 · 32 lines
# Converted from SqlServer_EnsureThreatDetectionTypes_Audit.json by ConvertTo-Bylaw.
Policy 'e756b945-1b1b-480b-8de8-9a0859d5f7ad' {

    Properties @{
        DisplayName   = '[Deprecated]: Advanced Threat Protection types should be set to ''All'' in SQL server Advanced Data Security settings'
        Description   = 'It is recommended to enable all Advanced Threat Protection types on your SQL servers. Enabling all types protects against SQL injection, database vulnerabilities, and any other anomalous activities.'
        Version       = '1.0.0-deprecated'
        Category      = 'SQL'
        Deprecated    = $true
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Sql/servers'

    AuditIfNotExists 'Microsoft.Sql/servers/securityAlertPolicies' -Name 'default' -Effect (Param Effect) {
        Require 'disabledAlerts is as required' {
            Field disabledAlerts | Must -Exist
            Each 'disabledAlerts[*]' {
                Element | Must -Be ''
            }
        }
    }
}

Source: built-in-policies/policyDefinitions/SQL/SqlServer_EnsureThreatDetectionTypes_Audit.json in Azure/azure-policy, under the MIT licence.