Sha256: d56d3c8271f21f0c3d7d6bbeb7bc54eb157f6f87586b219e583665612e9cccf0
Contents?: true
Size: 1.85 KB
Versions: 2
Compression:
Stored size: 1.85 KB
Contents
# frozen_string_literal: true module Mihari module Clients class BinaryEdge < Base # # @param [String] base_url # @param [String, nil] api_key # @param [Hash] headers # @param [Integer] pagnation_interval # @param [Integer, nil] timeout # def initialize( base_url = "https://api.binaryedge.io/v2", api_key:, headers: {}, pagination_interval: 0, timeout: nil ) raise(ArgumentError, "'api_key' argument is required") unless api_key headers["x-key"] = api_key super(base_url, headers: headers, pagination_interval: pagination_interval, timeout: timeout) end # # @param [String] query String used to query our data # @param [Integer] page Default 1, Maximum: 500 # @param [Integer, nil] only_ips If selected, only output IP addresses, ports and protocols. # # @return [Structs::BinaryEdge::Response] # def search(query, page: 1, only_ips: nil) params = { query: query, page: page, only_ips: only_ips }.compact res = get("/query/search", params: params) Structs::BinaryEdge::Response.from_dynamic! JSON.parse(res.body.to_s) end # # @param [String] query # @param [Integer, nil] only_ips # @param [Integer] pagination_limit # # @return [Enumerable<Structs::BinaryEdge::Response.>] # def search_with_pagination(query, only_ips: nil, pagination_limit: Mihari.config.pagination_limit) Enumerator.new do |y| (1..pagination_limit).each do |page| res = search(query, page: page, only_ips: only_ips) y.yield res break if res.events.length < res.pagesize sleep_pagination_interval end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mihari-5.6.0 | lib/mihari/clients/binaryedge.rb |
mihari-5.5.0 | lib/mihari/clients/binaryedge.rb |