Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"id": "7a0164a5-ec6e-40b2-938d-ab3edfd37dcd",
"queryName": "Beta - Backup Vault Without Immutability",
"severity": "HIGH",
"category": "Backup",
"descriptionText": "No 'azurerm_data_protection_backup_vault' resource should set 'immutability' to 'Disabled'. By locking the setting, malicious actors are prevented from disabling the setting and deleting backups.",
"descriptionUrl": "https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/data_protection_backup_vault#immutability-1",
"platform": "Terraform",
"descriptionID": "7a0164a5",
"cloudProvider": "azure",
"cwe": "754",
"riskScore": "6.0",
"experimental": "true"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package Cx

import data.generic.common as common_lib
import data.generic.terraform as tf_lib

CxPolicy[result] {
resource := input.document[i].resource.azurerm_data_protection_backup_vault[name]

results := get_results(resource, name)

result := {
"documentId": input.document[i].id,
"resourceType": "azurerm_data_protection_backup_vault",
"resourceName": tf_lib.get_resource_name(resource, name),
"searchKey": results.searchKey,
"issueType": results.issueType,
"keyExpectedValue": sprintf("'azurerm_data_protection_backup_vault[%s].immutability' should be set and enabled", [name]),
"keyActualValue": results.keyActualValue,
"searchLine": results.searchLine
}
}

get_results(resource, name) = results {
not common_lib.valid_key(resource, "immutability")
results := {
"searchKey": sprintf("azurerm_data_protection_backup_vault[%s]", [name]),
"issueType": "MissingAttribute",
"keyActualValue": sprintf("'azurerm_data_protection_backup_vault[%s].immutability' is undefined or null", [name]),
"searchLine": common_lib.build_search_line(["resource", "azurerm_data_protection_backup_vault", name], [])
}

} else = results {
resource.immutability == "Disabled"
results := {
"searchKey": sprintf("azurerm_data_protection_backup_vault[%s].immutability", [name]),
"issueType": "IncorrectValue",
"keyActualValue": sprintf("'azurerm_data_protection_backup_vault[%s].immutability' is set to 'Disabled'", [name]),
"searchLine": common_lib.build_search_line(["resource", "azurerm_data_protection_backup_vault", name, "immutability"], [])
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resource "azurerm_data_protection_backup_vault" "negative1" {
name = "negative1-backup-vault"
resource_group_name = azurerm_resource_group.negative1.name
location = azurerm_resource_group.negative1.location
datastore_type = "VaultStore"
redundancy = "LocallyRedundant"

immutability = "Unlocked"
}

resource "azurerm_data_protection_backup_vault" "negative2" {
name = "negative2-backup-vault"
resource_group_name = azurerm_resource_group.negative2.name
location = azurerm_resource_group.negative2.location
datastore_type = "VaultStore"
redundancy = "LocallyRedundant"

immutability = "Locked"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resource "azurerm_data_protection_backup_vault" "positive1" {
name = "positive1-backup-vault"
resource_group_name = azurerm_resource_group.positive1.name
location = azurerm_resource_group.positive1.location
datastore_type = "VaultStore"
redundancy = "LocallyRedundant"

# missing immutability - defaults to Disabled
}

resource "azurerm_data_protection_backup_vault" "positive2" {
name = "positive2-backup-vault"
resource_group_name = azurerm_resource_group.positive2.name
location = azurerm_resource_group.positive2.location
datastore_type = "VaultStore"
redundancy = "LocallyRedundant"

immutability = "Disabled"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"queryName": "Beta - Backup Vault Without Immutability",
"severity": "HIGH",
"line": 1
},
{
"queryName": "Beta - Backup Vault Without Immutability",
"severity": "HIGH",
"line": 18
}
]
4 changes: 4 additions & 0 deletions assets/similarityID_transition/terraform_azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ similarityIDChangeList:
queryName: Sensitive Port Is Exposed To Wide Private Network
observations: ""
change: 5
- queryId: 7a0164a5-ec6e-40b2-938d-ab3edfd37dcd
queryName: Beta - Backup Vault Without Immutability
observations: ""
change: 2
Loading