Sha256: 9462aef238f0da5886fc342440ca06c4d857a3c7046c821f6d0efbc9ae6e932e

Contents?: true

Size: 1003 Bytes

Versions: 9

Compression:

Stored size: 1003 Bytes

Contents

# frozen_string_literal: true

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

        submit(kit.decoded_url, source: kit.source)
      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.api_timeout
      end

      def tags
        %w[miteru phishkit]
      end

      def visibility
        Miteru.config.urlscan_submit_visibility
      end

      #
      # @param [String] url
      # @param [String] source
      #
      def submit(url, source:)
        http.post("https://urlscan.io/api/v1/scan/", json: {tags: tags + ["source:#{source}"], visibility:, url:})
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
miteru-3.0.0 lib/miteru/notifiers/urlscan.rb
miteru-2.4.0 lib/miteru/notifiers/urlscan.rb
miteru-2.3.2 lib/miteru/notifiers/urlscan.rb
miteru-2.3.1 lib/miteru/notifiers/urlscan.rb
miteru-2.3.0 lib/miteru/notifiers/urlscan.rb
miteru-2.2.4 lib/miteru/notifiers/urlscan.rb
miteru-2.2.3 lib/miteru/notifiers/urlscan.rb
miteru-2.2.2 lib/miteru/notifiers/urlscan.rb
miteru-2.2.1 lib/miteru/notifiers/urlscan.rb