<commit_before>module Spree::PayoneFrontend
  class StatusCheck
    def initialize request
      @request = request
    end

    def valid_request?
      if @request.post? and valid_ip?
        true
      else
        false
      end
    end

    private

    def valid_ip?
      ip = @request.ip.to_s
      if ip =~ /^192.168.127.12$/ or
         ip =~ /^213.178.72.197$/ or
         ip =~ /^217.70.200.[0-9]$/ or
         ip =~ /^217.70.200.[1-9][0-9]$/ or
         ip =~ /^217.70.200.[1-2][0-4][0-9]$/ or
         ip =~ /^217.70.200.[1-2]5[0-5]$/ or
         ip =~ /^185.60.20.[0-9]$/ or
         ip =~ /^185.60.20.[1-9][0-9]$/ or
         ip =~ /^185.60.20.[1-2][0-4][0-9]$/ or
         ip =~ /^185.60.20.[1-2]5[0-5]$/

        true
      else
        false
      end
    end

  end
end<commit_msg>Better check for IP address ranges.<commit_after>module Spree::PayoneFrontend
  class StatusCheck
    def initialize request
      @request = request
    end

    def valid_request?
      if @request.post? and valid_ip?
        true
      else
        false
      end
    end

    private

    def valid_ip?
      [
        '192.168.127.12/31',
        '172.16.31.10/24',
        '192.168.3.11/24'
      ].any? do |address_block|
        IPAddr.new(address_block) === request.remote_ip
      end
    end

  end
end
{'fraction_non_alphanumeric': 0.1534954407294833, 'fraction_numerical': 0.11474164133738601, 'mean_word_length': 1.4943181818181819, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 5, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1999014', 'n_tokens_mistral': 581, 'n_tokens_neox': 498, 'n_words': 103}