Selectively suppress Azure.Deployment.SecureParameter
#2526
-
Hi there 👋 Our CI picked up PSRule.Rules.Azure v1.31.0 and we get errors related to the new Some of those errors are false-positive that we'd like to exclude, but we couldn't find out how to selectively do this. For example, we have a Bicep template to store a secret in Key Vault: param keyVaultName string = uniqueString('akv', resourceGroup().id)
param secretName string = 'ExampleSecret'
@secure()
param secretValue string = ''
param override bool = true
resource secret 'Microsoft.KeyVault/vaults/secrets@2019-09-01' = if (override) {
name: '${keyVaultName}/${secretName}'
properties: {
attributes: {
enabled: true
}
value: secretValue
}
}
output secretUri string = secret.properties.secretUri
output secretUriWithVersion string = secret.properties.secretUriWithVersion Here, the I was wondering if we could leverage a suppression group to selectively allow such cases? Another question is, I couldn't find documentation telling what sort of "input object" gets passed to the suppression group, which could help figure out how I could construct the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@mderriey You should be able to create a suppression group but this is also a bug so I'll raise one off this discussion. #2528 To create a suppression group the rule triggers off ---
# Synopsis: Example suppressing Azure.Deployment.SecureParameter.
apiVersion: github.com/microsoft/PSRule/v1
kind: SuppressionGroup
metadata:
name: Example
spec:
rule:
- PSRule.Rules.Azure\Azure.Deployment.SecureParameter
if:
allOf:
- type: .
equals: Microsoft.Resources/deployments
- field: properties.template.parameters.secretName
exists: true The input object that is passed to the suppression group is the same object that is analyzed by the rule. Because PSRule for Azure runs expansion before processing most content so troubleshoot what the object looks like you can use the Export-AzRuleTemplateData PowerShell cmdlet. For example: This cmdlet will dump a JSON file containing an array of all the input resource objects that will be passed through PSRule. Each object is passed separately to evaluate any suppression groups and each rule. |
Beta Was this translation helpful? Give feedback.
@mderriey You should be able to create a suppression group but this is also a bug so I'll raise one off this discussion. #2528
To create a suppression group the rule triggers off
Microsoft.Resources/deployments
(PSRule.Rules.Azure/src/PSRule.Rules.Azure/rules/Azure.Deployment.Rule.ps1
Lines 20 to 23 in 7f4efa5