class SiteInspector::Endpoint::Headers

Public Instance Methods

[](header) click to toggle source
# File lib/site-inspector/checks/headers.rb, line 53
def [](header)
  headers[header]
end
all() click to toggle source

Returns an array of hashes of downcased key/value header pairs (or an empty hash)

# File lib/site-inspector/checks/headers.rb, line 48
def all
  @all ||= response&.headers ? response.headers.transform_keys(&:downcase) : {}
end
Also aliased as: headers
click_jacking_protection() click to toggle source
# File lib/site-inspector/checks/headers.rb, line 30
def click_jacking_protection
  headers['x-frame-options']
end
click_jacking_protection?() click to toggle source
# File lib/site-inspector/checks/headers.rb, line 15
def click_jacking_protection?
  !!click_jacking_protection
end
content_security_policy() click to toggle source
# File lib/site-inspector/checks/headers.rb, line 26
def content_security_policy
  headers['content-security-policy']
end
content_security_policy?() click to toggle source
# File lib/site-inspector/checks/headers.rb, line 11
def content_security_policy?
  !!content_security_policy
end
headers()
Alias for: all
server() click to toggle source
# File lib/site-inspector/checks/headers.rb, line 34
def server
  headers['server']
end
strict_transport_security() click to toggle source

TODO: kill this

# File lib/site-inspector/checks/headers.rb, line 22
def strict_transport_security
  headers['strict-transport-security']
end
strict_transport_security?() click to toggle source

TODO: kill this

# File lib/site-inspector/checks/headers.rb, line 7
def strict_transport_security?
  !!strict_transport_security
end
to_h() click to toggle source
# File lib/site-inspector/checks/headers.rb, line 57
def to_h
  {
    strict_transport_security: strict_transport_security || false,
    content_security_policy: content_security_policy || false,
    click_jacking_protection: click_jacking_protection || false,
    server: server,
    xss_protection: xss_protection || false
  }
end
xss_protection() click to toggle source
# File lib/site-inspector/checks/headers.rb, line 38
def xss_protection
  headers['x-xss-protection']
end
xss_protection?() click to toggle source

more specific checks than presence of headers

# File lib/site-inspector/checks/headers.rb, line 43
def xss_protection?
  xss_protection == '1; mode=block'
end