Gallery › Network › Azure Community Policy
deny-new-security-rules-with-source-any-adding-to-existing-nsgs
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
need to add description
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 65 lines
{
"name": "53dd9c12-ee3e-4f5e-b817-e5613fc25c30",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "deny-new-security-rules-with-source-any-adding-to-existing-nsgs",
"description": "need to add description",
"metadata": {
"version": "1.0.0",
"category": "Network"
},
"mode": "All",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Deny, Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Deny",
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/networkSecurityGroups/securityRules"
},
{
"field": "Microsoft.Network/networkSecurityGroups/securityRules/access",
"equals": "Allow"
},
{
"field": "Microsoft.Network/networkSecurityGroups/securityRules/direction",
"equals": "Inbound"
},
{
"field": "Microsoft.Network/networkSecurityGroups/securityRules/sourceAddressPrefix",
"in": [
"*",
"Internet"
]
},
{
"not": {
"field": "Microsoft.Network/networkSecurityGroups/securityRules/sourceAddressPrefixes[*]",
"in": [
"*",
"Internet"
]
}
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw53dd9c12-ee3e-4f5e-b817-e5613fc25c30.bylaw.ps1 · 39 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '53dd9c12-ee3e-4f5e-b817-e5613fc25c30' {
Properties @{
DisplayName = 'deny-new-security-rules-with-source-any-adding-to-existing-nsgs'
Description = 'need to add description'
Version = '1.0.0'
Category = 'Network'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.Network/networkSecurityGroups/securityRules' {
When {
Field access | Must -Be 'Allow'
Field direction | Must -Be 'Inbound'
Field sourceAddressPrefix | Must -BeIn @('*', 'Internet')
}
Require 'sourceAddressPrefixes exists' {
Field sourceAddressPrefixes | Must -Exist
}
Require 'sourceAddressPrefixes is as required' {
Each 'sourceAddressPrefixes[*]' {
Element | Must -BeIn @('*', 'Internet')
}
}
}
Effect (Param Effect)
}Source: policyDefinitions/Network/deny-new-security-rules-with-source-any-adding-to-existing-nsgs/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw