Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce the egg's file denylist more thoroughly #29

Merged
merged 4 commits into from
Sep 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions server/filesystem/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,21 @@ import (
// and the compressed file will be placed at that location named
// `archive-{date}.tar.gz`.
func (fs *Filesystem) CompressFiles(dir string, paths []string) (ufs.FileInfo, error) {
var validPaths []string
for _, file := range paths {
if err := fs.IsIgnored(path.Join(dir, file)); err != nil {
return nil, err
// file is in file denylist so skip it and continue to check the next files
continue
QuintenQVD0 marked this conversation as resolved.
Show resolved Hide resolved
}
validPaths = append(validPaths, file)
}
a := &Archive{Filesystem: fs, BaseDirectory: dir, Files: paths}

// If there are no valid paths, return an error
if len(validPaths) == 0 {
return nil, fmt.Errorf("no valid files to compress")
}

a := &Archive{Filesystem: fs, BaseDirectory: dir, Files: validPaths}
d := path.Join(
dir,
fmt.Sprintf("archive-%s.tar.gz", strings.ReplaceAll(time.Now().Format(time.RFC3339), ":", "")),
Expand Down
Loading