fix(exec): fail closed on file URI and cross-volume paths
This commit is contained in:
parent
bdef3e411f
commit
c297a57807
1 changed files with 8 additions and 0 deletions
|
|
@ -441,6 +441,14 @@ func (t *ExecTool) guardCommand(command, cwd string) string {
|
|||
continue
|
||||
}
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
pathVolume := filepath.VolumeName(p)
|
||||
cwdVolume := filepath.VolumeName(cwdPath)
|
||||
if pathVolume != "" && cwdVolume != "" && !strings.EqualFold(pathVolume, cwdVolume) {
|
||||
return "Command blocked by safety guard (path outside working dir)"
|
||||
}
|
||||
}
|
||||
|
||||
rel, err := filepath.Rel(cwdPath, p)
|
||||
if err != nil {
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue