Skip to content

Commit

Permalink
fix(terraform): Fix CKV_Azure_234 (#5886)
Browse files Browse the repository at this point in the history
* Fix CKV_Azure_234

* typo
  • Loading branch information
tsmithv11 committed Dec 21, 2023
1 parent 748f4b7 commit 68b141b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def __init__(self) -> None:

def scan_resource_conf(self, conf: dict[str, list[Any]]) -> CheckResult:
return (
CheckResult.PASSED
if conf.get("resource_type", [""])[0].lower() == "arm" and conf.get("tier", [""])[0].lower() == "standard"
else CheckResult.FAILED
CheckResult.FAILED
if conf.get("resource_type", [""])[0].lower() == "arm" and conf.get("tier", [""])[0].lower() != "standard"
else CheckResult.PASSED
)

def get_evaluated_keys(self) -> list[str]:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Case 1: Pass: tier is Standard and resource_type is Arm

resource "azurerm_security_center_subscription_pricing" "pass" {
resource "azurerm_security_center_subscription_pricing" "pass_1" {
tier = "Standard"
resource_type = "Arm"
}
Expand All @@ -13,10 +13,16 @@ resource "azurerm_security_center_subscription_pricing" "fail_1" {
resource_type = "arm"
}

# Case 3: Fails as "resource_type" should be "Arm"
# Case 3: Pass as policy should only check if the resource_type is "Arm"

resource "azurerm_security_center_subscription_pricing" "fail_2" {
tier = "Standard"
resource "azurerm_security_center_subscription_pricing" "pass_2" {
tier = "Free"
resource_type = "Dns"
}

# Case 4: Pass as policy should only check if the resource_type is "Arm"

resource "azurerm_security_center_subscription_pricing" "pass_3" {
tier = "Free"
resource_type = "VirtualMachine"
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ def test(self):
summary = report.get_summary()

passing_resources = {
'azurerm_security_center_subscription_pricing.pass',
'azurerm_security_center_subscription_pricing.pass_1',
'azurerm_security_center_subscription_pricing.pass_2',
'azurerm_security_center_subscription_pricing.pass_3',
}
failing_resources = {
'azurerm_security_center_subscription_pricing.fail_1',
'azurerm_security_center_subscription_pricing.fail_2',
}
skipped_resources = {}

Expand Down

0 comments on commit 68b141b

Please sign in to comment.