I do have applied the built-in Azure Policy Key Vault keys should have an expiration date with a Subscription first and Resource Group scope then. The policy has Audit effect. I have created a new key in Key Vault without an expiration date. Microsoft Defender for Cloud though does not shows any non-compliant warning here. Do I have to upgrade its plan, or maybe apply the policy Microsoft Defender for Key Vault should be enabled as well? But also in the Policy page I see this policy is defined and assigned but it shows to be Compliant, when it should not be! Actually it shows 0 resources compliant and 0 resources non-compliant. Also this is strange, it is like it is not applied at all.
This is the Azure policy:
{
"properties": {
"displayName": "Key Vault keys should have an expiration date",
"policyType": "BuiltIn",
"mode": "Microsoft.KeyVault.Data",
"description": "Cryptographic keys should have a defined expiration date and not be permanent. Keys that are valid forever provide a potential attacker with more time to compromise the key. It is a recommended security practice to set expiration dates on cryptographic keys.",
"metadata": {
"version": "1.0.2",
"category": "Key Vault"
},
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "'Audit' allows a non-compliant resource to be created, but flags it as non-compliant. 'Deny' blocks the resource creation. 'Disable' turns off the policy."
},
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.KeyVault.Data/vaults/keys"
},
{
"field": "Microsoft.KeyVault.Data/vaults/keys/attributes.expiresOn",
"exists": false
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/152b15f7-8e1f-4c1f-ab71-8c010ba5dbc0",
"type": "Microsoft.Authorization/policyDefinitions",
"name": "152b15f7-8e1f-4c1f-ab71-8c010ba5dbc0"
}