Skip to content

Commit

Permalink
fix(terraform): Replaced / with os.pathsep to support windows better …
Browse files Browse the repository at this point in the history
…in terraform runner (#5473)

* Replaced / with os.pathsep to support windows better in terraform runner

* Used os.sep instead of os.pathsep which is the correct one
  • Loading branch information
bo156 authored Aug 22, 2023
1 parent 83f6981 commit c1799eb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions checkov/terraform/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def get_connected_node(self, entity: dict[str, Any], root_folder: str) -> Option
full_file_path = connected_entity[CustomAttributes.FILE_PATH]
connected_node_data = {}
connected_node_data['code_block'] = connected_entity_context.get('code_lines')
connected_node_data['file_path'] = f"/{os.path.relpath(full_file_path, root_folder)}"
connected_node_data['file_path'] = f"{os.sep}{os.path.relpath(full_file_path, root_folder)}"
connected_node_data['file_line_range'] = [connected_entity_context.get('start_line'),
connected_entity_context.get('end_line')]
connected_node_data['resource'] = ".".join(connected_entity_context['definition_path'])
Expand Down Expand Up @@ -276,7 +276,7 @@ def get_graph_checks_report(self, root_folder: str, runner_filter: RunnerFilter,
check_name=check.name,
check_result=copy_of_check_result,
code_block=censored_code_lines,
file_path=f"/{os.path.relpath(full_file_path, root_folder)}",
file_path=f"{os.sep}{os.path.relpath(full_file_path, root_folder)}",
file_line_range=[entity_context.get('start_line'),
entity_context.get('end_line')],
resource=resource,
Expand Down Expand Up @@ -344,7 +344,7 @@ def check_tf_definition(
full_file_path.file_path)})
abs_scanned_file = get_abs_path(full_file_path)
abs_referrer = None
scanned_file = f"/{os.path.relpath(abs_scanned_file, root_folder)}"
scanned_file = f"{os.sep}{os.path.relpath(abs_scanned_file, root_folder)}"
logging.debug(f"Scanning file: {scanned_file}")
self.run_all_blocks(definition, self.context, full_file_path, root_folder, report,
scanned_file, runner_filter, abs_referrer)
Expand Down Expand Up @@ -415,7 +415,7 @@ def run_block(
continue
caller_file_line_range = [caller_context.get('start_line'), caller_context.get('end_line')]
abs_caller_file = get_abs_path(module_full_path)
caller_file_path = f"/{os.path.relpath(abs_caller_file, root_folder)}"
caller_file_path = f"{os.sep}{os.path.relpath(abs_caller_file, root_folder)}"

if entity_context_path_header is None:
entity_context_path = [block_type] + definition_path
Expand Down

0 comments on commit c1799eb

Please sign in to comment.