Plugins: Improved handling of symlinks (#51324)
Improves how we handle symlinks in plugin management.
This commit is contained in:
@@ -619,7 +619,7 @@ func isSymlinkRelativeTo(basePath string, symlinkDestPath string, symlinkOrigPat
|
||||
return false
|
||||
}
|
||||
|
||||
if strings.HasPrefix(p, ".."+string(filepath.Separator)) {
|
||||
if p == ".." || strings.HasPrefix(p, ".."+string(filepath.Separator)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,6 +280,34 @@ func TestIsSymlinkRelativeTo(t *testing.T) {
|
||||
symlinkOrigPath: "/dir/sub-dir/test1.txt",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
desc: "Symbolic link pointing to relative file outside basePath should return false",
|
||||
basePath: "/dir",
|
||||
symlinkDestPath: "../../",
|
||||
symlinkOrigPath: "/dir/sub-sir/symlink.txt",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
desc: "Symbolic link pointing to relative file outside basePath should return false",
|
||||
basePath: "/dir",
|
||||
symlinkDestPath: "../..",
|
||||
symlinkOrigPath: "/dir/sub-sir/symlink.txt",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
desc: "Symbolic link pointing to relative file outside basePath should return false",
|
||||
basePath: "/dir",
|
||||
symlinkDestPath: "../../",
|
||||
symlinkOrigPath: "/dir/sub-sir/",
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
desc: "Symbolic link pointing to relative file outside basePath should return false",
|
||||
basePath: "/dir",
|
||||
symlinkDestPath: "../..",
|
||||
symlinkOrigPath: "/dir/sub-sir/",
|
||||
expected: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tcs {
|
||||
|
||||
Reference in New Issue
Block a user