bridgecrewio / checkov

Prevent cloud misconfigurations and find vulnerabilities during build-time in infrastructure as code, container images and open source packages with Checkov by Bridgecrew.
https://www.checkov.io/
Apache License 2.0
6.71k stars 1.07k forks source link

Checkov crashing on terraform config since 3.2.120 #6398

Open jgroves71 opened 4 weeks ago

jgroves71 commented 4 weeks ago

Describe the issue Checkov throwing a traceback since upgrading to version 3.2.120

Examples Please share an example code sample (in the IaC of your choice) + the expected outcomes.

Exception Trace checkov -d . --skip-check CKV_AZURE_234 --var-file "../../IAC-AB118-Terraform Core Modules/core.production.tfvars" --var-file ./terraform.production.tfvars [ secrets framework ]: 100%|████████████████████|[8/8], Current File Scanned=.\variables.tf [ terraform framework ]: 7%|█▎ |[6/92], Current File Scanned=....\IAC-AB118-Terraform Core Modules\Azure_Terraform_Modules\azurecaf_name\azurecaf.tf 2024-06-04 10:21:40,304 [MainThread ] [ERROR] Exception traceback: Traceback (most recent call last): File "C:\Program Files\Python312\Lib\site-packages\checkov\main.py", line 523, in run self.scan_reports = runner_registry.run( ^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\Python312\Lib\site-packages\checkov\common\runners\runner_registry.py", line 176, in run for result in parallel_runner_results: File "C:\Program Files\Python312\Lib\concurrent\futures_base.py", line 619, in result_iterator yield _result_or_cancel(fs.pop()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\Python312\Lib\concurrent\futures_base.py", line 317, in _result_or_cancel return fut.result(timeout) ^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\Python312\Lib\concurrent\futures_base.py", line 449, in result return self.get_result() ^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\Python312\Lib\concurrent\futures_base.py", line 401, in get_result raise self._exception File "C:\Program Files\Python312\Lib\concurrent\futures\thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\Python312\Lib\site-packages\checkov\common\runners\runner_registry.py", line 835, in _parallel_run report = runner.run( ^^^^^^^^^^^ File "C:\Program Files\Python312\Lib\site-packages\checkov\terraform\runner.py", line 134, in run self.check_tf_definition(report, root_folder, runner_filter, collect_skip_comments) File "C:\Program Files\Python312\Lib\site-packages\checkov\terraform\runner.py", line 235, in check_tf_definition self.run_all_blocks( File "C:\Program Files\Python312\Lib\site-packages\checkov\terraform\runner.py", line 311, in run_all_blocks self.run_block( File "C:\Program Files\Python312\Lib\site-packages\checkov\terraform\runner.py", line 365, in run_block caller_context = definition_context[module_full_path].get(BlockType.MODULE, {}).get(module_name)


KeyError: tf_source_modules:{"path": "C:\\agent\\_work\\9\\s\\IAC-AB118-Terraform Core Modules\\Azure_Terraform_Modules\\nsgflowlogs\\nsgflowlogs.tf", "name": "nsgflowlog_storage_account", "foreach_idx": null, "nested_tf_module": {"path": "C:\\agent\\_work\\9\\s\\IAC-AB118-Tooling\\Tooling subscription\\main.tf", "name": "nsgflowlogs", "foreach_idx": 0, "nested_tf_module": null}}, file_path:C:\agent\_work\9\s\IAC-AB118-Terraform Core Modules\Azure_Terraform_Modules\storage_account\1_0_0\storage_account.tf
[ terraform framework ]:   7%|█▎                  |[6/92], Current File Scanned=..\..\IAC-AB118-Terraform Core Modules\Azure_Terraform_Modules\azurecaf_name\azurecaf.tf
```

**Desktop (please complete the following information):**
 - OS: Windows server 2022
 - Checkov Version: Since 3.2.120 (still happening in 3.2.125)

**Additional context**
This traceback seems to be happening somewhere in a module which has not changed in a long time.
jgroves71 commented 4 days ago

Bump...still an issue for me even in most recent version (upgraded today). I've had to disable checkov scans in my environment pending a resolution to this.