File tree Expand file tree Collapse file tree 2 files changed +4
-13
lines changed
Expand file tree Collapse file tree 2 files changed +4
-13
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ def validate_and_sanitise(
7878 machine_config = get_machine_config (instrument_name = instrument_name )[
7979 instrument_name
8080 ]
81- base_path = machine_config .rsync_basepath .as_posix ()
81+ rsync_basepath = machine_config .rsync_basepath .resolve ()
8282
8383 # Check that full file path doesn't contain unallowed characters
8484 # Currently allows only:
@@ -91,7 +91,7 @@ def validate_and_sanitise(
9191 raise ValueError (f"Unallowed characters present in { file } " )
9292
9393 # Check that it's not accessing somehwere it's not allowed
94- if not str (full_path ).startswith (str (base_path )):
94+ if not str (full_path ).startswith (str (rsync_basepath )):
9595 raise ValueError (f"{ file } points to a directory that is not permitted" )
9696
9797 # Check that it is of a permitted file type
Original file line number Diff line number Diff line change @@ -64,16 +64,7 @@ def _validate_and_sanitise(
6464 machine_config = get_machine_config (instrument_name = instrument_name )[
6565 instrument_name
6666 ]
67- rsync_basepath = machine_config .rsync_basepath
68- try :
69- base_path = list (rsync_basepath .parents )[- 2 ].as_posix ()
70- except IndexError :
71- logger .warning (f"Base path { rsync_basepath !r} is too short" )
72- base_path = rsync_basepath .as_posix ()
73- except Exception as e :
74- raise Exception (
75- f"Unexpected exception encountered when loading the file base path: { e } "
76- )
67+ rsync_basepath = machine_config .rsync_basepath .resolve ()
7768
7869 # Check that full file path doesn't contain unallowed characters
7970 # Currently allows only:
@@ -86,7 +77,7 @@ def _validate_and_sanitise(
8677 raise ValueError (f"Unallowed characters present in { file } " )
8778
8879 # Check that it's not accessing somehwere it's not allowed
89- if not str (full_path ).startswith (str (base_path )):
80+ if not str (full_path ).startswith (str (rsync_basepath )):
9081 raise ValueError (f"{ file } points to a directory that is not permitted" )
9182
9283 # Check that it is of a permitted file type
You can’t perform that action at this time.
0 commit comments