diff --git a/lib/project_honeypot.rb b/lib/project_honeypot.rb index aa862a1..5d5ac47 100644 --- a/lib/project_honeypot.rb +++ b/lib/project_honeypot.rb @@ -6,7 +6,7 @@ require "project_honeypot/rack/forbidden" module ProjectHoneypot class << self - attr_accessor :api_key, :score, :last_activity + attr_accessor :api_key, :score, :last_activity, :offenses def api_key raise "ProjectHoneypot really needs its api_key set to work" unless @api_key diff --git a/lib/project_honeypot/url.rb b/lib/project_honeypot/url.rb index da16d96..396c71b 100644 --- a/lib/project_honeypot/url.rb +++ b/lib/project_honeypot/url.rb @@ -27,11 +27,18 @@ module ProjectHoneypot score = hash[:score] || ProjectHoneypot.score last_activity = hash[:last_activity] || ProjectHoneypot.last_activity + forbidden_offenses = hash[:offenses] || + ProjectHoneypot.offenses || + [:comment_spammer, :harvester, :suspicious] + + detected_offenses = forbidden_offenses & @offenses + @safe || + detected_offenses.length == 0 || !( last_activity.nil? && score.nil? || - !score.nil? && self.score > score || - !last_activity.nil? && self.last_activity > last_activity + !score.nil? && self.score >= score || + !last_activity.nil? && self.last_activity >= last_activity ) end