Skip to content
Open
Changes from 1 commit
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: 7 additions & 1 deletion pr_agent/git_providers/gerrit_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,16 @@ def split_suggestion(self, msg) -> tuple[str, str]:

def publish_code_suggestions(self, code_suggestions: list):
msg = []
repo_root = pathlib.Path(self.repo_path).resolve()
for suggestion in code_suggestions:
# Sanitize file path to prevent directory traversal
target_path = (repo_root / suggestion["relevant_file"]).resolve()
if not str(target_path).startswith(str(repo_root)):
get_logger().warning(f"Skipping suggestion with path traversal: {suggestion['relevant_file']}")
Comment thread
qodo-free-for-open-source-projects[bot] marked this conversation as resolved.
Outdated
continue
Comment thread
qodo-free-for-open-source-projects[bot] marked this conversation as resolved.
description, code = self.split_suggestion(suggestion['body'])
add_suggestion(
pathlib.Path(self.repo_path) / suggestion["relevant_file"],
target_path,
code,
suggestion["relevant_lines_start"],
suggestion["relevant_lines_end"],
Expand Down
Loading