Bylaw

Gallery › Service Bus › Azure built-in policies

All authorization rules except RootManageSharedAccessKey should be removed from Service Bus namespace

Converted Policy Audit Deny Disabled Mode All Version 1.0.1

Service Bus clients should not use a namespace level access policy that provides access to all queues and topics in a namespace. To align with the least privilege security model, you should create access policies at the entity level for queues and topics to provide access to only the specific entity

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

Azure Policy JSONAuditNamespaceAccessRules_Audit.json · 50 lines
{
  "properties": {
    "displayName": "All authorization rules except RootManageSharedAccessKey should be removed from Service Bus namespace",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Service Bus clients should not use a namespace level access policy that provides access to all queues and topics in a namespace. To align with the least privilege security model, you should create access policies at the entity level for queues and topics to provide access to only the specific entity",
    "metadata": {
      "version": "1.0.1",
      "category": "Service Bus"
    },
    "version": "1.0.1",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "The effect determines what happens when the policy rule is evaluated to match"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.ServiceBus/namespaces/authorizationRules"
          },
          {
            "field": "name",
            "notEquals": "RootManageSharedAccessKey"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.1"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/a1817ec0-a368-432a-8057-8371e17ac6ee",
  "name": "a1817ec0-a368-432a-8057-8371e17ac6ee"
}
Bylawa1817ec0-a368-432a-8057-8371e17ac6ee.bylaw.ps1 · 29 lines
# Converted from AuditNamespaceAccessRules_Audit.json by ConvertTo-Bylaw.
Policy 'a1817ec0-a368-432a-8057-8371e17ac6ee' {

    Properties @{
        DisplayName   = 'All authorization rules except RootManageSharedAccessKey should be removed from Service Bus namespace'
        Description   = 'Service Bus clients should not use a namespace level access policy that provides access to all queues and topics in a namespace. To align with the least privilege security model, you should create access policies at the entity level for queues and topics to provide access to only the specific entity'
        Version       = '1.0.1'
        Category      = 'Service Bus'
        PolicyVersion = '1.0.1'
        Mode          = 'All'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match'
    }

    Resource 'Microsoft.ServiceBus/namespaces/authorizationRules' {

        Require 'name is RootManageSharedAccessKey' {
            Field name | Must -Be 'RootManageSharedAccessKey'
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Service Bus/AuditNamespaceAccessRules_Audit.json in Azure/azure-policy, under the MIT licence.