Skip to content

Commit a4830c8

Browse files
committed
fix: resolve Snyk security warning with path traversal
1 parent 75e2cc5 commit a4830c8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

openapi3/loader_uri_reader.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/http"
88
"net/url"
99
"os"
10+
"path"
1011
"path/filepath"
1112
"sync"
1213
)
@@ -79,7 +80,7 @@ func ReadFromFile(loader *Loader, location *url.URL) ([]byte, error) {
7980
if !is_file(location) {
8081
return nil, ErrURINotSupported
8182
}
82-
return os.ReadFile(filepath.FromSlash(location.Path))
83+
return os.ReadFile(path.Clean(filepath.FromSlash(location.Path)))
8384
}
8485

8586
// URIMapCache returns a ReadFromURIFunc that caches the contents read from URI

0 commit comments

Comments
 (0)