Bylaw

Gallery › Security Center › Azure built-in policies

[Deprecated]: Operating system version should be the most current version for your cloud service roles

Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.0-deprecated Deprecated

Keeping the operating system (OS) on the most recent supported version for your cloud service roles enhances the systems security posture.

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

Azure Policy JSONASC_UpdateOsVersion.json · 55 lines
{
  "properties": {
    "displayName": "[Deprecated]: Operating system version should be the most current version for your cloud service roles",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Keeping the operating system (OS) on the most recent supported version for your cloud service roles enhances the systems security posture.",
    "metadata": {
      "version": "1.0.0-deprecated",
      "category": "Security Center",
      "deprecated": true
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "AuditIfNotExists",
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "in": [
          "Microsoft.ClassicCompute/domainNames/slots/roles"
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/assessments",
          "name": "8bc390da-9eb6-938d-25ed-44a35d9bcc9d",
          "existenceCondition": {
            "field": "Microsoft.Security/assessments/status.code",
            "in": [
              "NotApplicable",
              "Healthy"
            ]
          }
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/5a913c68-0590-402c-a531-e57e19379da3",
  "name": "5a913c68-0590-402c-a531-e57e19379da3"
}
Bylaw5a913c68-0590-402c-a531-e57e19379da3.bylaw.ps1 · 34 lines
# Converted from ASC_UpdateOsVersion.json by ConvertTo-Bylaw.
Policy '5a913c68-0590-402c-a531-e57e19379da3' {

    Properties @{
        DisplayName   = '[Deprecated]: Operating system version should be the most current version for your cloud service roles'
        Description   = 'Keeping the operating system (OS) on the most recent supported version for your cloud service roles enhances the systems security posture.'
        Version       = '1.0.0-deprecated'
        Category      = 'Security Center'
        Deprecated    = $true
        PolicyVersion = '1.0.0'
        Mode          = 'All'
    }

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

    Resource * {

        Require 'type is not one of 1 value' {
            Field type | Must -Not -BeIn @('Microsoft.ClassicCompute/domainNames/slots/roles') -IfPresent
        }
    }

    AuditIfNotExists 'Microsoft.Security/assessments' -Name '8bc390da-9eb6-938d-25ed-44a35d9bcc9d' -Effect (Param Effect) {
        Require 'status.code is one of 2 values' {
            Field status.code | Must -BeIn @('NotApplicable', 'Healthy')
        }
    }
}

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