Class: Miteru::Website
- Inherits:
-
Object
- Object
- Miteru::Website
- Defined in:
- lib/miteru/website.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #has_kits? ⇒ Boolean
- #index? ⇒ Boolean
-
#initialize(url) ⇒ Website
constructor
A new instance of Website.
- #kits ⇒ Object
- #kits? ⇒ Boolean
- #message ⇒ Object
- #ok? ⇒ Boolean
- #title ⇒ Object
Constructor Details
#initialize(url) ⇒ Website
Returns a new instance of Website.
8 9 10 |
# File 'lib/miteru/website.rb', line 8 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/miteru/website.rb', line 7 def url @url end |
Instance Method Details
#has_kits? ⇒ Boolean
35 36 37 38 39 |
# File 'lib/miteru/website.rb', line 35 def has_kits? ok? && index? && kits? rescue Addressable::URI::InvalidURIError, ArgumentError, Encoding::CompatibilityError, HTTP::Error, LL::ParserError, OpenSSL::SSL::SSLError => _e false end |
#index? ⇒ Boolean
27 28 29 |
# File 'lib/miteru/website.rb', line 27 def index? title.to_s.start_with? "Index of" end |
#kits ⇒ Object
16 17 18 19 20 21 |
# File 'lib/miteru/website.rb', line 16 def kits @kits ||= links.map do |link| kit = Kit.new(base_url: url, link: link.to_s) kit.valid? ? kit : nil end.compact end |
#kits? ⇒ Boolean
31 32 33 |
# File 'lib/miteru/website.rb', line 31 def kits? !kits.empty? end |
#message ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/miteru/website.rb', line 41 def return "It doesn't contain a phishing kit." unless kits? filename_with_sizes = kits.map(&:filename_with_size).join(", ") noun = kits.length == 1 ? "a phishing kit" : "phishing kits" "It might contain #{noun}: #{filename_with_sizes}." end |
#ok? ⇒ Boolean
23 24 25 |
# File 'lib/miteru/website.rb', line 23 def ok? response.code == 200 end |
#title ⇒ Object
12 13 14 |
# File 'lib/miteru/website.rb', line 12 def title doc&.at_css("title")&.text end |