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 uploaded file type and size #4479

Merged
merged 7 commits into from
May 29, 2019
Merged

Validate uploaded file type and size #4479

merged 7 commits into from
May 29, 2019

Conversation

danlipert
Copy link
Contributor

@danlipert danlipert commented May 24, 2019

Description

This PR checks uploaded files' type directly via libmagic. This is useful to narrow the potential attack vectors due to accepting user-uploaded files.

Refers/Fixes

#4432

Testing

Tested both the profile resume upload and NDA upload and reupload forms by submitting invalid files that satisfied the client-side file type (file extension) checks. Response from server was as expected with appropriate alert shades. I then manually submitted the correct form of file and was able to create a bounty, apply to work, submit work, and payout. I tested with PDF, DOCX and DOC files for the NDA.

@codecov
Copy link

codecov bot commented May 28, 2019

Codecov Report

Merging #4479 into master will decrease coverage by 0.01%.
The diff coverage is 10%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4479      +/-   ##
==========================================
- Coverage   30.08%   30.07%   -0.02%     
==========================================
  Files         209      209              
  Lines       16850    16867      +17     
  Branches     2267     2271       +4     
==========================================
+ Hits         5070     5072       +2     
- Misses      11582    11597      +15     
  Partials      198      198
Impacted Files Coverage Δ
app/dashboard/views.py 14.47% <10%> (-0.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d59ae5c...9a75bc6. Read the comment docs.

@codecov
Copy link

codecov bot commented May 28, 2019

Codecov Report

Merging #4479 into master will decrease coverage by 0.01%.
The diff coverage is 10%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4479      +/-   ##
==========================================
- Coverage   30.04%   30.02%   -0.02%     
==========================================
  Files         209      209              
  Lines       16864    16881      +17     
  Branches     2272     2276       +4     
==========================================
+ Hits         5067     5069       +2     
- Misses      11601    11616      +15     
  Partials      196      196
Impacted Files Coverage Δ
app/dashboard/views.py 14.26% <10%> (-0.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c9b68e2...18d11bb. Read the comment docs.

@danlipert danlipert marked this pull request as ready for review May 28, 2019 12:21
'message': 'No File Found'
}
elif uploaded_file.size > 31457280:
# 30MB max file size
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would 30 MB be too much?

@danlipert
Copy link
Contributor Author

danlipert commented May 29, 2019 via email

@thelostone-mc thelostone-mc merged commit 3249e6f into master May 29, 2019
@thelostone-mc thelostone-mc deleted the validate-uploads branch July 4, 2019 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants