Bylaw

Gallery › Security Center › Azure built-in policies

System updates should be installed on your machines (powered by Update Center)

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.1

Your machines are missing system, security, and critical updates. Software updates often include critical patches to security holes. Such holes are frequently exploited in malware attacks so it's vital to keep your software updated. To install all outstanding patches and secure your machines, follow the remediation steps.

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

Azure Policy JSONASC_MissingSystemUpdatesV2_Audit.json · 56 lines
{
  "properties": {
    "displayName": "System updates should be installed on your machines (powered by Update Center)",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Your machines are missing system, security, and critical updates. Software updates often include critical patches to security holes. Such holes are frequently exploited in malware attacks so it's vital to keep your software updated. To install all outstanding patches and secure your machines, follow the remediation steps.",
    "metadata": {
      "version": "1.0.1",
      "category": "Security Center"
    },
    "version": "1.0.1",
    "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.Compute/virtualMachines",
          "Microsoft.HybridCompute/machines"
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/assessments",
          "name": "e1145ab1-eb4f-43d8-911b-36ddf771d13f",
          "existenceCondition": {
            "field": "Microsoft.Security/assessments/status.code",
            "in": [
              "NotApplicable",
              "Healthy"
            ]
          }
        }
      }
    },
    "versions": [
      "1.0.1",
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/f85bf3e0-d513-442e-89c3-1784ad63382b",
  "name": "f85bf3e0-d513-442e-89c3-1784ad63382b"
}
Bylawf85bf3e0-d513-442e-89c3-1784ad63382b.bylaw.ps1 · 33 lines
# Converted from ASC_MissingSystemUpdatesV2_Audit.json by ConvertTo-Bylaw.
Policy 'f85bf3e0-d513-442e-89c3-1784ad63382b' {

    Properties @{
        DisplayName   = 'System updates should be installed on your machines (powered by Update Center)'
        Description   = 'Your machines are missing system, security, and critical updates. Software updates often include critical patches to security holes. Such holes are frequently exploited in malware attacks so it''s vital to keep your software updated. To install all outstanding patches and secure your machines, follow the remediation steps.'
        Version       = '1.0.1'
        Category      = 'Security Center'
        PolicyVersion = '1.0.1'
        Mode          = 'Indexed'
    }

    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 2 values' {
            Field type | Must -Not -BeIn @('Microsoft.Compute/virtualMachines', 'Microsoft.HybridCompute/machines') -IfPresent
        }
    }

    AuditIfNotExists 'Microsoft.Security/assessments' -Name 'e1145ab1-eb4f-43d8-911b-36ddf771d13f' -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_MissingSystemUpdatesV2_Audit.json in Azure/azure-policy, under the MIT licence.