Skip to content

Commit

Permalink
Merge pull request #42 from uclibs/feature/samvera-deprecated#319-sam…
Browse files Browse the repository at this point in the history
…vera-deprecated#318-samvera-deprecated#316-samvera-deprecated#320-hailstorm-fixes

Fix Hailstorm vulnerabilities
  • Loading branch information
scherztc committed May 21, 2015
2 parents d3e319b + 8074816 commit 7102d1f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
11 changes: 11 additions & 0 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CatalogController < ApplicationController
CatalogController.solr_search_params_logic += [:show_only_works]
CatalogController.solr_search_params_logic += [:show_only_editors]
before_filter :agreed_to_terms_of_service!
before_filter :check_parameters?

skip_before_filter :default_html_head

Expand Down Expand Up @@ -342,6 +343,14 @@ def self.search_config
config.spell_max = 5
end

def check_parameters?(params_to_check=[:page, :per_page])
params_to_check.each do |param|
render(:file => File.join(Rails.root, 'public/404.html'), :status => 404) unless params[param].to_i.to_s == params[param] or params[param].nil?
render(:file => File.join(Rails.root, 'public/404.html'), :status => 404) unless params[param].to_i < 1000
end
render(:file => File.join(Rails.root, 'public/404.html'), :status => 404) unless params[:q].nil? or params[:q].length < 1000
end

protected

# Override Hydra::PolicyAwareAccessControlsEnforcement
Expand Down Expand Up @@ -416,4 +425,6 @@ def exclude_class_filter(klass)
'-' + ActiveFedora::SolrService.construct_query_for_rel(has_model:
klass.to_class_uri)
end


end
2 changes: 1 addition & 1 deletion lib/tasks/embargo_manager.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace :embargomanager do
solr_results = ActiveFedora::SolrService.query( 'embargo_release_date_dtsi:[* TO *]' )
solr_results.each do |work|
if Date.parse(work['embargo_release_date_dtsi']) <= Date.today
Sufia.queue.push(EmbargoWorker.new(work['id']))
Sufia.queue.push(EmbargoWorker.new(work['id']))
receiver = work['depositor_tesim']
mail_contents = work['desc_metadata__title_tesim']
EmbargoMailer.notify(receiver, mail_contents).deliver
Expand Down
5 changes: 2 additions & 3 deletions spec/controllers/catalog_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe CatalogController do

describe "when logged in" do
let(:user) { FactoryGirl.create(:user) }
let!(:work1) { FactoryGirl.create(:generic_work, user: user) }
Expand All @@ -21,7 +21,7 @@
it "should return just my works" do
get 'index', works: 'mine'
response.should be_successful
assigns(:document_list).map(&:id).should == [work1.id]
assigns(:document_list).map(&:id).should == [work1.id]
end
end

Expand Down Expand Up @@ -75,6 +75,5 @@
assigns(:document_list).map(&:id).should include(work2.id)
end
end

end
end
29 changes: 29 additions & 0 deletions spec/features/catalog_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,35 @@
describe_options[:js] = true
end

describe "Visit the catalog index page" do
context "when the per_page parameter is out of range" do
it "returns a custom error page" do
visit ('/catalog?per_page=1000')
expect(page).to have_content("The page you were looking for doesn't exist")
end
end
end

describe "Visit the catalog index page" do
context "when the page parameter is out of range" do
it "returns a custom error page" do
visit ('/catalog?page=1000')
expect(page).to have_content("The page you were looking for doesn't exist")
end
end
end

describe "Visit the catalog index page" do
context "when the q parameter is out of range" do
it "returns a custom error page" do
long_string = ""
250.times{long_string << "test"}
visit ("/catalog?q=#{long_string}")
expect(page).to have_content("The page you were looking for doesn't exist")
end
end
end

describe 'catalog search', describe_options do
before do
Rails.configuration.consider_all_requests_local = true
Expand Down

0 comments on commit 7102d1f

Please sign in to comment.