Bylaw

Gallery › Security Center › Azure built-in policies

Linux virtual machines should use Secure Boot

Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.1

To protect against the installation of malware-based rootkits and boot kits, enable Secure Boot on supported Linux virtual machines. Secure Boot ensures that only signed operating systems and drivers will be allowed to run. This assessment only applies to Linux virtual machines that have the Azure Monitor Agent installed.

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

Azure Policy JSONASC_EnableSecureBootOnLinuxVM_Audit.json · 65 lines
{
  "properties": {
    "displayName": "Linux virtual machines should use Secure Boot",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "To protect against the installation of malware-based rootkits and boot kits, enable Secure Boot on supported Linux virtual machines. Secure Boot ensures that only signed operating systems and drivers will be allowed to run. This assessment only applies to Linux virtual machines that have the Azure Monitor Agent installed.",
    "metadata": {
      "category": "Security Center",
      "version": "1.0.1"
    },
    "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": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Compute/virtualMachines/extensions"
          },
          {
            "field": "Microsoft.Compute/virtualMachines/extensions/type",
            "equals": "AzureSecurityLinuxAgent"
          },
          {
            "field": "Microsoft.Compute/virtualMachines/extensions/publisher",
            "equals": "Microsoft.Azure.Security.Monitoring"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/assessments",
          "name": "0396b18c-41aa-489c-affd-4ee5d1714a59",
          "existenceCondition": {
            "field": "Microsoft.Security/assessments/status.code",
            "in": [
              "NotApplicable",
              "Healthy"
            ]
          }
        }
      }
    },
    "versions": [
      "1.0.1",
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/b1bb3592-47b8-4150-8db0-bfdcc2c8965b",
  "name": "b1bb3592-47b8-4150-8db0-bfdcc2c8965b"
}
Bylawb1bb3592-47b8-4150-8db0-bfdcc2c8965b.bylaw.ps1 · 37 lines
# Converted from ASC_EnableSecureBootOnLinuxVM_Audit.json by ConvertTo-Bylaw.
Policy 'b1bb3592-47b8-4150-8db0-bfdcc2c8965b' {

    Properties @{
        DisplayName   = 'Linux virtual machines should use Secure Boot'
        Description   = 'To protect against the installation of malware-based rootkits and boot kits, enable Secure Boot on supported Linux virtual machines. Secure Boot ensures that only signed operating systems and drivers will be allowed to run. This assessment only applies to Linux virtual machines that have the Azure Monitor Agent installed.'
        Category      = 'Security Center'
        Version       = '1.0.1'
        PolicyVersion = '1.0.1'
        Mode          = 'All'
    }

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

    Resource 'Microsoft.Compute/virtualMachines/extensions' {

        When {
            Field 'Microsoft.Compute/virtualMachines/extensions/type' | Must -Be 'AzureSecurityLinuxAgent'
        }

        Require 'publisher is not Microsoft.Azure.Security.Monitoring' {
            Field publisher | Must -Not -Be 'Microsoft.Azure.Security.Monitoring' -IfPresent
        }
    }

    AuditIfNotExists 'Microsoft.Security/assessments' -Name '0396b18c-41aa-489c-affd-4ee5d1714a59' -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_EnableSecureBootOnLinuxVM_Audit.json in Azure/azure-policy, under the MIT licence.