Bylaw

Gallery › Storage › Azure built-in policies

Encryption in transit should be required for Azure Files SMB and NFS protocols

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

Azure Files can enforce encryption in transit for SMB and NFS protocols so that clients connect only over encrypted channels. Requiring encryption in transit protects data exchanged with file shares from network-layer attacks such as man-in-the-middle, eavesdropping, and session hijacking, and helps meet regulatory and organizational data-protection requirements.

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

Azure Policy JSONStorageFileServicesEncryptionInTransit_Audit.json · 58 lines
{
  "properties": {
    "displayName": "Encryption in transit should be required for Azure Files SMB and NFS protocols",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Azure Files can enforce encryption in transit for SMB and NFS protocols so that clients connect only over encrypted channels. Requiring encryption in transit protects data exchanged with file shares from network-layer attacks such as man-in-the-middle, eavesdropping, and session hijacking, and helps meet regulatory and organizational data-protection requirements.",
    "metadata": {
      "version": "1.0.0",
      "category": "Storage"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "The effect determines what happens when the policy rule is evaluated to match"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Storage/storageAccounts/fileServices"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Storage/storageAccounts/fileServices/protocolSettings.smb.encryptionInTransit.required",
                "equals": "false"
              },
              {
                "field": "Microsoft.Storage/storageAccounts/fileServices/protocolSettings.nfs.encryptionInTransit.required",
                "equals": "false"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/e5612cea-18dc-40b0-9390-8bf77072d5df",
  "name": "e5612cea-18dc-40b0-9390-8bf77072d5df"
}
Bylawe5612cea-18dc-40b0-9390-8bf77072d5df.bylaw.ps1 · 33 lines
# Converted from StorageFileServicesEncryptionInTransit_Audit.json by ConvertTo-Bylaw.
Policy 'e5612cea-18dc-40b0-9390-8bf77072d5df' {

    Properties @{
        DisplayName   = 'Encryption in transit should be required for Azure Files SMB and NFS protocols'
        Description   = 'Azure Files can enforce encryption in transit for SMB and NFS protocols so that clients connect only over encrypted channels. Requiring encryption in transit protects data exchanged with file shares from network-layer attacks such as man-in-the-middle, eavesdropping, and session hijacking, and helps meet regulatory and organizational data-protection requirements.'
        Version       = '1.0.0'
        Category      = 'Storage'
        PolicyVersion = '1.0.0'
        Mode          = 'All'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match'
    }

    Resource 'Microsoft.Storage/storageAccounts/fileServices' {

        Require 'protocolSettings.smb.encryptionInTransit.required is not false' {
            Field protocolSettings.smb.encryptionInTransit.required | Must -Not -Be 'false' -IfPresent
        }

        Require 'protocolSettings.nfs.encryptionInTransit.required is not false' {
            Field protocolSettings.nfs.encryptionInTransit.required | Must -Not -Be 'false' -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Storage/StorageFileServicesEncryptionInTransit_Audit.json in Azure/azure-policy, under the MIT licence.