You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After applying checkov -d . --framework kustomize onto existing project I got generic error.
2023-05-23 14:08:01,563 [MainThread ] [ERROR] Exception traceback:
Traceback (most recent call last):
File "/home/marek/.local/lib/python3.10/site-packages/checkov/main.py", line 463, in run
self.scan_reports = runner_registry.run(
File "/home/marek/.local/lib/python3.10/site-packages/checkov/common/runners/runner_registry.py", line 102, in run
self.runners[0].run(root_folder, external_checks_dir=external_checks_dir, files=files,
File "/home/marek/.local/lib/python3.10/site-packages/checkov/kustomize/runner.py", line 557, in run
self.run_kustomize_to_k8s(root_folder, files, runner_filter)
File "/home/marek/.local/lib/python3.10/site-packages/checkov/kustomize/runner.py", line 498, in run_kustomize_to_k8s
self.kustomizeProcessedFolderAndMeta[kustomize_dir] = self._parseKustomization(kustomize_dir)
File "/home/marek/.local/lib/python3.10/site-packages/checkov/kustomize/runner.py", line 271, in _parseKustomization
if 'resources' in fileContent:
TypeError: argument of type 'NoneType' is not iterable
Traceback (most recent call last):
File "/home/marek/.local/bin/checkov", line 9, in <module>
sys.exit(Checkov().run())
File "/home/marek/.local/lib/python3.10/site-packages/checkov/main.py", line 463, in run
self.scan_reports = runner_registry.run(
File "/home/marek/.local/lib/python3.10/site-packages/checkov/common/runners/runner_registry.py", line 102, in run
self.runners[0].run(root_folder, external_checks_dir=external_checks_dir, files=files,
File "/home/marek/.local/lib/python3.10/site-packages/checkov/kustomize/runner.py", line 557, in run
self.run_kustomize_to_k8s(root_folder, files, runner_filter)
File "/home/marek/.local/lib/python3.10/site-packages/checkov/kustomize/runner.py", line 498, in run_kustomize_to_k8s
self.kustomizeProcessedFolderAndMeta[kustomize_dir] = self._parseKustomization(kustomize_dir)
File "/home/marek/.local/lib/python3.10/site-packages/checkov/kustomize/runner.py", line 271, in _parseKustomization
if 'resources' in fileContent:
TypeError: argument of type 'NoneType' is not iterable
After some digging inside _parseKustomization at kustomize/runner.py:247 and applying try block loop body I found out file that was causing me the issue. I had following folders in kubernetess directory: base, prod,stage,dev. But dev contained totally empty kustomization.yaml file. Filling this file with yaml content solves the issue.
However maybe its worth to add some checks on fileContent object before we attempt to examine it for its contents.
checkov -v
2.3.234
The text was updated successfully, but these errors were encountered:
marekiwaniak
changed the title
kustomize fails on empty kustomizatio.yaml file without meaningful message
kustomize fails on empty kustomization.yaml file without meaningful message
May 23, 2023
Alternatively, this could be turned into a failing policy saying that an empty kustomization file is confusing/undefined behavior/something else and should be avoided. Either case, it shouldn't crash the scanner.
After applying
checkov -d . --framework kustomize
onto existing project I got generic error.After some digging inside _parseKustomization at kustomize/runner.py:247 and applying try block loop body I found out file that was causing me the issue. I had following folders in kubernetess directory: base, prod,stage,dev. But dev contained totally empty kustomization.yaml file. Filling this file with yaml content solves the issue.
However maybe its worth to add some checks on
fileContent
object before we attempt to examine it for its contents.The text was updated successfully, but these errors were encountered: