MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / IsPathWithinWorkspace

Function IsPathWithinWorkspace

tools/bash/validation.go:298–315  ·  view source on GitHub ↗
(path string, workspaceRoot string)

Source from the content-addressed store, hash-verified

296}
297
298func 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
317func ValidatePaths(command string, workspaceRoot string) (bool, []string) {
318 paths := ExtractPaths(command)

Callers 1

ValidatePathsFunction · 0.85

Calls 1

resolvePathFunction · 0.85

Tested by

no test coverage detected