Skip to content

Commit 90e2c6a

Browse files
committed
Added validation check that gain reference file originates from where we expect it to
1 parent fd89f54 commit 90e2c6a

File tree

1 file changed

+8
-0
lines changed
  • src/murfey/instrument_server

1 file changed

+8
-0
lines changed

src/murfey/instrument_server/api.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,14 @@ def upload_gain_reference(
335335
headers={"Authorization": f"Bearer {tokens[session_id]}"},
336336
).json()
337337

338+
# Validate that file passed is from the gain reference directory
339+
gain_ref_dir = machine_config.get("gain_reference_directory", "")
340+
if not safe_gain_path.startswith(gain_ref_dir):
341+
raise ValueError(
342+
"Gain reference file does not originate from the gain reference directory "
343+
f"{gain_ref_dir!r}"
344+
)
345+
338346
# Return the rsync URL if set, otherwise assume you are syncing via Murfey
339347
rsync_url = urlparse(str(machine_config.get("rsync_url", _get_murfey_url())))
340348
rsync_module = machine_config.get("rsync_module", "data")

0 commit comments

Comments
 (0)