diff options
Diffstat (limited to 'internal/jail/jail_test.go')
-rw-r--r-- | internal/jail/jail_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/jail/jail_test.go b/internal/jail/jail_test.go index ed52c39b..2e505803 100644 --- a/internal/jail/jail_test.go +++ b/internal/jail/jail_test.go @@ -295,3 +295,20 @@ func TestJailIntoCleansNestedDirs(t *testing.T) { _, err := os.Stat(jailPath) require.NoError(t, err, "/ in jail (corresponding to external directory) was removed") } + +func TestJailIntoSubpathsFails(t *testing.T) { + jailPath := tmpJailPath() + require.NoError(t, os.MkdirAll(jailPath, 0755)) + defer os.RemoveAll(jailPath) + + pagesRoot := "/pages/sub/path" + + chroot := jail.Into(jailPath) + chroot.MkDir(pagesRoot, 0755) + err := chroot.Build() + require.Error(t, err, "err") + require.Contains(t, err.Error(), "no such file or directory") + + _, err = os.Stat(path.Join(jailPath, pagesRoot)) + require.True(t, os.IsNotExist(err), "%s in jail was not removed", pagesRoot) +} |