Repository: bridgecrewio/checkov

Issue:
Fails when using debug in pycharm
**Describe the issue**
It works fine if i dont use debug in pycharm
If i skip the kustomize framework or kubernaties nothing hanges still crashes

**Examples**
I have PYCHARM_HOSTED=1
I dont have any kubernaties or kustomize code just plain cloudformation
**Exception Trace**
```sh
2022-10-17 09:56:07,611 [ThreadPoolEx] [DEBUG]  Running graph check: CKV_AWS_57
2022-10-17 09:56:07,612 [ThreadPoolEx] [DEBUG]  Running graph check: CKV2_AWS_9
2022-10-17 09:56:07,612 [ThreadPoolEx] [DEBUG]  Running graph check: CKV_AWS_144
2022-10-17 09:56:07,613 [ThreadPoolEx] [DEBUG]  Running graph check: CKV_AWS_145
2022-10-17 09:56:07,613 [ThreadPoolEx] [DEBUG]  Running graph check: CKV2_ADO_1
Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/concurrent/futures/_base.py", line 608, in result_iterator
    yield fs.pop().result()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/concurrent/futures/_base.py", line 438, in result
    return self.__get_result()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/concurrent/futures/_base.py", line 390, in __get_result
    raise self._exception
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/<REDACTED>/checkov/checkov/common/runners/runner_registry.py", line 84, in _parallel_run
    return runner.run(
  File "/Users/<REDACTED>/checkov/checkov/kustomize/runner.py", line 475, in run
    self.run_kustomize_to_k8s(root_folder, files, runner_filter)
  File "/Users/<REDACTED>/checkov/checkov/kustomize/runner.py", line 439, in run_kustomize_to_k8s
    manager = multiprocessing.Manager()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/multiprocessing/context.py", line 57, in Manager
    m.start()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/multiprocessing/managers.py", line 557, in start
    self._address = reader.recv()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/multiprocessing/connection.py", line 255, in recv
    buf = self._recv_bytes()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/multiprocessing/connection.py", line 419, in _recv_bytes
    buf = self._recv(4)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/multiprocessing/connection.py", line 388, in _recv
    raise EOFError
EOFError
```

**checkov version:**
2.1.270'





Discussion:
Also if i comment out this in the main file it works
    # kustomize_runner(),
hey @coffeecoco thanks for reaching out. Most of my colleagues and myself use `pycharm` and haven't seen this issue. Since it crashes on the initialization of `multiprocessing.Manager()` I think your Python version or `pycharm` have problems. `multiprocessing` belongs to the Python binary, so there is nothing we can update, but I can adjust some code to not trigger this part, if it is actually not needed 😄 
I also found some reports about your issue connected with a hidden OOM error, maybe you should check, if the memory consumption of your `pycharm`.

Resolving patch:
diff --git a/checkov/kustomize/runner.py b/checkov/kustomize/runner.py
--- a/checkov/kustomize/runner.py
+++ b/checkov/kustomize/runner.py
@@ -421,6 +421,10 @@ def run_kustomize_to_k8s(
         self, root_folder: str | None, files: list[str] | None, runner_filter: RunnerFilter
     ) -> None:
         kustomize_dirs = find_kustomize_directories(root_folder, files, runner_filter.excluded_paths)
+        if not kustomize_dirs:
+            # nothing to process
+            return
+
         for kustomize_dir in kustomize_dirs:
             self.kustomizeProcessedFolderAndMeta[kustomize_dir] = self._parseKustomization(kustomize_dir)
         self.target_folder_path = tempfile.mkdtemp()
@@ -474,6 +478,11 @@ def run(
 
         self.run_kustomize_to_k8s(root_folder, files, runner_filter)
         report = Report(self.check_type)
+
+        if not self.kustomizeProcessedFolderAndMeta:
+            # nothing to process
+            return report
+
         target_dir = ""
         try:
             k8s_runner = K8sKustomizeRunner()


Test patch: