Sha256: 5e56de29b83fd2d8ad3276fb6c544ff5618f45142ae71f0dad9b3ed2fefc9f01
Contents?: true
Size: 1.81 KB
Versions: 4
Compression:
Stored size: 1.81 KB
Contents
# frozen_string_literal: true module Mihari module Analyzers class ZoomEye < Base # @return [String, nil] attr_reader :api_key # @return [String] attr_reader :type # # @param [String] query # @param [Hash, nil] options # @param [String, nil] api_key # @param [String] type # def initialize(query, options: nil, api_key: nil, type: "host") super(query, options: options) @type = type @api_key = api_key || Mihari.config.zoomeye_api_key end 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 def configuration_keys %w[zoomeye_api_key] end private # # Check whether a type is valid or not # # @return [Boolean] # def valid_type? %w[host web].include? type end def client @client ||= Clients::ZoomEye.new(api_key: api_key, interval: interval) end # # Convert responses into an array of String # # @param [Hash] response # # @return [Array<Mihari::Artifact>] # def convert(res) matches = res["matches"] || [] matches.map do |match| data = match["ip"] if data.is_a?(Array) data.map { |d| Artifact.new(data: d, source: source, metadata: match) } else Artifact.new(data: data, source: source, metadata: match) end end.flatten end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
mihari-5.4.7 | lib/mihari/analyzers/zoomeye.rb |
mihari-5.4.6 | lib/mihari/analyzers/zoomeye.rb |
mihari-5.4.5 | lib/mihari/analyzers/zoomeye.rb |
mihari-5.4.4 | lib/mihari/analyzers/zoomeye.rb |