SECURITY: protect upload params, only allow very strict filenames

This commit is contained in:
Sam
2016-12-19 10:16:18 +11:00
parent 30e0154e5d
commit 15b5fddd49
4 changed files with 75 additions and 0 deletions

View File

@ -33,6 +33,20 @@ describe UploadsController do
})
end
it 'fails if type is invalid' do
xhr :post, :create, file: logo, type: "invalid type cause has space"
expect(response.status).to eq 403
xhr :post, :create, file: logo, type: "\\invalid"
expect(response.status).to eq 403
xhr :post, :create, file: logo, type: "invalid."
expect(response.status).to eq 403
xhr :post, :create, file: logo, type: "toolong"*100
expect(response.status).to eq 403
end
it 'is successful with an image' do
Jobs.expects(:enqueue).with(:create_thumbnails, anything)