Class: Miteru::Website
- Inherits:
-
Object
- Object
- Miteru::Website
- Defined in:
- lib/miteru/website.rb
Constant Summary collapse
- VALID_EXTENSIONS =
Miteru.configuration.valid_extensions
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
- #links ⇒ Object
- #message ⇒ Object
- #ok? ⇒ Boolean
- #title ⇒ Object
Constructor Details
#initialize(url) ⇒ Website
Returns a new instance of Website.
11 12 13 |
# File 'lib/miteru/website.rb', line 11 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'lib/miteru/website.rb', line 9 def url @url end |
Instance Method Details
#has_kits? ⇒ Boolean
38 39 40 41 42 |
# File 'lib/miteru/website.rb', line 38 def has_kits? kits? rescue Addressable::URI::InvalidURIError, ArgumentError, Encoding::CompatibilityError, HTTP::Error, LL::ParserError, OpenSSL::SSL::SSLError => _e false end |
#index? ⇒ Boolean
30 31 32 |
# File 'lib/miteru/website.rb', line 30 def index? title.to_s.start_with? "Index of" end |
#kits ⇒ Object
19 20 21 22 23 24 |
# File 'lib/miteru/website.rb', line 19 def kits @kits ||= links.filter_map do |link| kit = Kit.new(link) kit.valid? ? kit : nil end end |
#kits? ⇒ Boolean
34 35 36 |
# File 'lib/miteru/website.rb', line 34 def kits? !kits.empty? end |
#links ⇒ Object
52 53 54 |
# File 'lib/miteru/website.rb', line 52 def links (href_links + possible_file_links).compact.uniq end |
#message ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/miteru/website.rb', line 44 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
26 27 28 |
# File 'lib/miteru/website.rb', line 26 def ok? response.code == 200 end |
#title ⇒ Object
15 16 17 |
# File 'lib/miteru/website.rb', line 15 def title doc&.at_css("title")&.text end |