Skip to content

Commit bf37ec1

Browse files
committed
fix: address review feedback — correct file_read/file_edit path resolution, data_dir exclusion, macOS SBPL deny rules
1 parent 6482a64 commit bf37ec1

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/sandbox.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -297,18 +297,25 @@ impl Sandbox {
297297
.workspace
298298
.canonicalize()
299299
.unwrap_or_else(|_| self.workspace.clone());
300-
if canonical.starts_with(&workspace_canonical) {
301-
return true;
302-
}
303-
304300
let data_dir_canonical = self
305301
.data_dir
306302
.canonicalize()
307303
.unwrap_or_else(|_| self.data_dir.clone());
308304

305+
if canonical.starts_with(&data_dir_canonical) {
306+
return false;
307+
}
308+
309+
if canonical.starts_with(&workspace_canonical) {
310+
return true;
311+
}
312+
309313
let config = self.config.load();
310314
for path in config.all_writable_paths() {
311315
let allowed = path.canonicalize().unwrap_or_else(|_| path.clone());
316+
if allowed.starts_with(&data_dir_canonical) {
317+
continue;
318+
}
312319
if canonical.starts_with(&allowed) {
313320
return true;
314321
}
@@ -319,14 +326,9 @@ impl Sandbox {
319326
continue;
320327
}
321328
if canonical.starts_with(&allowed) {
322-
return true;
329+
return !canonical.starts_with(&data_dir_canonical);
323330
}
324331
}
325-
326-
if canonical.starts_with(&data_dir_canonical) {
327-
return false;
328-
}
329-
330332
false
331333
}
332334

src/tools/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ impl Tool for FileWriteTool {
333333
}
334334

335335
async fn call(&self, args: Self::Args) -> Result<Self::Output, Self::Error> {
336-
let path = self.context.resolve_path(&args.path)?;
336+
let path = self.context.resolve_writable_path(&args.path)?;
337337

338338
// Ensure parent directory exists if requested
339339
if args.create_dirs

0 commit comments

Comments
 (0)