diff --git a/client/client_test.go b/client/client_test.go index 51836291a..e4b66d892 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -80,11 +80,12 @@ func testLocalSymlinkEscape(t *testing.T, sb integration.Sandbox) { require.NoError(t, err) defer c.Close() - test := []byte(`set -x + test := []byte(`set -ex [[ -L /mount/foo ]] [[ -L /mount/sub/bar ]] [[ -L /mount/bax ]] [[ -f /mount/bay ]] +[[ -f /mount/sub/sub2/file ]] [[ ! -f /mount/baz ]] [[ ! -f /mount/etc/passwd ]] [[ ! -f /mount/etc/group ]] @@ -102,6 +103,9 @@ func testLocalSymlinkEscape(t *testing.T, sb integration.Sandbox) { fstest.Symlink("bay", "bax"), // target for symlink (not requested) fstest.CreateFile("bay", []byte{}, 0600), + // file with many subdirs + fstest.CreateDir("sub/sub2", 0700), + fstest.CreateFile("sub/sub2/file", []byte{}, 0600), // unused file that shouldn't be included fstest.CreateFile("baz", []byte{}, 0600), fstest.CreateFile("test.sh", test, 0700), @@ -110,7 +114,7 @@ func testLocalSymlinkEscape(t *testing.T, sb integration.Sandbox) { defer os.RemoveAll(dir) local := llb.Local("mylocal", llb.FollowPaths([]string{ - "test.sh", "foo", "sub/bar", "bax", + "test.sh", "foo", "sub/bar", "bax", "sub/sub2/file", })) st := llb.Image("busybox:latest"). diff --git a/vendor.conf b/vendor.conf index ee1375da2..e4068737a 100644 --- a/vendor.conf +++ b/vendor.conf @@ -39,7 +39,7 @@ golang.org/x/time f51c12702a4d776e4c1fa9b0fabab841babae631 github.com/docker/docker 71cd53e4a197b303c6ba086bd584ffd67a884281 github.com/pkg/profile 5b67d428864e92711fcbd2f8629456121a56d91f -github.com/tonistiigi/fsutil 8839685ae8c3c8bd67d0ce28e9b3157b23c1c7a5 +github.com/tonistiigi/fsutil 8abad97ee3969cdf5e9c367f46adba2c212b3ddb github.com/hashicorp/go-immutable-radix 826af9ccf0feeee615d546d69b11f8e98da8c8f1 git://github.com/tonistiigi/go-immutable-radix.git github.com/hashicorp/golang-lru a0d98a5f288019575c6d1f4bb1573fef2d1fcdc4 github.com/mitchellh/hashstructure 2bca23e0e452137f789efbc8610126fd8b94f73b diff --git a/vendor/github.com/tonistiigi/fsutil/walker.go b/vendor/github.com/tonistiigi/fsutil/walker.go index 3a44172db..aa5099145 100644 --- a/vendor/github.com/tonistiigi/fsutil/walker.go +++ b/vendor/github.com/tonistiigi/fsutil/walker.go @@ -107,6 +107,9 @@ func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) err } } if !matched { + if fi.IsDir() { + return filepath.SkipDir + } return nil } if !partial && fi.IsDir() { @@ -236,7 +239,7 @@ func trimUntilIndex(str, sep string, count int) string { s = s[idx+len(sep):] i += idx + len(sep) c++ - if c >= count { + if c > count { return str[:i-len(sep)] } }