Sha256: efef32a078d2a475deb6482442431d5e22fd6dafecabf20fbc4da7aff211e85d
Contents?: true
Size: 1.31 KB
Versions: 11
Compression:
Stored size: 1.31 KB
Contents
# frozen_string_literal: true require "binaryedge" module Mihari module Analyzers class BinaryEdge < Base attr_reader :title attr_reader :description attr_reader :query attr_reader :tags def initialize(query, title: nil, description: nil, tags: []) super() @query = query @title = title || "BinaryEdge lookup" @description = description || "query = #{query}" @tags = tags end def artifacts results = search return [] unless results || results.empty? results.map do |result| events = result.dig("events") || [] events.map do |event| event.dig "origin", "ip" end.compact end.flatten.compact.uniq end private PAGE_SIZE = 20 def search_with_page(query, page: 1) api.host.search(query, page: page) end def search responses = [] (1..Float::INFINITY).each do |page| res = search_with_page(query, page: page) total = res.dig("total").to_i responses << res break if total <= page * PAGE_SIZE end responses end def config_keys %w(BINARYEDGE_API_KEY) end def api @api ||= ::BinaryEdge::API.new end end end end
Version data entries
11 entries across 11 versions & 1 rubygems