Skip to content
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
18 changes: 17 additions & 1 deletion sentinelops-backend/app/services/local_git_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,30 @@
return ""
if not self._is_within_allowed_root(normalized):
return ""

normalized_real = os.path.realpath(normalized)
if normalized_real != normalized:
return ""

# Do not allow linking via symlinked repository directories.
if os.path.islink(normalized):
return ""
if not os.path.isdir(normalized):
return ""

git_dir = os.path.join(normalized, ".git")
git_dir_real = os.path.realpath(git_dir)
normalized_prefix = normalized + os.sep
try:
if not (
git_dir_real == normalized
or git_dir_real.startswith(normalized_prefix)
):
return ""
except ValueError:
return ""
# Require a real .git directory inside the repository path and reject symlinks.
if not os.path.isdir(git_dir) or os.path.islink(git_dir):
if not os.path.isdir(git_dir_real) or os.path.islink(git_dir_real):

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
return ""
return normalized

Expand Down
Loading