Gallery › General › Azure built-in policies
Audit usage of custom RBAC roles
Converted Policy Audit Disabled Mode All Version 1.0.1
Audit built-in roles such as 'Owner, Contributer, Reader' instead of custom RBAC roles, which are error prone. Using custom roles is treated as an exception and requires a rigorous review and threat modeling
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONSubscription_AuditCustomRBACRoles_Audit.json · 49 lines
{
"properties": {
"displayName": "Audit usage of custom RBAC roles",
"policyType": "BuiltIn",
"mode": "All",
"description": "Audit built-in roles such as 'Owner, Contributer, Reader' instead of custom RBAC roles, which are error prone. Using custom roles is treated as an exception and requires a rigorous review and threat modeling",
"metadata": {
"version": "1.0.1",
"category": "General"
},
"version": "1.0.1",
"parameters": {
"effect": {
"type": "string",
"defaultValue": "Audit",
"allowedValues": [
"Audit",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Authorization/roleDefinitions"
},
{
"field": "Microsoft.Authorization/roleDefinitions/type",
"equals": "CustomRole"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.1"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/a451c1ef-c6ca-483d-87ed-f49761e3ffb5",
"name": "a451c1ef-c6ca-483d-87ed-f49761e3ffb5"
}Bylawa451c1ef-c6ca-483d-87ed-f49761e3ffb5.bylaw.ps1 · 29 lines
# Converted from Subscription_AuditCustomRBACRoles_Audit.json by ConvertTo-Bylaw.
Policy 'a451c1ef-c6ca-483d-87ed-f49761e3ffb5' {
Properties @{
DisplayName = 'Audit usage of custom RBAC roles'
Description = 'Audit built-in roles such as ''Owner, Contributer, Reader'' instead of custom RBAC roles, which are error prone. Using custom roles is treated as an exception and requires a rigorous review and threat modeling'
Version = '1.0.1'
Category = 'General'
PolicyVersion = '1.0.1'
Mode = 'All'
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Authorization/roleDefinitions' {
Require 'type is not CustomRole' {
Field 'Microsoft.Authorization/roleDefinitions/type' | Must -Not -Be 'CustomRole' -IfPresent
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/General/Subscription_AuditCustomRBACRoles_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw