Add custom offenses list to determine if safe or not
parent
1a3eeaf4cf
commit
e0b488868a
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue