github-pages-health-check 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/github-pages-health-check.gemspec +1 -1
- data/lib/github-pages-health-check/domain.rb +77 -24
- data/lib/github-pages-health-check/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 132f9dcae46fe334470c7bc86fb3b98ba4e895cd
|
4
|
+
data.tar.gz: 0ff1b4b2bd51d97011f065208b779990d1a86184
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9e2d427d05ce7396e9cb1924230aa2736ea102da7b831615a2611153e67523ddf4f8190e01d5119fa67513d7230b39cf6231014b73df04505ca82e55e84f776
|
7
|
+
data.tar.gz: 7650c557747924073b9e2e46f2ba7107a4a3a2130ae5b2ea86d964f6ca5dcacd8e9efa13ec20d427f2de92189b3599d19c88b02e3ab4d399d1af03eb10dccee1
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1
|
1
|
+
2.3.1
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.require_paths = ['lib']
|
16
16
|
|
17
17
|
s.add_dependency("net-dns", "~> 0.8")
|
18
|
-
s.add_dependency("public_suffix", "~>
|
18
|
+
s.add_dependency("public_suffix", "~> 2.0")
|
19
19
|
s.add_dependency("typhoeus", "~> 0.7")
|
20
20
|
s.add_dependency("addressable", "~> 2.3")
|
21
21
|
s.add_dependency("octokit", "~> 4.0")
|
@@ -21,11 +21,11 @@ module GitHubPages
|
|
21
21
|
|
22
22
|
HASH_METHODS = [
|
23
23
|
:host, :uri, :dns_resolves?, :proxied?, :cloudflare_ip?, :fastly_ip?,
|
24
|
-
:old_ip_address?, :a_record?, :cname_record?, :
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:valid_domain
|
24
|
+
:old_ip_address?, :a_record?, :cname_record?, :mx_records_present?,
|
25
|
+
:valid_domain?, :apex_domain?, :should_be_a_record?,
|
26
|
+
:cname_to_github_user_domain?, :cname_to_pages_dot_github_dot_com?,
|
27
|
+
:cname_to_fastly?, :pointed_to_github_pages_ip?, :pages_domain?,
|
28
|
+
:served_by_pages?, :valid_domain?, :https?, :enforces_https?, :https_error
|
29
29
|
].freeze
|
30
30
|
|
31
31
|
def initialize(host)
|
@@ -64,7 +64,7 @@ module GitHubPages
|
|
64
64
|
return false unless valid_domain?
|
65
65
|
return false if github_domain? || apex_domain?
|
66
66
|
return true if cname_to_pages_dot_github_dot_com? || cname_to_fastly?
|
67
|
-
!cname_to_github_user_domain?
|
67
|
+
!cname_to_github_user_domain? && should_be_cname_record?
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -72,7 +72,7 @@ module GitHubPages
|
|
72
72
|
# Used as an escape hatch to prevent false positives on DNS checkes
|
73
73
|
def valid_domain?
|
74
74
|
return @valid if defined? @valid
|
75
|
-
@valid = PublicSuffix.valid?(host)
|
75
|
+
@valid = PublicSuffix.valid?(host, default_rule: nil)
|
76
76
|
end
|
77
77
|
|
78
78
|
# Is this domain an apex domain, meaning a CNAME would be innapropriate
|
@@ -94,7 +94,11 @@ module GitHubPages
|
|
94
94
|
|
95
95
|
# Should the domain be an apex record?
|
96
96
|
def should_be_a_record?
|
97
|
-
!pages_domain? && apex_domain?
|
97
|
+
!pages_domain? && (apex_domain? || mx_records_present?)
|
98
|
+
end
|
99
|
+
|
100
|
+
def should_be_cname_record?
|
101
|
+
!should_be_a_record?
|
98
102
|
end
|
99
103
|
|
100
104
|
# Is the domain's first response an A record to a valid GitHub Pages IP?
|
@@ -170,13 +174,20 @@ module GitHubPages
|
|
170
174
|
return unless valid_domain?
|
171
175
|
@dns = Timeout.timeout(TIMEOUT) do
|
172
176
|
GitHubPages::HealthCheck.without_warnings do
|
173
|
-
|
177
|
+
unless host.nil?
|
178
|
+
resolver.search(absolute_domain, Net::DNS::A).answer +
|
179
|
+
resolver.search(absolute_domain, Net::DNS::MX).answer
|
180
|
+
end
|
174
181
|
end
|
175
182
|
end
|
176
183
|
rescue StandardError
|
177
184
|
@dns = nil
|
178
185
|
end
|
179
186
|
|
187
|
+
def resolver
|
188
|
+
@resolver ||= Net::DNS::Resolver.new
|
189
|
+
end
|
190
|
+
|
180
191
|
# Are we even able to get the DNS record?
|
181
192
|
def dns?
|
182
193
|
!(dns.nil? || dns.empty?)
|
@@ -199,30 +210,28 @@ module GitHubPages
|
|
199
210
|
# Is this domain's first response a CNAME record?
|
200
211
|
def cname_record?
|
201
212
|
return unless dns?
|
202
|
-
|
213
|
+
return false unless cname
|
214
|
+
cname.valid_domain?
|
203
215
|
end
|
204
216
|
alias cname? cname_record?
|
205
217
|
|
206
218
|
# The domain to which this domain's CNAME resolves
|
207
219
|
# Returns nil if the domain is not a CNAME
|
208
220
|
def cname
|
209
|
-
return unless
|
221
|
+
return unless dns.first.class == Net::DNS::RR::CNAME
|
210
222
|
@cname ||= Domain.new(dns.first.cname.to_s)
|
211
223
|
end
|
212
224
|
|
225
|
+
def mx_records_present?
|
226
|
+
return unless dns?
|
227
|
+
dns.any? { |answer| answer.class == Net::DNS::RR::MX }
|
228
|
+
end
|
229
|
+
|
213
230
|
def served_by_pages?
|
214
231
|
return @served_by_pages if defined? @served_by_pages
|
215
232
|
return unless dns_resolves?
|
216
233
|
|
217
234
|
@served_by_pages = begin
|
218
|
-
response = Typhoeus.head(uri, TYPHOEUS_OPTIONS)
|
219
|
-
|
220
|
-
# Workaround for webmock not playing nicely with Typhoeus redirects
|
221
|
-
# See https://github.com/bblimke/webmock/issues/237
|
222
|
-
if response.mock? && response.headers["Location"]
|
223
|
-
response = Typhoeus.head(response.headers["Location"], TYPHOEUS_OPTIONS)
|
224
|
-
end
|
225
|
-
|
226
235
|
return false unless response.mock? || response.return_code == :ok
|
227
236
|
return true if response.headers["Server"] == "GitHub.com"
|
228
237
|
|
@@ -231,15 +240,59 @@ module GitHubPages
|
|
231
240
|
end
|
232
241
|
end
|
233
242
|
|
234
|
-
def uri
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
243
|
+
def uri(overrides={})
|
244
|
+
options = { :host => host, :scheme => scheme, :path => "/" }
|
245
|
+
options = options.merge(overrides)
|
246
|
+
Addressable::URI.new(options).normalize.to_s
|
247
|
+
end
|
248
|
+
|
249
|
+
# Does this domain respond to HTTPS requests with a valid cert?
|
250
|
+
def https?
|
251
|
+
https_response.return_code == :ok
|
252
|
+
end
|
253
|
+
|
254
|
+
# The response code of the HTTPS request, if it failed.
|
255
|
+
# Useful for diagnosing cert errors
|
256
|
+
def https_error
|
257
|
+
https_response.return_code unless https?
|
258
|
+
end
|
259
|
+
|
260
|
+
# Does this domain redirect HTTP requests to HTTPS?
|
261
|
+
def enforces_https?
|
262
|
+
return false unless https? && http_response.headers["Location"]
|
263
|
+
redirect = Addressable::URI.parse(http_response.headers["Location"])
|
264
|
+
redirect.scheme == "https" && redirect.host == host
|
239
265
|
end
|
240
266
|
|
241
267
|
private
|
242
268
|
|
269
|
+
# The domain's response to HTTP(S) requests, following redirects
|
270
|
+
def response
|
271
|
+
return @response if defined? @response
|
272
|
+
|
273
|
+
@response = Typhoeus.head(uri, TYPHOEUS_OPTIONS)
|
274
|
+
|
275
|
+
# Workaround for webmock not playing nicely with Typhoeus redirects
|
276
|
+
# See https://github.com/bblimke/webmock/issues/237
|
277
|
+
if @response.mock? && @response.headers["Location"]
|
278
|
+
@response = Typhoeus.head(response.headers["Location"], TYPHOEUS_OPTIONS)
|
279
|
+
end
|
280
|
+
|
281
|
+
@response
|
282
|
+
end
|
283
|
+
|
284
|
+
# The domain's response to HTTP requests, without following redirects
|
285
|
+
def http_response
|
286
|
+
options = TYPHOEUS_OPTIONS.merge(:followlocation => false )
|
287
|
+
@http_response ||= Typhoeus.head(uri(:scheme => "http"), options)
|
288
|
+
end
|
289
|
+
|
290
|
+
# The domain's response to HTTPS requests, without following redirects
|
291
|
+
def https_response
|
292
|
+
options = TYPHOEUS_OPTIONS.merge(:followlocation => false )
|
293
|
+
@https_response ||= Typhoeus.head(uri(:scheme => "https"), options)
|
294
|
+
end
|
295
|
+
|
243
296
|
# Parse the URI. Accept either domain names or full URI's.
|
244
297
|
# Used by the initializer so we can be more flexible with inputs.
|
245
298
|
#
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github-pages-health-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-dns
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: typhoeus
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -215,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
215
|
version: '0'
|
216
216
|
requirements: []
|
217
217
|
rubyforge_project:
|
218
|
-
rubygems_version: 2.
|
218
|
+
rubygems_version: 2.5.1
|
219
219
|
signing_key:
|
220
220
|
specification_version: 4
|
221
221
|
summary: Checks your GitHub Pages site for commons DNS configuration issues
|