Class: CMSScanner::Model::Headers

Inherits:
InterestingFinding show all
Defined in:
app/models/headers.rb

Overview

Interesting Headers

Constant Summary

Constants included from Finders::Finding

Finders::Finding::FINDING_OPTS

Instance Attribute Summary

Attributes inherited from InterestingFinding

#url

Instance Method Summary collapse

Methods inherited from InterestingFinding

#==, #initialize, #type

Methods included from Finders::Finding

#<=>, #confidence, #confidence=, #confirmed_by, #eql?, included, #parse_finding_options

Constructor Details

This class inherits a constructor from CMSScanner::Model::InterestingFinding

Instance Method Details

#entriesHash

Returns The headers.

Returns:

  • (Hash)

    The headers



8
9
10
11
12
13
# File 'app/models/headers.rb', line 8

def entries
  res = NS::Browser.get(url)
  return [] unless res&.headers

  res.headers
end

#interesting_entriesArray<String>

Returns The interesting headers detected.

Returns:

  • (Array<String>)

    The interesting headers detected



16
17
18
19
20
21
22
23
24
25
# File 'app/models/headers.rb', line 16

def interesting_entries
  results = []

  entries.each do |header, value|
    next if known_headers.include?(header.downcase)

    results << "#{header}: #{Array(value).join(', ')}"
  end
  results
end

#known_headersArray<String>

Returns Downcased known headers.

Returns:

  • (Array<String>)

    Downcased known headers



28
29
30
31
32
33
34
35
36
# File 'app/models/headers.rb', line 28

def known_headers
  %w[
    age accept-ranges cache-control content-encoding content-length content-type connection date
    etag expires keep-alive location last-modified link pragma set-cookie strict-transport-security
    transfer-encoding vary x-cache x-content-security-policy x-content-type-options
    x-frame-options x-language x-permitted-cross-domain-policies x-pingback x-varnish
    x-webkit-csp x-xss-protection
  ]
end

#to_sString

Returns:

  • (String)


39
40
41
# File 'app/models/headers.rb', line 39

def to_s
  @to_s ||= 'Headers'
end