Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion server/gti/gti_mcp/tools/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,15 @@ async def analyse_file(file_path: str, ctx: Context):
Returns:
The analysis report.
"""
import os
resolved = os.path.realpath(os.path.abspath(file_path))
allowed_dir = os.path.realpath("/tmp/gti-uploads")
if not resolved.startswith(allowed_dir + os.sep):
raise ValueError(
f"Access denied: file_path must be within {allowed_dir}"
)
async with vt_client(ctx) as client:
with open(file_path, "rb") as f:
with open(resolved, "rb") as f:
analysis = await client.scan_file_async(file=f)
logging.info(f"File {file_path} uploaded.")

Expand Down