Class: Mihari::Analyzers::ZoomEye

Inherits:
Base show all
Defined in:
lib/mihari/analyzers/zoomeye.rb

Overview

ZoomEye analyzer

Constant Summary

Constants included from Concerns::Retriable

Concerns::Retriable::DEFAULT_CONDITION, Concerns::Retriable::RETRIABLE_ERRORS

Instance Attribute Summary collapse

Attributes inherited from Base

#query

Attributes inherited from Mihari::Actor

#options

Instance Method Summary collapse

Methods inherited from Base

#call, from_params, #ignore_error?, inherited, #normalized_artifacts, #pagination_interval, #pagination_limit, #parallel?, #result, #truncated_query

Methods inherited from Mihari::Actor

#call, configuration_keys, key, key_aliases, keys, #result, #retry_exponential_backoff, #retry_interval, #retry_times, #timeout, type, #validate_configuration!

Methods included from Concerns::Retriable

#retry_on_error

Methods included from Concerns::Configurable

#configuration_keys?, #configured?

Constructor Details

#initialize(query, options: nil, api_key: nil, type: "host") ⇒ ZoomEye

Returns a new instance of ZoomEye.

Parameters:

  • query (String)
  • options (Hash, nil) (defaults to: nil)
  • api_key (String, nil) (defaults to: nil)
  • type (String) (defaults to: "host")


21
22
23
24
25
26
# File 'lib/mihari/analyzers/zoomeye.rb', line 21

def initialize(query, options: nil, api_key: nil, type: "host")
  super(query, options:)

  @type = type
  @api_key = api_key || Mihari.config.zoomeye_api_key
end

Instance Attribute Details

#api_keyString? (readonly)

Returns:

  • (String, nil)


10
11
12
# File 'lib/mihari/analyzers/zoomeye.rb', line 10

def api_key
  @api_key
end

#typeString (readonly)

Returns:

  • (String)


13
14
15
# File 'lib/mihari/analyzers/zoomeye.rb', line 13

def type
  @type
end

Instance Method Details

#artifactsObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/mihari/analyzers/zoomeye.rb', line 28

def artifacts
  case type
  when "host"
    client.host_search_with_pagination(query).map do |res|
      convert(res)
    end.flatten
  when "web"
    client.web_search_with_pagination(query).map do |res|
      convert(res)
    end.flatten
  else
    raise ValueError, "#{type} type is not supported." unless valid_type?
  end
end