Repository: bridgecrewio/checkov

Issue:
Failing to perform Checkov Scan against Helm chart "[ERROR]  Failed to run check:... "
**Describe the bug**
I am performing a Checkov scan again the dependency track chart in [this](https://github.com/evryfs/helm-charts/tree/master/charts/dependency-track) repo. Instead of receiving scan results the scan fails and exits stating `"[ERROR]  Failed to run check:....at file: /dependency-track/templates/frontend/deployment.yaml"` i'm not sure what is causing this, could it be a configuration issue in the chart?

**To Reproduce**
Steps to reproduce the behavior:
1. Clone [this](https://github.com/evryfs/helm-charts) repo `git clone https://github.com/evryfs/helm-charts.git`
2. Run Checkov command  `checkov -d "/helm-charts/charts/dependency-track"`
3. See error

**Expected behavior**
I expect to see scan results without any errors

**Logs**
```console
$ checkov -d "/helm-charts/charts/dependency-track" 

2021-09-14 16:38:51,343 [MainThread  ] [ERROR]  Failed to run check: Containers should run as a high UID to avoid host conflict for configuration: {'apiVersion': 'apps/v1', 'kind': 'Deployment', 'metadata': {'name': 'RELEASE-NAME-dependency-track-frontend', 'labels': {'app.kubernetes.io/name': 'dependency-track', 'helm.sh/chart': 'dependency-track-1.1.3', 'app.kubernetes.io/instance': 'RELEASE-NAME', 'app.kubernetes.io/managed-by': 'Helm', 'app.kubernetes.io/component': 'frontend', '__startline__': 8, '__endline__': 13}, '__startline__': 6, '__endline__': 13}, 'spec': {'replicas': 2, 'selector': {'matchLabels': {'app.kubernetes.io/name': 'dependency-track', 'app.kubernetes.io/instance': 'RELEASE-NAME', 'app.kubernetes.io/component': 'frontend', '__startline__': 17, '__endline__': 20}, '__startline__': 16, '__endline__': 20}, 'template': {'metadata': {'labels': {'app.kubernetes.io/name': 'dependency-track', 'helm.sh/chart': 'dependency-track-1.1.3', 'app.kubernetes.io/instance': 'RELEASE-NAME', 'app.kubernetes.io/managed-by': 'Helm', 'app.kubernetes.io/component': 'frontend', '__startline__': 23, '__endline__': 28}, '__startline__': 22, '__endline__': 28}, 'spec': {'serviceAccountName': 'RELEASE-NAME-dependency-track-frontend', 'securityContext': None, 'containers': [{'name': 'dependency-track-frontend', 'securityContext': {'allowPrivilegeEscalation': False, 'runAsUser': 101, '__startline__': 35, '__endline__': 37}, 'resources': {'limits': {'cpu': 1, 'memory': '512Mi', '__startline__': 39, '__endline__': 41}, 'requests': {'cpu': '100m', 'memory': '128Mi', '__startline__': 42, '__endline__': 44}, '__startline__': 38, '__endline__': 44}, 'image': 'docker.io/dependencytrack/frontend:4.3.1', 'imagePullPolicy': 'IfNotPresent', 'env': [{'name': 'API_BASE_URL', 'value': '', '__startline__': 47, '__endline__': 49}], 'ports': [{'name': 'http', 'containerPort': 8080, 'protocol': 'TCP', '__startline__': 50, '__endline__': 53}], 'volumeMounts': [{'name': 'tmp', 'mountPath': '/tmp', '__startline__': 54, '__endline__': 58}], 'livenessProbe': {'httpGet': {'port': 'http', 'path': '/', '__startline__': 60, '__endline__': 62}, 'initialDelaySeconds': 60, 'periodSeconds': 10, 'timeoutSeconds': 2, 'successThreshold': 1, 'failureThreshold': 3, '__startline__': 59, '__endline__': 67}, 'readinessProbe': {'httpGet': {'port': 'http', 'path': '/', '__startline__': 69, '__endline__': 71}, 'initialDelaySeconds': 60, 'periodSeconds': 10, 'timeoutSeconds': 2, 'successThreshold': 1, 'failureThreshold': 3, '__startline__': 68, '__endline__': 76}, '__startline__': 33, '__endline__': 76, 'apiVersion': 'apps/v1', 'kind': 'containers', 'parent': 'Deployment.RELEASE-NAME-dependency-track-frontend.default (container 0)', 'parent_metadata': {'name': 'RELEASE-NAME-dependency-track-frontend', 'labels': {'app.kubernetes.io/name': 'dependency-track', 'helm.sh/chart': 'dependency-track-1.1.3', 'app.kubernetes.io/instance': 'RELEASE-NAME', 'app.kubernetes.io/managed-by': 'Helm', 'app.kubernetes.io/component': 'frontend', '__startline__': 8, '__endline__': 13}, '__startline__': 6, '__endline__': 13}}], 'volumes': [{'name': 'tmp', 'emptyDir': {'__startline__': 78, '__endline__': 78}, '__startline__': 77, '__endline__': 86}], '__startline__': 29, '__endline__': 86}, '__startline__': 21, '__endline__': 86}, '__startline__': 14, '__endline__': 86}, '__startline__': 3, '__endline__': 86} at file: /dependency-track/templates/frontend/deployment.yaml


       _               _              
   ___| |__   ___  ___| | _______   __
  / __| '_ \ / _ \/ __| |/ / _ \ \ / /
 | (__| | | |  __/ (__|   < (_) \ V / 
  \___|_| |_|\___|\___|_|\_\___/ \_/  
                                      
By bridgecrew.io | version: 2.0.255 
Update available 2.0.255 -> 2.0.413
Run pip3 install -U checkov to update 


secrets scan results:

Passed checks: 0, Failed checks: 1, Skipped checks: 0

Check: CKV_SECRET_6: "Base64 High Entropy String"
	FAILED for resource: a709c1ac99f328abf9969fbfcb04913f8c9133bc
	File: /values.yaml:168-169
	Guide: https://docs.bridgecrew.io/docs/git_secrets_6

		168 |   postgresqlPassword: deptrack


$ echo $?                                                                         
1

```

**Desktop (please complete the following information):**
 - OS: iOS
 - Checkov Version :2.0.255
 
**Additional context**
I performed a `helm template` and this is the result of `dependency-track/templates/frontend/deployment.yaml`
```
# Source: dependency-track/templates/frontend/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-dependency-track-frontend
  labels:
    app.kubernetes.io/name: dependency-track
    helm.sh/chart: dependency-track-1.1.3
    app.kubernetes.io/instance: test
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: frontend
spec:
  replicas: 2
  selector:
    matchLabels:
      app.kubernetes.io/name: dependency-track
      app.kubernetes.io/instance: test
      app.kubernetes.io/component: frontend
  template:
    metadata:
      labels:
        app.kubernetes.io/name: dependency-track
        helm.sh/chart: dependency-track-1.1.3
        app.kubernetes.io/instance: test
        app.kubernetes.io/managed-by: Helm
        app.kubernetes.io/component: frontend
    spec:
      serviceAccountName: test-dependency-track-frontend
      securityContext:
        null
      containers:
      - name: dependency-track-frontend
        securityContext:
            allowPrivilegeEscalation: false
            runAsUser: 101
        resources: 
          limits:
            cpu: 1
            memory: 512Mi
          requests:
            cpu: 100m
            memory: 128Mi
        image: docker.io/dependencytrack/frontend:4.3.1
        imagePullPolicy: IfNotPresent
        env:
        - name: API_BASE_URL
          value: ""
        ports:
        - name: http
          containerPort: 8080
          protocol: TCP
        volumeMounts:
        - name: tmp
          mountPath: /tmp
        #- name: config
        #  mountPath: /app/static
        livenessProbe:
          httpGet:
            port: http
            path: /
          initialDelaySeconds: 60
          periodSeconds: 10
          timeoutSeconds: 2
          successThreshold: 1
          failureThreshold: 3
        readinessProbe:
          httpGet:
            port: http
            path: /
          initialDelaySeconds: 60
          periodSeconds: 10
          timeoutSeconds: 2
          successThreshold: 1
          failureThreshold: 3
      volumes:
      - name: tmp
        emptyDir: {}
      # https://github.com/DependencyTrack/frontend/issues/60
      # - name: config
      #  configMap:
      #    name: test-dependency-track-frontend
      #    items:
      #    - key: config.json
      #      path: config.json
```




Discussion:
This is the error/output I get when trying the same:
```
2021-09-15 08:05:30,873 [MainThread  ] [ERROR]  Failed to run check: Containers should run as a high UID to avoid host conflict for configuration: {'apiVersion': 'apps/v1', 'kind': 'Deployment', 'metadata': {'
name': 'RELEASE-NAME-dependency-track-frontend', 'labels': {'app.kubernetes.io/name': 'dependency-track', 'helm.sh/chart': 'dependency-track-1.1.3', 'app.kubernetes.io/instance': 'RELEASE-NAME', 'app.kubernete
s.io/managed-by': 'Helm', 'app.kubernetes.io/component': 'frontend', '__startline__': 8, '__endline__': 13}, '__startline__': 6, '__endline__': 13}, 'spec': {'replicas': 2, 'selector': {'matchLabels': {'app.ku
bernetes.io/name': 'dependency-track', 'app.kubernetes.io/instance': 'RELEASE-NAME', 'app.kubernetes.io/component': 'frontend', '__startline__': 17, '__endline__': 20}, '__startline__': 16, '__endline__': 20},
 'template': {'metadata': {'labels': {'app.kubernetes.io/name': 'dependency-track', 'helm.sh/chart': 'dependency-track-1.1.3', 'app.kubernetes.io/instance': 'RELEASE-NAME', 'app.kubernetes.io/managed-by': 'Hel
m', 'app.kubernetes.io/component': 'frontend', '__startline__': 23, '__endline__': 28}, '__startline__': 22, '__endline__': 28}, 'spec': {'serviceAccountName': 'RELEASE-NAME-dependency-track-frontend', 'securi
tyContext': None, 'containers': [{'name': 'dependency-track-frontend', 'securityContext': {'allowPrivilegeEscalation': False, 'runAsUser': 101, '__startline__': 35, '__endline__': 37}, 'resources': {'limits':
{'cpu': 1, 'memory': '512Mi', '__startline__': 39, '__endline__': 41}, 'requests': {'cpu': '100m', 'memory': '128Mi', '__startline__': 42, '__endline__': 44}, '__startline__': 38, '__endline__': 44}, 'image':
'docker.io/dependencytrack/frontend:4.3.1', 'imagePullPolicy': 'IfNotPresent', 'env': [{'name': 'API_BASE_URL', 'value': '', '__startline__': 47, '__endline__': 49}], 'ports': [{'name': 'http', 'containerPort'
: 8080, 'protocol': 'TCP', '__startline__': 50, '__endline__': 53}], 'volumeMounts': [{'name': 'tmp', 'mountPath': '/tmp', '__startline__': 54, '__endline__': 58}], 'livenessProbe': {'httpGet': {'port': 'http'
, 'path': '/', '__startline__': 60, '__endline__': 62}, 'initialDelaySeconds': 60, 'periodSeconds': 10, 'timeoutSeconds': 2, 'successThreshold': 1, 'failureThreshold': 3, '__startline__': 59, '__endline__': 67
}, 'readinessProbe': {'httpGet': {'port': 'http', 'path': '/', '__startline__': 69, '__endline__': 71}, 'initialDelaySeconds': 60, 'periodSeconds': 10, 'timeoutSeconds': 2, 'successThreshold': 1, 'failureThres
hold': 3, '__startline__': 68, '__endline__': 76}, '__startline__': 33, '__endline__': 76, 'apiVersion': 'apps/v1', 'kind': 'containers', 'parent': 'Deployment.RELEASE-NAME-dependency-track-frontend.default (c
ontainer 0)', 'parent_metadata': {'name': 'RELEASE-NAME-dependency-track-frontend', 'labels': {'app.kubernetes.io/name': 'dependency-track', 'helm.sh/chart': 'dependency-track-1.1.3', 'app.kubernetes.io/instan
ce': 'RELEASE-NAME', 'app.kubernetes.io/managed-by': 'Helm', 'app.kubernetes.io/component': 'frontend', '__startline__': 8, '__endline__': 13}, '__startline__': 6, '__endline__': 13}}], 'volumes': [{'name': 't
mp', 'emptyDir': {'__startline__': 78, '__endline__': 78}, '__startline__': 77, '__endline__': 86}], '__startline__': 29, '__endline__': 86}, '__startline__': 21, '__endline__': 86}, '__startline__': 14, '__en
dline__': 86}, '__startline__': 3, '__endline__': 86} at file: /dependency-track/templates/frontend/deployment.yaml
Traceback (most recent call last):
  File "/usr/local/bin/checkov", line 8, in <module>
    exit(run())
  File "/usr/local/lib/python3.7/site-packages/checkov/main.py", line 176, in run
    files=file, guidelines=guidelines)
  File "/usr/local/lib/python3.7/site-packages/checkov/common/runners/runner_registry.py", line 60, in run
    collect_skip_comments=collect_skip_comments,
  File "/usr/local/lib/python3.7/site-packages/checkov/helm/runner.py", line 197, in run
    shutil.move(target_dir, save_error_dir)
  File "/usr/local/lib/python3.7/tempfile.py", line 807, in __exit__
    self.cleanup()
  File "/usr/local/lib/python3.7/tempfile.py", line 811, in cleanup
    _shutil.rmtree(self.name)
  File "/usr/local/lib/python3.7/shutil.py", line 485, in rmtree
    onerror(os.lstat, path, sys.exc_info())
  File "/usr/local/lib/python3.7/shutil.py", line 483, in rmtree
    orig_st = os.lstat(path)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp4jvzhfs_'
```
If I then skip that specific check, it continues to error, but for a different check:
```
checkov -d ./ --skip-check CKV_K8S_40

2021-09-15 08:08:34,091 [MainThread  ] [ERROR]  Failed to run check: Minimize the admission of root containers for configuration: {'apiVersion': 'apps/v1', 'kind': 'Deployment', 'metadata': {'name': 'RELEASE-N
AME-dependency-track-frontend', 'labels': {'app.kubernetes.io/name': 'dependency-track', 'helm.sh/chart': 'dependency-track-1.1.3', 'app.kubernetes.io/instance': 'RELEASE-NAME', 'app.kubernetes.io/managed-by':
 'Helm', 'app.kubernetes.io/component': 'frontend', '__startline__': 8, '__endline__': 13}, '__startline__': 6, '__endline__': 13}, 'spec': {'replicas': 2, 'selector': {'matchLabels': {'app.kubernetes.io/name'
: 'dependency-track', 'app.kubernetes.io/instance': 'RELEASE-NAME', 'app.kubernetes.io/component': 'frontend', '__startline__': 17, '__endline__': 20}, '__startline__': 16, '__endline__': 20}, 'template': {'me
tadata': {'labels': {'app.kubernetes.io/name': 'dependency-track', 'helm.sh/chart': 'dependency-track-1.1.3', 'app.kubernetes.io/instance': 'RELEASE-NAME', 'app.kubernetes.io/managed-by': 'Helm', 'app.kubernet
es.io/component': 'frontend', '__startline__': 23, '__endline__': 28}, '__startline__': 22, '__endline__': 28}, 'spec': {'serviceAccountName': 'RELEASE-NAME-dependency-track-frontend', 'securityContext': None,
 'containers': [{'name': 'dependency-track-frontend', 'securityContext': {'allowPrivilegeEscalation': False, 'runAsUser': 101, '__startline__': 35, '__endline__': 37}, 'resources': {'limits': {'cpu': 1, 'memor
y': '512Mi', '__startline__': 39, '__endline__': 41}, 'requests': {'cpu': '100m', 'memory': '128Mi', '__startline__': 42, '__endline__': 44}, '__startline__': 38, '__endline__': 44}, 'image': 'docker.io/depend
encytrack/frontend:4.3.1', 'imagePullPolicy': 'IfNotPresent', 'env': [{'name': 'API_BASE_URL', 'value': '', '__startline__': 47, '__endline__': 49}], 'ports': [{'name': 'http', 'containerPort': 8080, 'protocol
': 'TCP', '__startline__': 50, '__endline__': 53}], 'volumeMounts': [{'name': 'tmp', 'mountPath': '/tmp', '__startline__': 54, '__endline__': 58}], 'livenessProbe': {'httpGet': {'port': 'http', 'path': '/', '_
_startline__': 60, '__endline__': 62}, 'initialDelaySeconds': 60, 'periodSeconds': 10, 'timeoutSeconds': 2, 'successThreshold': 1, 'failureThreshold': 3, '__startline__': 59, '__endline__': 67}, 'readinessProb
e': {'httpGet': {'port': 'http', 'path': '/', '__startline__': 69, '__endline__': 71}, 'initialDelaySeconds': 60, 'periodSeconds': 10, 'timeoutSeconds': 2, 'successThreshold': 1, 'failureThreshold': 3, '__star
tline__': 68, '__endline__': 76}, '__startline__': 33, '__endline__': 76, 'apiVersion': 'apps/v1', 'kind': 'containers', 'parent': 'Deployment.RELEASE-NAME-dependency-track-frontend.default (container 0)', 'pa
rent_metadata': {'name': 'RELEASE-NAME-dependency-track-frontend', 'labels': {'app.kubernetes.io/name': 'dependency-track', 'helm.sh/chart': 'dependency-track-1.1.3', 'app.kubernetes.io/instance': 'RELEASE-NAM
E', 'app.kubernetes.io/managed-by': 'Helm', 'app.kubernetes.io/component': 'frontend', '__startline__': 8, '__endline__': 13}, '__startline__': 6, '__endline__': 13}}], 'volumes': [{'name': 'tmp', 'emptyDir':
{'__startline__': 78, '__endline__': 78}, '__startline__': 77, '__endline__': 86}], '__startline__': 29, '__endline__': 86}, '__startline__': 21, '__endline__': 86}, '__startline__': 14, '__endline__': 86}, '_
_startline__': 3, '__endline__': 86} at file: /dependency-track/templates/frontend/deployment.yaml
Traceback (most recent call last):
  File "/usr/local/bin/checkov", line 8, in <module>
    exit(run())
  File "/usr/local/lib/python3.7/site-packages/checkov/main.py", line 176, in run
    files=file, guidelines=guidelines)
  File "/usr/local/lib/python3.7/site-packages/checkov/common/runners/runner_registry.py", line 60, in run
    collect_skip_comments=collect_skip_comments,
  File "/usr/local/lib/python3.7/site-packages/checkov/helm/runner.py", line 197, in run
    shutil.move(target_dir, save_error_dir)
  File "/usr/local/lib/python3.7/tempfile.py", line 807, in __exit__
    self.cleanup()
  File "/usr/local/lib/python3.7/tempfile.py", line 811, in cleanup
    _shutil.rmtree(self.name)
  File "/usr/local/lib/python3.7/shutil.py", line 485, in rmtree
    onerror(os.lstat, path, sys.exc_info())
  File "/usr/local/lib/python3.7/shutil.py", line 483, in rmtree
    orig_st = os.lstat(path)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpbv1i_tf0'
```
If I then perform `helm template` prior to mounting into a container and then run `checkov -d ./` (using v4.0.413) I get:
```
2021-09-15 08:12:09,552 [MainThread  ] [ERROR]  Failed to run check: Containers should run as a high UID to avoid host conflict for configuration: {'apiVersion': 'apps/v1', 'kind': 'Deployment', 'metadata': {'
name': 'mytest-dependency-track-frontend', 'labels': {'app.kubernetes.io/name': 'dependency-track', 'helm.sh/chart': 'dependency-track-1.1.3', 'app.kubernetes.io/instance': 'mytest', 'app.kubernetes.io/managed
-by': 'Helm', 'app.kubernetes.io/component': 'frontend', '__startline__': 8, '__endline__': 13}, '__startline__': 6, '__endline__': 13}, 'spec': {'replicas': 2, 'selector': {'matchLabels': {'app.kubernetes.io/
name': 'dependency-track', 'app.kubernetes.io/instance': 'mytest', 'app.kubernetes.io/component': 'frontend', '__startline__': 17, '__endline__': 20}, '__startline__': 16, '__endline__': 20}, 'template': {'met
adata': {'labels': {'app.kubernetes.io/name': 'dependency-track', 'helm.sh/chart': 'dependency-track-1.1.3', 'app.kubernetes.io/instance': 'mytest', 'app.kubernetes.io/managed-by': 'Helm', 'app.kubernetes.io/c
omponent': 'frontend', '__startline__': 23, '__endline__': 28}, '__startline__': 22, '__endline__': 28}, 'spec': {'serviceAccountName': 'mytest-dependency-track-frontend', 'securityContext': None, 'containers'
: [{'name': 'dependency-track-frontend', 'securityContext': {'allowPrivilegeEscalation': False, 'runAsUser': 101, '__startline__': 35, '__endline__': 37}, 'resources': {'limits': {'cpu': 1, 'memory': '512Mi',
'__startline__': 39, '__endline__': 41}, 'requests': {'cpu': '100m', 'memory': '128Mi', '__startline__': 42, '__endline__': 44}, '__startline__': 38, '__endline__': 44}, 'image': 'docker.io/dependencytrack/fro
ntend:4.3.1', 'imagePullPolicy': 'IfNotPresent', 'env': [{'name': 'API_BASE_URL', 'value': '', '__startline__': 47, '__endline__': 49}], 'ports': [{'name': 'http', 'containerPort': 8080, 'protocol': 'TCP', '__
startline__': 50, '__endline__': 53}], 'volumeMounts': [{'name': 'tmp', 'mountPath': '/tmp', '__startline__': 54, '__endline__': 58}], 'livenessProbe': {'httpGet': {'port': 'http', 'path': '/', '__startline__'
: 60, '__endline__': 62}, 'initialDelaySeconds': 60, 'periodSeconds': 10, 'timeoutSeconds': 2, 'successThreshold': 1, 'failureThreshold': 3, '__startline__': 59, '__endline__': 67}, 'readinessProbe': {'httpGet
': {'port': 'http', 'path': '/', '__startline__': 69, '__endline__': 71}, 'initialDelaySeconds': 60, 'periodSeconds': 10, 'timeoutSeconds': 2, 'successThreshold': 1, 'failureThreshold': 3, '__startline__': 68,
 '__endline__': 76}, '__startline__': 33, '__endline__': 76, 'apiVersion': 'apps/v1', 'kind': 'containers', 'parent': 'Deployment.mytest-dependency-track-frontend.default (container 0)', 'parent_metadata': {'n
ame': 'mytest-dependency-track-frontend', 'labels': {'app.kubernetes.io/name': 'dependency-track', 'helm.sh/chart': 'dependency-track-1.1.3', 'app.kubernetes.io/instance': 'mytest', 'app.kubernetes.io/managed-
by': 'Helm', 'app.kubernetes.io/component': 'frontend', '__startline__': 8, '__endline__': 13}, '__startline__': 6, '__endline__': 13}}], 'volumes': [{'name': 'tmp', 'emptyDir': {'__startline__': 78, '__endlin
e__': 78}, '__startline__': 77, '__endline__': 86}], '__startline__': 29, '__endline__': 86}, '__startline__': 21, '__endline__': 86}, '__startline__': 14, '__endline__': 86}, '__startline__': 3, '__endline__'
: 86} at file: /templates/frontend/deployment.yaml
Traceback (most recent call last):
  File "/usr/local/bin/checkov", line 8, in <module>
    exit(run())
  File "/usr/local/lib/python3.7/site-packages/checkov/main.py", line 176, in run
    files=file, guidelines=guidelines)
  File "/usr/local/lib/python3.7/site-packages/checkov/common/runners/runner_registry.py", line 60, in run
    collect_skip_comments=collect_skip_comments,
  File "/usr/local/lib/python3.7/site-packages/checkov/kubernetes/runner.py", line 174, in run
    results = registry.scan(k8_file, entity_conf, skipped_checks, runner_filter)
  File "/usr/local/lib/python3.7/site-packages/checkov/kubernetes/base_registry.py", line 26, in scan
    entity_name=entity_type, entity_type=entity_type, skip_info=skip_info)
  File "/usr/local/lib/python3.7/site-packages/checkov/common/checks/base_check.py", line 67, in run
    raise e
  File "/usr/local/lib/python3.7/site-packages/checkov/common/checks/base_check.py", line 54, in run
    check_result["result"] = self.scan_entity_conf(entity_configuration, entity_type)
  File "/usr/local/lib/python3.7/site-packages/checkov/kubernetes/base_spec_check.py", line 20, in scan_entity_conf
    return self.scan_spec_conf(conf, entity_type)
  File "/usr/local/lib/python3.7/site-packages/checkov/kubernetes/base_spec_check.py", line 32, in wrapper
    return wrapped(self, conf)
  File "/usr/local/lib/python3.7/site-packages/checkov/kubernetes/checks/RootContainersHighUID.py", line 49, in scan_spec_conf
    results["pod"]["runAsUser"] = check_runAsUser(spec)
  File "/usr/local/lib/python3.7/site-packages/checkov/kubernetes/checks/RootContainersHighUID.py", line 97, in check_runAsUser
    if "runAsUser" in spec["securityContext"]:
TypeError: argument of type 'NoneType' is not iterable
```

**Note:** `'runAsUser': 101,`
I've just spotted:
```
    spec:
      serviceAccountName: mytest-dependency-track-frontend
      securityContext:
        null
```

I've just inserted a dummy value and replaced the `null` and then when I scan I get:
```
/chart/dependency-track # checkov -d ./


       _               _
   ___| |__   ___  ___| | _______   __
  / __| '_ \ / _ \/ __| |/ / _ \ \ / /
 | (__| | | |  __/ (__|   < (_) \ V /
  \___|_| |_|\___|\___|_|\_\___/ \_/

By bridgecrew.io | version: 2.0.413
Update available 2.0.413 -> 2.0.415
Run pip3 install -U checkov to update

kubernetes scan results:

Passed checks: 242, Failed checks: 34, Skipped checks: 0
```
@schosterbarak although the error is with our chart, I believe Checkov needs to be handling it better, as we couldn't really do anything with:
```
Traceback (most recent call last):
  File "/usr/local/bin/checkov", line 8, in <module>
    exit(run())
  File "/usr/local/lib/python3.7/site-packages/checkov/main.py", line 176, in run
    files=file, guidelines=guidelines)
  File "/usr/local/lib/python3.7/site-packages/checkov/common/runners/runner_registry.py", line 60, in run
    collect_skip_comments=collect_skip_comments,
  File "/usr/local/lib/python3.7/site-packages/checkov/helm/runner.py", line 197, in run
    shutil.move(target_dir, save_error_dir)
  File "/usr/local/lib/python3.7/tempfile.py", line 807, in __exit__
    self.cleanup()
  File "/usr/local/lib/python3.7/tempfile.py", line 811, in cleanup
    _shutil.rmtree(self.name)
  File "/usr/local/lib/python3.7/shutil.py", line 485, in rmtree
    onerror(os.lstat, path, sys.exc_info())
  File "/usr/local/lib/python3.7/shutil.py", line 483, in rmtree
    orig_st = os.lstat(path)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpbv1i_tf0'
```
@mtcolman i agree. let me see what can we do to for better output there

Resolving patch:
diff --git a/checkov/kubernetes/checks/PodSecurityContext.py b/checkov/kubernetes/checks/PodSecurityContext.py
--- a/checkov/kubernetes/checks/PodSecurityContext.py
+++ b/checkov/kubernetes/checks/PodSecurityContext.py
@@ -41,7 +41,7 @@ def scan_spec_conf(self, conf):
             spec = inner_spec if inner_spec else spec
 
         if spec:
-            if "securityContext" in spec:
+            if spec.get("securityContext"):
                 if spec["securityContext"]:
                     return CheckResult.PASSED
         return CheckResult.FAILED
diff --git a/checkov/kubernetes/checks/RootContainers.py b/checkov/kubernetes/checks/RootContainers.py
--- a/checkov/kubernetes/checks/RootContainers.py
+++ b/checkov/kubernetes/checks/RootContainers.py
@@ -98,7 +98,7 @@ def scan_spec_conf(self, conf):
 check = RootContainers()
 
 def check_runAsNonRoot(spec):
-    if "securityContext" in spec:
+    if spec.get("securityContext"):
         if "runAsNonRoot" in spec["securityContext"]:
             if spec["securityContext"]["runAsNonRoot"]:
                 return "PASSED"
@@ -107,7 +107,7 @@ def check_runAsNonRoot(spec):
     return "ABSENT"
 
 def check_runAsUser(spec):
-    if "securityContext" in spec:
+    if spec.get("securityContext"):
         if "runAsUser" in spec["securityContext"]:
             if spec["securityContext"]["runAsUser"] > 0:
                 return "PASSED"
diff --git a/checkov/kubernetes/checks/RootContainersHighUID.py b/checkov/kubernetes/checks/RootContainersHighUID.py
--- a/checkov/kubernetes/checks/RootContainersHighUID.py
+++ b/checkov/kubernetes/checks/RootContainersHighUID.py
@@ -93,7 +93,7 @@ def scan_spec_conf(self, conf):
 check = RootContainersHighUID()
 
 def check_runAsUser(spec):
-    if "securityContext" in spec:
+    if spec.get("securityContext"):
         if "runAsUser" in spec["securityContext"]:
             if spec["securityContext"]["runAsUser"] >= 10000:
                 return "PASSED"


Test patch: