Azure / PSRule.Rules.Azure

Rules to validate Azure resources and infrastructure as code (IaC) using PSRule.
https://azure.github.io/PSRule.Rules.Azure/
MIT License
383 stars 84 forks source link

[BUG] Fix handling of multi-line descriptions for policy definition and assignment exports #2973

Closed BernieWhite closed 1 month ago

BernieWhite commented 1 month ago

Existing rule

No response

Description of the issue

When multi-line descriptions are used the synopsis is broken over multiple lines, creating invalid JSON.

Error messages

No response

Reproduction

/providers/Microsoft.Authorization/policyDefinitions/82bf5b87-728b-4a74-ba4d-6123845cf542

which generates.

{
  // Synopsis: Microsoft Defender for Azure Cosmos DB is an Azure-native layer of security that detects attempts to exploit databases in your Azure Cosmos DB accounts.
  Defender for Azure Cosmos DB detects potential SQL injections, known bad actors based on Microsoft Threat Intelligence, suspicious access patterns, and potential exploitations of your database through compromised identities or malicious insiders.
  "apiVersion":"github.com/microsoft/PSRule/v1","kind":"Rule","metadata":{"name":"Azure.Policy.76c22119afc9","displayName":"Configure Microsoft Defender for Azure Cosmos DB to be enabled","tags":{"Azure.Policy/category":"Security Center"},"annotations":{"Azure.Policy/id":"/providers/Microsoft.Authorization/policyDefinitions/82bf5b87-728b-4a74-ba4d-6123845cf542","Azure.Policy/version":"1.0.0"}},"spec":{"recommend":"Microsoft Defender for Azure Cosmos DB is an Azure-native layer of security that detects attempts to exploit databases in your Azure Cosmos DB accounts.\r\nDefender for Azure Cosmos DB detects potential SQL injections, known bad actors based on Microsoft Threat Intelligence, suspicious access patterns, and potential exploitations of your database through compromised identities or malicious insiders.","type":["Microsoft.Resources/subscriptions"],"with":["PSRule.Rules.Azure\\Azure.Policy.All"],"where":{"allOf":[]},"condition":{"field":"resources","allOf":[{"field":"properties.pricingTier","equals":"Standard"}],"where":{"allOf":[{"type":".","equals":"Microsoft.Security/pricings"},{"name":".","equals":"CosmosDbs"}]}}}
}

Version of PSRule

2.9.0

Version of PSRule for Azure

1.37.0

Additional context

No response