Resolve issues with G304 (#10115)

This commit is contained in:
Preston Van Loon
2022-01-21 10:52:31 -06:00
committed by GitHub
parent 8d610319bc
commit 26120e26cb
3 changed files with 6 additions and 5 deletions

View File

@@ -48,7 +48,7 @@ func DeleteAndCreateFile(tmpPath, fileName string) (*os.File, error) {
return nil, err
}
}
newFile, err := os.Create(path.Join(tmpPath, fileName))
newFile, err := os.Create(filepath.Clean(path.Join(tmpPath, fileName)))
if err != nil {
return nil, err
}
@@ -161,7 +161,7 @@ func WritePprofFiles(testDir string, index int) error {
return writeURLRespAtPath(url, filePath)
}
func writeURLRespAtPath(url, filePath string) error {
func writeURLRespAtPath(url, fp string) error {
resp, err := http.Get(url) // #nosec G107 -- Safe, used internally
if err != nil {
return err
@@ -176,7 +176,7 @@ func writeURLRespAtPath(url, filePath string) error {
if err != nil {
return err
}
file, err := os.Create(filePath)
file, err := os.Create(filepath.Clean(fp))
if err != nil {
return err
}