リンター ルール - 入れ子になったデプロイのセキュリティで保護されたパラメーター

外部スコープの入れ子になったデプロイ リソースは、セキュリティで保護されたパラメーターまたは list* 関数には使用しないでください。 デプロイ履歴でセキュリティで保護された値を公開できます。

リンター ルールのコード

ルール設定をカスタマイズするには、Bicep 構成ファイルで次の値を使用します。

secure-params-in-nested-deploy

解決策

デプロイの properties.expressionEvaluationOptions.scopeinner に設定するか、代わりに Bicep モジュールを使用します。

次の例では、外部スコープの入れ子になったデプロイ リソースでセキュリティで保護されたパラメーターが参照されているため、このテストは失敗します。

@secure()
param secureValue string

resource nested 'Microsoft.Resources/deployments@2021-04-01' = {
  name: 'nested'
  properties: {
    mode: 'Incremental'
    template: {
      '$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#'
      contentVersion: '1.0.0.0'
      variables: {}
      resources: [
        {
          name: 'outerImplicit'
          type: 'Microsoft.Network/networkSecurityGroups'
          apiVersion: '2019-11-01'
          location: '[resourceGroup().location]'
          properties: {
            securityRules: [
              {
                name: 'outerImplicit'
                properties: {
                  description: format('{0}', secureValue)
                  protocol: 'Tcp'
                }
              }
            ]
          }
        }
      ]
    }
  }
}

これを修正するには、デプロイの properties.expressionEvaluationOptions.scope を 'inner' に設定します。

@secure()
param secureValue string

resource nested 'Microsoft.Resources/deployments@2021-04-01' = {
  name: 'nested'
  properties: {
    mode: 'Incremental'
    expressionEvaluationOptions: {
      scope: 'Inner'      // Set to inner scope
    }
    template: {
      '$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#'
      contentVersion: '1.0.0.0'
      variables: {}
      resources: [
        {
          name: 'outerImplicit'
          type: 'Microsoft.Network/networkSecurityGroups'
          apiVersion: '2019-11-01'
          location: '[resourceGroup().location]'
          properties: {
            securityRules: [
              {
                name: 'outerImplicit'
                properties: {
                  description: format('{0}', secureValue)
                  protocol: 'Tcp'
                }
              }
            ]
          }
        }
      ]
    }
  }
}

次のステップ

リンターの詳細については、「Bicep リンターの使用方法」を参照してください。