Skip to content

Commit

Permalink
Skip tests that fail due to Ruby bug 14060 on Ruby 2.4.4.
Browse files Browse the repository at this point in the history
On Ruby 2.4.4 in safe mode, require will fail with a SecurityError for
any file that has not previously been loaded, regardless of whether the
file name is tainted.

See https://bugs.ruby-lang.org/issues/14060#note-5

Failing test job:
https://travis-ci.org/tzinfo/tzinfo/jobs/422745006

(cherry picked from commit ed162f3)
  • Loading branch information
philr committed Aug 30, 2018
1 parent 6f07fa5 commit 7a660fc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/tc_ruby_data_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def test_load_timezone_info_minus
end

def test_load_timezone_info_tainted
skip_if_has_bug_14060

safe_test do
identifier = 'Europe/Amsterdam'.dup.taint
assert(identifier.tainted?)
Expand All @@ -65,6 +67,8 @@ def test_load_timezone_info_tainted
end

def test_load_timezone_info_tainted_and_frozen
skip_if_has_bug_14060

safe_test do
info = @data_source.load_timezone_info('Europe/Amsterdam'.dup.taint.freeze)
assert_equal('Europe/Amsterdam', info.identifier)
Expand Down
4 changes: 4 additions & 0 deletions test/tc_timezone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ def test_get_tainted_and_frozen_loaded
end

def test_get_tainted_not_previously_loaded
skip_if_has_bug_14060

safe_test do
identifier = 'Europe/Andorra'.dup.taint
assert(identifier.tainted?)
Expand All @@ -271,6 +273,8 @@ def test_get_tainted_not_previously_loaded
end

def test_get_tainted_and_frozen_not_previously_loaded
skip_if_has_bug_14060

safe_test do
tz = Timezone.get('Europe/Amsterdam'.dup.taint.freeze)
assert_equal('Europe/Amsterdam', tz.identifier)
Expand Down
10 changes: 10 additions & 0 deletions test/test_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ def safe_test(options = {})
thread.join
end
end

def skip_if_has_bug_14060
# On Ruby 2.4.4 in safe mode, require will fail with a SecurityError for
# any file that has not previously been loaded, regardless of whether the
# file name is tainted.
# See https://bugs.ruby-lang.org/issues/14060#note-5.
if RUBY_ENGINE == 'ruby' && RUBY_VERSION == '2.4.4'
skip('Skipping test due to Ruby 2.4.4 being affected by Bug 14060 (see https://bugs.ruby-lang.org/issues/14060#note-5)')
end
end

def assert_array_same_items(expected, actual, msg = nil)
full_message = message(msg, '') { diff(expected, actual) }
Expand Down

0 comments on commit 7a660fc

Please sign in to comment.