Gallery › Security Center › Azure built-in policies
Configure supported Linux virtual machines to automatically enable Secure Boot
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 5.1.0
Configure supported Linux virtual machines to automatically enable Secure Boot to mitigate against malicious and unauthorized changes to the boot chain. Once enabled, only trusted bootloaders, kernel and kernel drivers will be allowed to run.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONASC_EnableLinuxSB_DINE.json · 122 lines
{
"properties": {
"displayName": "Configure supported Linux virtual machines to automatically enable Secure Boot",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Configure supported Linux virtual machines to automatically enable Secure Boot to mitigate against malicious and unauthorized changes to the boot chain. Once enabled, only trusted bootloaders, kernel and kernel drivers will be allowed to run.",
"metadata": {
"category": "Security Center",
"version": "5.1.0"
},
"version": "5.1.0",
"parameters": {
"effect": {
"type": "string",
"defaultValue": "DeployIfNotExists",
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Compute/virtualMachines"
},
{
"anyOf": [
{
"field": "Microsoft.Compute/virtualMachines/storageProfile.osDisk.osType",
"like": "Linux*"
},
{
"field": "Microsoft.Compute/virtualMachines/osProfile.linuxConfiguration",
"exists": "true"
}
]
},
{
"field": "Microsoft.Compute/virtualMachines/securityProfile.securityType",
"equals": "TrustedLaunch"
},
{
"field": "Microsoft.Compute/virtualMachines/securityProfile.uefiSettings",
"exists": "true"
},
{
"field": "Microsoft.Compute/virtualMachines/securityProfile.uefiSettings.secureBootEnabled",
"notEquals": "true"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Compute/virtualMachines",
"name": "[field('fullName')]",
"existenceCondition": {
"field": "Microsoft.Compute/virtualMachines/securityProfile.uefiSettings.secureBootEnabled",
"equals": "true"
},
"roleDefinitionIds": [
"/providers/microsoft.authorization/roleDefinitions/9980e02c-c2be-4d73-94e8-173b1dc7cf3c"
],
"deployment": {
"properties": {
"mode": "incremental",
"parameters": {
"vmName": {
"value": "[field('name')]"
},
"location": {
"value": "[field('location')]"
}
},
"template": {
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string"
},
"location": {
"type": "string"
}
},
"resources": [
{
"name": "[parameters('vmName')]",
"location": "[parameters('location')]",
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2020-12-01",
"properties": {
"securityProfile": {
"uefiSettings": {
"secureBootEnabled": "true"
},
"securityType": "TrustedLaunch"
}
}
}
]
}
}
}
}
}
},
"versions": [
"5.1.0",
"5.0.0-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/95406fc3-1f69-47b0-8105-4c03b276ec5c",
"name": "95406fc3-1f69-47b0-8105-4c03b276ec5c"
}Bylaw95406fc3-1f69-47b0-8105-4c03b276ec5c.bylaw.ps1 · 46 lines
# Converted from ASC_EnableLinuxSB_DINE.json by ConvertTo-Bylaw.
Policy '95406fc3-1f69-47b0-8105-4c03b276ec5c' {
Properties @{
DisplayName = 'Configure supported Linux virtual machines to automatically enable Secure Boot'
Description = 'Configure supported Linux virtual machines to automatically enable Secure Boot to mitigate against malicious and unauthorized changes to the boot chain. Once enabled, only trusted bootloaders, kernel and kernel drivers will be allowed to run.'
Category = 'Security Center'
Version = '5.1.0'
PolicyVersion = '5.1.0'
Mode = 'Indexed'
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Compute/virtualMachines' {
When {
AnyOf {
Field storageProfile.osDisk.osType | Must -BeLike 'Linux*'
Field osProfile.linuxConfiguration | Must -Exist
}
Field securityProfile.securityType | Must -Be 'TrustedLaunch'
Field securityProfile.uefiSettings | Must -Exist
}
Require 'securityProfile.uefiSettings.secureBootEnabled is true' {
Field securityProfile.uefiSettings.secureBootEnabled | Must -Be 'true'
}
}
DeployIfNotExists 'Microsoft.Compute/virtualMachines' -Role 'Virtual Machine Contributor' -Name (Arm '[field(''fullName'')]') -Effect (Param Effect) {
Require 'securityProfile.uefiSettings.secureBootEnabled is true' {
Field securityProfile.uefiSettings.secureBootEnabled | Must -Be 'true'
}
Deployment -TemplateFile './templates/95406fc3-1f69-47b0-8105-4c03b276ec5c.json' -Parameters ([ordered]@{
vmName = (Arm '[field(''name'')]')
location = (Arm '[field(''location'')]')
})
}
}Its deployment templates are written beside it:
templates/95406fc3-1f69-47b0-8105-4c03b276ec5c.json
Source: built-in-policies/policyDefinitions/Security Center/ASC_EnableLinuxSB_DINE.json in Azure/azure-policy, under the MIT licence.
Bylaw