Skip to content

Commit

Permalink
fix(terraform): ensure TFModule is created properly in definition con…
Browse files Browse the repository at this point in the history
…text (#5446)

ensure TFModule is created properly in definition context
  • Loading branch information
tronxd committed Aug 16, 2023
1 parent c72b91c commit 74739f4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions checkov/terraform/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from checkov.common.util.secrets import omit_secret_value_from_checks, omit_secret_value_from_graph_checks
from checkov.common.variables.context import EvaluationContext
from checkov.runner_filter import RunnerFilter
from checkov.terraform.modules.module_objects import TFDefinitionKey
from checkov.terraform.modules.module_objects import TFDefinitionKey, TFModule
from checkov.terraform.checks.data.registry import data_registry
from checkov.terraform.checks.module.registry import module_registry
from checkov.terraform.checks.provider.registry import provider_registry
Expand Down Expand Up @@ -301,9 +301,11 @@ def get_graph_checks_report(self, root_folder: str, runner_filter: RunnerFilter,

def get_entity_context_and_evaluations(self, entity: dict[str, Any]) -> dict[str, Any] | None:
block_type = entity[CustomAttributes.BLOCK_TYPE]
full_file_path = entity[CustomAttributes.FILE_PATH]

full_file_path = TFDefinitionKey(file_path=entity.get(CustomAttributes.FILE_PATH), tf_source_modules=entity.get(CustomAttributes.SOURCE_MODULE_OBJECT))
tf_source_module_obj = entity.get(CustomAttributes.SOURCE_MODULE_OBJECT)
if isinstance(tf_source_module_obj, dict):
tf_source_module_obj = TFModule.from_json(tf_source_module_obj)
full_file_path = TFDefinitionKey(file_path=entity.get(CustomAttributes.FILE_PATH),
tf_source_modules=tf_source_module_obj)

definition_path = entity[CustomAttributes.BLOCK_NAME].split('.')
entity_context_path = [block_type] + definition_path
Expand Down

0 comments on commit 74739f4

Please sign in to comment.