github-pages-health-check 1.17.1 → 1.17.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/push-cibuild.yml +1 -0
- data/Gemfile +1 -0
- data/README.md +37 -0
- data/config/cloudflare-ips.txt +9 -2
- data/config/fastly-ips.txt +4 -2
- data/github-pages-health-check.gemspec +1 -1
- data/lib/github-pages-health-check/domain.rb +80 -27
- data/lib/github-pages-health-check/version.rb +1 -1
- data/script/check +2 -0
- data/script/update-cdn-ips +34 -6
- metadata +5 -6
- data/.travis.yml +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b93b42aca0a60b8bd7d5df583585ec14e09c171077bf389e0d53699e935a344c
|
4
|
+
data.tar.gz: 9616ee04e0a5c2e80e2a1f32b66e401a39f98f31ba30317ffcb8e98c810994ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 911c9d7e94f6a943a6789bc701b7bdf3ff1aa74b4ed0083d18304b40e903b0056175ea5c8990b1ef091156543cf651efcb3a38d80b7bb6721725b1b40c87ade1
|
7
|
+
data.tar.gz: 5dbcdd645e5f05c758126c1ce6dda0338a41ae6404f152ef18de7e2b6b37308446dd5b06cbf4f154d57a0c5eca87a1623debe3760aada69639b9d85193de6298
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -81,3 +81,40 @@ check = GitHubPages::HealthCheck::Site.new "github/pages-health-check", access_t
|
|
81
81
|
```
|
82
82
|
|
83
83
|
You can also set `OCTOKIT_ACCESS_TOKEN` as an environmental variable, or via a `.env` file in your working directory.
|
84
|
+
|
85
|
+
### Command Line
|
86
|
+
|
87
|
+
```
|
88
|
+
./script/check pages.github.com
|
89
|
+
|
90
|
+
host: pages.github.com
|
91
|
+
uri: https://pages.github.com/
|
92
|
+
nameservers: :default
|
93
|
+
dns_resolves?: true
|
94
|
+
proxied?: false
|
95
|
+
cloudflare_ip?: false
|
96
|
+
fastly_ip?: false
|
97
|
+
old_ip_address?: false
|
98
|
+
a_record?: false
|
99
|
+
cname_record?: true
|
100
|
+
mx_records_present?: false
|
101
|
+
valid_domain?: true
|
102
|
+
apex_domain?: false
|
103
|
+
should_be_a_record?: false
|
104
|
+
cname_to_github_user_domain?: true
|
105
|
+
cname_to_pages_dot_github_dot_com?: false
|
106
|
+
cname_to_fastly?: false
|
107
|
+
pointed_to_github_pages_ip?: false
|
108
|
+
non_github_pages_ip_present?: false
|
109
|
+
pages_domain?: true
|
110
|
+
served_by_pages?: true
|
111
|
+
valid?: true
|
112
|
+
reason:
|
113
|
+
https?: true
|
114
|
+
enforces_https?: true
|
115
|
+
https_error:
|
116
|
+
https_eligible?: true
|
117
|
+
caa_error:
|
118
|
+
dns_zone_soa?: false
|
119
|
+
dns_zone_ns?: false
|
120
|
+
```
|
data/config/cloudflare-ips.txt
CHANGED
@@ -9,7 +9,14 @@
|
|
9
9
|
197.234.240.0/22
|
10
10
|
198.41.128.0/17
|
11
11
|
162.158.0.0/15
|
12
|
-
172.64.0.0/13
|
13
|
-
131.0.72.0/22
|
14
12
|
104.16.0.0/13
|
15
13
|
104.24.0.0/14
|
14
|
+
172.64.0.0/13
|
15
|
+
131.0.72.0/22
|
16
|
+
2400:cb00::/32
|
17
|
+
2606:4700::/32
|
18
|
+
2803:f800::/32
|
19
|
+
2405:b500::/32
|
20
|
+
2405:8100::/32
|
21
|
+
2a06:98c0::/29
|
22
|
+
2c0f:f248::/32
|
data/config/fastly-ips.txt
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
103.245.222.0/23
|
5
5
|
103.245.224.0/24
|
6
6
|
104.156.80.0/20
|
7
|
-
146.75.0.0/
|
7
|
+
146.75.0.0/17
|
8
8
|
151.101.0.0/16
|
9
9
|
157.52.64.0/18
|
10
10
|
167.82.0.0/17
|
@@ -14,4 +14,6 @@
|
|
14
14
|
172.111.64.0/18
|
15
15
|
185.31.16.0/22
|
16
16
|
199.27.72.0/21
|
17
|
-
199.232.0.0/16
|
17
|
+
199.232.0.0/16
|
18
|
+
2a04:4e40::/32
|
19
|
+
2a04:4e42::/32
|
@@ -19,6 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.add_dependency("addressable", "~> 2.3")
|
20
20
|
s.add_dependency("dnsruby", "~> 1.60")
|
21
21
|
s.add_dependency("octokit", "~> 4.0")
|
22
|
-
s.add_dependency("public_suffix", ">=
|
22
|
+
s.add_dependency("public_suffix", ">= 3.0", "< 5.0")
|
23
23
|
s.add_dependency("typhoeus", "~> 1.3")
|
24
24
|
end
|
@@ -77,15 +77,25 @@ module GitHubPages
|
|
77
77
|
185.199.111.153
|
78
78
|
).freeze
|
79
79
|
|
80
|
+
CURRENT_IPV6_ADDRESSES = %w(
|
81
|
+
2606:50c0:8000::153
|
82
|
+
2606:50c0:8001::153
|
83
|
+
2606:50c0:8002::153
|
84
|
+
2606:50c0:8003::153
|
85
|
+
).freeze
|
86
|
+
|
87
|
+
CURRENT_IP_ADDRESSES_ALL =
|
88
|
+
(CURRENT_IP_ADDRESSES + CURRENT_IPV6_ADDRESSES).freeze
|
89
|
+
|
80
90
|
HASH_METHODS = %i[
|
81
91
|
host uri nameservers dns_resolves? proxied? cloudflare_ip?
|
82
|
-
fastly_ip? old_ip_address? a_record?
|
83
|
-
mx_records_present? valid_domain? apex_domain?
|
84
|
-
|
85
|
-
|
86
|
-
non_github_pages_ip_present? pages_domain?
|
92
|
+
fastly_ip? old_ip_address? a_record? aaaa_record? aaaa_record_present?
|
93
|
+
cname_record? mx_records_present? valid_domain? apex_domain?
|
94
|
+
should_be_a_record? cname_to_github_user_domain?
|
95
|
+
cname_to_pages_dot_github_dot_com? cname_to_fastly?
|
96
|
+
pointed_to_github_pages_ip? non_github_pages_ip_present? pages_domain?
|
87
97
|
served_by_pages? valid? reason valid_domain? https?
|
88
|
-
enforces_https? https_error https_eligible? caa_error
|
98
|
+
enforces_https? https_error https_eligible? caa_error dns_zone_soa? dns_zone_ns?
|
89
99
|
].freeze
|
90
100
|
|
91
101
|
def self.redundant(host)
|
@@ -128,8 +138,8 @@ module GitHubPages
|
|
128
138
|
def invalid_aaaa_record?
|
129
139
|
return @invalid_aaaa_record if defined? @invalid_aaaa_record
|
130
140
|
|
131
|
-
@invalid_aaaa_record =
|
132
|
-
|
141
|
+
@invalid_aaaa_record =
|
142
|
+
(valid_domain? && aaaa_record_present? && !should_be_a_record?)
|
133
143
|
end
|
134
144
|
|
135
145
|
def invalid_a_record?
|
@@ -164,7 +174,10 @@ module GitHubPages
|
|
164
174
|
# Is this domain an apex domain, meaning a CNAME would be innapropriate
|
165
175
|
def apex_domain?
|
166
176
|
return @apex_domain if defined?(@apex_domain)
|
167
|
-
|
177
|
+
|
178
|
+
return false unless valid_domain?
|
179
|
+
|
180
|
+
return true if dns_zone_soa? && dns_zone_ns?
|
168
181
|
|
169
182
|
# PublicSuffix.domain pulls out the apex-level domain name.
|
170
183
|
# E.g. PublicSuffix.domain("techblog.netflix.com") # => "netflix.com"
|
@@ -177,6 +190,30 @@ module GitHubPages
|
|
177
190
|
:ignore_private => true) == unicode_host
|
178
191
|
end
|
179
192
|
|
193
|
+
#
|
194
|
+
# Does the domain have an associated SOA record?
|
195
|
+
#
|
196
|
+
def dns_zone_soa?
|
197
|
+
return @soa_records if defined?(@soa_records)
|
198
|
+
return false unless dns?
|
199
|
+
|
200
|
+
@soa_records = dns.any? do |answer|
|
201
|
+
answer.type == Dnsruby::Types::SOA && answer.name.to_s == host
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
#
|
206
|
+
# Does the domain have assoicated NS records?
|
207
|
+
#
|
208
|
+
def dns_zone_ns?
|
209
|
+
return @ns_records if defined?(@ns_records)
|
210
|
+
return false unless dns?
|
211
|
+
|
212
|
+
@ns_records = dns.any? do |answer|
|
213
|
+
answer.type == Dnsruby::Types::NS && answer.name.to_s == host
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
180
217
|
# Should the domain use an A record?
|
181
218
|
def should_be_a_record?
|
182
219
|
!pages_io_domain? && (apex_domain? || mx_records_present?)
|
@@ -186,20 +223,20 @@ module GitHubPages
|
|
186
223
|
!should_be_a_record?
|
187
224
|
end
|
188
225
|
|
189
|
-
# Is the domain's first response an A record to a valid GitHub Pages IP?
|
226
|
+
# Is the domain's first response an A or AAAA record to a valid GitHub Pages IP?
|
190
227
|
def pointed_to_github_pages_ip?
|
191
|
-
|
228
|
+
return false unless address_record?
|
229
|
+
|
230
|
+
CURRENT_IP_ADDRESSES_ALL.include?(dns.first.address.to_s.downcase)
|
192
231
|
end
|
193
232
|
|
194
|
-
# Are any of the domain's A records pointing elsewhere?
|
233
|
+
# Are any of the domain's A or AAAA records pointing elsewhere?
|
195
234
|
def non_github_pages_ip_present?
|
196
235
|
return unless dns?
|
197
236
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
false
|
237
|
+
dns
|
238
|
+
.select { |a| Dnsruby::Types::A == a.type || Dnsruby::Types::AAAA == a.type }
|
239
|
+
.any? { |a| !github_pages_ip?(a.address.to_s) }
|
203
240
|
end
|
204
241
|
|
205
242
|
# Is the domain's first response a CNAME to a pages domain?
|
@@ -278,7 +315,9 @@ module GitHubPages
|
|
278
315
|
Dnsruby::Types::A,
|
279
316
|
Dnsruby::Types::AAAA,
|
280
317
|
Dnsruby::Types::CNAME,
|
281
|
-
Dnsruby::Types::MX
|
318
|
+
Dnsruby::Types::MX,
|
319
|
+
Dnsruby::Types::NS,
|
320
|
+
Dnsruby::Types::SOA
|
282
321
|
].freeze
|
283
322
|
|
284
323
|
# Returns an array of DNS answers
|
@@ -316,9 +355,18 @@ module GitHubPages
|
|
316
355
|
|
317
356
|
# Is this domain's first response an A record?
|
318
357
|
def a_record?
|
358
|
+
return @is_a_record if defined?(@is_a_record)
|
319
359
|
return unless dns?
|
320
360
|
|
321
|
-
|
361
|
+
@is_a_record = Dnsruby::Types::A == dns.first.type
|
362
|
+
end
|
363
|
+
|
364
|
+
# Is this domain's first response an AAAA record?
|
365
|
+
def aaaa_record?
|
366
|
+
return @is_aaaa_record if defined?(@is_aaaa_record)
|
367
|
+
return unless dns?
|
368
|
+
|
369
|
+
@is_aaaa_record = Dnsruby::Types::AAAA == dns.first.type
|
322
370
|
end
|
323
371
|
|
324
372
|
def aaaa_record_present?
|
@@ -339,6 +387,8 @@ module GitHubPages
|
|
339
387
|
# The domain to which this domain's CNAME resolves
|
340
388
|
# Returns nil if the domain is not a CNAME
|
341
389
|
def cname
|
390
|
+
return unless dns?
|
391
|
+
|
342
392
|
cnames = dns.take_while { |answer| answer.type == Dnsruby::Types::CNAME }
|
343
393
|
return if cnames.empty?
|
344
394
|
|
@@ -356,7 +406,6 @@ module GitHubPages
|
|
356
406
|
return unless dns_resolves?
|
357
407
|
|
358
408
|
@served_by_pages = begin
|
359
|
-
return false unless response.mock? || response.return_code == :ok
|
360
409
|
return true if response.headers["Server"] == "GitHub.com"
|
361
410
|
|
362
411
|
# Typhoeus mangles the case of the header, compare insensitively
|
@@ -393,8 +442,6 @@ module GitHubPages
|
|
393
442
|
def https_eligible?
|
394
443
|
# Can't have any IP's which aren't GitHub's present.
|
395
444
|
return false if non_github_pages_ip_present?
|
396
|
-
# Can't have any AAAA records present
|
397
|
-
return false if aaaa_record_present?
|
398
445
|
# Must be a CNAME or point to our IPs.
|
399
446
|
|
400
447
|
# Only check the one domain if a CNAME. Don't check the parent domain.
|
@@ -406,13 +453,17 @@ module GitHubPages
|
|
406
453
|
|
407
454
|
# Any errors querying CAA records
|
408
455
|
def caa_error
|
409
|
-
return nil unless caa
|
456
|
+
return nil unless caa&.errored?
|
410
457
|
|
411
458
|
caa.error.class.name
|
412
459
|
end
|
413
460
|
|
414
461
|
private
|
415
462
|
|
463
|
+
def address_record?
|
464
|
+
a_record? || aaaa_record?
|
465
|
+
end
|
466
|
+
|
416
467
|
def caa
|
417
468
|
@caa ||= GitHubPages::HealthCheck::CAA.new(
|
418
469
|
:host => cname&.host || host,
|
@@ -487,10 +538,12 @@ module GitHubPages
|
|
487
538
|
def cdn_ip?(cdn)
|
488
539
|
return unless dns?
|
489
540
|
|
490
|
-
|
491
|
-
|
541
|
+
address_records = dns.select do |answer|
|
542
|
+
Dnsruby::Types::A == answer.type || Dnsruby::Types::AAAA == answer.type
|
543
|
+
end
|
544
|
+
return false if !address_records || address_records.empty?
|
492
545
|
|
493
|
-
|
546
|
+
address_records.all? do |answer|
|
494
547
|
cdn.controls_ip?(answer.address)
|
495
548
|
end
|
496
549
|
end
|
@@ -500,7 +553,7 @@ module GitHubPages
|
|
500
553
|
end
|
501
554
|
|
502
555
|
def github_pages_ip?(ip_addr)
|
503
|
-
|
556
|
+
CURRENT_IP_ADDRESSES_ALL.include?(ip_addr&.to_s&.downcase)
|
504
557
|
end
|
505
558
|
end
|
506
559
|
end
|
data/script/check
CHANGED
data/script/update-cdn-ips
CHANGED
@@ -8,15 +8,43 @@ require "open-uri"
|
|
8
8
|
require "json"
|
9
9
|
|
10
10
|
SOURCES = {
|
11
|
-
:cloudflare => "https://www.cloudflare.com/ips-v4",
|
12
|
-
:fastly => "https://api.fastly.com/public-ip-list"
|
11
|
+
:cloudflare => ["https://www.cloudflare.com/ips-v4", "https://www.cloudflare.com/ips-v6"],
|
12
|
+
:fastly => ["https://api.fastly.com/public-ip-list"]
|
13
13
|
}.freeze
|
14
14
|
|
15
|
-
|
15
|
+
def parse_fastly(data)
|
16
|
+
json_data = JSON.parse(data)
|
17
|
+
(json_data["addresses"] + json_data["ipv6_addresses"]).join("\n")
|
18
|
+
end
|
19
|
+
|
20
|
+
def parse_cloudflare(data)
|
21
|
+
data
|
22
|
+
end
|
23
|
+
|
24
|
+
def fetch_ips_from_cdn(urls)
|
25
|
+
urls.map do |url|
|
26
|
+
puts "Fetching #{url}..."
|
27
|
+
URI.parse(url).open.read
|
28
|
+
end.join("\n")
|
29
|
+
end
|
30
|
+
|
31
|
+
def update_cdn_file(source, data)
|
16
32
|
file = "config/#{source}-ips.txt"
|
17
|
-
puts "Fetching #{url}..."
|
18
|
-
data = open(url).read
|
19
|
-
data = JSON.parse(data)["addresses"].join("\n") if source == :fastly
|
20
33
|
File.write(file, data)
|
34
|
+
puts "Writing contents to #{file} and staging changes."
|
21
35
|
`git add --verbose #{file}`
|
22
36
|
end
|
37
|
+
|
38
|
+
def parse_cdn_response(source, ips)
|
39
|
+
send("parse_#{source}", ips)
|
40
|
+
end
|
41
|
+
|
42
|
+
def update_cdn_ips(source, urls)
|
43
|
+
ips = fetch_ips_from_cdn(urls)
|
44
|
+
data = parse_cdn_response(source, ips)
|
45
|
+
update_cdn_file(source, data)
|
46
|
+
end
|
47
|
+
|
48
|
+
SOURCES.each do |source, urls|
|
49
|
+
update_cdn_ips(source, urls)
|
50
|
+
end
|
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.17.
|
4
|
+
version: 1.17.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: '3.0'
|
62
62
|
- - "<"
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '5.0'
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
requirements:
|
69
69
|
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version:
|
71
|
+
version: '3.0'
|
72
72
|
- - "<"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '5.0'
|
@@ -99,7 +99,6 @@ files:
|
|
99
99
|
- ".rspec"
|
100
100
|
- ".rubocop.yml"
|
101
101
|
- ".ruby-version"
|
102
|
-
- ".travis.yml"
|
103
102
|
- Dockerfile
|
104
103
|
- Gemfile
|
105
104
|
- LICENSE.md
|
@@ -161,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
160
|
- !ruby/object:Gem::Version
|
162
161
|
version: '0'
|
163
162
|
requirements: []
|
164
|
-
rubygems_version: 3.
|
163
|
+
rubygems_version: 3.2.9
|
165
164
|
signing_key:
|
166
165
|
specification_version: 4
|
167
166
|
summary: Checks your GitHub Pages site for commons DNS configuration issues
|