(path string, workspaceRoot string)
| 296 | } |
| 297 | |
| 298 | func IsPathWithinWorkspace(path string, workspaceRoot string) bool { |
| 299 | resolved, err := resolvePath(path) |
| 300 | if err != nil { |
| 301 | return false |
| 302 | } |
| 303 | |
| 304 | root, err := resolvePath(workspaceRoot) |
| 305 | if err != nil { |
| 306 | return false |
| 307 | } |
| 308 | |
| 309 | rel, err := filepath.Rel(root, resolved) |
| 310 | if err != nil { |
| 311 | return false |
| 312 | } |
| 313 | |
| 314 | return rel == "." || (!strings.HasPrefix(rel, ".."+string(filepath.Separator)) && rel != "..") |
| 315 | } |
| 316 | |
| 317 | func ValidatePaths(command string, workspaceRoot string) (bool, []string) { |
| 318 | paths := ExtractPaths(command) |
no test coverage detected