Sha256: 0f430ea8305ce11762f0cd2489973dfdc8c4d0c6d12b9160ea72ed26f2a72625

Contents?: true

Size: 786 Bytes

Versions: 3

Compression:

Stored size: 786 Bytes

Contents

# frozen_string_literal: true

require "urlscan"

module Miteru
  module Notifiers
    class UrlScan < Base
      #
      # Notifiy to urlscan.io
      #
      # @param [Miteru::Website website
      #
      def notify(website)
        kits = website.kits.select(&:downloaded?)
        return unless notifiable? && kits.any?

        kits.each { |kit| submit(kit.url) }
      end

      def notifiable?
        Miteru.configuration.urlscan_api_key?
      end

      private

      def api
        @api ||= ::UrlScan::API.new(Miteru.configuration.urlscan_api_key)
      end

      def submit(url)
        api.submit(url, tags: ["miteru", "phishkit"], visibility: Miteru.configuration.urlscan_submit_visibility)
      rescue StandardError
        # do nothing
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
miteru-1.2.2 lib/miteru/notifiers/urlscan.rb
miteru-1.2.1 lib/miteru/notifiers/urlscan.rb
miteru-1.2.0 lib/miteru/notifiers/urlscan.rb