1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/spec/ruby/security/cve_2018_6914_spec.rb
normal 9366d7092f spec/ruby/security/cve_2018_6914_spec.rb: get rid of leftover files
I ran out of inodes in $TMPDIR :<

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-11 08:33:32 +00:00

56 lines
1.6 KiB
Ruby

require_relative '../spec_helper'
require 'tempfile'
describe "CVE-2018-6914 is resisted by" do
before :all do
@traversal_path = Array.new(Dir.pwd.split('/').count, '..').join('/') + Dir.pwd + '/'
@traversal_path.delete!(':') if /mswin|mingw/ =~ RUBY_PLATFORM
end
it "Tempfile.open by deleting separators" do
begin
expect = Dir.glob(@traversal_path + '*').count
t = Tempfile.open([@traversal_path, 'foo'])
actual = Dir.glob(@traversal_path + '*').count
actual.should == expect
ensure
t.close!
end
end
it "Tempfile.new by deleting separators" do
begin
expect = Dir.glob(@traversal_path + '*').count
t = Tempfile.new(@traversal_path + 'foo')
actual = Dir.glob(@traversal_path + '*').count
actual.should == expect
ensure
t.close!
end
end
it "Tempfile.create by deleting separators" do
expect = Dir.glob(@traversal_path + '*').count
Tempfile.create(@traversal_path + 'foo') do
actual = Dir.glob(@traversal_path + '*').count
actual.should == expect
end
end
it "Dir.mktmpdir by deleting separators" do
expect = Dir.glob(@traversal_path + '*').count
Dir.mktmpdir(@traversal_path + 'foo') do
actual = Dir.glob(@traversal_path + '*').count
actual.should == expect
end
end
it "Dir.mktmpdir with an array by deleting separators" do
expect = Dir.glob(@traversal_path + '*').count
Dir.mktmpdir([@traversal_path, 'foo']) do
actual = Dir.glob(@traversal_path + '*').count
actual.should == expect
end
end
end