Sha256: 2b092ace52a54b56d206bc85b82b9b601cd9d18e164e07b83d783ad9888e120a

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require "digest/sha2"
require "uri"

module Fushin
  module Models
    class Website < Model
      attr_reader :url
      def initialize(url)
        @url = url
      end

      def uri
        @uri ||= URI(url)
      end

      def domain
        uri.hostname
      end

      def urlscan_link
        "https://urlscan.io/domain/#{domain}"
      end

      def url_for_vt
        uri.path.empty? ? "#{url}/" : url
      end

      def vt_link
        "https://www.virustotal.com/#/url/#{Digest::SHA256.hexdigest(url_for_vt)}"
      end

      def to_attachements
        [
          {
            fallback: "virustotal.com link",
            title: "VT: #{url}",
            title_link: vt_link,
            footer: "virustotal.com",
            footer_icon: "http://www.google.com/s2/favicons?domain=virustotal.com"
          },
          {
            fallback: "urlscan.io link",
            title: "urlscan.io: #{domain}",
            title_link: urlscan_link,
            footer: "urlscan.io",
            footer_icon: "http://www.google.com/s2/favicons?domain=urlscan.io"
          },
        ]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fushin-0.2.0 lib/fushin/models/website.rb
fushin-0.1.1 lib/fushin/models/website.rb
fushin-0.1.0 lib/fushin/models/website.rb