refactor: gallery inconsistencies (#2647)

* refactor(gallery): move under core/

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

* fix(unarchive): do not allow symlinks

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>

---------

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto 2024-06-24 17:32:12 +02:00 committed by GitHub
parent 69206fcd4b
commit a181dd0ebc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 93 additions and 54 deletions

View file

@ -2,6 +2,7 @@ package utils
import (
"fmt"
"os"
"github.com/mholt/archiver/v3"
)
@ -52,5 +53,17 @@ func ExtractArchive(archive, dst string) error {
case *archiver.TarZstd:
v.Tar = mytar
}
err = archiver.Walk(archive, func(f archiver.File) error {
if f.FileInfo.Mode()&os.ModeSymlink != 0 {
return fmt.Errorf("archive contains a symlink")
}
return nil
})
if err != nil {
return err
}
return un.Unarchive(archive, dst)
}