Gallery › Mission › Azure built-in policies
App Service app slots should restrict slot access rules to specified sources in Mission Platform products and services
Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0
This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. Restrict Slot Access Rules to Specified Sources.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONAppRestrictSlotAccessRules_Audit.json · 130 lines
{
"properties": {
"displayName": "App Service app slots should restrict slot access rules to specified sources in Mission Platform products and services",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. Restrict Slot Access Rules to Specified Sources.",
"metadata": {
"version": "1.0.0",
"category": "Mission"
},
"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"
},
"allowedServiceTags": {
"type": "Array",
"metadata": {
"displayName": "Allowed Service Tags",
"description": " List of allowed Service Tags."
},
"defaultValue": []
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Web/sites/slots"
},
{
"anyOf": [
{
"count": {
"field": "Microsoft.Web/sites/slots/siteConfig.ipSecurityRestrictions[*]",
"where": {
"not": {
"anyOf": [
{
"allOf": [
{
"value": "[current('Microsoft.Web/sites/slots/siteConfig.ipSecurityRestrictions[*].tag')]",
"equals": "ServiceTag"
},
{
"value": "[current('Microsoft.Web/sites/slots/siteConfig.ipSecurityRestrictions[*].ipAddress')]",
"in": "[parameters('allowedServiceTags')]"
}
]
},
{
"allOf": [
{
"value": "[current('Microsoft.Web/sites/slots/siteConfig.ipSecurityRestrictions[*].Action')]",
"equals": "Deny"
},
{
"value": "[current('Microsoft.Web/sites/slots/siteConfig.ipSecurityRestrictions[*].ipAddress')]",
"equals": "Any"
}
]
}
]
}
}
},
"greater": 0
},
{
"count": {
"field": "Microsoft.Web/sites/slots/siteConfig.scmIpSecurityRestrictions[*]",
"where": {
"not": {
"anyOf": [
{
"allOf": [
{
"value": "[current('Microsoft.Web/sites/slots/siteConfig.scmIpSecurityRestrictions[*].tag')]",
"equals": "ServiceTag"
},
{
"value": "[current('Microsoft.Web/sites/slots/siteConfig.scmIpSecurityRestrictions[*].ipAddress')]",
"in": "[parameters('allowedServiceTags')]"
}
]
},
{
"allOf": [
{
"value": "[current('Microsoft.Web/sites/slots/siteConfig.scmIpSecurityRestrictions[*].Action')]",
"equals": "Deny"
},
{
"value": "[current('Microsoft.Web/sites/slots/siteConfig.scmIpSecurityRestrictions[*].ipAddress')]",
"equals": "Any"
}
]
}
]
}
}
},
"greater": 0
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/86bd411a-a3c4-45a5-9af5-e365febff482",
"name": "86bd411a-a3c4-45a5-9af5-e365febff482"
}Bylaw86bd411a-a3c4-45a5-9af5-e365febff482.bylaw.ps1 · 56 lines
# Converted from AppRestrictSlotAccessRules_Audit.json by ConvertTo-Bylaw.
Policy '86bd411a-a3c4-45a5-9af5-e365febff482' {
Properties @{
DisplayName = 'App Service app slots should restrict slot access rules to specified sources in Mission Platform products and services'
Description = 'This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. Restrict Slot Access Rules to Specified Sources.'
Version = '1.0.0'
Category = 'Mission'
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'
}
Parameter AllowedServiceTags @{
Type = 'Array'
Default = @()
DisplayName = 'Allowed Service Tags'
Description = ' List of allowed Service Tags.'
}
Resource 'Microsoft.Web/sites/slots' {
Require 'siteConfig.ipSecurityRestrictions is as required' {
Count 'siteConfig.ipSecurityRestrictions[*]' -Where {
AnyOf {
Arm '[current(''Microsoft.Web/sites/slots/siteConfig.ipSecurityRestrictions[*].tag'')]' | Must -Not -Be 'ServiceTag'
Arm '[current(''Microsoft.Web/sites/slots/siteConfig.ipSecurityRestrictions[*].ipAddress'')]' | Must -Not -BeIn (Param AllowedServiceTags)
}
AnyOf {
Arm '[current(''Microsoft.Web/sites/slots/siteConfig.ipSecurityRestrictions[*].Action'')]' | Must -Not -Be 'Deny'
Arm '[current(''Microsoft.Web/sites/slots/siteConfig.ipSecurityRestrictions[*].ipAddress'')]' | Must -Not -Be 'Any'
}
} | Must -Be 0
}
Require 'siteConfig.scmIpSecurityRestrictions is as required' {
Count 'siteConfig.scmIpSecurityRestrictions[*]' -Where {
AnyOf {
Arm '[current(''Microsoft.Web/sites/slots/siteConfig.scmIpSecurityRestrictions[*].tag'')]' | Must -Not -Be 'ServiceTag'
Arm '[current(''Microsoft.Web/sites/slots/siteConfig.scmIpSecurityRestrictions[*].ipAddress'')]' | Must -Not -BeIn (Param AllowedServiceTags)
}
AnyOf {
Arm '[current(''Microsoft.Web/sites/slots/siteConfig.scmIpSecurityRestrictions[*].Action'')]' | Must -Not -Be 'Deny'
Arm '[current(''Microsoft.Web/sites/slots/siteConfig.scmIpSecurityRestrictions[*].ipAddress'')]' | Must -Not -Be 'Any'
}
} | Must -Be 0
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/Mission/AppRestrictSlotAccessRules_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw