Sha256: f48f7dd9e32527182f9bcf789e80f48e970d5e2519ae4fab0938f211339f675d
Contents?: true
Size: 1.68 KB
Versions: 6
Compression:
Stored size: 1.68 KB
Contents
# frozen_string_literal: true require "otx_ruby" module Mihari module Analyzers class OTX < Base include Mixins::Refang param :query attr_reader :type def initialize(*args, **kwargs) super @query = refang(query) @type = TypeChecker.type(query) end def artifacts search || [] end private def configuration_keys %w[otx_api_key] end def domain_client @domain_client ||= ::OTX::Domain.new(Mihari.config.otx_api_key) end def ip_client @ip_client ||= ::OTX::IP.new(Mihari.config.otx_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
6 entries across 6 versions & 1 rubygems