Bylaw

Gallery › Network › Azure built-in policies

Azure Web Application Firewall on Azure Front Door should have request body inspection enabled

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Ensure that Web Application Firewalls associated to Azure Front Doors have request body inspection enabled. This allows the WAF to inspect properties within the HTTP body that may not be evaluated in the HTTP headers, cookies, or URI.

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

Azure Policy JSONAzureWAFonAFDShouldHaveRequestBodyInspectionEnabled.json · 50 lines
{
  "properties": {
    "displayName": "Azure Web Application Firewall on Azure Front Door should have request body inspection enabled",
    "policyType": "BuiltIn",
    "version": "1.0.0",
    "mode": "Indexed",
    "description": "Ensure that Web Application Firewalls associated to Azure Front Doors have request body inspection enabled. This allows the WAF to inspect properties within the HTTP body that may not be evaluated in the HTTP headers, cookies, or URI.",
    "metadata": {
      "version": "1.0.0",
      "category": "Network"
    },
    "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"
          },
          {
            "field": "Microsoft.Network/frontdoorWebApplicationFirewallPolicies/policySettings.requestBodyCheck",
            "equals": "Disabled"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/4598f028-de1f-4694-8751-84dceb5f86b9",
  "name": "4598f028-de1f-4694-8751-84dceb5f86b9"
}
Bylaw4598f028-de1f-4694-8751-84dceb5f86b9.bylaw.ps1 · 28 lines
# Converted from AzureWAFonAFDShouldHaveRequestBodyInspectionEnabled.json by ConvertTo-Bylaw.
Policy '4598f028-de1f-4694-8751-84dceb5f86b9' {

    Properties @{
        DisplayName   = 'Azure Web Application Firewall on Azure Front Door should have request body inspection enabled'
        Description   = 'Ensure that Web Application Firewalls associated to Azure Front Doors have request body inspection enabled. This allows the WAF to inspect properties within the HTTP body that may not be evaluated in the HTTP headers, cookies, or URI.'
        Version       = '1.0.0'
        Category      = 'Network'
        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 'policySettings.requestBodyCheck is not Disabled' {
            Field policySettings.requestBodyCheck | Must -Not -Be 'Disabled' -IfPresent
        }
    }

    Effect (Param Effect)
}

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