mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-20 02:24:59 +00:00
feat:OpaqueErrors
to hide error information (#2486)
* adds a new configuration option to hide all error message information from http requests --------- Signed-off-by: Dave Lee <dave@gray101.com>
This commit is contained in:
parent
17cf6c4a4d
commit
d072835796
10 changed files with 78 additions and 41 deletions
|
@ -33,11 +33,17 @@ func GetURI(url string, basePath string, f func(url string, i []byte) error) err
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Check if the local file is rooted in basePath
|
||||
err = utils.VerifyPath(resolvedFile, basePath)
|
||||
// ???
|
||||
resolvedBasePath, err := filepath.EvalSymlinks(basePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Check if the local file is rooted in basePath
|
||||
err = utils.InTrustedRoot(resolvedFile, resolvedBasePath)
|
||||
if err != nil {
|
||||
log.Debug().Str("resolvedFile", resolvedFile).Str("basePath", basePath).Msg("downloader.GetURI blocked an attempt to ready a file url outside of basePath")
|
||||
return err
|
||||
}
|
||||
// Read the response body
|
||||
body, err := os.ReadFile(resolvedFile)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue