Bylaw

Gallery › Network › Azure built-in policies

Bot Protection should be enabled for Azure Front Door WAF

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

This policy ensures that bot protection is enabled in all Azure Front Door 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-AFD-WAF_Audit.json · 64 lines
{
  "properties": {
    "displayName": "Bot Protection should be enabled for Azure Front Door WAF",
    "policyType": "BuiltIn",
    "version": "1.0.0",
    "mode": "Indexed",
    "description": "This policy ensures that bot protection is enabled in all Azure Front Door 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/frontdoorWebApplicationFirewallPolicies"
          },
          {
            "count": {
              "field": "Microsoft.Network/frontdoorWebApplicationFirewallPolicies/managedRules.managedRuleSets[*]",
              "where": {
                "anyOf": [
                  {
                    "field": "Microsoft.Network/frontdoorWebApplicationFirewallPolicies/managedRules.managedRuleSets[*].ruleSetType",
                    "equals": "Microsoft_BotManagerRuleSet"
                  },
                  {
                    "field": "Microsoft.Network/frontdoorWebApplicationFirewallPolicies/managedRules.managedRuleSets[*].ruleSetType",
                    "equals": "BotProtection"
                  }
                ]
              }
            },
            "less": 1
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/27f7fb01-5fdb-44ad-954c-d582f8659533",
  "name": "27f7fb01-5fdb-44ad-954c-d582f8659533"
}
Bylaw27f7fb01-5fdb-44ad-954c-d582f8659533.bylaw.ps1 · 33 lines
# Converted from BotProtection-Enabled-AFD-WAF_Audit.json by ConvertTo-Bylaw.
Policy '27f7fb01-5fdb-44ad-954c-d582f8659533' {

    Properties @{
        DisplayName   = 'Bot Protection should be enabled for Azure Front Door WAF'
        Description   = 'This policy ensures that bot protection is enabled in all Azure Front Door 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/frontdoorWebApplicationFirewallPolicies' {

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

    Effect (Param Effect)
}

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