Skip to content

Commit 15848c0

Browse files
committed
Fixed: enforce absolute path validation for workdir in execute_command
The BashArgs.workdir documentation states it must be an absolute path, but this constraint was not enforced. Added is_absolute() check before is_dir() check to provide a clearer error message when a relative path is provided.
1 parent 29f6d4c commit 15848c0

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎src/llm-coding-tools-core/src/operations/bash/async_impl.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ pub async fn execute_command(
1616
timeout: Duration,
1717
) -> ToolResult<BashOutput> {
1818
if let Some(dir) = workdir {
19+
if !dir.is_absolute() {
20+
return Err(ToolError::InvalidPath(format!(
21+
"working directory must be an absolute path: {}",
22+
dir.display()
23+
)));
24+
}
1925
if !dir.is_dir() {
2026
return Err(ToolError::InvalidPath(format!(
2127
"working directory does not exist: {}",

‎src/llm-coding-tools-core/src/operations/bash/blocking_impl.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ pub fn execute_command(
1616
timeout: Duration,
1717
) -> ToolResult<BashOutput> {
1818
if let Some(dir) = workdir {
19+
if !dir.is_absolute() {
20+
return Err(ToolError::InvalidPath(format!(
21+
"working directory must be an absolute path: {}",
22+
dir.display()
23+
)));
24+
}
1925
if !dir.is_dir() {
2026
return Err(ToolError::InvalidPath(format!(
2127
"working directory does not exist: {}",

0 commit comments

Comments
 (0)