Bylaw

Gallery › Storage › Azure Landing Zones Library

Allowed Copy scope should be restricted for Storage Accounts

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

Azure Storage accounts should restrict the allowed copy scope. Enforce this for increased data exfiltration protection.

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

Azure Policy JSONDeny-Storage-CopyScope.alz_policy_definition.json · 72 lines
{
  "name": "Deny-Storage-CopyScope",
  "properties": {
    "description": "Azure Storage accounts should restrict the allowed copy scope. Enforce this for increased data exfiltration protection.",
    "displayName": "Allowed Copy scope should be restricted for Storage Accounts",
    "metadata": {
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ],
      "category": "Storage",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "version": "1.0.0"
    },
    "mode": "All",
    "parameters": {
      "allowedCopyScope": {
        "allowedValues": [
          "AAD",
          "PrivateLink"
        ],
        "defaultValue": "AAD",
        "metadata": {
          "description": "Specify the allowed copy scope.",
          "displayName": "Allowed Copy Scope"
        },
        "type": "String"
      },
      "effect": {
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny",
        "metadata": {
          "description": "Enable or disable the execution of the policy",
          "displayName": "Effect"
        },
        "type": "String"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "equals": "Microsoft.Storage/storageAccounts",
            "field": "type"
          },
          {
            "anyOf": [
              {
                "exists": "false",
                "field": "Microsoft.Storage/storageAccounts/allowedCopyScope"
              },
              {
                "field": "Microsoft.Storage/storageAccounts/allowedCopyScope",
                "notEquals": "[parameters('allowedCopyScope')]"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawDeny-Storage-CopyScope.bylaw.ps1 · 38 lines
# Converted from Deny-Storage-CopyScope.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Deny-Storage-CopyScope' {

    Properties @{
        DisplayName = 'Allowed Copy scope should be restricted for Storage Accounts'
        Description = 'Azure Storage accounts should restrict the allowed copy scope. Enforce this for increased data exfiltration protection.'
        Category    = 'Storage'
        Version     = '1.0.0'
        Mode        = 'All'
        Metadata    = [ordered]@{ alzCloudEnvironments = @('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment'); source = 'https://github.com/Azure/Enterprise-Scale/' }
    }

    Parameter AllowedCopyScope @{
        AllowedValues = @('AAD', 'PrivateLink')
        Default       = 'AAD'
        DisplayName   = 'Allowed Copy Scope'
        Description   = 'Specify the allowed copy scope.'
    }
    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Deny'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.Storage/storageAccounts' {

        Require 'allowedCopyScope exists' {
            Field allowedCopyScope | Must -Exist
        }

        Require 'allowedCopyScope is the AllowedCopyScope parameter' {
            Field allowedCopyScope | Must -Be (Param AllowedCopyScope)
        }
    }

    Effect (Param Effect)
}

Source: policy_definitions/Deny-Storage-CopyScope.alz_policy_definition.json in Azure/Azure-Landing-Zones-Library, under the MIT licence.