Skip to content

Commit bf0d0d5

Browse files
Merge pull request #62 from snyk/fix/upload-revision-validate-files
Fix/upload revision validate files
2 parents 12d9214 + 8567194 commit bf0d0d5

File tree

5 files changed

+206
-221
lines changed

5 files changed

+206
-221
lines changed

internal/fileupload/errors.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ type FileCountLimitError = uploadrevision.FileCountLimitError
2020
// FileAccessError indicates a file access permission issue.
2121
type FileAccessError = uploadrevision.FileAccessError
2222

23-
// DirectoryError indicates an issue with directory operations.
24-
type DirectoryError = uploadrevision.DirectoryError
23+
// SpecialFileError indicates a path points to a special file (device, pipe, socket, etc.) instead of a regular file.
24+
type SpecialFileError = uploadrevision.SpecialFileError
2525

2626
// HTTPError indicates an HTTP request/response error.
2727
type HTTPError = uploadrevision.HTTPError

internal/fileupload/uploadrevision/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ func validateFiles(files []UploadFile) error {
195195
return NewFileAccessError(file.Path, err)
196196
}
197197

198-
if fileInfo.IsDir() {
199-
return NewDirectoryError(file.Path)
198+
if !fileInfo.Mode().IsRegular() {
199+
return NewSpecialFileError(file.Path, fileInfo.Mode())
200200
}
201201

202202
if fileInfo.Size() > fileSizeLimit {

0 commit comments

Comments
 (0)