Bylaw

Gallery › Service Fabric › Azure built-in policies

Service Fabric clusters should have the ClusterProtectionLevel property set to EncryptAndSign

Converted Policy Audit Deny Disabled Mode Indexed Version 1.1.0

Service Fabric provides three levels of protection (None, Sign and EncryptAndSign) for node-to-node communication using a primary cluster certificate. Set the protection level to ensure that all node-to-node messages are encrypted and digitally signed

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

Azure Policy JSONAuditClusterProtectionLevel_Audit.json · 62 lines
{
  "properties": {
    "displayName": "Service Fabric clusters should have the ClusterProtectionLevel property set to EncryptAndSign",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Service Fabric provides three levels of protection (None, Sign and EncryptAndSign) for node-to-node communication using a primary cluster certificate. Set the protection level to ensure that all node-to-node messages are encrypted and digitally signed",
    "metadata": {
      "version": "1.1.0",
      "category": "Service Fabric"
    },
    "version": "1.1.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.ServiceFabric/clusters"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.ServiceFabric/clusters/fabricSettings[*].name",
                "notEquals": "Security"
              },
              {
                "field": "Microsoft.ServiceFabric/clusters/fabricSettings[*].parameters[*].name",
                "notEquals": "ClusterProtectionLevel"
              },
              {
                "field": "Microsoft.ServiceFabric/clusters/fabricSettings[*].parameters[*].value",
                "notEquals": "EncryptAndSign"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.1.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/617c02be-7f02-4efd-8836-3180d47b6c68",
  "name": "617c02be-7f02-4efd-8836-3180d47b6c68"
}
Bylaw617c02be-7f02-4efd-8836-3180d47b6c68.bylaw.ps1 · 47 lines
# Converted from AuditClusterProtectionLevel_Audit.json by ConvertTo-Bylaw.
Policy '617c02be-7f02-4efd-8836-3180d47b6c68' {

    Properties @{
        DisplayName   = 'Service Fabric clusters should have the ClusterProtectionLevel property set to EncryptAndSign'
        Description   = 'Service Fabric provides three levels of protection (None, Sign and EncryptAndSign) for node-to-node communication using a primary cluster certificate. Set the protection level to ensure that all node-to-node messages are encrypted and digitally signed'
        Version       = '1.1.0'
        Category      = 'Service Fabric'
        PolicyVersion = '1.1.0'
        Mode          = 'Indexed'
    }

    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.ServiceFabric/clusters' {

        Require 'fabricSettings and name are as required' {
            Count 'fabricSettings[*]' -Where {
                Field name | Must -Be 'Security'
            } | Must -Not -Be 0
        }

        Require 'fabricSettings, parameters and name are as required' {
            Count 'fabricSettings[*]' -Where {
                Count 'parameters[*]' -Where {
                    Field name | Must -Be 'ClusterProtectionLevel'
                } | Must -BeGreaterThan 0
            } | Must -Not -Be 0
        }

        Require 'fabricSettings, parameters and value are as required' {
            Count 'fabricSettings[*]' -Where {
                Count 'parameters[*]' -Where {
                    Field value | Must -Be 'EncryptAndSign'
                } | Must -BeGreaterThan 0
            } | Must -Not -Be 0
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Service Fabric/AuditClusterProtectionLevel_Audit.json in Azure/azure-policy, under the MIT licence.