Skip to content

Commit 5daffe2

Browse files
Potential fix for code scanning alert no. 27: Uncontrolled data used in path expression
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent e6939da commit 5daffe2

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

MultimodalQnA/ui/gradio/multimodalqna_ui_gradio.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,17 @@ def ingest_with_caption(filepath, text_caption, audio_caption, request: gr.Reque
383383
is_audio_caption = audio_caption is not None
384384
if is_audio_caption:
385385
verified_audio_path = os.path.normpath(audio_caption)
386+
if not verified_audio_path.startswith(static_dir):
387+
print("Found malicious audio file path!")
388+
yield (
389+
gr.Textbox(
390+
visible=True,
391+
value="Your uploaded audio file's path is not allowed. Please upload a valid file.",
392+
)
393+
)
394+
return
386395
caption_basename = "{}{}".format(os.path.splitext(basename)[0], os.path.splitext(verified_audio_path)[-1])
387-
caption_file = audio_caption
396+
caption_file = verified_audio_path
388397
else:
389398
caption_basename = "{}.txt".format(os.path.splitext(basename)[0])
390399
caption_file = os.path.join(static_dir, caption_basename)

0 commit comments

Comments
 (0)