mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
da7976235f
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
60 lines
1.6 KiB
Ruby
60 lines
1.6 KiB
Ruby
require_relative '../spec_helper'
|
|
|
|
require 'tempfile'
|
|
require 'tmpdir'
|
|
|
|
describe "CVE-2018-6914 is resisted by" do
|
|
before :each do
|
|
@dir = tmp("CVE-2018-6914")
|
|
Dir.mkdir(@dir)
|
|
touch "#{@dir}/bar"
|
|
|
|
@traversal_path = Array.new(@dir.count('/'), '..').join('/') + @dir + '/'
|
|
@traversal_path.delete!(':') if platform_is(:windows)
|
|
|
|
@tempfile = nil
|
|
end
|
|
|
|
after :each do
|
|
@tempfile.close! if @tempfile
|
|
rm_r @dir
|
|
end
|
|
|
|
it "Tempfile.open by deleting separators" do
|
|
expect = Dir.glob(@traversal_path + '*').size
|
|
@tempfile = Tempfile.open([@traversal_path, 'foo'])
|
|
actual = Dir.glob(@traversal_path + '*').size
|
|
actual.should == expect
|
|
end
|
|
|
|
it "Tempfile.new by deleting separators" do
|
|
expect = Dir.glob(@traversal_path + '*').size
|
|
@tempfile = Tempfile.new(@traversal_path + 'foo')
|
|
actual = Dir.glob(@traversal_path + '*').size
|
|
actual.should == expect
|
|
end
|
|
|
|
it "Tempfile.create by deleting separators" do
|
|
expect = Dir.glob(@traversal_path + '*').size
|
|
Tempfile.create(@traversal_path + 'foo') do
|
|
actual = Dir.glob(@traversal_path + '*').size
|
|
actual.should == expect
|
|
end
|
|
end
|
|
|
|
it "Dir.mktmpdir by deleting separators" do
|
|
expect = Dir.glob(@traversal_path + '*').size
|
|
Dir.mktmpdir(@traversal_path + 'foo') do
|
|
actual = Dir.glob(@traversal_path + '*').size
|
|
actual.should == expect
|
|
end
|
|
end
|
|
|
|
it "Dir.mktmpdir with an array by deleting separators" do
|
|
expect = Dir.glob(@traversal_path + '*').size
|
|
Dir.mktmpdir([@traversal_path, 'foo']) do
|
|
actual = Dir.glob(@traversal_path + '*').size
|
|
actual.should == expect
|
|
end
|
|
end
|
|
end
|