Sha256: 6dd2df7f85b41a336829b6762aee9d324156b0e2bd9a0e6964a74ab0fd5c69dc

Contents?: true

Size: 956 Bytes

Versions: 65

Compression:

Stored size: 956 Bytes

Contents

require File.expand_path('../spec_helper.rb', __FILE__)

describe Rack::Protection::PathTraversal do
  it_behaves_like "any rack application"

  context 'escaping' do
    before do
      mock_app { |e| [200, {'Content-Type' => 'text/plain'}, [e['PATH_INFO']]] }
    end

    %w[/foo/bar /foo/bar/ / /.f /a.x].each do |path|
      it("does not touch #{path.inspect}") { get(path).body.should == path }
    end

    { # yes, this is ugly, feel free to change that
      '/..' => '/', '/a/../b' => '/b', '/a/../b/' => '/b/', '/a/.' => '/a/',
      '/%2e.' => '/', '/a/%2e%2e/b' => '/b', '/a%2f%2e%2e%2fb/' => '/b/',
      '//' => '/', '/%2fetc%2fpasswd' => '/etc/passwd'
    }.each do |a, b|
      it("replaces #{a.inspect} with #{b.inspect}") { get(a).body.should == b }
    end

    it 'should be able to deal with PATH_INFO = nil (fcgi?)' do
      app = Rack::Protection::PathTraversal.new(proc { 42 })
      app.call({}).should be == 42
    end
  end
end

Version data entries

65 entries across 63 versions & 5 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/rack-protection-1.2.0/spec/path_traversal_spec.rb
classiccms-0.7.4 vendor/bundle/gems/rack-protection-1.2.0/spec/path_traversal_spec.rb
classiccms-0.7.3 vendor/bundle/gems/rack-protection-1.2.0/spec/path_traversal_spec.rb
torquebox-console-0.3.0 vendor/bundle/jruby/1.9/gems/rack-protection-1.4.0/spec/path_traversal_spec.rb
classiccms-0.7.2 vendor/bundle/gems/rack-protection-1.2.0/spec/path_traversal_spec.rb
classiccms-0.7.1 vendor/bundle/gems/rack-protection-1.2.0/spec/path_traversal_spec.rb
classiccms-0.7.0 vendor/bundle/gems/rack-protection-1.2.0/spec/path_traversal_spec.rb
torquebox-console-0.2.5 vendor/bundle/jruby/1.9/gems/rack-protection-1.4.0/spec/path_traversal_spec.rb
torquebox-console-0.2.5 vendor/bundle/ruby/1.8/gems/rack-protection-1.4.0/spec/path_traversal_spec.rb
rack-protection-1.5.0 spec/path_traversal_spec.rb
torquebox-console-0.2.4 vendor/bundle/ruby/1.8/gems/rack-protection-1.4.0/spec/path_traversal_spec.rb
torquebox-console-0.2.4 vendor/bundle/jruby/1.9/gems/rack-protection-1.4.0/spec/path_traversal_spec.rb
torquebox-console-0.2.3 vendor/bundle/jruby/1.9/gems/rack-protection-1.4.0/spec/path_traversal_spec.rb
rack-protection-1.4.0 spec/path_traversal_spec.rb
classiccms-0.6.9 vendor/bundle/gems/rack-protection-1.2.0/spec/path_traversal_spec.rb
rack-protection-1.3.2 spec/path_traversal_spec.rb
rack-protection-1.3.1 spec/path_traversal_spec.rb
classiccms-0.6.8 vendor/bundle/gems/rack-protection-1.2.0/spec/path_traversal_spec.rb
classiccms-0.6.7 vendor/bundle/gems/rack-protection-1.2.0/spec/path_traversal_spec.rb
classiccms-0.6.6 vendor/bundle/gems/rack-protection-1.2.0/spec/path_traversal_spec.rb