我正在根据我的要求创建自定义策略,我想要定义策略,其中“所有网络端口都应限制在仅具有dev标签的网络安全组上”。
错误:无法解析策略规则:“在“LeafExpressionDefinition”类型的对象上找不到成员“退出”。路径“退出”。
azure 策略定义中存在两个内置策略:
所有网络端口都应限制在与您的虚拟机关联的网络安全组上。链接https://portal.azure.com/#blade/Microsoft_Azure_Policy/PolicyDetailBlade/definitionId/%2fproviders%2fMicrosoft.Authorization%2fpolicyDefinitions%2f9daedab3-fb2d-461e-b861-71790eead4f6
我结合并更新了我的要求,您可以检查创建的自定义策略,我认为一切正常。
{
"properties": {
"displayName": "All network ports should be restricted on network security groups associated to your virtual machine",
"policyType":"Indexed",
"mode": "All",
"description": "Azure Security Center has identified some of your network security groups' inbound rules to be too permissive. Inbound rules should not allow access from 'Any' or 'Internet' ranges. This can potentially enable attackers to target your resources.",
"metadata": {
"version": "3.0.0",
"category": "Security Center"
},
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "AuditIfNotExists"
},
"tagName": {
"type": "String",
"metadata": {
"displayName": "dev",
"description": "Name of the tag, such as 'develpment'"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field":"Microsoft.Network/networkInterfaces/networkSecurityGroup.id",
"exits": "true"
},
{
"field": "[concat('tags[', parameters('dev'), ']')]",
"Equals": "[parameters('tagValue')]"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Security/assessments",
"name": "3b20e985-f71f-483b-b078-f30d73936d43",
"existenceCondition": {
"field": "Microsoft.Security/assessments/status.code",
"in": [
"NotApplicable",
"Healthy"
]
}
}
}
}
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/9daedab3-fb2d-461e-b861-71790eead4f6",
"type": "Microsoft.Authorization/policyDefinitions",
"name": "9daedab3-fb2d-461e-b861-71790eead4f6"
}