class Mihari::Analyzers::OTX
Attributes
type[R]
Public Class Methods
new(*args, **kwargs)
click to toggle source
Calls superclass method
Mihari::Analyzers::Base::new
# File lib/mihari/analyzers/otx.rb, line 17 def initialize(*args, **kwargs) super @query = refang(query) @type = TypeChecker.type(query) end
Public Instance Methods
artifacts()
click to toggle source
# File lib/mihari/analyzers/otx.rb, line 24 def artifacts search || [] end
Private Instance Methods
configuration_keys()
click to toggle source
# File lib/mihari/analyzers/otx.rb, line 30 def configuration_keys %w[otx_api_key] end
domain_client()
click to toggle source
# File lib/mihari/analyzers/otx.rb, line 34 def domain_client @domain_client ||= ::OTX::Domain.new(Mihari.config.otx_api_key) end
domain_search()
click to toggle source
Domain search
@return [Array<String>]
# File lib/mihari/analyzers/otx.rb, line 72 def domain_search records = domain_client.get_passive_dns(query) records.filter_map do |record| record.address if record.record_type == "A" end.uniq end
ip_client()
click to toggle source
# File lib/mihari/analyzers/otx.rb, line 38 def ip_client @ip_client ||= ::OTX::IP.new(Mihari.config.otx_api_key) end
ip_search()
click to toggle source
IP search
@return [Array<String>]
# File lib/mihari/analyzers/otx.rb, line 84 def ip_search records = ip_client.get_passive_dns(query) records.filter_map do |record| record.hostname if record.record_type == "A" end.uniq end
search()
click to toggle source
IP/domain search
@return [Array<String>]
# File lib/mihari/analyzers/otx.rb, line 56 def search case type when "domain" domain_search when "ip" ip_search else raise InvalidInputError, "#{query}(type: #{type || "unknown"}) is not supported." unless valid_type? end end
valid_type?()
click to toggle source
Check whether a type is valid or not
@return [Boolean]
# File lib/mihari/analyzers/otx.rb, line 47 def valid_type? %w[ip domain].include? type end