Class: Magento

Inherits:
Fingerprinter::Technologies show all
Defined in:
lib/fingerprinter/technologies/cms/magento.rb

Overview

Magento Detection

Constant Summary collapse

META_CONTENT_REGEX =
[
  'Magento'
].freeze
HEADERS_REGEX =
{
  'x-magento-debug' => /\d/,
  'x-magento-cache-control' => /\w/
}.freeze
BODY_CONTENT_REGEX =
[
  /Magento_PageCache/,
  /Mage\.Cookies\.path/,
  /data-requiremodule="(mage|Magento_)/,
  %r{mage/cookies},
  /MAGENTO_/,
  /Magento Security Scan/,
  %r{js/mage/},
  /x-magento-init/
].freeze

Instance Attribute Summary

Attributes inherited from Fingerprinter::Technologies

#http_client, #results

Class Method Summary collapse

Methods inherited from Fingerprinter::Technologies

#initialize, kb, meta_detection, response_headers_check, #run, title_detection, whole_body_check

Constructor Details

This class inherits a constructor from Fingerprinter::Technologies

Class Method Details

.get_graphql(url) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/fingerprinter/technologies/cms/magento.rb', line 25

def self.get_graphql(url)
  url = File.join(Utilities::Urls.up_to_port(url),
                  '/graphql?query=+{customerDownloadableProducts+{+items+{+date+download_url}}+}')
  return if Utilities::Kb.inspected?(self, url)

  Utilities::Kb.inspected(self, url)
  Fingerprinter.http_client.get(url)[url]
end

.run(data) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fingerprinter/technologies/cms/magento.rb', line 34

def self.run(data)
  detected = meta_detection(data[:doc], META_CONTENT_REGEX) ||
             whole_body_check(data[:response], BODY_CONTENT_REGEX)

  unless detected
    response = get_graphql(data[:url])
    return unless response&.code == 200 && ['The current customer', 'graphql-authorization'].all? do |pattern|
                    response.body.include?(pattern)
                  end

  end

  'Magento'
end