Skip to content

Project files: validate mime before storing the file #361

@martastain

Description

@martastain

Story

File mimetype is now parsed only from the upload request header and then validated after the file is uploaded. We could check the file header as soon the first chunk arrives and abort the upload if the file is not supported

Problems

Files won't be uploaded to the project storage if they are not supported - this should be used for reviewables, not comment attachments.

Proposal

additional callable argument to ProjectStorage.handle_upload, that would accept a sequence of bytes and raise an exception if it does not match a valid signature. handle_upload would call this function as soon, there's enough bytes in the buffer to check the file header, before committing the chunk to the storage.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions