Sha256: c8e75aca00975eeddf419260dfe3fa6134efb12dc0e58ffc3f1aaf9e58947685

Contents?: true

Size: 734 Bytes

Versions: 3

Compression:

Stored size: 734 Bytes

Contents

# frozen_string_literal: true

require "urlscan"

module Miteru
  class Feeds
    class UrlScanPro < Feed
      def api
        @api ||= ::UrlScan::API.new(Miteru.configuration.urlscan_api_key)
      end

      def urls
        urls_from_pro_feed
      rescue ::UrlScan::ResponseError => e
        Miteru.logger.error "Failed to load urlscan.io pro feed (#{e})"
        []
      end

      private

      def api_key?
        Miteru.configuration.urlscan_api_key?
      end

      def urls_from_pro_feed
        return [] unless api_key?

        res = api.pro.phishfeed
        results = res["results"] || []
        results.map { |result| result["page_url"] }
      rescue ArgumentError => _e
        []
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
miteru-1.2.2 lib/miteru/feeds/urlscan_pro.rb
miteru-1.2.1 lib/miteru/feeds/urlscan_pro.rb
miteru-1.2.0 lib/miteru/feeds/urlscan_pro.rb