Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update CKV_AZURE_167 to correct check on retention policy #6758

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
@@ -1,5 +1,7 @@
from checkov.common.models.enums import CheckCategories
from checkov.terraform.checks.resource.base_resource_value_check import BaseResourceValueCheck
from typing import Any
from checkov.common.models.consts import ANY_VALUE


class ACREnableRetentionPolicy(BaseResourceValueCheck):
Expand All @@ -10,8 +12,10 @@ def __init__(self) -> None:
categories = (CheckCategories.GENERAL_SECURITY,)
super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)

def get_inspected_key(self) -> str:
return "retention_policy/enabled"
def get_inspected_key(self):
return "retention_policy_in_days"

def get_expected_value(self) -> Any:
return ANY_VALUE

check = ACREnableRetentionPolicy()
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ resource "azurerm_container_registry" "pass" {
sku = "Premium"
anonymous_pull_enabled = false
quarantine_policy_enabled = true
retention_policy {
enabled = true
}
retention_policy_in_days = 7
}


Expand All @@ -18,15 +16,3 @@ resource "azurerm_container_registry" "fail" {
location = azurerm_resource_group.rg.location
sku = "Premium"
}


resource "azurerm_container_registry" "fail2" {
name = "containerRegistry1"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
sku = "Standard"
quarantine_policy_enabled = false
retention_policy {
enabled = false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def test(self):
}
failing_resources = {
'azurerm_container_registry.fail',
'azurerm_container_registry.fail2'
}
skipped_resources = {}

Expand All @@ -39,4 +38,4 @@ def test(self):


if __name__ == '__main__':
unittest.main()
unittest.main()