Fixing comment attack by bot
This commit is contained in:
parent
4de197f4c4
commit
31af9ab6d0
3
Gemfile
3
Gemfile
|
@ -29,8 +29,6 @@ gem 'mini_magick'
|
||||||
gem 'html_truncator'
|
gem 'html_truncator'
|
||||||
gem 'nokogiri'
|
gem 'nokogiri'
|
||||||
gem 'figaro'
|
gem 'figaro'
|
||||||
gem 'rqrcode-with-patches', require: 'rqrcode'
|
|
||||||
gem 'chunky_png'
|
|
||||||
gem 'sidekiq'
|
gem 'sidekiq'
|
||||||
gem 'redis-namespace'
|
gem 'redis-namespace'
|
||||||
gem 'rest-client'
|
gem 'rest-client'
|
||||||
|
@ -39,6 +37,7 @@ gem 'newrelic_rpm'
|
||||||
gem 'puma'
|
gem 'puma'
|
||||||
|
|
||||||
gem 'mina', require: false
|
gem 'mina', require: false
|
||||||
|
|
||||||
gem 'mina-multistage', require: false
|
gem 'mina-multistage', require: false
|
||||||
gem 'mina-sidekiq', require: false
|
gem 'mina-sidekiq', require: false
|
||||||
gem 'mina-puma', require: false
|
gem 'mina-puma', require: false
|
||||||
|
|
|
@ -66,7 +66,6 @@ GEM
|
||||||
activesupport (>= 3.2.0)
|
activesupport (>= 3.2.0)
|
||||||
json (>= 1.7)
|
json (>= 1.7)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
chunky_png (1.3.5)
|
|
||||||
codeclimate-test-reporter (0.5.0)
|
codeclimate-test-reporter (0.5.0)
|
||||||
simplecov (>= 0.7.1, < 1.0.0)
|
simplecov (>= 0.7.1, < 1.0.0)
|
||||||
coderay (1.1.1)
|
coderay (1.1.1)
|
||||||
|
@ -235,8 +234,6 @@ GEM
|
||||||
mime-types (>= 1.16, < 3.0)
|
mime-types (>= 1.16, < 3.0)
|
||||||
netrc (~> 0.7)
|
netrc (~> 0.7)
|
||||||
rouge (1.10.1)
|
rouge (1.10.1)
|
||||||
rqrcode-with-patches (0.6.0)
|
|
||||||
chunky_png
|
|
||||||
rspec (3.1.0)
|
rspec (3.1.0)
|
||||||
rspec-core (~> 3.1.0)
|
rspec-core (~> 3.1.0)
|
||||||
rspec-expectations (~> 3.1.0)
|
rspec-expectations (~> 3.1.0)
|
||||||
|
@ -332,7 +329,6 @@ DEPENDENCIES
|
||||||
byebug
|
byebug
|
||||||
capybara
|
capybara
|
||||||
carrierwave
|
carrierwave
|
||||||
chunky_png
|
|
||||||
codeclimate-test-reporter
|
codeclimate-test-reporter
|
||||||
coffee-rails (~> 4.1.0)
|
coffee-rails (~> 4.1.0)
|
||||||
database_cleaner
|
database_cleaner
|
||||||
|
@ -369,7 +365,6 @@ DEPENDENCIES
|
||||||
redis-namespace
|
redis-namespace
|
||||||
rest-client
|
rest-client
|
||||||
rouge
|
rouge
|
||||||
rqrcode-with-patches
|
|
||||||
rspec-rails (>= 2.8.1)
|
rspec-rails (>= 2.8.1)
|
||||||
rspec-sidekiq
|
rspec-sidekiq
|
||||||
sass-rails (~> 5.0)
|
sass-rails (~> 5.0)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class CommentsController < ApplicationController
|
class CommentsController < ApplicationController
|
||||||
layout false
|
layout false
|
||||||
helper_method :format_time
|
|
||||||
def index
|
def index
|
||||||
@post = Post.find( params[:blog_id] )
|
@post = Post.find( params[:blog_id] )
|
||||||
res = @post.comments.desc(:created_at).collect { |comment| build_json(comment) }
|
res = @post.comments.desc(:created_at).collect { |comment| build_json(comment) }
|
||||||
|
@ -8,6 +8,10 @@ class CommentsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
unless request.xhr?
|
||||||
|
logger.warning 'attack action detected'
|
||||||
|
redirect_to root_path
|
||||||
|
end
|
||||||
cookies[:name] = comment_params[:name]
|
cookies[:name] = comment_params[:name]
|
||||||
cookies[:email] = comment_params[:email]
|
cookies[:email] = comment_params[:email]
|
||||||
@post = Post.find( params[:blog_id] )
|
@post = Post.find( params[:blog_id] )
|
||||||
|
|
Loading…
Reference in New Issue