mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Cli: Improve error handling for installing plugins (#41257)
Improves error handling when installing plugins by checking for error before adding a defer of closing of the zip reader to not create a panic when there's an invalid zip file. Fixes #41029
This commit is contained in:
parent
78e9fe520b
commit
36cea0b48e
@ -527,14 +527,16 @@ func (i *Installer) extractFiles(archiveFile string, pluginID string, dest strin
|
||||
}
|
||||
|
||||
r, err := zip.OpenReader(archiveFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := r.Close(); err != nil {
|
||||
i.log.Warn("failed to close zip file", "err", err)
|
||||
}
|
||||
}()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, zf := range r.File {
|
||||
// We can ignore gosec G305 here since we check for the ZipSlip vulnerability below
|
||||
// nolint:gosec
|
||||
|
Loading…
Reference in New Issue
Block a user