class SiteInspector::Endpoint::Wappalyzer

Constants

ENDPOINT

Public Instance Methods

to_h() click to toggle source
# File lib/site-inspector/checks/wappalyzer.rb, line 8
def to_h
  return {} unless data['technologies']

  @to_h ||= begin
    technologies = {}
    data['technologies'].each do |t|
      category = t['categories'].first
      category = category ? category['name'] : 'Other'
      technologies[category] ||= []
      technologies[category].push t['name']
    end

    technologies
  end
end

Private Instance Methods

api_key() click to toggle source
# File lib/site-inspector/checks/wappalyzer.rb, line 57
def api_key
  @api_key ||= ENV['WAPPALYZER_API_KEY']
end
data() click to toggle source
# File lib/site-inspector/checks/wappalyzer.rb, line 35
def data
  return {} unless api_key && api_key != ''

  @data ||= begin
    SiteInspector.hydra.queue(request)
    SiteInspector.hydra.run

    response = request.response
    if response.success?
      JSON.parse(response.body).first
    else
      {}
    end
  end
end
request() click to toggle source
# File lib/site-inspector/checks/wappalyzer.rb, line 26
def request
  @request ||= begin
    options = SiteInspector.typhoeus_defaults
    headers = options[:headers].merge({ "x-api-key": api_key })
    options = options.merge(method: :get, headers: headers)
    Typhoeus::Request.new(url, options)
  end
end
url() click to toggle source
# File lib/site-inspector/checks/wappalyzer.rb, line 51
def url
  url = Addressable::URI.parse(ENDPOINT)
  url.query_values = { urls: endpoint.uri }
  url
end