diff --git a/Gemfile b/Gemfile index e91c3ae..ddc27ed 100644 --- a/Gemfile +++ b/Gemfile @@ -39,6 +39,7 @@ gem 'jbuilder', '~> 2.5' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development +gem 'rack-attack' group :development, :test do gem 'rspec-rails' @@ -48,13 +49,15 @@ end group :development do gem 'faker' + gem 'brakeman' + gem 'bundler-audit' # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '~> 3.0.5' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring - gem 'spring' - gem 'spring-watcher-listen', '~> 2.0.0' + # gem 'spring' + # gem 'spring-watcher-listen', '~> 2.0.0' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem diff --git a/Gemfile.lock b/Gemfile.lock index 30c443b..c5d1fc0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -46,7 +46,11 @@ GEM bootstrap-sass (3.3.7) autoprefixer-rails (>= 5.2.1) sass (>= 3.3.4) + brakeman (4.0.1) builder (3.2.3) + bundler-audit (0.6.0) + bundler (~> 1.2) + thor (~> 0.18) byebug (9.0.6) coffee-rails (4.2.1) coffee-script (>= 2.2.0) @@ -89,15 +93,17 @@ GEM mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) - mini_portile2 (2.1.0) + mini_portile2 (2.3.0) minitest (5.10.1) multi_json (1.12.1) nio4r (2.0.0) - nokogiri (1.7.1) - mini_portile2 (~> 2.1.0) + nokogiri (1.8.1) + mini_portile2 (~> 2.3.0) orm_adapter (0.5.0) puma (3.8.2) rack (2.0.1) + rack-attack (5.0.1) + rack rack-test (0.6.3) rack (>= 1.0) rails (5.0.2) @@ -153,11 +159,6 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - spring (2.0.1) - activesupport (>= 4.2) - spring-watcher-listen (2.0.1) - listen (>= 2.7, < 4.0) - spring (>= 1.2, < 3.0) sprockets (3.7.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -192,6 +193,8 @@ PLATFORMS DEPENDENCIES bootstrap-sass + brakeman + bundler-audit byebug coffee-rails (~> 4.2) devise @@ -200,11 +203,10 @@ DEPENDENCIES jquery-rails listen (~> 3.0.5) puma (~> 3.0) + rack-attack rails (~> 5.0.2) rspec-rails sass-rails (~> 5.0) - spring - spring-watcher-listen (~> 2.0.0) sqlite3 turbolinks (~> 5) tzinfo-data @@ -212,4 +214,4 @@ DEPENDENCIES web-console (>= 3.3.0) BUNDLED WITH - 1.14.6 + 1.16.0.pre.2 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 682a07d..b9b7409 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,7 @@ class ApplicationController < ActionController::Base # protect_from_forgery with: :exception + protect_from_forgery with: :exception helper_method :current_cart diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 245dece..8f28b01 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -9,10 +9,10 @@ def show @comments = @event.comments if params[:keyword] - @comments = @comments.where( "comments.content LIKE '%#{params[:keyword]}%'") + @comments = @comments.where( "comments.content LIKE ?", "%#{params[:keyword]}%") end - if params[:sort] + if params[:sort] && ["id DESC", "id ASC"].include?(params[:sort]) @comments = @comments.order(params[:sort]) end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f1d232d..fd6cac4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -21,7 +21,7 @@ def update protected def user_params - params.require(:user).permit(:nickname, :role) + params.require(:user).permit(:nickname) end end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index ed49051..1d62a20 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -7,9 +7,7 @@ def user_avatar_link(user) email_md5 = Digest::MD5.hexdigest(user.email) gravatar_url = "https://www.gravatar.com/avatar/#{email_md5}" - str = "