Skip to content

Commit

Permalink
add rule ckv_azure_139
Browse files Browse the repository at this point in the history
  • Loading branch information
lonegunmanb committed Mar 6, 2025
1 parent 42e2bd8 commit ac64208
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 221 deletions.
21 changes: 0 additions & 21 deletions policy/checkov/ACRAdminAccountDisabled.py

This file was deleted.

28 changes: 0 additions & 28 deletions policy/checkov/ACRAdminAccountDisabled.tf

This file was deleted.

33 changes: 0 additions & 33 deletions policy/checkov/ACRAnonymousPullDisabled.py

This file was deleted.

29 changes: 0 additions & 29 deletions policy/checkov/ACRAnonymousPullDisabled.tf

This file was deleted.

63 changes: 63 additions & 0 deletions policy/checkov/ACRPublicNetworkAccessDisabled.azapi.mock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"mock": {
"default": {
"resource_changes": [{
"address": "azurerm_container_registry.acr",
"mode": "managed",
"type": "azapi_resource",
"change": {
"actions": [
"create"
],
"after": {
"type": "Microsoft.ContainerRegistry/registries@2023-11-01-preview",
"body": {
"properties": {
"publicNetworkAccess": "Disabled"
}
}
}
}
}]
},
"invalid_true": {
"resource_changes": [{
"address": "azurerm_container_registry.acr",
"mode": "managed",
"type": "azapi_resource",
"change": {
"actions": [
"create"
],
"after": {
"type": "Microsoft.ContainerRegistry/registries@2023-11-01-preview",
"body": {
"properties": {
"publicNetworkAccess": "Enabled"
}
}
}
}
}]
},
"invalid_omitted": {
"resource_changes": [{
"address": "azurerm_container_registry.acr",
"mode": "managed",
"type": "azapi_resource",
"change": {
"actions": [
"create"
],
"after": {
"type": "Microsoft.ContainerRegistry/registries@2023-11-01-preview",
"body": {
"properties": {
}
}
}
}
}]
}
}
}
15 changes: 15 additions & 0 deletions policy/checkov/ACRPublicNetworkAccessDisabled.azapi.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package checkov

import rego.v1

valid_azapi_container_registry_public_network_access_disabled(resource) if {
resource.values.body.properties.publicNetworkAccess == "Disabled"
}

deny_CKV_AZURE_139 contains reason if {
resource := data.utils.resource(input, "azapi_resource")[_]
data.utils.is_azure_type(resource.values, "Microsoft.ContainerRegistry/registries")
not valid_azapi_container_registry_public_network_access_disabled(resource)

reason := sprintf("checkov/CKV_AZURE_139: Ensure ACR set to disable public networking: %s, https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/azure/ACRPublicNetworkAccessDisabled.py", [resource.address])
}
54 changes: 54 additions & 0 deletions policy/checkov/ACRPublicNetworkAccessDisabled.mock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"mock": {
"default": {
"resource_changes": [
{
"address": "azurerm_container_registry.acr",
"mode": "managed",
"type": "azurerm_container_registry",
"change": {
"actions": [
"create"
],
"after": {
"public_network_access_enabled": false
}
}
}
]
},
"invalid_true": {
"resource_changes": [
{
"address": "azurerm_container_registry.acr",
"mode": "managed",
"type": "azurerm_container_registry",
"change": {
"actions": [
"create"
],
"after": {
"public_network_access_enabled": true
}
}
}
]
},
"invalid_omitted": {
"resource_changes": [
{
"address": "azurerm_container_registry.acr",
"mode": "managed",
"type": "azurerm_container_registry",
"change": {
"actions": [
"create"
],
"after": {
}
}
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ deny_CKV_AZURE_139 contains reason if {
resource := data.utils.resource(input, "azurerm_container_registry")[_]
not valid_azurerm_container_registry_public_network_access_disabled(resource)

reason := sprintf("checkov/CKV_AZURE_139: Ensure ACR set to disable public networking %s", [resource.address])
reason := sprintf("%s https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/azure/ACRPublicNetworkAccessDisabled.py", [reason])
reason := sprintf("checkov/CKV_AZURE_139: Ensure ACR set to disable public networking: %s, https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/azure/ACRPublicNetworkAccessDisabled.py", [resource.address])
}

This file was deleted.

This file was deleted.

20 changes: 0 additions & 20 deletions policy/checkov/azurerm/ACRPublicNetworkAccessDisabled.py.bak

This file was deleted.

29 changes: 0 additions & 29 deletions policy/checkov/azurerm/ACRPublicNetworkAccessDisabled.tf.bak

This file was deleted.

0 comments on commit ac64208

Please sign in to comment.