Sha256: 6259bcc18e6882e29d756d61ec92ab50b57f962f19e47500e407296613103c08

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 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["results"] || []
        convert_to_records results
      end

      def lookup_by_domain(_data)
        []
      end

      def convert_to_records(results)
        results.map do |result|
          data = result["resolve"]
          first_seen = result["firstSeen"].to_s.split.first
          last_seen = result["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

1 entries across 1 versions & 1 rubygems

Version Path
ukemi-0.4.1 lib/ukemi/services/passivetotal.rb