Bylaw

Gallery › Security Center › Azure built-in policies

Management ports of virtual machines should be protected with just-in-time network access control

Converted Policy AuditIfNotExists Disabled Mode All Version 3.0.0

Possible network Just In Time (JIT) access will be monitored by Azure Security Center as recommendations

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

Azure Policy JSONASC_JITNetworkAccess_Audit.json · 52 lines
{
  "properties": {
    "displayName": "Management ports of virtual machines should be protected with just-in-time network access control",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Possible network Just In Time (JIT) access will be monitored by Azure Security Center as recommendations",
    "metadata": {
      "version": "3.0.0",
      "category": "Security Center"
    },
    "version": "3.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",
        "equals": "Microsoft.Compute/virtualMachines"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/assessments",
          "name": "805651bc-6ecd-4c73-9b55-97a19d0582d0",
          "existenceCondition": {
            "field": "Microsoft.Security/assessments/status.code",
            "in": [
              "NotApplicable",
              "Healthy"
            ]
          }
        }
      }
    },
    "versions": [
      "3.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/b0f33259-77d7-4c9e-aac6-3aabcfae693c",
  "name": "b0f33259-77d7-4c9e-aac6-3aabcfae693c"
}
Bylawb0f33259-77d7-4c9e-aac6-3aabcfae693c.bylaw.ps1 · 28 lines
# Converted from ASC_JITNetworkAccess_Audit.json by ConvertTo-Bylaw.
Policy 'b0f33259-77d7-4c9e-aac6-3aabcfae693c' {

    Properties @{
        DisplayName   = 'Management ports of virtual machines should be protected with just-in-time network access control'
        Description   = 'Possible network Just In Time (JIT) access will be monitored by Azure Security Center as recommendations'
        Version       = '3.0.0'
        Category      = 'Security Center'
        PolicyVersion = '3.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 'Microsoft.Compute/virtualMachines'

    AuditIfNotExists 'Microsoft.Security/assessments' -Name '805651bc-6ecd-4c73-9b55-97a19d0582d0' -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_JITNetworkAccess_Audit.json in Azure/azure-policy, under the MIT licence.