chore(provisionersdk): add test for not following symlinks (#11165)

This commit is contained in:
Ammar Bandukwala 2023-12-12 14:44:50 -06:00 committed by GitHub
parent 2471f3b9a8
commit 19c0cfdabf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -15,6 +15,22 @@ import (
func TestTar(t *testing.T) {
t.Parallel()
t.Run("NoFollowSymlink", func(t *testing.T) {
t.Parallel()
dir := t.TempDir()
file, err := os.CreateTemp(dir, "*.tf")
require.NoError(t, err)
_ = file.Close()
// If we follow symlinks, Tar would fail.
// See https://github.com/coder/coder/issues/5677.
err = os.Symlink("no-exists", filepath.Join(dir, "link"))
require.NoError(t, err)
err = provisionersdk.Tar(io.Discard, dir, 1024*1024)
require.NoError(t, err)
})
t.Run("HeaderBreakLimit", func(t *testing.T) {
t.Parallel()
dir := t.TempDir()