Skip to content

Commit 651824c

Browse files
committed
Do not allow paths in "archiveFileName" property in package_index.json
1 parent 3775f51 commit 651824c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

arduino/resources/helpers.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"os"
2121

2222
"github.com/arduino/go-paths-helper"
23+
"github.com/pkg/errors"
2324
"go.bug.st/downloader/v2"
2425
)
2526

@@ -30,7 +31,14 @@ func (r *DownloadResource) ArchivePath(downloadDir *paths.Path) (*paths.Path, er
3031
if err := staging.MkdirAll(); err != nil {
3132
return nil, err
3233
}
33-
return staging.Join(r.ArchiveFileName), nil
34+
35+
// Filter out paths from file name
36+
archiveFileName := paths.New(r.ArchiveFileName).Base()
37+
archivePath := staging.Join(archiveFileName).Clean()
38+
if archivePath.IsDir() {
39+
return nil, errors.Errorf("invalid filename or exinsting directory: %s", archivePath)
40+
}
41+
return archivePath, nil
3442
}
3543

3644
// IsCached returns true if the specified DownloadResource has already been downloaded

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy