Bylaw

Gallery › Security Center › Azure built-in policies

[Deprecated]: Pod Security Policies should be defined on Kubernetes Services

Converted Policy Audit Disabled Mode All Version 1.0.0-deprecated Deprecated

Define Pod Security Policies to reduce the attack vector by removing unnecessary application privileges. It is recommended to configure Pod Security Policies to only allow pods to access the resources which they have permissions to access.

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONASC_EnablePSP_KubernetesService_Audit_Deprecated.json · 58 lines
{
  "properties": {
    "displayName": "[Deprecated]: Pod Security Policies should be defined on Kubernetes Services",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Define Pod Security Policies to reduce the attack vector by removing unnecessary application privileges. It is recommended to configure Pod Security Policies to only allow pods to access the resources which they have permissions to access.",
    "metadata": {
      "version": "1.0.0-deprecated",
      "category": "Security Center",
      "deprecated": true
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Disabled",
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.ContainerService/managedClusters"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.ContainerService/managedClusters/enablePodSecurityPolicy",
                "exists": "false"
              },
              {
                "field": "Microsoft.ContainerService/managedClusters/enablePodSecurityPolicy",
                "equals": "false"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/3abeb944-26af-43ee-b83d-32aaf060fb94",
  "name": "3abeb944-26af-43ee-b83d-32aaf060fb94"
}
Bylaw3abeb944-26af-43ee-b83d-32aaf060fb94.bylaw.ps1 · 34 lines
# Converted from ASC_EnablePSP_KubernetesService_Audit_Deprecated.json by ConvertTo-Bylaw.
Policy '3abeb944-26af-43ee-b83d-32aaf060fb94' {

    Properties @{
        DisplayName   = '[Deprecated]: Pod Security Policies should be defined on Kubernetes Services'
        Description   = 'Define Pod Security Policies to reduce the attack vector by removing unnecessary application privileges. It is recommended to configure Pod Security Policies to only allow pods to access the resources which they have permissions to access.'
        Version       = '1.0.0-deprecated'
        Category      = 'Security Center'
        Deprecated    = $true
        PolicyVersion = '1.0.0'
        Mode          = 'All'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('Audit', 'Disabled')
        Default       = 'Disabled'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.ContainerService/managedClusters' {

        Require 'enablePodSecurityPolicy exists' {
            Field enablePodSecurityPolicy | Must -Exist
        }

        Require 'enablePodSecurityPolicy is not false' {
            Field enablePodSecurityPolicy | Must -Not -Be 'false' -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Security Center/ASC_EnablePSP_KubernetesService_Audit_Deprecated.json in Azure/azure-policy, under the MIT licence.