Repository: bridgecrewio/checkov

Issue:
Checkov Python error - kubernetes_pod_v1
I get the following error when parsing a **kubernetes_pod_v1** resource:
https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/pod_v1

```
Error: -18 02:46:45,476 [MainThread  ] [ERROR]  Failed to run check CKV_K8S_[27](https://github.com/technology-services-and-platforms-accnz/dotc-aks/actions/runs/4728024195/jobs/8389176473#step:21:28) on /tfplan.json:kubernetes_pod_v1.test
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/checkov/common/checks/base_check.py", line 73, in run
    check_result["result"] = self.scan_entity_conf(entity_configuration, entity_type)
  File "/usr/local/lib/python3.10/site-packages/checkov/terraform/checks/resource/base_resource_check.py", line 43, in scan_entity_conf
    return self.scan_resource_conf(conf)
  File "/usr/local/lib/python3.10/site-packages/checkov/terraform/checks/resource/kubernetes/DockerSocketVolume.py", line 36, in scan_resource_conf
    if v.get("host_path"):
  File "/usr/local/lib/python3.10/site-packages/checkov/common/parsers/node.py", line 189, in __getattr__
    raise TemplateAttributeError(f'***name*** is invalid')
checkov.common.parsers.node.TemplateAttributeError: get is invalid
[...]
```

For all the checks that fail.

Checkov Version: :2.3.165


Discussion:

Resolving patch:
diff --git a/checkov/terraform/checks/resource/kubernetes/DockerSocketVolume.py b/checkov/terraform/checks/resource/kubernetes/DockerSocketVolume.py
--- a/checkov/terraform/checks/resource/kubernetes/DockerSocketVolume.py
+++ b/checkov/terraform/checks/resource/kubernetes/DockerSocketVolume.py
@@ -33,7 +33,7 @@ def scan_resource_conf(self, conf: dict[str, list[Any]]):
         if "volume" in spec and spec.get("volume"):
             volumes = spec.get("volume")
             for idx, v in enumerate(volumes):
-                if v.get("host_path"):
+                if isinstance(v, dict) and v.get("host_path"):
                     if "path" in v["host_path"][0]:
                         if v["host_path"][0]["path"] == ["/var/run/docker.sock"]:
                             self.evaluated_keys = [f"spec/volume/{idx}/host_path/[0]/path"]
@@ -47,8 +47,7 @@ def scan_resource_conf(self, conf: dict[str, list[Any]]):
                     for idx, v in enumerate(volumes):
                         if isinstance(v, dict) and v.get("host_path"):
                             if "path" in v["host_path"][0]:
-                                path = v["host_path"][0]["path"]
-                                if path == ["/var/run/docker.sock"]:
+                                if v["host_path"][0]["path"] == ["/var/run/docker.sock"]:
                                     self.evaluated_keys = [f"spec/template/spec/volume/{idx}/host_path/[0]/path"]
                                     return CheckResult.FAILED
 


Test patch:
diff --git a/tests/terraform/checks/resource/kubernetes/example_DockerSocketVolume/main.tf b/tests/terraform/checks/resource/kubernetes/example_DockerSocketVolume/main.tf
--- a/tests/terraform/checks/resource/kubernetes/example_DockerSocketVolume/main.tf
+++ b/tests/terraform/checks/resource/kubernetes/example_DockerSocketVolume/main.tf
@@ -75,12 +75,7 @@ resource "kubernetes_pod_v1" "fail" {
 
   spec {
 
-    volume {
-      host_path {
-        path = "/var/run/docker.sock"
-        type = "Directory"
-      }
-    }
+    volume = "invalid"
 
     volume {
       host_path {