Module: Sonar::Search

Included in:
Client
Defined in:
lib/sonar/search.rb

Constant Summary collapse

QUERY_TYPES_MAP =

Implemented search query types

{
  '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)'
}

Instance Method Summary collapse

Instance Method Details

#search(params = {}) ⇒ Hashie::Mash

Get search

params take in search type as key and query as value 'rapid7.com'

Returns:

  • (Hashie::Mash)

    with response of search


28
29
30
31
32
33
34
35
# File 'lib/sonar/search.rb', line 28

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