Sha256: 638d707f6f5b481e79099cb445fd9c19faa4df09343ef73350816875dbd82d69

Contents?: true

Size: 926 Bytes

Versions: 4

Compression:

Stored size: 926 Bytes

Contents

# frozen_string_literal: true

require "passivetotal"

module Ukemi
  module Services
    class PassiveTotal < Service
      private

      def api
        @api ||= ::PassiveTotal::API.new
      end

      def config_keys
        %w(PASSIVETOTAL_USERNAME PASSIVETOTAL_API_KEY)
      end

      def lookup_by_ip(data)
        res = api.dns.passive(data)
        results = res.dig("results") || []
        convert_to_records results
      end

      def lookup_by_domain(_data)
        []
      end

      def convert_to_records(results)
        results.map do |result|
          data = result.dig("resolve")
          first_seen = result.dig("firstSeen").to_s.split.first
          last_seen = result.dig("lastSeen").to_s.split.first
          Record.new(
            data: data,
            first_seen: first_seen,
            last_seen: last_seen,
            source: name
          )
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ukemi-0.4.0 lib/ukemi/services/passivetotal.rb
ukemi-0.3.0 lib/ukemi/services/passivetotal.rb
ukemi-0.2.0 lib/ukemi/services/passivetotal.rb
ukemi-0.1.0 lib/ukemi/services/passivetotal.rb