feat(query): implements "Beta - Blob Storage Without Soft Delete"#7831
Merged
Conversation
Contributor
cx-eduardo-semanas
previously approved these changes
Nov 25, 2025
cx-eduardo-semanas
left a comment
Contributor
There was a problem hiding this comment.
LGTM, great job
…_blobs_on_azure_blob_storage_accounts_is_enabled
cx-artur-ribeiro
approved these changes
Dec 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








Reason for Proposed Changes
Currently there is no query to ensure that resources of type "azurerm_storage_account" configure a value of 7 to 365 on their "blob_properties.delete_retention_policy.days" field.
Quoting CIS_Microsoft_Azure_Foundations_Benchmark_v5.0.0 page 486: "
Blobs can be deleted incorrectly. An attacker or malicious user may do this deliberately in order to cause disruption. Deleting an Azure storage blob results in immediate data loss. Enabling this configuration for Azure storage accounts ensures that even if blobs are deleted from the storage account, the blobs are recoverable for a specific period of time, which is defined in the "Retention policies," ranging from 7 to 365 days."Through the Terraform documentation for the resource we can see a "delete_retention_policy" block left empty will assume the default value of 7 for the missing "days" field. With this all we have to do is ensure the "delete_retention_policy" block is defined and that the value associated with the "days" field, if set, is higher than
6.Proposed Changes
Implemented the missing query.
The query will flag any "azurerm_storage_account" resource that does not set the "blob_properties" block, or does set it but does not set a "delete_retention_policy" block within. Additionally it will flag if the "days" field is set to a value lower than
7.Note that a check to ensure the days field is "valid" as in between 1 and 365 was not done since those would be found in the "
terraform plan" stage. (was tested)I submit this contribution under the Apache-2.0 license.