Gallery › Kubernetes › Azure built-in policies
[Deprecated]: Kubernetes clusters should gate deployment of vulnerable images
Doesn't convert yet Policy Audit Deny Disabled Mode Microsoft.Kubernetes.Data Version 2.1.0-deprecated Deprecated
This policy definition is no longer the recommended way to achieve its intent. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.
ConvertTo-Bylaw can't convert this policy yet:
- BYL6002 Its mode, Microsoft.Kubernetes.Data, is a resource provider mode, which language version 1.0 doesn't support.
Azure Policy JSONBlockVulnerableImages.json · 221 lines
{
"properties": {
"displayName": "[Deprecated]: Kubernetes clusters should gate deployment of vulnerable images",
"policyType": "BuiltIn",
"mode": "Microsoft.Kubernetes.Data",
"description": "This policy definition is no longer the recommended way to achieve its intent. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.",
"metadata": {
"version": "2.1.0-deprecated",
"category": "Kubernetes",
"deprecated": true
},
"version": "2.1.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "'Audit' allows a non-compliant resource to be created or updated, but flags it as non-compliant. 'Deny' blocks the non-compliant resource creation or update. 'Disabled' turns off the policy.",
"portalReview": true
},
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"defaultValue": "Audit"
},
"excludedNamespaces": {
"type": "Array",
"metadata": {
"displayName": "Namespace exclusions",
"description": "List of Kubernetes namespaces to exclude from policy evaluation. System namespaces \"kube-system\", \"gatekeeper-system\" and \"azure-arc\" are always excluded by design. \"azure-extensions-usage-system\" is optional to remove."
},
"defaultValue": [
"kube-system",
"gatekeeper-system",
"azure-arc",
"azure-extensions-usage-system"
]
},
"namespaces": {
"type": "Array",
"metadata": {
"displayName": "Namespace inclusions",
"description": "List of Kubernetes namespaces the policy would apply to. An empty list means the policy is applied to all resources in all namespaces."
},
"defaultValue": []
},
"labelSelector": {
"type": "Object",
"metadata": {
"displayName": "Kubernetes label selector",
"description": "Label query to select Kubernetes resources for policy evaluation. An empty label selector matches all Kubernetes resources."
},
"defaultValue": {},
"schema": {
"description": "A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all resources.",
"type": "object",
"properties": {
"matchLabels": {
"description": "matchLabels is a map of {key,value} pairs.",
"type": "object",
"additionalProperties": {
"type": "string"
},
"minProperties": 1
},
"matchExpressions": {
"description": "matchExpressions is a list of values, a key, and an operator.",
"type": "array",
"items": {
"type": "object",
"properties": {
"key": {
"description": "key is the label key that the selector applies to.",
"type": "string"
},
"operator": {
"description": "operator represents a key's relationship to a set of values.",
"type": "string",
"enum": [
"In",
"NotIn",
"Exists",
"DoesNotExist"
]
},
"values": {
"description": "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty.",
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"key",
"operator"
],
"additionalProperties": false
},
"minItems": 1
}
},
"additionalProperties": false
}
},
"excludedImages": {
"type": "Array",
"metadata": {
"displayName": "Excluded images regex",
"description": "A list of RegEx rules used to exclude container images from policy evaluation. For example: exclude all images from the repo microsoft-defender-in-cluster-defense-repo in the blockreg ACR - [\"(blockreg.azurecr.io/microsoft-defender-in-cluster-defense-repo).*\"]. Use an empty list to apply this policy to all container images.",
"portalReview": true
},
"defaultValue": []
},
"severityThresholdForExcludingNotPatchableFindings": {
"type": "string",
"metadata": {
"displayName": "Severity threshold for excluding vulnerabilities without a patch",
"description": "Specify the maximum severity for exempting vulnerabilities without a patch. For example, specify Medium to ignore Low and Medium vulnerabilities without a patch.",
"portalReview": true
},
"allowedValues": [
"None",
"Low",
"Medium",
"High"
],
"defaultValue": "None"
},
"excludeFindingIDs": {
"type": "Array",
"metadata": {
"displayName": "Exclude findings IDs",
"description": "A list of finding IDs that the policy should exempt.",
"portalReview": true
},
"defaultValue": []
},
"severity": {
"type": "Object",
"metadata": {
"displayName": "Severity threshold",
"description": "The number of allowed findings per severity for an image. e.g. \"{\"High\":0,\"Medium\":3,\"Low\":10}\"",
"portalReview": true
},
"defaultValue": {
"High": 0,
"Medium": 0,
"Low": 0
},
"schema": {
"type": "object",
"properties": {
"High": {
"type": "integer"
},
"Medium": {
"type": "integer"
},
"Low": {
"type": "integer"
}
},
"required": [
"High",
"Medium",
"Low"
],
"additionalProperties": false
}
}
},
"policyRule": {
"if": {
"field": "type",
"in": [
"Microsoft.ContainerService/managedClusters"
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"templateInfo": {
"sourceType": "PublicURL",
"url": "https://store.policy.core.windows.net/kubernetes/container-no-vulnerable-images/v1/template.yaml"
},
"apiGroups": [
"",
"apps"
],
"kinds": [
"Pod",
"Deployment",
"ReplicaSet",
"StatefulSet",
"DaemonSet",
"Job",
"CronJob",
"ReplicationController"
],
"excludedNamespaces": "[parameters('excludedNamespaces')]",
"namespaces": "[parameters('namespaces')]",
"labelSelector": "[parameters('labelSelector')]",
"values": {
"excludedImages": "[parameters('excludedImages')]",
"severityThresholdForExcludingNotPatchableFindings": "[parameters('severityThresholdForExcludingNotPatchableFindings')]",
"excludeFindingIDs": "[parameters('excludeFindingIDs')]",
"severity": "[parameters('severity')]"
}
}
}
},
"versions": [
"2.1.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/13cd7ae3-5bc0-4ac4-a62d-4f7c120b9759",
"name": "13cd7ae3-5bc0-4ac4-a62d-4f7c120b9759"
}Source: built-in-policies/policyDefinitions/Kubernetes/BlockVulnerableImages.json in Azure/azure-policy, under the MIT licence.
Bylaw