Share via


Linter szabály – biztonságos paramok beágyazott üzembe helyezésben

A külső hatókörű beágyazott üzembehelyezési erőforrások nem használhatók biztonságos paraméterekhez vagy listázási* függvényekhez. A biztonságos értékeket közzéteheti az üzembe helyezési előzményekben.

Linter-szabály kódja

A bicep-konfigurációs fájlban a következő érték használatával szabhatja testre a szabálybeállításokat:

secure-params-in-nested-deploy

Megoldás

Állítsa be az üzemelő példány properties.expressionEvaluationOptions.scope tulajdonságát inner bicep-modulra, vagy használjon helyette.

Az alábbi példa nem felel meg a tesztnek, mert a rendszer egy külső hatókörű beágyazott üzembehelyezési erőforrásban hivatkozik egy biztonságos paraméterre.

@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'
                }
              }
            ]
          }
        }
      ]
    }
  }
}

Kijavíthatja, ha az üzembe helyezés properties.expressionEvaluationOptions.scope tulajdonságát "inner" értékre állítja:

@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'
                }
              }
            ]
          }
        }
      ]
    }
  }
}

Következő lépések

A linterről további információt a Bicep-linter használata című témakörben talál.