File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 1414 process_gain as _process_gain ,
1515)
1616from murfey .server .murfey_db import murfey_db
17+ from murfey .util import sanitise_path
1718from murfey .util .config import get_machine_config
1819from murfey .util .db import Session
1920
@@ -51,9 +52,17 @@ async def create_symlink(
5152 instrument_name
5253 ]
5354 rsync_basepath = (machine_config .rsync_basepath or Path ("" )).resolve ()
54- symlink_full_path = rsync_basepath / symlink_params .symlink
55+ symlink_full_path = sanitise_path (rsync_basepath / symlink_params .symlink )
56+ # Verify that the symlink provided does not lead elsewhere
57+ if not symlink_full_path .resolve ().is_relative_to (rsync_basepath ):
58+ logger .warning (
59+ "Symlink rejected because it will be created in a forbidden location"
60+ )
61+ return ""
62+ # Remove and replace symlink if it exists are 'override' is set
5563 if symlink_full_path .is_symlink () and symlink_params .override :
5664 symlink_full_path .unlink ()
65+ # If a file/folder already exists using the desired symlink name, return empty string
5766 if symlink_full_path .exists ():
5867 return ""
5968 symlink_full_path .symlink_to (rsync_basepath / symlink_params .target )
You can’t perform that action at this time.
0 commit comments