mirror of
https://github.com/phishingclub/phishingclub.git
synced 2026-02-12 16:12:44 +00:00
12 lines
474 B
Go
12 lines
474 B
Go
package utils
|
|
|
|
import "path/filepath"
|
|
|
|
// GetSafePathWithinRoot returns a safe path within a root
|
|
// safeRootPath is the root directory and must be a SAFE string
|
|
// unsafePath is the path to be joined to the root and can be UNSAFE string
|
|
// example: GetSafePathWithinRoot("/home/user", "../etc/passwd") returns "/home/user/etc/passwd"
|
|
func GetSafePathWithinRoot(safeRootPath, unsafePath string) string {
|
|
return filepath.Join(safeRootPath, filepath.Clean("/"+unsafePath))
|
|
}
|