CKV_GCP_12 - BaseResourceValueCheck class implementation
-from checkov.terraform.checks.resource.base_resource_check import BaseResourceCheck
+from checkov.terraform.checks.resource.base_resource_value_check import BaseResourceValueCheck
from checkov.common.models.enums import CheckResult, CheckCategories
-class GKENetworkPolicyEnabled(BaseResourceCheck):
+class GKENetworkPolicyEnabled(BaseResourceValueCheck):
def __init__(self):
name = "Ensure Network Policy is enabled on Kubernetes Engine Clusters"
id = "CKV_GCP_12"
@@ -10,17 +10,15 @@ class GKENetworkPolicyEnabled(BaseResourceCheck):
categories = [CheckCategories.KUBERNETES]
super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)
- def scan_resource_conf(self, conf):
+ def get_inspected_key(self):
"""
Looks for monitoring configuration on google_container_cluster:
https://www.terraform.io/docs/providers/google/r/container_cluster.html
:param conf: google_container_cluster configuration
:return: <CheckResult>
"""
- if 'network_policy' in conf:
- if 'enabled' in conf['network_policy'][0]:
- if conf['network_policy'][0]['enabled']:
- return CheckResult.PASSED
- return CheckResult.FAILED
+
+ return 'network_policy/[0]/enabled'
+
check = GKENetworkPolicyEnabled()
