tzinfo 1.2.8 → 1.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9569ae7387d4f2847ba35f6a1268fbbc9019f9bbef1cc72e70569757320db079
4
- data.tar.gz: bb66169c01610b980c35be5c7102d780d07167b785acd6ea5887b89d15eb107d
3
+ metadata.gz: e6364432a0aef34ccf3b6b1ecad65dd6f7f13843ac503cbcea1f693b74c96b46
4
+ data.tar.gz: 825fd6905101f51fa700dfa682490851952de8a692c03954d12f38944f8814c8
5
5
  SHA512:
6
- metadata.gz: d9847f779c051d96c2457d364b18bdc9bc74e9b17ffd8e84106ce9c6562b2634e60f08b81af9fff6ba7c0af3b898ba4483fe8e9fa31b3e004251b203c1bee933
7
- data.tar.gz: 8737907d69e81c06650a1f01b1ba45afc83f38a66b44fca093431cfea65208a92f56ada755e9f87724a6b866ecbfed11d1ef09552bbf983ce47c15c90269a322
6
+ metadata.gz: ef4b1b6a189bbf011294210d2e0651f41bc82e1db8fe342c9f8dbcefd473e8b49b9affa67bc9a395a5831b376db8d37b5942cfade1dacf5485f23ce3d6f78a46
7
+ data.tar.gz: 2871fbd7aded391c88a74724138073675690710dfca6adbbbe610ec4395e8d6631fad93b22d684650d04d9affeed0ab64a1d7489f766eb9ab1996556329c6ddc
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,22 @@
1
+ Version 1.2.10 - 19-Jul-2022
2
+ ----------------------------
3
+
4
+ * Fixed a relative path traversal bug that could cause arbitrary files to be
5
+ loaded with require when used with RubyDataSource. Please refer to
6
+ https://github.com/tzinfo/tzinfo/security/advisories/GHSA-5cm2-9h8c-rvfx for
7
+ details. CVE-2022-31163.
8
+ * Ignore the SECURITY file from Arch Linux's tzdata package. #134.
9
+
10
+
11
+ Version 1.2.9 - 16-Dec-2020
12
+ ---------------------------
13
+
14
+ * Fixed an incorrect InvalidTimezoneIdentifier exception raised when loading a
15
+ zoneinfo file that includes rules specifying an additional transition to the
16
+ final defined offset (for example, Africa/Casablanca in version 2018e of the
17
+ Time Zone Database). #123.
18
+
19
+
1
20
  Version 1.2.8 - 8-Nov-2020
2
21
  --------------------------
3
22
 
@@ -5,7 +24,7 @@ Version 1.2.8 - 8-Nov-2020
5
24
  default by zic version 2020b and later. The POSIX-style TZ string is now used
6
25
  calculate DST transition times after the final defined transition in the file.
7
26
  The 64-bit section is now always used regardless of whether Time has support
8
- for 64-bit times.
27
+ for 64-bit times. #120.
9
28
  * Rubinius is no longer supported.
10
29
 
11
30
 
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2005-2020 Philip Ross
1
+ Copyright (c) 2005-2022 Philip Ross
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of
4
4
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  TZInfo - Ruby Timezone Library
2
2
  ==============================
3
3
 
4
- [![RubyGems](https://img.shields.io/gem/v/tzinfo)](https://rubygems.org/gems/tzinfo) [![Travis CI Build](https://img.shields.io/travis/com/tzinfo/tzinfo/1.2?logo=travis)](https://travis-ci.com/tzinfo/tzinfo) [![AppVeyor Build](https://img.shields.io/appveyor/build/philr/tzinfo/1.2?logo=appveyor)](https://ci.appveyor.com/project/philr/tzinfo/branch/1.2)
4
+ [![RubyGems](https://img.shields.io/gem/v/tzinfo?logo=rubygems&label=Gem)](https://rubygems.org/gems/tzinfo) [![Tests](https://github.com/tzinfo/tzinfo/workflows/Tests/badge.svg?branch=1.2&event=push)](https://github.com/tzinfo/tzinfo/actions?query=workflow%3ATests+branch%3A1.2+event%3Apush)
5
5
 
6
6
  [TZInfo](https://tzinfo.github.io) provides daylight savings aware
7
7
  transformations between times in different timezones.
@@ -38,7 +38,7 @@ module TZInfo
38
38
  # Raises InvalidTimezoneIdentifier if the timezone is not found or the
39
39
  # identifier is invalid.
40
40
  def load_timezone_info(identifier)
41
- raise InvalidTimezoneIdentifier, 'Invalid identifier' if identifier !~ /^[A-Za-z0-9\+\-_]+(\/[A-Za-z0-9\+\-_]+)*$/
41
+ raise InvalidTimezoneIdentifier, 'Invalid identifier' if identifier !~ /\A[A-Za-z0-9+\-_]+(\/[A-Za-z0-9+\-_]+)*\z/
42
42
 
43
43
  identifier = identifier.gsub(/-/, '__m__').gsub(/\+/, '__p__')
44
44
 
@@ -87,6 +87,29 @@ module TZInfo
87
87
  # The default value of ZoneinfoDataSource.alternate_iso3166_tab_search_path.
88
88
  DEFAULT_ALTERNATE_ISO3166_TAB_SEARCH_PATH = ['/usr/share/misc/iso3166.tab', '/usr/share/misc/iso3166'].freeze
89
89
 
90
+ # File and directories in the top level zoneinfo directory that will be
91
+ # excluded from the list of available time zones:
92
+ #
93
+ # - +VERSION is included on Mac OS X.
94
+ # - leapseconds is a list of leap seconds.
95
+ # - localtime is the current local timezone (may be a link).
96
+ # - posix, posixrules and right are directories containing other versions
97
+ # of the zoneinfo files.
98
+ # - SECURITY is included in the Arch Linux tzdata package.
99
+ # - src is a directory containing the tzdata source included on Solaris.
100
+ # - timeconfig is a symlink included on Slackware.
101
+ EXCLUDED_FILENAMES = [
102
+ '+VERSION',
103
+ 'leapseconds',
104
+ 'localtime',
105
+ 'posix',
106
+ 'posixrules',
107
+ 'right',
108
+ 'SECURITY',
109
+ 'src',
110
+ 'timeconfig'
111
+ ].freeze
112
+
90
113
  # Paths to be checked to find the system zoneinfo directory.
91
114
  @@search_path = DEFAULT_SEARCH_PATH.dup
92
115
 
@@ -352,16 +375,8 @@ module TZInfo
352
375
  # identifiers.
353
376
  def load_timezone_index
354
377
  index = []
355
-
356
- # Ignoring particular files:
357
- # +VERSION is included on Mac OS X.
358
- # leapseconds is a list of leap seconds.
359
- # localtime is the current local timezone (may be a link).
360
- # posix, posixrules and right are directories containing other versions of the zoneinfo files.
361
- # src is a directory containing the tzdata source included on Solaris.
362
- # timeconfig is a symlink included on Slackware.
363
-
364
- enum_timezones(nil, ['+VERSION', 'leapseconds', 'localtime', 'posix', 'posixrules', 'right', 'src', 'timeconfig']) do |identifier|
378
+
379
+ enum_timezones(nil, EXCLUDED_FILENAMES) do |identifier|
365
380
  index << identifier
366
381
  end
367
382
 
@@ -313,8 +313,13 @@ module TZInfo
313
313
  last_year = (Time.at(last_defined[:at]).utc + previous_offset[:utc_total_offset]).year
314
314
 
315
315
  if last_year <= GENERATE_UP_TO
316
- generated = rules.transitions(last_year).find_all {|t| t.at > last_defined[:at] } +
317
- (last_year + 1).upto(GENERATE_UP_TO).map {|y| rules.transitions(y) }.flatten
316
+ last_defined_offset = offsets[last_defined[:offset]]
317
+
318
+ generated = rules.transitions(last_year).find_all do |t|
319
+ t.at > last_defined[:at] && !offset_matches_rule?(last_defined_offset, t.offset)
320
+ end
321
+
322
+ generated += (last_year + 1).upto(GENERATE_UP_TO).map {|y| rules.transitions(y) }.flatten
318
323
 
319
324
  unless generated.empty?
320
325
  transitions[-1] = validate_and_fix_last_defined_transition_offset(file, offsets, last_defined, generated[0].previous_offset)
@@ -0,0 +1 @@
1
+ raise 'This should never be executed'
@@ -48,9 +48,15 @@ class TCRubyDataSource < Minitest::Test
48
48
 
49
49
  def test_load_timezone_info_invalid
50
50
  assert_raises(InvalidTimezoneIdentifier) do
51
- @data_source.load_timezone_info('../Definitions/UTC')
51
+ @data_source.load_timezone_info('../definitions/UTC')
52
52
  end
53
53
  end
54
+
55
+ def test_load_timezone_info_directory_traversal
56
+ test_data_depth = TZINFO_TEST_DATA_DIR.scan('/').size
57
+ payload_path = File.join(TESTS_DIR, 'assets', 'payload')
58
+ assert_raises(InvalidTimezoneIdentifier) { Timezone.get("foo\n#{'/..' * (test_data_depth + 4)}#{payload_path}") }
59
+ end
54
60
 
55
61
  def test_load_timezone_info_nil
56
62
  assert_raises(InvalidTimezoneIdentifier) do
data/test/tc_timezone.rb CHANGED
@@ -213,7 +213,7 @@ class TCTimezone < Minitest::Test
213
213
  end
214
214
 
215
215
  def test_get_invalid
216
- assert_raises(InvalidTimezoneIdentifier) { Timezone.get('../Definitions/UTC') }
216
+ assert_raises(InvalidTimezoneIdentifier) { Timezone.get('../definitions/UTC') }
217
217
  end
218
218
 
219
219
  def test_get_nil
@@ -374,7 +374,7 @@ class TCZoneinfoDataSource < Minitest::Test
374
374
 
375
375
  def test_load_timezone_info_invalid
376
376
  assert_raises(InvalidTimezoneIdentifier) do
377
- @data_source.load_timezone_info('../Definitions/Europe/London')
377
+ @data_source.load_timezone_info('../zoneinfo/Europe/London')
378
378
  end
379
379
  end
380
380
 
@@ -818,6 +818,25 @@ class TCZoneinfoDataSource < Minitest::Test
818
818
  end
819
819
  end
820
820
 
821
+ def test_timezone_identifiers_ignored_security_file
822
+ # The Arch linux tzdata package includes a file named SECURITY giving
823
+ # instructions for reporting security-related bugs.
824
+
825
+ Dir.mktmpdir('tzinfo_test') do |dir|
826
+ FileUtils.touch(File.join(dir, 'zone.tab'))
827
+ FileUtils.touch(File.join(dir, 'iso3166.tab'))
828
+ FileUtils.cp(File.join(@data_source.zoneinfo_dir, 'EST'), File.join(dir, 'EST'))
829
+
830
+ File.open(File.join(dir, 'SECURITY'), 'w') do |f|
831
+ f.binmode
832
+ f.write("Please report any sensitive security-related bugs...\n")
833
+ end
834
+
835
+ data_source = ZoneinfoDataSource.new(dir)
836
+ assert_equal(['EST'], data_source.timezone_identifiers)
837
+ end
838
+ end
839
+
821
840
  def test_load_country_info
822
841
  info = @data_source.load_country_info('GB')
823
842
  assert_equal('GB', info.code)
@@ -1895,7 +1895,18 @@ class TCZoneinfoTimezoneInfo < Minitest::Test
1895
1895
  end
1896
1896
  end
1897
1897
 
1898
- def test_load_tz_string_specifies_transition_to_offset_of_final_transition_same_year
1898
+ def test_load_tz_string_specifies_transition_to_offset_of_final_transition_same_year_skip_dst_start
1899
+ # TZInfo v1.2.8 considered this to be an error. However, this is a valid
1900
+ # situation with Africa/Casablanca in 2018e.
1901
+ #
1902
+ # The last defined transitions are:
1903
+ # At 2037-03-29 02:00Z change to WEST UTC+1
1904
+ # At 2037-10-04 02:00Z change to WET UTC+0
1905
+ #
1906
+ # The rules define the end of DST to be at 03:00 local time on the last
1907
+ # Sunday of October (2037-10-31). This later transition needs to be
1908
+ # ignored.
1909
+
1899
1910
  offsets = [
1900
1911
  {:gmtoff => 7142, :isdst => false, :abbrev => 'LMT'},
1901
1912
  {:gmtoff => 7200, :isdst => false, :abbrev => 'XST'},
@@ -1916,9 +1927,76 @@ class TCZoneinfoTimezoneInfo < Minitest::Test
1916
1927
  JulianDayOfYearTransitionRule.new(300, 7200)
1917
1928
  )
1918
1929
 
1930
+ generate_up_to = ZoneinfoTimezoneInfo::GENERATE_UP_TO
1931
+
1919
1932
  tzif_test(offsets, transitions, :rules => rules) do |path, format|
1920
- error = assert_raises(InvalidZoneinfoFile) { ZoneinfoTimezoneInfo.new('Invalid/Offset', path, @posix_tz_parser) }
1921
- assert_equal("The first offset indicated by the POSIX-style TZ string did not match the final defined offset in file '#{path}'.", error.message)
1933
+ info = ZoneinfoTimezoneInfo.new('Ignore/Std', path, @posix_tz_parser)
1934
+ assert_equal('Ignore/Std', info.identifier)
1935
+
1936
+ assert_period(:LMT, 7142, 0, false, nil, Time.utc(1971, 1, 2, 2, 0, 0) - 7142, info)
1937
+ assert_period(:XST, 7200, 0, false, Time.utc(1971, 1, 2, 2, 0, 0) - 7142, Time.utc(1981, 4, 10, 1, 0, 0) - 7200, info)
1938
+ assert_period(:XDT, 7200, 3600, true, Time.utc(1981, 4, 10, 1, 0, 0) - 7200, Time.utc(1981, 10, 27, 2, 0, 0) - 10800, info)
1939
+ assert_period(:XST, 7200, 0, false, Time.utc(1981, 10, 27, 2, 0, 0) - 10800, Time.utc(1982, 4, 10, 1, 0, 0) - 7200, info)
1940
+ assert_period(:XDT, 7200, 3600, true, Time.utc(1982, 4, 10, 1, 0, 0) - 7200, Time.utc(1982, 10, 27, 2, 0, 0) - 10800, info)
1941
+
1942
+ 1983.upto(generate_up_to).each do |year|
1943
+ assert_period(:XST, 7200, 0, false, Time.utc(year - 1, 10, 27, 2, 0, 0) - 10800, Time.utc(year, 4, 11, 1, 0, 0) - 7200, info)
1944
+ assert_period(:XDT, 7200, 3600, true, Time.utc(year, 4, 11, 1, 0, 0) - 7200, Time.utc(year, 10, 27, 2, 0, 0) - 10800, info)
1945
+ end
1946
+
1947
+ assert_period(:XST, 7200, 0, false, Time.utc(generate_up_to, 10, 27, 2, 0, 0) - 10800, nil, info)
1948
+ end
1949
+ end
1950
+
1951
+ def test_load_tz_string_specifies_transition_to_offset_of_final_transition_same_year_skip_dst_end
1952
+ # TZInfo v1.2.8 considered this to be an error. However, this is a valid
1953
+ # situation with Africa/Casablanca in 2018e.
1954
+ #
1955
+ # The last defined transitions are:
1956
+ # At 2037-03-29 02:00Z change to WEST UTC+1
1957
+ # At 2037-10-04 02:00Z change to WET UTC+0
1958
+ #
1959
+ # The rules define the end of DST to be at 03:00 local time on the last
1960
+ # Sunday of October (2037-10-31). This later transition needs to be
1961
+ # ignored.
1962
+
1963
+ offsets = [
1964
+ {:gmtoff => 7142, :isdst => false, :abbrev => 'LMT'},
1965
+ {:gmtoff => 7200, :isdst => false, :abbrev => 'XST'},
1966
+ {:gmtoff => 10800, :isdst => true, :abbrev => 'XDT'}
1967
+ ]
1968
+
1969
+ transitions = [
1970
+ {:at => Time.utc(1971, 1, 2, 2, 0, 0) - 7142, :offset_index => 1},
1971
+ {:at => Time.utc(1981, 4, 10, 1, 0, 0) - 7200, :offset_index => 2},
1972
+ {:at => Time.utc(1981, 10, 27, 2, 0, 0) - 10800, :offset_index => 1}
1973
+ ]
1974
+
1975
+ rules = AnnualRules.new(
1976
+ TimezoneOffset.new(7200, 0, 'XST'),
1977
+ TimezoneOffset.new(7200, 3600, 'XDT'),
1978
+ JulianDayOfYearTransitionRule.new(100, 3600),
1979
+ JulianDayOfYearTransitionRule.new(301, 7200)
1980
+ )
1981
+
1982
+ generate_up_to = ZoneinfoTimezoneInfo::GENERATE_UP_TO
1983
+
1984
+ tzif_test(offsets, transitions, :rules => rules) do |path, format|
1985
+ info = ZoneinfoTimezoneInfo.new('Ignore/Std', path, @posix_tz_parser)
1986
+ assert_equal('Ignore/Std', info.identifier)
1987
+
1988
+ assert_period(:LMT, 7142, 0, false, nil, Time.utc(1971, 1, 2, 2, 0, 0) - 7142, info)
1989
+ assert_period(:XST, 7200, 0, false, Time.utc(1971, 1, 2, 2, 0, 0) - 7142, Time.utc(1981, 4, 10, 1, 0, 0) - 7200, info)
1990
+ assert_period(:XDT, 7200, 3600, true, Time.utc(1981, 4, 10, 1, 0, 0) - 7200, Time.utc(1981, 10, 27, 2, 0, 0) - 10800, info)
1991
+ assert_period(:XST, 7200, 0, false, Time.utc(1981, 10, 27, 2, 0, 0) - 10800, Time.utc(1982, 4, 10, 1, 0, 0) - 7200, info)
1992
+
1993
+ 1982.upto(generate_up_to - 1).each do |year|
1994
+ assert_period(:XDT, 7200, 3600, true, Time.utc(year, 4, 10, 1, 0, 0) - 7200, Time.utc(year, 10, 28, 2, 0, 0) - 10800, info)
1995
+ assert_period(:XST, 7200, 0, false, Time.utc(year, 10, 28, 2, 0, 0) - 10800, Time.utc(year + 1, 4, 10, 1, 0, 0) - 7200, info)
1996
+ end
1997
+
1998
+ assert_period(:XDT, 7200, 3600, true, Time.utc(generate_up_to, 4, 10, 1, 0, 0) - 7200, Time.utc(generate_up_to, 10, 28, 2, 0, 0) - 10800, info)
1999
+ assert_period(:XST, 7200, 0, false, Time.utc(generate_up_to, 10, 28, 2, 0, 0) - 10800, nil, info)
1922
2000
  end
1923
2001
  end
1924
2002
 
data/test/test_utils.rb CHANGED
@@ -153,6 +153,22 @@ module Kernel
153
153
 
154
154
  actual_lines = process.readlines
155
155
  actual_lines = actual_lines.collect {|l| l.chomp}
156
+
157
+ # Ignore warnings from JRuby 1.7 and 9.0 on modern versions of Java:
158
+ # https://github.com/tzinfo/tzinfo/runs/1664655982#step:8:1893
159
+ #
160
+ # Ignore untaint deprecation warnings from Bundler 1 on Ruby 3.0.
161
+ actual_lines = actual_lines.reject do |l|
162
+ l.start_with?('unsupported Java version') ||
163
+ l.start_with?('WARNING: An illegal reflective access operation has occurred') ||
164
+ l.start_with?('WARNING: Illegal reflective access by') ||
165
+ l.start_with?('WARNING: Please consider reporting this to the maintainers of') ||
166
+ l.start_with?('WARNING: All illegal access operations will be denied in a future release') ||
167
+ l.start_with?('WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations') ||
168
+ l.start_with?('io/console on JRuby shells out to stty for most operations') ||
169
+ l =~ /\/bundler-1\..*\/lib\/bundler\/.*\.rb:\d+: warning: (Object|Pathname)#untaint is deprecated and will be removed in Ruby 3\.2\.\z/
170
+ end
171
+
156
172
  assert_equal(expected_lines, actual_lines)
157
173
  end
158
174
  end
data/tzinfo.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'tzinfo'
3
- s.version = '1.2.8'
3
+ s.version = '1.2.10'
4
4
  s.summary = 'Daylight savings aware timezone library'
5
5
  s.description = 'TZInfo provides daylight savings aware transformations between times in different time zones.'
6
6
  s.author = 'Philip Ross'
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tzinfo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.8
4
+ version: 1.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Ross
@@ -29,7 +29,7 @@ cert_chain:
29
29
  J3Zn/kSTjTekiaspyGbczC3PUaeJNxr+yCvR4sk71Xmk/GaKKGOHedJ1uj/LAXrA
30
30
  MR0mpl7b8zCg0PFC1J73uw==
31
31
  -----END CERTIFICATE-----
32
- date: 2020-11-08 00:00:00.000000000 Z
32
+ date: 2022-07-19 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: thread_safe
@@ -92,6 +92,7 @@ files:
92
92
  - lib/tzinfo/zoneinfo_country_info.rb
93
93
  - lib/tzinfo/zoneinfo_data_source.rb
94
94
  - lib/tzinfo/zoneinfo_timezone_info.rb
95
+ - test/assets/payload.rb
95
96
  - test/tc_annual_rules.rb
96
97
  - test/tc_country.rb
97
98
  - test/tc_country_index_definition.rb
@@ -190,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
191
  - !ruby/object:Gem::Version
191
192
  version: '0'
192
193
  requirements: []
193
- rubygems_version: 3.1.4
194
+ rubygems_version: 3.3.7
194
195
  signing_key:
195
196
  specification_version: 4
196
197
  summary: Daylight savings aware timezone library
metadata.gz.sig CHANGED
Binary file