Cleaning up the codebase.
This commit is contained in:
16
fileutil/symlinks.go
Normal file
16
fileutil/symlinks.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package fileutil
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ValidateSymlink checks to make sure a symlink exists in some top-level
|
||||
// directory.
|
||||
func ValidateSymlink(symlink, topLevel string) bool {
|
||||
target, err := filepath.EvalSymlinks(symlink)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return strings.HasPrefix(target, topLevel)
|
||||
}
|
||||
Reference in New Issue
Block a user