Class: SiteInspector::Endpoint::Headers
- Inherits:
-
Check
- Object
- Check
- SiteInspector::Endpoint::Headers
show all
- Defined in:
- lib/site-inspector/checks/headers.rb
Instance Attribute Summary
Attributes inherited from Check
#endpoint
Instance Method Summary
collapse
Methods inherited from Check
enabled=, enabled?, #host, #initialize, #inspect, #name, name, #request, #response
Instance Method Details
#[](header) ⇒ Object
51
52
53
|
# File 'lib/site-inspector/checks/headers.rb', line 51
def []()
[]
end
|
#all ⇒ Object
Also known as:
Returns an array of hashes of downcased key/value header pairs (or an empty hash)
46
47
48
|
# File 'lib/site-inspector/checks/headers.rb', line 46
def all
@all ||= (response && response.) ? Hash[response..map { |k, v| [k.downcase, v] }] : {}
end
|
#click_jacking_protection ⇒ Object
28
29
30
|
# File 'lib/site-inspector/checks/headers.rb', line 28
def click_jacking_protection
['x-frame-options']
end
|
#click_jacking_protection? ⇒ Boolean
13
14
15
|
# File 'lib/site-inspector/checks/headers.rb', line 13
def click_jacking_protection?
!!click_jacking_protection
end
|
#content_security_policy ⇒ Object
24
25
26
|
# File 'lib/site-inspector/checks/headers.rb', line 24
def content_security_policy
['content-security-policy']
end
|
#content_security_policy? ⇒ Boolean
9
10
11
|
# File 'lib/site-inspector/checks/headers.rb', line 9
def content_security_policy?
!!content_security_policy
end
|
#server ⇒ Object
32
33
34
|
# File 'lib/site-inspector/checks/headers.rb', line 32
def server
['server']
end
|
#strict_transport_security ⇒ Object
20
21
22
|
# File 'lib/site-inspector/checks/headers.rb', line 20
def strict_transport_security
['strict-transport-security']
end
|
#strict_transport_security? ⇒ Boolean
5
6
7
|
# File 'lib/site-inspector/checks/headers.rb', line 5
def strict_transport_security?
!!strict_transport_security
end
|
#to_h ⇒ Object
55
56
57
58
59
60
61
62
63
|
# File 'lib/site-inspector/checks/headers.rb', line 55
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 ⇒ Object
36
37
38
|
# File 'lib/site-inspector/checks/headers.rb', line 36
def xss_protection
['x-xss-protection']
end
|
#xss_protection? ⇒ Boolean
more specific checks than presence of headers
41
42
43
|
# File 'lib/site-inspector/checks/headers.rb', line 41
def xss_protection?
xss_protection == '1; mode=block'
end
|