Class: Mihari::Analyzers::PassiveTotal

Inherits:
Base show all
Includes:
Concerns::Refangable
Defined in:
lib/mihari/analyzers/passivetotal.rb

Overview

PassiveTotal 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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Concerns::Refangable

#refang

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, 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?

Constructor Details

#initialize(query, options: nil, api_key: nil, username: nil) ⇒ PassiveTotal

Returns a new instance of PassiveTotal.

Parameters:

  • query (String)
  • options (Hash, nil) (defaults to: nil)
  • api_key (String, nil) (defaults to: nil)
  • username (String, nil) (defaults to: nil)


26
27
28
29
30
31
32
33
# File 'lib/mihari/analyzers/passivetotal.rb', line 26

def initialize(query, options: nil, api_key: nil, username: nil)
  super(refang(query), options:)

  @type = DataType.type(query)

  @username = username || Mihari.config.passivetotal_username
  @api_key = api_key || Mihari.config.passivetotal_api_key
end

Instance Attribute Details

#api_keyString? (readonly)

Returns:

  • (String, nil)


18
19
20
# File 'lib/mihari/analyzers/passivetotal.rb', line 18

def api_key
  @api_key
end

#typeString? (readonly)

Returns:

  • (String, nil)


12
13
14
# File 'lib/mihari/analyzers/passivetotal.rb', line 12

def type
  @type
end

#usernameString? (readonly)

Returns:

  • (String, nil)


15
16
17
# File 'lib/mihari/analyzers/passivetotal.rb', line 15

def username
  @username
end

Class Method Details

.key_aliasesArray<String>?

Returns:

  • (Array<String>, nil)


56
57
58
# File 'lib/mihari/analyzers/passivetotal.rb', line 56

def key_aliases
  ["pt"]
end

Instance Method Details

#artifactsObject



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/mihari/analyzers/passivetotal.rb', line 35

def artifacts
  case type
  when "domain", "ip"
    passive_dns_search
  when "mail"
    reverse_whois_search
  when "hash"
    ssl_search
  else
    raise ValueError, "#{query}(type: #{type || "unknown"}) is not supported." unless valid_type?
  end
end

#configured?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/mihari/analyzers/passivetotal.rb', line 48

def configured?
  configuration_keys? || (username? && api_key?)
end