Sha256: c36e093b584ca2e9b17cf3175353cd5eda5edb2b45e24900e3553513a5c1ce9f
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
# frozen_string_literal: true require "oga" module Miteru class Website attr_reader :url def initialize(url) @url = url end def title doc&.at_css("title")&.text end def kits @kits ||= links.map do |link| kit = Kit.new(base_url: url, link: link.to_s) kit.valid? ? kit : nil end.compact end def ok? response.code == 200 end def index? title.to_s.start_with? "Index of" end def kits? !kits.empty? end def has_kits? ok? && index? && kits? rescue Addressable::URI::InvalidURIError, ArgumentError, Encoding::CompatibilityError, HTTP::Error, LL::ParserError, OpenSSL::SSL::SSLError => _e false end def message return "It doesn't contain a phishing kit." unless kits? kit_names = kits.map(&:basename).join(", ") noun = kits.length == 1 ? "a phishing kit" : "phishing kits" "It might contain #{noun}: #{kit_names}." end private def response @response ||= get end def get HTTPClient.get url end def doc @doc ||= parse_html(response.body.to_s) end def parse_html(html) Oga.parse_html(html) rescue ArgumentError, Encoding::CompatibilityError, LL::ParserError => _e nil end def links if doc doc.css("a").map { |a| a.get("href") }.compact else [] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
miteru-0.12.8 | lib/miteru/website.rb |