fix(vision): reject rooted image paths on windows

This commit is contained in:
Hunter Bown
2026-05-12 14:13:19 -05:00
parent 190eb6b162
commit 2326220b7e
+7 -6
View File
@@ -1,6 +1,6 @@
//! `image_analyze` tool — analyze images using a dedicated vision model.
use std::path::Path;
use std::path::{Component, Path};
use std::time::Duration;
use async_trait::async_trait;
@@ -109,11 +109,12 @@ impl ToolSpec for ImageAnalyzeTool {
.unwrap_or("Describe this image in detail.");
let image_path_buf = Path::new(image_path);
if image_path_buf.is_absolute()
|| image_path_buf
.components()
.any(|c| matches!(c, std::path::Component::ParentDir))
{
if image_path_buf.components().any(|c| {
matches!(
c,
Component::Prefix(_) | Component::RootDir | Component::ParentDir
)
}) {
return Err(ToolError::execution_failed(
"image_path must be a relative path within the workspace and cannot escape it.",
));