File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -52,8 +52,16 @@ async def create_symlink(
5252 ]
5353 rsync_basepath = (machine_config .rsync_basepath or Path ("" )).resolve ()
5454 symlink_full_path = rsync_basepath / symlink_params .symlink
55+ # Verify that the symlink provided does not lead elsewhere
56+ if not symlink_full_path .resolve ().is_relative_to (rsync_basepath ):
57+ logger .warning (
58+ "Symlink rejected because it will be created in a forbidden location"
59+ )
60+ return ""
61+ # Remove and replace symlink if it exists are 'override' is set
5562 if symlink_full_path .is_symlink () and symlink_params .override :
5663 symlink_full_path .unlink ()
64+ # If a file/folder already exists using the desired symlink name, return empty string
5765 if symlink_full_path .exists ():
5866 return ""
5967 symlink_full_path .symlink_to (rsync_basepath / symlink_params .target )
You can’t perform that action at this time.
0 commit comments