Class: Miteru::Website

Inherits:
Object
  • Object
show all
Defined in:
lib/miteru/website.rb

Constant Summary collapse

VALID_EXTENSIONS =
Miteru.configuration.valid_extensions

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#urlObject (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

Returns:

  • (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

Returns:

  • (Boolean)


30
31
32
# File 'lib/miteru/website.rb', line 30

def index?
  title.to_s.start_with? "Index of"
end

#kitsObject



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

Returns:

  • (Boolean)


34
35
36
# File 'lib/miteru/website.rb', line 34

def kits?
  !kits.empty?
end


52
53
54
# File 'lib/miteru/website.rb', line 52

def links
  (href_links + possible_file_links).compact.uniq
end

#messageObject



44
45
46
47
48
49
50
# File 'lib/miteru/website.rb', line 44

def message
  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

Returns:

  • (Boolean)


26
27
28
# File 'lib/miteru/website.rb', line 26

def ok?
  response.code == 200
end

#titleObject



15
16
17
# File 'lib/miteru/website.rb', line 15

def title
  doc&.at_css("title")&.text
end