Bylaw

Gallery › Container Registry › Azure Community Policy

Container Registries prevent access to trusted services

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

This policy configures container registry acr_firewall_bypass to prevent access to trusted services

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

Azure Policy JSONazurepolicy.json · 56 lines
{
  "name": "87d66c96-5b33-48cf-bc41-c1356bb565dc",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Container Registries prevent access to trusted services",
    "description": "This policy configures container registry acr_firewall_bypass to prevent access to trusted services",
    "metadata": {
      "category": "Container Registry",
      "createdBy": "",
      "updatedBy": null,
      "updatedOn": null,
      "version": "1.0.0"
    },
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Deny, Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Deny",
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "equals": "Microsoft.ContainerRegistry/registries",
            "field": "type"
          },
          {
            "anyOf": [
              {
                "exists": "false",
                "field": "Microsoft.ContainerRegistry/registries/networkRuleBypassOptions"
              },
              {
                "equals": "AzureServices",
                "field": "Microsoft.ContainerRegistry/registries/networkRuleBypassOptions"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw87d66c96-5b33-48cf-bc41-c1356bb565dc.bylaw.ps1 · 31 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '87d66c96-5b33-48cf-bc41-c1356bb565dc' {

    Properties @{
        DisplayName = 'Container Registries prevent access to trusted services'
        Description = 'This policy configures container registry acr_firewall_bypass to prevent access to trusted services'
        Category    = 'Container Registry'
        Version     = '1.0.0'
        Mode        = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Deny', 'Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Deny, Audit or Disabled the execution of the Policy'
    }

    Resource 'Microsoft.ContainerRegistry/registries' {

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

        Require 'networkRuleBypassOptions is not AzureServices' {
            Field networkRuleBypassOptions | Must -Not -Be 'AzureServices' -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Container Registry/container-registries-prevent-access-to-trusted-services/azurepolicy.json in Azure/Community-Policy, under the MIT licence.