Skip to content

Commit

Permalink
Fix code scanning alert no. 2: Arbitrary file access during archive e…
Browse files Browse the repository at this point in the history
…xtraction ("Zip Slip")

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
mvdkleijn and github-advanced-security[bot] committed Oct 7, 2024
1 parent 8320055 commit b34a63b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/config/icons.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ func unzipFile(src, dest string) error {
defer reader.Close()

for _, file := range reader.File {
if strings.Contains(file.Name, "..") {
log.Warn().Str("file", file.Name).Msg("skipping file with invalid path")
continue
}
path := filepath.Join(dest, file.Name)
if file.FileInfo().IsDir() {
os.MkdirAll(path, os.ModePerm)
Expand Down

0 comments on commit b34a63b

Please sign in to comment.