def run_rules(url, rules)
      str = url.to_s
      return str if rules.nil?
      rules.each do |rule|
        case rule
        when 'noproto'
          str = str.gsub(%r{^https?://}, '')
        when 'nossl', 'http'
          str = str.gsub(%r{^https://}, 'http://')
        when 'ssl', 'https'
          str = str.gsub(%r{^http://}, 'https://')
        when 'base32'
          str = Base32.encode(str).to_s
        when 'base64'
          str = Base64.encode64(str).delete("\n")
        when 'md4'
          str = OpenSSL::Digest::MD4.hexdigest(str)
        when 'md5'
          md5 = Digest::MD5.new
          md5.update str
          str = md5.hexdigest
        when 'sha1'
          str = Digest::SHA1.hexdigest(str)
        when 'reverse'
          str = str.reverse
        when 'upcase'
          str = str.upcase
        when 'downcase'
          str = str.downcase
        when 'rot13'
          str = str.tr('A-Za-z', 'N-ZA-Mn-za-m')
        when 'urlencode'
          str = CGI.escape(str).gsub(/\+/, '%20')
        when 'urldecode'
          str = CGI.unescape(str)
        when 'append-hash'
          str = "#{str}##{rand(36**6).to_s(36)}"
        when 'append-method-get'
          separator = str.include?('?') ? '&' : '?'
          str = "#{str}#{separator}method=get&_method=get"
        else
          logger.warn("Unknown rule: #{rule}")
        end
      end
      str
    end
def run_rules(url, rules)
      str = url.to_s
      return str if rules.nil?
      rules.each do |rule|
        case rule
        when 'noproto'
          str = str.gsub(%r{^https?://}, '')
        when 'nossl', 'http'
          str = str.gsub(%r{^https://}, 'http://')
        when 'ssl', 'https'
          str = str.gsub(%r{^http://}, 'https://')
        when 'base32'
          str = Base32.encode(str).to_s
        when 'base64'
          str = Base64.encode64(str).delete("\n")
        when 'md4'
          str = OpenSSL::Digest::MD4.hexdigest(str)
        when 'md5'
          md5 = Digest::MD5.new
          md5.update str
          str = md5.hexdigest
        when 'sha1'
          str = Digest::SHA1.hexdigest(str)
        when 'reverse'
          str = str.reverse
        when 'upcase'
          str = str.upcase
        when 'downcase'
          str = str.downcase
        when 'rot13'
          str = str.tr('A-Za-z', 'N-ZA-Mn-za-m')
        when 'urlencode'
          str = CGI.escape(str).gsub(/\+/, '%20')
        when 'urldecode'
          str = CGI.unescape(str)
        when 'append-hash'
          str = "#{str}##{rand(36**6).to_s(36)}"
        when 'append-method-get'
          separator = str.include?('?') ? '&' : '?'
          str = "#{str}#{separator}method=get&_method=get"
        else
          logger.warn("Unknown rule: #{rule}")
        end
      end
      str
    end
Run a specified URL through SSRF rules

 @param [String] url request URL
 @param [String] rules comma separated list of rules

 @return [String] modified request URL