Sha256: 0d3faa37bfc38eaac1cbc2d1c0f2e4fc7a3dd6879c4f5c60db9edd351e7087e8

Contents?: true

Size: 598 Bytes

Versions: 3

Compression:

Stored size: 598 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)
        data = JSON.parse(res.body.to_s)

        Structs::Shodan::InternetDBResponse.from_dynamic! data
      end

      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-5.7.2 lib/mihari/enrichers/shodan.rb
mihari-5.7.1 lib/mihari/enrichers/shodan.rb
mihari-5.7.0 lib/mihari/enrichers/shodan.rb