Skip to content

Commit

Permalink
Allow absolute paths when not restricting to workspace root (Signific…
Browse files Browse the repository at this point in the history
…ant-Gravitas#4946)

* restrict_to_root fix

* Fix formatting

---------

Co-authored-by: Reinier van der Leer <github@pwuts.nl>
  • Loading branch information
2 people authored and dayofthedave committed Jul 17, 2023
1 parent db548e9 commit a2826d5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion autogpt/workspace/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ def _sanitize_path(
logger.debug(f"Resolved root as '{root}'")

# Allow exception for absolute paths if they are contained in your workspace directory.
if relative_path.is_absolute() and not relative_path.is_relative_to(root):
if (
relative_path.is_absolute()
and restrict_to_root
and not relative_path.is_relative_to(root)
):
raise ValueError(
f"Attempted to access absolute path '{relative_path}' in workspace '{root}'."
)
Expand Down

0 comments on commit a2826d5

Please sign in to comment.