Bylaw

Gallery › Network › Azure built-in policies

Bot Protection should be enabled for Azure Application Gateway WAF

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

This policy ensures that bot protection is enabled in all Azure Application Gateway Web Application Firewall (WAF) policies

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

Azure Policy JSONBotProtection-Enabled-AppGW-WAF_Audit.json · 56 lines
{
  "properties": {
    "displayName": "Bot Protection should be enabled for Azure Application Gateway WAF",
    "policyType": "BuiltIn",
    "version": "1.0.0",
    "mode": "Indexed",
    "description": "This policy ensures that bot protection is enabled in all Azure Application Gateway Web Application Firewall (WAF) policies",
    "metadata": {
      "category": "Network",
      "version": "1.0.0"
    },
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies"
          },
          {
            "count": {
              "field": "Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/managedRules.managedRuleSets[*]",
              "where": {
                "field": "Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/managedRules.managedRuleSets[*].ruleSetType",
                "equals": "Microsoft_BotManagerRuleSet"
              }
            },
            "less": 1
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/ebea0d86-7fbd-42e3-8a46-27e7568c2525",
  "name": "ebea0d86-7fbd-42e3-8a46-27e7568c2525"
}
Bylawebea0d86-7fbd-42e3-8a46-27e7568c2525.bylaw.ps1 · 30 lines
# Converted from BotProtection-Enabled-AppGW-WAF_Audit.json by ConvertTo-Bylaw.
Policy 'ebea0d86-7fbd-42e3-8a46-27e7568c2525' {

    Properties @{
        DisplayName   = 'Bot Protection should be enabled for Azure Application Gateway WAF'
        Description   = 'This policy ensures that bot protection is enabled in all Azure Application Gateway Web Application Firewall (WAF) policies'
        Category      = 'Network'
        Version       = '1.0.0'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies' {

        Require 'managedRules.managedRuleSets and ruleSetType are as required' {
            Count 'managedRules.managedRuleSets[*]' -Where {
                Field ruleSetType | Must -Be 'Microsoft_BotManagerRuleSet'
            } | Must -BeGreaterOrEqual 1
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Network/BotProtection-Enabled-AppGW-WAF_Audit.json in Azure/azure-policy, under the MIT licence.