Skip to content

Commit d9db531

Browse files
committed
Sanitise and verify FIB output file path
1 parent b8d2b4f commit d9db531

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/murfey/server/api/workflow_fib.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import murfey.util.db as MurfeyDB
1414
from murfey.server.api.auth import validate_instrument_token
1515
from murfey.server.murfey_db import murfey_db
16+
from murfey.util import sanitise_path
1617
from murfey.util.config import get_machine_config
1718
from murfey.util.models import LamellaSiteInfo
1819

@@ -85,6 +86,12 @@ async def make_gif(
8586
machine_config = get_machine_config(instrument_name=instrument_name)[
8687
instrument_name
8788
]
89+
rsync_basepath = machine_config.rsync_basepath or Path(".").resolve()
90+
91+
# Sanitise and verify that the output directory is relative to rsync basepath
92+
output_dir = sanitise_path(gif_params.output_file.parent)
93+
if not output_dir.is_relative_to(rsync_basepath):
94+
logger.error("Output directory path is not permitted")
8895

8996
# Create the directory structure
9097
if not (output_dir := gif_params.output_file.parent).exists():

0 commit comments

Comments
 (0)