Skip to content

Commit

Permalink
add rule ckv_azure_5
Browse files Browse the repository at this point in the history
  • Loading branch information
lonegunmanb committed Mar 7, 2025
1 parent d578111 commit 385c56b
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 81 deletions.
50 changes: 50 additions & 0 deletions policy/checkov/AKSRbacEnabled.azapi.mock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"mock": {
"enabled": {
"resource_changes": [
{
"address": "azapi_resource.res",
"mode": "managed",
"name": "res",
"type": "azapi_resource",
"change": {
"actions": [
"create"
],
"after": {
"body": {
"properties": {
"enableRBAC": true
},
"type": "Microsoft.ContainerService/managedClusters@2024-05-01"
}
}
}
}
]
},
"invalid_disabled": {
"resource_changes": [
{
"address": "azapi_resource.res",
"mode": "managed",
"name": "res",
"type": "azapi_resource",
"change": {
"actions": [
"create"
],
"after": {
"body": {
"properties": {
"enableRBAC": false
},
"type": "Microsoft.ContainerService/managedClusters@2024-05-01"
}
}
}
}
]
},
}
}
15 changes: 15 additions & 0 deletions policy/checkov/AKSRbacEnabled.azapi.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package checkov

import rego.v1

valid_azapi_kubernetes_cluster_rbac_enabled(resource) if {
resource.values.body.properties.enableRBAC == true
}

deny_CKV_AZURE_5 contains reason if {
resource := data.utils.resource(input, "azapi_resource")[_]
data.utils.is_azure_type(resource.values, "Microsoft.ContainerService/managedClusters")
not valid_azapi_kubernetes_cluster_rbac_enabled(resource)

reason := sprintf("checkov/CKV_AZURE_5: Ensure RBAC is enabled on AKS clusters %s https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/azure/AKSRbacEnabled.py", [resource.address])
}
46 changes: 46 additions & 0 deletions policy/checkov/AKSRbacEnabled.mock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"mock": {
"enabled": {
"resource_changes": [
{
"address": "azurerm_kubernetes_cluster.example",
"mode": "managed",
"type": "azurerm_kubernetes_cluster",
"name": "example",
"provider_name": "registry.terraform.io/hashicorp/azurerm",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"role_based_access_control_enabled": true
}
}
}
]
},
"enabled_v2": {
"resource_changes": [
{
"address": "azurerm_kubernetes_cluster.example",
"mode": "managed",
"type": "azurerm_kubernetes_cluster",
"name": "example",
"provider_name": "registry.terraform.io/hashicorp/azurerm",
"change": {
"actions": [
"create"
],
"before": null,
"after": {
"role_based_access_control": [{
"enabled": true
}]
}
}
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ deny_CKV_AZURE_5 contains reason if {
resource := data.utils.resource(input, "azurerm_kubernetes_cluster")[_]
not valid_azurerm_kubernetes_cluster_rbac_enabled(resource)

reason := sprintf("checkov/CKV_AZURE_5: Ensure RBAC is enabled on AKS clusters %s", [resource.address])

reason := sprintf("%s https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/azure/AKSRbacEnabled.py", [reason])
reason := sprintf("checkov/CKV_AZURE_5: Ensure RBAC is enabled on AKS clusters %s https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/azure/AKSRbacEnabled.py", [resource.address])
}
32 changes: 0 additions & 32 deletions policy/checkov/azurerm/AKSRbacEnabled.py.bak

This file was deleted.

46 changes: 0 additions & 46 deletions policy/checkov/azurerm/AKSRbacEnabled.tf.bak

This file was deleted.

0 comments on commit 385c56b

Please sign in to comment.