Bylaw

Gallery › Security Center › Azure built-in policies

[Deprecated]: Web ports should be restricted on Network Security Groups associated to your VM

Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.0-deprecated Deprecated

Azure security center has discovered that some of your virtual machines are running web applications, and the NSGs associated to these virtual machines are overly permissive with regards to the web application ports

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

Azure Policy JSONASC_UnprotectedWebApps_Audit_deprecated.json · 56 lines
{
  "properties": {
    "displayName": "[Deprecated]: Web ports should be restricted on Network Security Groups associated to your VM",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Azure security center has discovered that some of your virtual machines are running web applications, and the NSGs associated to these virtual machines are overly permissive with regards to the web application ports",
    "metadata": {
      "version": "1.0.0-deprecated",
      "category": "Security Center",
      "deprecated": true
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Disabled",
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "in": [
          "Microsoft.Compute/virtualMachines",
          "Microsoft.ClassicCompute/virtualMachines"
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Security/complianceResults",
          "name": "unprotectedWebApplication",
          "existenceCondition": {
            "field": "Microsoft.Security/complianceResults/resourceStatus",
            "in": [
              "OffByPolicy",
              "Healthy"
            ]
          }
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/201ea587-7c90-41c3-910f-c280ae01cfd6",
  "name": "201ea587-7c90-41c3-910f-c280ae01cfd6"
}
Bylaw201ea587-7c90-41c3-910f-c280ae01cfd6.bylaw.ps1 · 34 lines
# Converted from ASC_UnprotectedWebApps_Audit_deprecated.json by ConvertTo-Bylaw.
Policy '201ea587-7c90-41c3-910f-c280ae01cfd6' {

    Properties @{
        DisplayName   = '[Deprecated]: Web ports should be restricted on Network Security Groups associated to your VM'
        Description   = 'Azure security center has discovered that some of your virtual machines are running web applications, and the NSGs associated to these virtual machines are overly permissive with regards to the web application ports'
        Version       = '1.0.0-deprecated'
        Category      = 'Security Center'
        Deprecated    = $true
        PolicyVersion = '1.0.0'
        Mode          = 'All'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('AuditIfNotExists', 'Disabled')
        Default       = 'Disabled'
        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.ClassicCompute/virtualMachines') -IfPresent
        }
    }

    AuditIfNotExists 'Microsoft.Security/complianceResults' -Name 'unprotectedWebApplication' -Effect (Param Effect) {
        Require 'resourceStatus is one of 2 values' {
            Field resourceStatus | Must -BeIn @('OffByPolicy', 'Healthy')
        }
    }
}

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