-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(terraform): add CKV2_AZURE_47, ensure storage account is configu…
…red without blob anonymous access (#5888) Add CKV2_AZURE_47, ensure storage account is configured without blob anonymous access.
- Loading branch information
Showing
3 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
.../terraform/checks/graph_checks/azure/AzureStorageAccConfigWithoutBlobAnonymousAccess.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
metadata: | ||
id: "CKV2_AZURE_47" | ||
name: "Ensure storage account is configured without blob anonymous access" | ||
category: "IAM" | ||
|
||
definition: | ||
and: | ||
- cond_type: "attribute" | ||
resource_types: "azurerm_storage_account" | ||
attribute: "allow_nested_items_to_be_public" | ||
operator: "exists" | ||
|
||
- cond_type: "attribute" | ||
resource_types: "azurerm_storage_account" | ||
attribute: "allow_nested_items_to_be_public" | ||
operator: "equals_ignore_case" | ||
value: "false" |
5 changes: 5 additions & 0 deletions
5
...form/graph/checks/resources/AzureStorageAccConfigWithoutBlobAnonymousAccess/expected.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pass: | ||
- "azurerm_storage_account.pass" | ||
fail: | ||
- "azurerm_storage_account.fail_1" | ||
- "azurerm_storage_account.fail_2" |
52 changes: 52 additions & 0 deletions
52
.../terraform/graph/checks/resources/AzureStorageAccConfigWithoutBlobAnonymousAccess/main.tf
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
variable "rg-name" { | ||
default = "pud-bc-rg" | ||
} | ||
|
||
variable "location" { | ||
default = "northeurope" | ||
} | ||
|
||
# Case 1: Pass: allow_nested_items_to_be_public = False | ||
|
||
resource "azurerm_storage_account" "pass" { | ||
name = "pud-storage2023abc1" | ||
resource_group_name = var.rg-name | ||
location = var.location | ||
account_tier = "Standard" | ||
account_replication_type = "GRS" | ||
allow_nested_items_to_be_public = false | ||
|
||
tags = { | ||
bc_status = "pass" | ||
} | ||
} | ||
|
||
# Case 2: Fail: allow_nested_items_to_be_public does NOT exist | ||
|
||
resource "azurerm_storage_account" "fail_1" { | ||
name = "pud-storage2023abc2" | ||
resource_group_name = var.rg-name | ||
location = var.location | ||
account_tier = "Standard" | ||
account_replication_type = "GRS" | ||
|
||
tags = { | ||
bc_status = "fail_1" | ||
} | ||
} | ||
|
||
# Case 3: Fail: allow_nested_items_to_be_public = True | ||
|
||
resource "azurerm_storage_account" "fail_2" { | ||
name = "pud-storage2023abc3" | ||
resource_group_name = var.rg-name | ||
location = var.location | ||
account_tier = "Standard" | ||
account_replication_type = "GRS" | ||
allow_nested_items_to_be_public = true | ||
|
||
|
||
tags = { | ||
bc_status = "fail_2" | ||
} | ||
} |