Sha256: fcd08d51c0d80c78058da5a31c08bab3d01e752b79aad885fbaa232853011a2f

Contents?: true

Size: 740 Bytes

Versions: 12

Compression:

Stored size: 740 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Analyzers
    module Clients
      class OTX
        attr_reader :api_key

        def initialize(api_key)
          @api_key = api_key
        end

        def query_by_ip(ip)
          get "https://otx.alienvault.com/api/v1/indicators/IPv4/#{ip}/passive_dns"
        end

        def query_by_domain(domain)
          get "https://otx.alienvault.com/api/v1/indicators/domain/#{domain}/passive_dns"
        end

        private

        def headers
          { "x-otx-api-key": api_key }
        end

        def get(url)
          res = HTTP.get(url, headers: headers)
          JSON.parse(res.body.to_s)
        rescue HTTPError
          nil
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mihari-5.1.0 lib/mihari/analyzers/clients/otx.rb
mihari-5.0.1 lib/mihari/analyzers/clients/otx.rb
mihari-5.0.0 lib/mihari/analyzers/clients/otx.rb
mihari-4.12.0 lib/mihari/analyzers/clients/otx.rb
mihari-4.11.0 lib/mihari/analyzers/clients/otx.rb
mihari-4.10.0 lib/mihari/analyzers/clients/otx.rb
mihari-4.9.0 lib/mihari/analyzers/clients/otx.rb
mihari-4.8.0 lib/mihari/analyzers/clients/otx.rb
mihari-4.7.4 lib/mihari/analyzers/clients/otx.rb
mihari-4.7.3 lib/mihari/analyzers/clients/otx.rb
mihari-4.7.2 lib/mihari/analyzers/clients/otx.rb
mihari-4.7.1 lib/mihari/analyzers/clients/otx.rb