forked from containers/podman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libpod: fix lookup for subpath in volumes
a subdirectory that is below a mount destination is detected as a subpath. Closes: containers#15789 Signed-off-by: Giuseppe Scrivano <[email protected]>
- Loading branch information
Showing
3 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package libpod | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestIsSubDir(t *testing.T) { | ||
assert.True(t, isSubDir("/foo", "/foo")) | ||
assert.True(t, isSubDir("/foo/bar", "/foo")) | ||
assert.True(t, isSubDir("/foo/bar", "/foo/")) | ||
assert.True(t, isSubDir("/foo/bar", "/foo//")) | ||
assert.True(t, isSubDir("/foo/bar/", "/foo")) | ||
assert.True(t, isSubDir("/foo/bar/baz/", "/foo")) | ||
assert.True(t, isSubDir("/foo/bar/baz/", "/foo/bar")) | ||
assert.True(t, isSubDir("/foo/bar/baz/", "/foo/bar/")) | ||
assert.False(t, isSubDir("/foo/bar/baz/", "/foobar/")) | ||
assert.False(t, isSubDir("/foo/bar/baz/../../", "/foobar/")) | ||
assert.False(t, isSubDir("/foo/bar/baz/", "../foo/bar")) | ||
assert.False(t, isSubDir("/foo/bar/baz/", "../foo/")) | ||
assert.False(t, isSubDir("/foo/bar/baz/", "../foo")) | ||
assert.False(t, isSubDir("/", "..")) | ||
assert.False(t, isSubDir("//", "..")) | ||
assert.False(t, isSubDir("//", "../")) | ||
assert.False(t, isSubDir("//", "..//")) | ||
assert.True(t, isSubDir("/foo/bar/baz/../../", "/foo/")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters