Sha256: 2d0c4e683e65e226988b8d11c9f604d730143dfbaffd2c6e66d4b2390063c695

Contents?: true

Size: 1.22 KB

Versions: 13

Compression:

Stored size: 1.22 KB

Contents

# encoding: utf-8

module Sonar
  module Search
    # Implemented search query types
    QUERY_TYPES_MAP = {
      'certificate' => 'Certificate lookup',
      'certips'     => 'Certificate to IPs',
      'rdns'        => 'IP to Reverse DNS Lookup or DNS Lookup to IP',
      'fdns'        => 'Domains to IP or IPs to Domain',
      'ipcerts'     => 'IP to Certificates',
      'namecerts'   => 'Domain to Certificates',
      'links_to'    => 'HTTP References to Domain',
      'ports'       => 'Open Ports',
      'processed'   => 'Open Ports (Processed)',
      'raw'         => 'Open Ports (Raw)',
      'sslcert'     => 'Certificate Details',
      'whois_ip'    => 'Whois (IP)'
    }

    ##
    # Get search
    #
    # params take in search type as key and query as value
    # {fdns: 'rapid7.com'}
    #
    # @return [Hashie::Mash] with response of search
    def search(params = {})
      type_query = params.select { |k, _v| QUERY_TYPES_MAP.keys.include?(k.to_s) }.first
      fail ArgumentError, "The query type provided is invalid or not yet implemented." unless type_query
      type = type_query[0].to_sym
      params[:q] = type_query[1]
      params = extract_params(params)
      get_search_endpoint(type, params)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
sonar-client-0.1.2 lib/sonar/search.rb
sonar-client-0.1.1 lib/sonar/search.rb
sonar-client-0.1.1.pre lib/sonar/search.rb
sonar-client-0.1.0 lib/sonar/search.rb
sonar-client-0.0.9 lib/sonar/search.rb
sonar-client-0.0.8 lib/sonar/search.rb
sonar-client-0.0.7 lib/sonar/search.rb
sonar-client-0.0.6 lib/sonar/search.rb
sonar-client-0.0.5 lib/sonar/search.rb
sonar-client-0.0.4 lib/sonar/search.rb
sonar-client-0.0.3 lib/sonar/search.rb
sonar-client-0.0.2 lib/sonar/search.rb
sonar-client-0.0.1 lib/sonar/search.rb