class Aquatone::Collectors::Passivetotal

Constants

API_BASE_URI

Public Instance Methods

run() click to toggle source
# File lib/aquatone/collectors/passivetotal.rb, line 13
def run
  response = get_request(
    "#{API_BASE_URI}/v2/enrichment/subdomains?query=.#{url_escape(domain.name)}",
    :basic_auth => {:username => get_key("passivetotal_key"), :password => get_key("passivetotal_secret")}
  )
  body = response.parsed_response
  if response.code != 200
    failure(failure(body["message"] || "PassiveTotal API returned unexpected response code: #{response.code}"))
  end
  if !(body.key?("success") && body["success"])
    failure("Request failed")
  end
  body["subdomains"].each do |subdomain|
    add_host("#{subdomain}.#{domain.name}")
  end
end