Fix for gosec rule G304 - sanitize filepaths

This commit is contained in:
Monica Debbeler
2021-07-07 13:52:11 +10:00
committed by Mike Farah
parent f67a83a5bc
commit ffb6cbf769
3 changed files with 6 additions and 3 deletions
+2 -1
View File
@@ -5,6 +5,7 @@ import (
"container/list"
"io"
"os"
"path/filepath"
yaml "gopkg.in/yaml.v3"
)
@@ -13,7 +14,7 @@ func readStream(filename string) (io.Reader, error) {
if filename == "-" {
return bufio.NewReader(os.Stdin), nil
} else {
return os.Open(filename) // nolint gosec
return os.Open(filepath.Clean(filename))
}
}