Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(terraform): Replaced / with os.pathsep to support windows better in terraform runner #5473

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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