Sha256: 2266d416265e480ce9851dcd64a3b8457642d1fa07e534e2d1e0302cc431fba1
Contents?: true
Size: 1.8 KB
Versions: 9
Compression:
Stored size: 1.8 KB
Contents
# frozen_string_literal: true require "otx_ruby" module Mihari module Analyzers class OTX < Base include Mixins::Refang param :query # @return [String, nil] attr_reader :type # @return [String, nil] attr_reader :api_key def initialize(*args, **kwargs) super @query = refang(query) @type = TypeChecker.type(query) @api_key = kwargs[:api_key] || Mihari.config.otx_api_key end def artifacts search || [] end private def configuration_keys %w[otx_api_key] end def domain_client @domain_client ||= ::OTX::Domain.new(api_key) end def ip_client @ip_client ||= ::OTX::IP.new(api_key) end # # Check whether a type is valid or not # # @return [Boolean] # def valid_type? %w[ip domain].include? type end # # IP/domain search # # @return [Array<String>] # 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 # # Domain search # # @return [Array<String>] # 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 search # # @return [Array<String>] # 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 end end end
Version data entries
9 entries across 9 versions & 1 rubygems