Gallery › Container Registry › Azure built-in policies
Container registries should not allow unrestricted network access
Converted Policy Audit Deny Disabled Mode Indexed Version 2.0.0
Azure container registries by default accept connections over the internet from hosts on any network. To protect your registries from potential threats, allow access from only specific private endpoints, public IP addresses or address ranges. If your registry doesn't have network rules configured, it will appear in the unhealthy resources. Learn more about Container Registry network rules here: https://aka.ms/acr/privatelink, https://aka.ms/acr/portal/public-network and https://aka.ms/acr/vnet.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
{
"properties": {
"displayName": "Container registries should not allow unrestricted network access",
"description": "Azure container registries by default accept connections over the internet from hosts on any network. To protect your registries from potential threats, allow access from only specific private endpoints, public IP addresses or address ranges. If your registry doesn't have network rules configured, it will appear in the unhealthy resources. Learn more about Container Registry network rules here: https://aka.ms/acr/privatelink, https://aka.ms/acr/portal/public-network and https://aka.ms/acr/vnet.",
"policyType": "BuiltIn",
"mode": "Indexed",
"metadata": {
"version": "2.0.0",
"category": "Container Registry"
},
"version": "2.0.0",
"parameters": {
"effect": {
"type": "String",
"defaultValue": "Audit",
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.ContainerRegistry/registries"
},
{
"allOf": [
{
"anyof": [
{
"field": "Microsoft.ContainerRegistry/registries/networkRuleSet.defaultAction",
"exists": "false"
},
{
"field": "Microsoft.ContainerRegistry/registries/networkRuleSet.defaultAction",
"equals": "Allow"
}
]
},
{
"anyof": [
{
"field": "Microsoft.ContainerRegistry/registries/publicNetworkAccess",
"exists": "false"
},
{
"field": "Microsoft.ContainerRegistry/registries/publicNetworkAccess",
"equals": "Enabled"
}
]
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"2.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/d0793b48-0edc-4296-a390-4c75d1bdfd71",
"name": "d0793b48-0edc-4296-a390-4c75d1bdfd71"
}# Converted from ACR_NetworkRulesExist_AuditDeny.json by ConvertTo-Bylaw.
Policy 'd0793b48-0edc-4296-a390-4c75d1bdfd71' {
Properties @{
DisplayName = 'Container registries should not allow unrestricted network access'
Description = 'Azure container registries by default accept connections over the internet from hosts on any network. To protect your registries from potential threats, allow access from only specific private endpoints, public IP addresses or address ranges. If your registry doesn''t have network rules configured, it will appear in the unhealthy resources. Learn more about Container Registry network rules here: https://aka.ms/acr/privatelink, https://aka.ms/acr/portal/public-network and https://aka.ms/acr/vnet.'
Version = '2.0.0'
Category = 'Container Registry'
PolicyVersion = '2.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.ContainerRegistry/registries' {
When {
AnyOf {
Field networkRuleSet.defaultAction | Must -Not -Exist
Field networkRuleSet.defaultAction | Must -Be 'Allow'
}
}
Require 'publicNetworkAccess exists' {
Field publicNetworkAccess | Must -Exist
}
Require 'publicNetworkAccess is not Enabled' {
Field publicNetworkAccess | Must -Not -Be 'Enabled' -IfPresent
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/Container Registry/ACR_NetworkRulesExist_AuditDeny.json in Azure/azure-policy, under the MIT licence.
Bylaw