forked from loafle/openapi-generator-original
[Go] Address Gosec vulnerabilities in Go client mustache template (#12540)
* Fix potential file inclusion via variable * Fix deferring unsafe method "Close" on type "*os.File" * Update samples * Correction to use existing variable * Correction generated samples
This commit is contained in:
@@ -430,11 +430,14 @@ func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err err
|
||||
|
||||
// Add a file to the multipart request
|
||||
func addFile(w *multipart.Writer, fieldName, path string) error {
|
||||
file, err := os.Open(path)
|
||||
file, err := os.Open(filepath.Clean(path))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
err = file.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
part, err := w.CreateFormFile(fieldName, filepath.Base(path))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user