Sha256: 2eee15e506dc09c65650c766401477bccb0c89afbca37705de3063dd2fae6bf3

Contents?: true

Size: 956 Bytes

Versions: 2

Compression:

Stored size: 956 Bytes

Contents

# frozen_string_literal: true

module Miteru
  module Notifiers
    class UrlScan < Base
      #
      # @param [Miteru::Website] website
      #
      def call(website)
        return unless callable?

        kits = website.kits.select(&:downloaded?)
        return unless kits.any?

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

      def callable?
        !Miteru.config.urlscan_api_key.nil?
      end

      private

      #
      # @return [::HTTP::Client]
      #
      def http
        @http ||= HTTP::Factory.build(headers:, timeout:)
      end

      def headers
        {"api-key": Miteru.config.urlscan_api_key}
      end

      def timeout
        Miteru.config.timeout
      end

      def tags
        %w[miteru phishkit]
      end

      def visibility
        Miteru.config.urlscan_submit_visibility
      end

      def submit(url)
        http.post("/api/v1/scan/", json: {tags:, visibility:, url:})
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
miteru-2.0.1 lib/miteru/notifiers/urlscan.rb
miteru-2.0.0 lib/miteru/notifiers/urlscan.rb