Skip to content

Commit

Permalink
add rule ckv_azure_115
Browse files Browse the repository at this point in the history
  • Loading branch information
lonegunmanb committed Mar 6, 2025
1 parent 1653673 commit d1650f1
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 114 deletions.
68 changes: 68 additions & 0 deletions policy/checkov/AKSLocalAdminDisabled.azapi.mock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"mock": {
"default": {
"resource_changes": [
{
"address": "azurerm_kubernetes_cluster.example",
"mode": "managed",
"type": "azapi_resource",
"change": {
"actions": [
"create"
],
"after": {
"type": "Microsoft.ContainerService/managedClusters@2024-05-01",
"body": {
"properties": {
"disableLocalAccounts": true
}
}
}
}
}
]
},
"invalid_false": {
"resource_changes": [
{
"address": "azurerm_kubernetes_cluster.example",
"mode": "managed",
"type": "azapi_resource",
"change": {
"actions": [
"create"
],
"after": {
"type": "Microsoft.ContainerService/managedClusters@2024-05-01",
"body": {
"properties": {
"disableLocalAccounts": false
}
}
}
}
}
]
},
"invalid_omitted": {
"resource_changes": [
{
"address": "azurerm_kubernetes_cluster.example",
"mode": "managed",
"type": "azapi_resource",
"change": {
"actions": [
"create"
],
"after": {
"type": "Microsoft.ContainerService/managedClusters@2024-05-01",
"body": {
"properties": {}
}
}
}
}
]
}
}
}
15 changes: 15 additions & 0 deletions policy/checkov/AKSLocalAdminDisabled.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_local_admin_disabled(resource) if {
resource.values.body.properties.disableLocalAccounts == true
}

deny_CKV_AZURE_141 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_local_admin_disabled(resource)

reason := sprintf("checkov/CKV_AZURE_141: Ensure AKS local admin account is disabled %s: https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/azure/AKSLocalAdminDisabled.py", [resource.address])
}
53 changes: 53 additions & 0 deletions policy/checkov/AKSLocalAdminDisabled.mock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"mock": {
"default": {
"resource_changes": [
{
"address": "azurerm_kubernetes_cluster.example",
"mode": "managed",
"type": "azurerm_kubernetes_cluster",
"change": {
"actions": [
"create"
],
"after": {
"local_account_disabled": true
}
}
}
]
},
"invalid_false": {
"resource_changes": [
{
"address": "azurerm_kubernetes_cluster.example",
"mode": "managed",
"type": "azurerm_kubernetes_cluster",
"change": {
"actions": [
"create"
],
"after": {
"local_account_disabled": false
}
}
}
]
},
"invalid_omitted": {
"resource_changes": [
{
"address": "azurerm_kubernetes_cluster.example",
"mode": "managed",
"type": "azurerm_kubernetes_cluster",
"change": {
"actions": [
"create"
],
"after": {}
}
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ deny_CKV_AZURE_141 contains reason if {
resource := data.utils.resource(input, "azurerm_kubernetes_cluster")[_]
not valid_azurerm_kubernetes_cluster_local_admin_disabled(resource)

reason := sprintf("checkov/CKV_AZURE_141: Ensure AKS local admin account is disabled %s", ["https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/azure/AKSLocalAdminDisabled.py"])
reason := sprintf("checkov/CKV_AZURE_141: Ensure AKS local admin account is disabled %s: https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/azure/AKSLocalAdminDisabled.py", [resource.address])
}
15 changes: 0 additions & 15 deletions policy/checkov/azurerm/AKSLocalAdminDisabled.azapi.rego.bak

This file was deleted.

36 changes: 0 additions & 36 deletions policy/checkov/azurerm/AKSLocalAdminDisabled.mock.json.bak

This file was deleted.

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

This file was deleted.

42 changes: 0 additions & 42 deletions policy/checkov/azurerm/AKSLocalAdminDisabled.tf.bak

This file was deleted.

0 comments on commit d1650f1

Please sign in to comment.