MCPcopy Create free account
hub / github.com/MertJSX/folderhost / IsSafePath

Function IsSafePath

utils/is_safe_path.go:11–19  ·  view source on GitHub ↗
(requestedPath string)

Source from the content-addressed store, hash-verified

9)
10
11func IsSafePath(requestedPath string) bool {
12 baseDir := filepath.Clean(fmt.Sprintf("./%s", config.Config.Folder))
13
14 fullPath := filepath.Join(baseDir, requestedPath)
15
16 cleanPath := filepath.Clean(fullPath)
17
18 return strings.HasPrefix(cleanPath, baseDir)
19}

Callers 5

CheckAuthFunction · 0.92
HandleWebsocketFunction · 0.92
processWebSocketMessageFunction · 0.92
extractFileFunction · 0.85
archiveItemFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected