Sha256: c37d2528eb64cb9f638feb6b9d98f8c80388f8e0f53ea5914e4b51b0ea1abcff

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require "addressable/uri"

module Onyphe
  module Clients
    class Search < Client
      def datascan(params, page: 1)
        search("datascan", params, page)
      end

      def synscan(params, page: 1)
        search("synscan", params, page)
      end

      def inetnum(params, page: 1)
        search("inetnum", params, page)
      end

      def threatlist(params, page: 1)
        search("threatlist", params, page)
      end

      def pastries(params, page: 1)
        search("pastries", params, page)
      end

      def resolver(params, page: 1)
        search("resolver", params, page)
      end

      def sniffer(params, page: 1)
        search("sniffer", params, page)
      end

      def ctl(params, page: 1)
        search("ctl", params, page)
      end

      def onionscan(params, page: 1)
        search("onionscan", params, page)
      end

      private

      def search(type, params, page)
        get("/search/#{type}/#{params_to_uri_string(params)}", page: page) { |json| json }
      end

      def params_to_uri_string(params)
        s = params.map do |k, v|
          v = "\"#{v}\"" if v.to_s.include? " "
          [k, v].join(":")
        end.join(" ")

        Addressable::URI.encode s
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
onyphe-1.1.0 lib/onyphe/clients/search.rb
onyphe-1.0.0 lib/onyphe/clients/search.rb