Class: SiteInspector::Endpoint::Hsts
- Inherits:
-
Check
- Object
- Check
- SiteInspector::Endpoint::Hsts
show all
- Defined in:
- lib/site-inspector/checks/hsts.rb
Overview
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
#enabled? ⇒ Boolean
26
27
28
29
30
|
# File 'lib/site-inspector/checks/hsts.rb', line 26
def enabled?
return false unless max_age
max_age.positive?
end
|
#include_subdomains? ⇒ Boolean
18
19
20
|
# File 'lib/site-inspector/checks/hsts.rb', line 18
def include_subdomains?
pairs.key?(:includesubdomains)
end
|
#max_age ⇒ Object
14
15
16
|
# File 'lib/site-inspector/checks/hsts.rb', line 14
def max_age
pairs[:"max-age"].to_i
end
|
#preload? ⇒ Boolean
22
23
24
|
# File 'lib/site-inspector/checks/hsts.rb', line 22
def preload?
pairs.key?(:preload)
end
|
#preload_ready? ⇒ Boolean
Google’s minimum max-age for automatic preloading
33
34
35
|
# File 'lib/site-inspector/checks/hsts.rb', line 33
def preload_ready?
include_subdomains? && preload? && max_age >= 10_886_400
end
|
#to_h ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/site-inspector/checks/hsts.rb', line 37
def to_h
{
valid: valid?,
max_age: max_age,
include_subdomains: include_subdomains?,
preload: preload?,
enabled: enabled?,
preload_ready: preload_ready?
}
end
|
#valid? ⇒ Boolean
8
9
10
11
12
|
# File 'lib/site-inspector/checks/hsts.rb', line 8
def valid?
return false unless
pairs.none? { |key, value| "#{key}#{value}" =~ /[\s'"]/ }
end
|