From 38ce8618e11adda42c091bf9149ff461b725b729 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Thu, 8 Jul 2021 10:14:01 +1000 Subject: [PATCH] Revert "Fix for gosec rule G304 - sanitize filepaths" This reverts commit ffb6cbf769687a270f60c6e9975cc48f9c5b5bb4. --- pkg/yqlib/file_utils.go | 3 +-- pkg/yqlib/utils.go | 3 +-- test/utils.go | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pkg/yqlib/file_utils.go b/pkg/yqlib/file_utils.go index 4c18823e..cfe8d2c4 100644 --- a/pkg/yqlib/file_utils.go +++ b/pkg/yqlib/file_utils.go @@ -3,7 +3,6 @@ package yqlib import ( "io" "os" - "path/filepath" ) func safelyRenameFile(from string, to string) { @@ -26,7 +25,7 @@ func safelyRenameFile(from string, to string) { // thanks https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang func copyFileContents(src, dst string) (err error) { - in, err := os.Open(filepath.Clean(src)) + in, err := os.Open(src) // nolint gosec if err != nil { return err } diff --git a/pkg/yqlib/utils.go b/pkg/yqlib/utils.go index 6786f1b4..dd93d248 100644 --- a/pkg/yqlib/utils.go +++ b/pkg/yqlib/utils.go @@ -5,7 +5,6 @@ import ( "container/list" "io" "os" - "path/filepath" yaml "gopkg.in/yaml.v3" ) @@ -14,7 +13,7 @@ func readStream(filename string) (io.Reader, error) { if filename == "-" { return bufio.NewReader(os.Stdin), nil } else { - return os.Open(filepath.Clean(filename)) + return os.Open(filename) // nolint gosec } } diff --git a/test/utils.go b/test/utils.go index 9af291c0..3cd61385 100644 --- a/test/utils.go +++ b/test/utils.go @@ -5,7 +5,6 @@ import ( "fmt" "io/ioutil" "os" - "path/filepath" "reflect" "strings" "testing" @@ -82,7 +81,7 @@ func WriteTempYamlFile(content string) string { } func ReadTempYamlFile(name string) string { - content, _ := ioutil.ReadFile(filepath.Clean(name)) + content, _ := ioutil.ReadFile(name) return string(content) }