Skip to content

Commit f7d2e26

Browse files
authored
Merge pull request #9050 from mhashizume/PUP-11718/main/old-rubies
(PUP-11718) Delete Ruby < 3.1 and OpenSSL < 1.1.1 code paths
2 parents 523d881 + cd21153 commit f7d2e26

File tree

6 files changed

+9
-58
lines changed

6 files changed

+9
-58
lines changed

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ group(:test) do
4242
gem "rspec", "~> 3.1", require: false
4343
gem "rspec-expectations", ["~> 3.9", "!= 3.9.3"]
4444
gem "rspec-its", "~> 1.1", require: false
45-
gem 'vcr', RUBY_VERSION.to_f >= 3.2 ? '~> 6.1' : '~> 5.0', require: false
45+
gem 'vcr', '~> 6.1', require: false
4646
gem 'webmock', '~> 3.0', require: false
47-
gem 'webrick', '~> 1.7', require: false if RUBY_VERSION.to_f >= 3.0
47+
gem 'webrick', '~> 1.7', require: false
4848
gem 'yard', require: false
4949

5050
gem 'rubocop', '1.28.0', require: false, platforms: [:ruby]

lib/puppet/ssl/ssl_provider.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def print(ssl_context, alg = 'SHA256')
235235
def default_flags
236236
# checking the signature of the self-signed cert doesn't add any security,
237237
# but it's a sanity check to make sure the cert isn't corrupt. This option
238-
# is only available in openssl 1.1+
238+
# is not available in JRuby's OpenSSL library.
239239
if defined?(OpenSSL::X509::V_FLAG_CHECK_SS_SIGNATURE)
240240
OpenSSL::X509::V_FLAG_CHECK_SS_SIGNATURE
241241
else

lib/puppet/util.rb

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,10 @@ def default_env
3434
end
3535
module_function :default_env
3636

37-
if RUBY_VERSION >= "2.6"
38-
def create_erb(content)
39-
ERB.new(content, trim_mode: '-')
40-
end
41-
else
42-
def create_erb(content)
43-
ERB.new(content, 0, '-')
44-
end
37+
def create_erb(content)
38+
ERB.new(content, trim_mode: '-')
4539
end
40+
4641
module_function :create_erb
4742

4843
# @param name [String] The name of the environment variable to retrieve

lib/puppet/util/monkey_patches.rb

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,39 +29,13 @@ def daemonize
2929
end
3030
end
3131

32-
if RUBY_VERSION.to_f < 3.0
33-
# absolute/relative were optimized to avoid chop_basename in ruby 3
34-
# see https://github.com/ruby/ruby/commit/39312cf4d6c2ab3f07d688ad1a467c8f84b58db0
35-
require 'pathname'
36-
class Pathname
37-
if File.dirname('A:') == 'A:.' # DOSish drive letter
38-
ABSOLUTE_PATH = /\A(?:[A-Za-z]:|#{SEPARATOR_PAT})/o
39-
else
40-
ABSOLUTE_PATH = /\A#{SEPARATOR_PAT}/o
41-
end
42-
private_constant :ABSOLUTE_PATH
43-
44-
def absolute?
45-
ABSOLUTE_PATH.match? @path
46-
end
47-
48-
def relative?
49-
!absolute?
50-
end
51-
end
52-
end
53-
54-
# (#19151) Reject all SSLv2 ciphers and handshakes
5532
require_relative '../../puppet/ssl/openssl_loader'
5633
unless Puppet::Util::Platform.jruby_fips?
5734
class OpenSSL::SSL::SSLContext
5835
if DEFAULT_PARAMS[:options]
59-
DEFAULT_PARAMS[:options] |= OpenSSL::SSL::OP_NO_SSLv2 | OpenSSL::SSL::OP_NO_SSLv3
36+
DEFAULT_PARAMS[:options] |= OpenSSL::SSL::OP_NO_SSLv3
6037
else
61-
DEFAULT_PARAMS[:options] = OpenSSL::SSL::OP_NO_SSLv2 | OpenSSL::SSL::OP_NO_SSLv3
62-
end
63-
if DEFAULT_PARAMS[:ciphers]
64-
DEFAULT_PARAMS[:ciphers] << ':!SSLv2'
38+
DEFAULT_PARAMS[:options] = OpenSSL::SSL::OP_NO_SSLv3
6539
end
6640

6741
alias __original_initialize initialize

spec/unit/http/factory_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def create_connection(site)
140140
end
141141

142142
context 'tls' do
143-
it "sets the minimum version to TLS 1.0", if: RUBY_VERSION.to_f >= 2.5 do
143+
it "sets the minimum version to TLS 1.0" do
144144
conn = create_connection(site)
145145
expect(conn.min_version).to eq(OpenSSL::SSL::TLS1_VERSION)
146146
end

spec/unit/util/monkey_patches_spec.rb

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,10 @@
2929
end
3030

3131
describe OpenSSL::SSL::SSLContext do
32-
it 'disables SSLv2 via the SSLContext#options bitmask' do
33-
expect(subject.options & OpenSSL::SSL::OP_NO_SSLv2).to eq(OpenSSL::SSL::OP_NO_SSLv2)
34-
end
35-
3632
it 'disables SSLv3 via the SSLContext#options bitmask' do
3733
expect(subject.options & OpenSSL::SSL::OP_NO_SSLv3).to eq(OpenSSL::SSL::OP_NO_SSLv3)
3834
end
3935

40-
it 'explicitly disable SSLv2 ciphers using the ! prefix so they cannot be re-added' do
41-
cipher_str = OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:ciphers]
42-
if cipher_str
43-
expect(cipher_str.split(':')).to include('!SSLv2')
44-
end
45-
end
46-
4736
it 'does not exclude SSLv3 ciphers shared with TLSv1' do
4837
cipher_str = OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:ciphers]
4938
if cipher_str
@@ -55,13 +44,6 @@
5544
expect_any_instance_of(described_class).to receive(:set_params)
5645
subject
5746
end
58-
59-
it 'has no ciphers with version SSLv2 enabled' do
60-
ciphers = subject.ciphers.select do |name, version, bits, alg_bits|
61-
/SSLv2/.match(version)
62-
end
63-
expect(ciphers).to be_empty
64-
end
6547
end
6648

6749

0 commit comments

Comments
 (0)