Class: ProjectHoneypot::Url
- Inherits:
-
Object
- Object
- ProjectHoneypot::Url
- Defined in:
- lib/project_honeypot/url.rb
Constant Summary collapse
- SEARCH_ENGINES =
%w( Undocumented AltaVista Ask Baidu Excite Google Looksmart Lycos MSN Yahoo Cuil InfoSeek Miscellaneous )
Instance Attribute Summary collapse
-
#ip_address ⇒ Object
readonly
Returns the value of attribute ip_address.
-
#last_activity ⇒ Object
readonly
Returns the value of attribute last_activity.
-
#offenses ⇒ Object
readonly
Returns the value of attribute offenses.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#search_engine ⇒ Object
readonly
Returns the value of attribute search_engine.
Instance Method Summary collapse
- #comment_spammer? ⇒ Boolean
- #harvester? ⇒ Boolean
-
#initialize(ip_address, honeypot_response) ⇒ Url
constructor
A new instance of Url.
- #safe?(hash = {}) ⇒ Boolean
- #search_engine? ⇒ Boolean
- #suspicious? ⇒ Boolean
Constructor Details
#initialize(ip_address, honeypot_response) ⇒ Url
Returns a new instance of Url.
20 21 22 23 24 |
# File 'lib/project_honeypot/url.rb', line 20 def initialize(ip_address, honeypot_response) @ip_address = ip_address @safe = honeypot_response.nil? process_score(honeypot_response) end |
Instance Attribute Details
#ip_address ⇒ Object (readonly)
Returns the value of attribute ip_address.
19 20 21 |
# File 'lib/project_honeypot/url.rb', line 19 def ip_address @ip_address end |
#last_activity ⇒ Object (readonly)
Returns the value of attribute last_activity.
19 20 21 |
# File 'lib/project_honeypot/url.rb', line 19 def last_activity @last_activity end |
#offenses ⇒ Object (readonly)
Returns the value of attribute offenses.
19 20 21 |
# File 'lib/project_honeypot/url.rb', line 19 def offenses @offenses end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
19 20 21 |
# File 'lib/project_honeypot/url.rb', line 19 def score @score end |
#search_engine ⇒ Object (readonly)
Returns the value of attribute search_engine.
19 20 21 |
# File 'lib/project_honeypot/url.rb', line 19 def search_engine @search_engine end |
Instance Method Details
#comment_spammer? ⇒ Boolean
49 50 51 |
# File 'lib/project_honeypot/url.rb', line 49 def comment_spammer? @offenses.include?(:comment_spammer) end |
#harvester? ⇒ Boolean
53 54 55 |
# File 'lib/project_honeypot/url.rb', line 53 def harvester? @offenses.include?(:harvester) end |
#safe?(hash = {}) ⇒ Boolean
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/project_honeypot/url.rb', line 26 def safe?(hash = {}) 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 ) end |
#search_engine? ⇒ Boolean
45 46 47 |
# File 'lib/project_honeypot/url.rb', line 45 def search_engine? @offenses.include?(:search_engine) end |
#suspicious? ⇒ Boolean
57 58 59 |
# File 'lib/project_honeypot/url.rb', line 57 def suspicious? @offenses.include?(:suspicious) end |