github-pages-health-check 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/config/fastly-ips.txt +14 -0
- data/lib/github-pages-health-check.rb +3 -1
- data/lib/github-pages-health-check/{cloudflare.rb → cdn.rb} +6 -5
- data/lib/github-pages-health-check/cdns/cloudflare.rb +8 -0
- data/lib/github-pages-health-check/cdns/fastly.rb +8 -0
- data/lib/github-pages-health-check/domain.rb +25 -11
- data/lib/github-pages-health-check/error.rb +4 -0
- data/lib/github-pages-health-check/version.rb +1 -1
- data/script/check-cdn-ips +20 -0
- data/script/cibuild +1 -1
- data/script/update-cdn-ips +20 -0
- metadata +9 -6
- data/script/check-cloudflare-ips +0 -17
- data/script/update-cloudflare-ips +0 -14
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 55c8b9311f05c9c89c57e74f4e47700964f97b16
         | 
| 4 | 
            +
              data.tar.gz: 7bf75965fb566b0bd9c6a5945cb073bea18a6fdc
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 611f792db12ab0f8ea674a4368c2300126340a0da1a2d4d6c0e8974ac07b498a0d488d01b1ecd193c314b473357836b25743daa6f538ffd71be3462aca7b2806
         | 
| 7 | 
            +
              data.tar.gz: af8a4e34b798af708a3df0cbe8dafaa5d49e7b987ba9e1ac846d1f215ce278f5f37d2f34c0e71dacfa22e5d8cf0366b8b3bd6675a87a9271c31d0a7a1c16fcb4
         | 
| @@ -19,7 +19,9 @@ end | |
| 19 19 | 
             
            module GitHubPages
         | 
| 20 20 | 
             
              module HealthCheck
         | 
| 21 21 |  | 
| 22 | 
            -
                autoload : | 
| 22 | 
            +
                autoload :CDN,        "github-pages-health-check/cdn"
         | 
| 23 | 
            +
                autoload :CloudFlare, "github-pages-health-check/cdns/cloudflare"
         | 
| 24 | 
            +
                autoload :Fastly,     "github-pages-health-check/cdns/fastly"
         | 
| 23 25 | 
             
                autoload :Error,      "github-pages-health-check/error"
         | 
| 24 26 | 
             
                autoload :Errors,     "github-pages-health-check/errors"
         | 
| 25 27 | 
             
                autoload :Checkable,  "github-pages-health-check/checkable"
         | 
| @@ -1,22 +1,23 @@ | |
| 1 1 | 
             
            module GitHubPages
         | 
| 2 2 | 
             
              module HealthCheck
         | 
| 3 | 
            -
                class  | 
| 3 | 
            +
                class CDN
         | 
| 4 4 | 
             
                  include Singleton
         | 
| 5 5 |  | 
| 6 6 | 
             
                  # Internal: The path of the config file.
         | 
| 7 | 
            -
                  attr_reader :path
         | 
| 7 | 
            +
                  attr_reader :name, :path
         | 
| 8 8 |  | 
| 9 9 | 
             
                  # Public: Does cloudflare control this address?
         | 
| 10 10 | 
             
                  def self.controls_ip?(address)
         | 
| 11 11 | 
             
                    instance.controls_ip?(address)
         | 
| 12 12 | 
             
                  end
         | 
| 13 13 |  | 
| 14 | 
            -
                  # Internal: Create a new  | 
| 14 | 
            +
                  # Internal: Create a new CDN info instance.
         | 
| 15 15 | 
             
                  def initialize(options = {})
         | 
| 16 | 
            +
                    @name = options.fetch(:name) { self.class.name.split("::").last.downcase }
         | 
| 16 17 | 
             
                    @path = options.fetch(:path) { default_config_path }
         | 
| 17 18 | 
             
                  end
         | 
| 18 19 |  | 
| 19 | 
            -
                  # Internal: Does  | 
| 20 | 
            +
                  # Internal: Does this CDN control this address?
         | 
| 20 21 | 
             
                  def controls_ip?(address)
         | 
| 21 22 | 
             
                    ranges.any? { |range| range.include?(address) }
         | 
| 22 23 | 
             
                  end
         | 
| @@ -34,7 +35,7 @@ module GitHubPages | |
| 34 35 | 
             
                  end
         | 
| 35 36 |  | 
| 36 37 | 
             
                  def default_config_path
         | 
| 37 | 
            -
                    File.expand_path("../../config | 
| 38 | 
            +
                    File.expand_path("../../config/#{name}-ips.txt", File.dirname(__FILE__))
         | 
| 38 39 | 
             
                  end
         | 
| 39 40 | 
             
                end
         | 
| 40 41 | 
             
              end
         | 
| @@ -4,10 +4,14 @@ module GitHubPages | |
| 4 4 |  | 
| 5 5 | 
             
                  attr_reader :host
         | 
| 6 6 |  | 
| 7 | 
            -
                  LEGACY_IP_ADDRESSES =  | 
| 8 | 
            -
                     | 
| 9 | 
            -
                     | 
| 10 | 
            -
                     | 
| 7 | 
            +
                  LEGACY_IP_ADDRESSES = [
         | 
| 8 | 
            +
                    # Legacy GitHub Datacenter
         | 
| 9 | 
            +
                    "207.97.227.245",
         | 
| 10 | 
            +
                    "204.232.175.78",
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                    # Legacy Fastly Datacenter
         | 
| 13 | 
            +
                    "199.27.73.133",
         | 
| 14 | 
            +
                    "199.27.76.133"
         | 
| 11 15 | 
             
                  ].freeze
         | 
| 12 16 |  | 
| 13 17 | 
             
                  CURRENT_IP_ADDRESSES = %w[
         | 
| @@ -16,7 +20,7 @@ module GitHubPages | |
| 16 20 | 
             
                  ].freeze
         | 
| 17 21 |  | 
| 18 22 | 
             
                  HASH_METHODS = [
         | 
| 19 | 
            -
                    :host, :uri, :dns_resolves?, :proxied?, :cloudflare_ip?,
         | 
| 23 | 
            +
                    :host, :uri, :dns_resolves?, :proxied?, :cloudflare_ip?, :fastly_ip?,
         | 
| 20 24 | 
             
                    :old_ip_address?, :a_record?, :cname_record?, :valid_domain?,
         | 
| 21 25 | 
             
                    :apex_domain?, :should_be_a_record?, :cname_to_github_user_domain?,
         | 
| 22 26 | 
             
                    :cname_to_pages_dot_github_dot_com?, :cname_to_fastly?,
         | 
| @@ -36,8 +40,8 @@ module GitHubPages | |
| 36 40 | 
             
                  def check!
         | 
| 37 41 | 
             
                    raise Errors::InvalidDomainError.new(domain: self) unless valid_domain?
         | 
| 38 42 | 
             
                    raise Errors::InvalidDNSError.new(domain: self)    unless dns_resolves?
         | 
| 39 | 
            -
                    return true if proxied?
         | 
| 40 43 | 
             
                    raise Errors::DeprecatedIPError.new(domain: self)      if deprecated_ip?
         | 
| 44 | 
            +
                    return true if proxied?
         | 
| 41 45 | 
             
                    raise Errors::InvalidARecordError.new(domain: self)    if invalid_a_record?
         | 
| 42 46 | 
             
                    raise Errors::InvalidCNAMEError.new(domain: self)      if invalid_cname?
         | 
| 43 47 | 
             
                    raise Errors::NotServedByPagesError.new(domain: self)  unless served_by_pages?
         | 
| @@ -138,10 +142,12 @@ module GitHubPages | |
| 138 142 |  | 
| 139 143 | 
             
                  # Does the domain resolve to a CloudFlare-owned IP
         | 
| 140 144 | 
             
                  def cloudflare_ip?
         | 
| 141 | 
            -
                     | 
| 142 | 
            -
             | 
| 143 | 
            -
             | 
| 144 | 
            -
             | 
| 145 | 
            +
                    cdn_ip?(CloudFlare)
         | 
| 146 | 
            +
                  end
         | 
| 147 | 
            +
             | 
| 148 | 
            +
                  # Does the domain resolve to a Fastly-owned IP
         | 
| 149 | 
            +
                  def fastly_ip?
         | 
| 150 | 
            +
                    cdn_ip?(Fastly)
         | 
| 145 151 | 
             
                  end
         | 
| 146 152 |  | 
| 147 153 | 
             
                  # Does this non-GitHub-pages domain proxy a GitHub Pages site?
         | 
| @@ -154,7 +160,7 @@ module GitHubPages | |
| 154 160 | 
             
                    return unless dns?
         | 
| 155 161 | 
             
                    return true if cloudflare_ip?
         | 
| 156 162 | 
             
                    return false if pointed_to_github_pages_ip? || cname_to_github_user_domain?
         | 
| 157 | 
            -
                    return false if cname_to_pages_dot_github_dot_com? || cname_to_fastly?
         | 
| 163 | 
            +
                    return false if cname_to_pages_dot_github_dot_com? || cname_to_fastly? || fastly_ip?
         | 
| 158 164 | 
             
                    served_by_pages?
         | 
| 159 165 | 
             
                  end
         | 
| 160 166 |  | 
| @@ -268,6 +274,14 @@ module GitHubPages | |
| 268 274 | 
             
                  def scheme
         | 
| 269 275 | 
             
                    @scheme ||= github_domain? ? "https" : "http"
         | 
| 270 276 | 
             
                  end
         | 
| 277 | 
            +
             | 
| 278 | 
            +
                  # Does the domain resolve to a CDN-owned IP
         | 
| 279 | 
            +
                  def cdn_ip?(cdn)
         | 
| 280 | 
            +
                    return unless dns?
         | 
| 281 | 
            +
                    dns.all? do |answer|
         | 
| 282 | 
            +
                      answer.class == Net::DNS::RR::A && cdn.controls_ip?(answer.address)
         | 
| 283 | 
            +
                    end
         | 
| 284 | 
            +
                  end
         | 
| 271 285 | 
             
                end
         | 
| 272 286 | 
             
              end
         | 
| 273 287 | 
             
            end
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            #!/bin/bash -e
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            script/update-cdn-ips >/dev/null 2>&1
         | 
| 4 | 
            +
            files=( cloudflare fastly)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            # `git diff --quiet` suppresses output and sets a return code
         | 
| 7 | 
            +
            # 0 - no changes
         | 
| 8 | 
            +
            # 1 - changes
         | 
| 9 | 
            +
            for file in "${files[@]}"
         | 
| 10 | 
            +
            do
         | 
| 11 | 
            +
              if git diff -w --quiet --cached "config/$file-ips.txt"
         | 
| 12 | 
            +
              then
         | 
| 13 | 
            +
                echo "$file IP list is up-to-date."
         | 
| 14 | 
            +
              else
         | 
| 15 | 
            +
                echo git reset "config/$file-ips.txt"
         | 
| 16 | 
            +
                git reset --quiet "config/$file-ips.txt"
         | 
| 17 | 
            +
                echo "*** $file IP list is out of date! Run script/update-cdn-ips!"
         | 
| 18 | 
            +
                exit 1
         | 
| 19 | 
            +
              fi
         | 
| 20 | 
            +
            done
         | 
    
        data/script/cibuild
    CHANGED
    
    
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            #/ Usage script/update-ips
         | 
| 3 | 
            +
            #/ updates config/cloudflare-ips.txt and config/fastly-ips.txt
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            require 'open-uri'
         | 
| 6 | 
            +
            require 'json'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            SOURCES = {
         | 
| 9 | 
            +
              cloudflare: "https://www.cloudflare.com/ips-v4",
         | 
| 10 | 
            +
              fastly: "https://api.fastly.com/public-ip-list"
         | 
| 11 | 
            +
            }
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            SOURCES.each do |source, url|
         | 
| 14 | 
            +
              file = "config/#{source}-ips.txt"
         | 
| 15 | 
            +
              puts "Fetching #{url}..."
         | 
| 16 | 
            +
              data = open(url).read
         | 
| 17 | 
            +
              data = JSON.parse(data)["addresses"].join("\n") if source == :fastly
         | 
| 18 | 
            +
              File.write(file, data)
         | 
| 19 | 
            +
              `git add --verbose #{file}`
         | 
| 20 | 
            +
            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. | 
| 4 | 
            +
              version: 1.2.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-08-09 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: net-dns
         | 
| @@ -164,10 +164,13 @@ files: | |
| 164 164 | 
             
            - LICENSE.md
         | 
| 165 165 | 
             
            - README.md
         | 
| 166 166 | 
             
            - config/cloudflare-ips.txt
         | 
| 167 | 
            +
            - config/fastly-ips.txt
         | 
| 167 168 | 
             
            - github-pages-health-check.gemspec
         | 
| 168 169 | 
             
            - lib/github-pages-health-check.rb
         | 
| 170 | 
            +
            - lib/github-pages-health-check/cdn.rb
         | 
| 171 | 
            +
            - lib/github-pages-health-check/cdns/cloudflare.rb
         | 
| 172 | 
            +
            - lib/github-pages-health-check/cdns/fastly.rb
         | 
| 169 173 | 
             
            - lib/github-pages-health-check/checkable.rb
         | 
| 170 | 
            -
            - lib/github-pages-health-check/cloudflare.rb
         | 
| 171 174 | 
             
            - lib/github-pages-health-check/domain.rb
         | 
| 172 175 | 
             
            - lib/github-pages-health-check/error.rb
         | 
| 173 176 | 
             
            - lib/github-pages-health-check/errors.rb
         | 
| @@ -186,12 +189,12 @@ files: | |
| 186 189 | 
             
            - lib/github-pages-health-check/version.rb
         | 
| 187 190 | 
             
            - script/bootstrap
         | 
| 188 191 | 
             
            - script/check
         | 
| 189 | 
            -
            - script/check- | 
| 192 | 
            +
            - script/check-cdn-ips
         | 
| 190 193 | 
             
            - script/cibuild
         | 
| 191 194 | 
             
            - script/console
         | 
| 192 195 | 
             
            - script/release
         | 
| 193 196 | 
             
            - script/test
         | 
| 194 | 
            -
            - script/update- | 
| 197 | 
            +
            - script/update-cdn-ips
         | 
| 195 198 | 
             
            homepage: https://github.com/github/github-pages-health-check
         | 
| 196 199 | 
             
            licenses:
         | 
| 197 200 | 
             
            - MIT
         | 
| @@ -212,7 +215,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 212 215 | 
             
                  version: '0'
         | 
| 213 216 | 
             
            requirements: []
         | 
| 214 217 | 
             
            rubyforge_project: 
         | 
| 215 | 
            -
            rubygems_version: 2. | 
| 218 | 
            +
            rubygems_version: 2.2.5
         | 
| 216 219 | 
             
            signing_key: 
         | 
| 217 220 | 
             
            specification_version: 4
         | 
| 218 221 | 
             
            summary: Checks your GitHub Pages site for commons DNS configuration issues
         | 
    
        data/script/check-cloudflare-ips
    DELETED
    
    | @@ -1,17 +0,0 @@ | |
| 1 | 
            -
            #!/bin/bash -e
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            script/update-cloudflare-ips >/dev/null 2>&1
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            # `git diff --quiet` suppresses output and sets a return code
         | 
| 6 | 
            -
            # 0 - no changes
         | 
| 7 | 
            -
            # 1 - changes
         | 
| 8 | 
            -
            if git diff -w --quiet --cached config/cloudflare-ips.txt
         | 
| 9 | 
            -
            then
         | 
| 10 | 
            -
              echo CloudFlare IP list is up-to-date.
         | 
| 11 | 
            -
              exit 0
         | 
| 12 | 
            -
            else
         | 
| 13 | 
            -
              echo git reset config/cloudflare-ips.txt
         | 
| 14 | 
            -
              git reset --quiet config/cloudflare-ips.txt
         | 
| 15 | 
            -
              echo '*** CloudFlare IP list is out of date! Run script/update-cloudflare-ips!'
         | 
| 16 | 
            -
              exit 1
         | 
| 17 | 
            -
            fi
         | 
| @@ -1,14 +0,0 @@ | |
| 1 | 
            -
            #!/bin/bash -e
         | 
| 2 | 
            -
            #/ Usage script/update-cloudflare-ips
         | 
| 3 | 
            -
            #/ updates config/cloudflare-ips.txt
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            source=https://www.cloudflare.com/ips-v4
         | 
| 6 | 
            -
            dest=config/cloudflare-ips.txt
         | 
| 7 | 
            -
             | 
| 8 | 
            -
            echo '====>' Downloading $source
         | 
| 9 | 
            -
            curl --silent --fail $source | tee $dest
         | 
| 10 | 
            -
            echo # cover for a missing newline
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            echo '====>' git add $dest
         | 
| 13 | 
            -
            git diff -w $dest
         | 
| 14 | 
            -
            git add --verbose $dest
         |