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

Validate file uploads #220

Open
EmilyDirsh opened this issue Mar 6, 2015 · 11 comments
Open

Validate file uploads #220

EmilyDirsh opened this issue Mar 6, 2015 · 11 comments

Comments

@EmilyDirsh
Copy link
Contributor

Currently file uploads are not validated. We should be restricting the type and size of files permitted to be uploaded.

This is a potential security issue, and can certainly cause a lot of usability issues if we try to treat something as an image that isn't.

Relevant: http://stackoverflow.com/questions/51572/determine-file-type-in-ruby

@sbagroy986
Copy link
Contributor

On it!

@sbagroy986
Copy link
Contributor

Found a gem for it. What file formats should I add as supported @EmilyDirsh ? JPEG and PNG?

@Alwahsh
Copy link
Collaborator

Alwahsh commented Mar 6, 2015

Why not make it configurable ?

@sbagroy986
Copy link
Contributor

I don't understand what you mean. Configurable how?

@Alwahsh
Copy link
Collaborator

Alwahsh commented Mar 6, 2015

For example, an Array with accepted formats put in the configuration file in initializers. Allow everything in that array and reject the rest

@sbagroy986
Copy link
Contributor

That is what I am doing :)

@EmilyDirsh
Copy link
Contributor Author

@sbagroy986, @Alwahsh is right - the whitelist should be configurable in the Rails config files. Check the documentation for the gem you're using - there should be a documented configuration parameter for the gem.

By default, we should allow jpg, png, gif (why not?), and svg

@sbagroy986
Copy link
Contributor

The gem actually just provides us the format of the file. So basically I'm gonna create an array of acceptable formats. The list is, thus, configurable.

@EmilyDirsh
Copy link
Contributor Author

@sbagroy986 which gem are you using?

@sbagroy986
Copy link
Contributor

Ruby FileMagic - https://github.com/blackwinter/ruby-filemagic
Its basically libmagic for ruby.

@sarupbanskota
Copy link
Contributor

What's the status on this? If it's yet to be worked on, @sonalkr132 would like to take it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants