Skip to content

Commit 998f68d

Browse files
ForestEckhardtryanmoran
authored andcommitted
Moves test to proper file and tries to make CodeQL happy let's hope
1 parent 82d7592 commit 998f68d

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

vacation/vacation.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,12 @@ func (z ZipArchive) Decompress(destination string) error {
411411
// This function checks to see that the given path is within the destination
412412
// directory or it is the destination directory itself i.e. ./
413413
func checkExtractPath(filePath string, destination string) error {
414+
if filePath == "."+string(os.PathSeparator) {
415+
return nil
416+
}
417+
414418
destpath := filepath.Join(destination, filePath)
415-
if !strings.HasPrefix(destpath, filepath.Clean(destination)+string(os.PathSeparator)) && destpath != filepath.Clean(destination) {
419+
if !strings.HasPrefix(destpath, filepath.Clean(destination)+string(os.PathSeparator)) {
416420
return fmt.Errorf("illegal file path %q: the file path does not occur within the destination directory", filePath)
417421
}
418422
return nil

vacation/vacation_tar_gzip_test.go

-6
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ func testVacationTarGzip(t *testing.T, context spec.G, it spec.S) {
3535
gw := gzip.NewWriter(buffer)
3636
tw := tar.NewWriter(gw)
3737

38-
// Some archive files will make a relative top level path directory these
39-
// should still successfully decompress.
40-
Expect(tw.WriteHeader(&tar.Header{Name: "./", Mode: 0755, Typeflag: tar.TypeDir})).To(Succeed())
41-
_, err = tw.Write(nil)
42-
Expect(err).NotTo(HaveOccurred())
43-
4438
Expect(tw.WriteHeader(&tar.Header{Name: "some-dir", Mode: 0755, Typeflag: tar.TypeDir})).To(Succeed())
4539
_, err = tw.Write(nil)
4640
Expect(err).NotTo(HaveOccurred())

vacation/vacation_tar_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ func testVacationTar(t *testing.T, context spec.G, it spec.S) {
3333
buffer := bytes.NewBuffer(nil)
3434
tw := tar.NewWriter(buffer)
3535

36+
// Some archive files will make a relative top level path directory these
37+
// should still successfully decompress.
38+
Expect(tw.WriteHeader(&tar.Header{Name: "./", Mode: 0755, Typeflag: tar.TypeDir})).To(Succeed())
39+
_, err = tw.Write(nil)
40+
Expect(err).NotTo(HaveOccurred())
41+
3642
Expect(tw.WriteHeader(&tar.Header{Name: "some-dir", Mode: 0755, Typeflag: tar.TypeDir})).To(Succeed())
3743
_, err = tw.Write(nil)
3844
Expect(err).NotTo(HaveOccurred())

0 commit comments

Comments
 (0)