Skip to content

Commit 2a8761d

Browse files
committed
Validate setup file path inputted
1 parent 801cdb1 commit 2a8761d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/murfey/server/api/bootstrap.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,12 @@ def get_msys2_setup(setup_file: str):
297297
MSYS2 distribution that then remains on the client machines.
298298
"""
299299

300+
# Validate characters in sent path
301+
if not bool(re.fullmatch(r"^[\w\.\-]+$", setup_file)):
302+
raise ValueError("Unallowed characters present in requested setup file")
303+
300304
# Allow only '.exe', 'tar.xz', 'tar.zst', or '.sig' files
301-
if not any(setup_file.endswith(suffix) for suffix in (msys2_file_ext)):
305+
if not any(setup_file.endswith(ext) for ext in (msys2_file_ext)):
302306
raise ValueError(f"{setup_file!r} is not a valid executable")
303307

304308
installer = requests.get(f"{msys2_url}/distrib/{setup_file}")

0 commit comments

Comments
 (0)