Sha256: 5ea4265bb5e0ea87762064a8c2c1d5686833210579b0d4115e9ed97787e35448

Contents?: true

Size: 599 Bytes

Versions: 3

Compression:

Stored size: 599 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Enrichers
    #
    # Shodan enricher
    #
    class Shodan < Base
      #
      # Query Shodan Internet DB
      #
      # @param [String] ip
      #
      # @return [Mihari::Structs::Shodan::InternetDBResponse, nil]
      #
      def call(ip)
        url = "https://internetdb.shodan.io/#{ip}"
        res = http.get(url)
        Structs::Shodan::InternetDBResponse.from_dynamic! JSON.parse(res.body.to_s)
      end
      memo_wise :call

      private

      def http
        HTTP::Factory.build timeout: timeout
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mihari-6.3.0 lib/mihari/enrichers/shodan.rb
mihari-6.2.0 lib/mihari/enrichers/shodan.rb
mihari-6.1.0 lib/mihari/enrichers/shodan.rb