Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions script/update-openssl
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
#!/usr/bin/env ruby

raise "Usage: #{$0} NEW_VERSION SHA" unless ARGV.size == 2
new_version, sha = ARGV
require 'open-uri'
require 'digest/sha2'
require 'tempfile'

raise "Usage: #{$0} NEW_VERSION" unless ARGV.size == 1
new_version = ARGV[0]

Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The open-uri library enables Kernel.open to automatically open URIs, which can be a security concern. While the URL is constructed from a version parameter and targets a specific GitHub pattern, consider using URI.open explicitly (which you are doing) and potentially adding validation that the version parameter only contains expected characters (digits and dots) to prevent any potential URL manipulation.

Suggested change
unless new_version.match?(/\A\d+(?:\.\d+)*[a-z]?\z/)
raise "Invalid OpenSSL version: #{new_version.inspect}"
end

Copilot uses AI. Check for mistakes.
major_minor = new_version.split('.')[0..1].join('.')

url = "https://github.com/openssl/openssl/releases/download/openssl-#{new_version}/openssl-#{new_version}.tar.gz"
sha = nil

Tempfile.create(['openssl', '.tar.gz']) do |tmpfile|
URI.open(url) do |remote_file|
IO.copy_stream(remote_file, tmpfile)
Comment on lines +16 to +17
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using URI.open to download content from the internet without explicit error handling could result in unclear error messages if the download fails (network issues, 404 errors, SSL certificate problems). Consider wrapping this in a begin-rescue block to provide more user-friendly error messages, especially since this changes the script from requiring a pre-computed SHA256 to automatically downloading and computing it.

Suggested change
URI.open(url) do |remote_file|
IO.copy_stream(remote_file, tmpfile)
begin
URI.open(url) do |remote_file|
IO.copy_stream(remote_file, tmpfile)
end
rescue OpenURI::HTTPError => e
abort "Failed to download #{url}: #{e.message}"
rescue SocketError, IOError, SystemCallError => e
abort "Network error while downloading #{url}: #{e.class}: #{e.message}"

Copilot uses AI. Check for mistakes.
end
tmpfile.rewind

sha = Digest::SHA256.file(tmpfile.path).hexdigest
end

Dir.glob('share/ruby-build/*') do |file|
contents = File.read(file)

Expand Down
2 changes: 1 addition & 1 deletion share/ruby-build/4.1-dev
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
install_package "openssl-3.0.18" "https://github.com/openssl/openssl/releases/download/openssl-3.0.18/openssl-3.0.18.tar.gz#d80c34f5cf902dccf1f1b5df5ebb86d0392e37049e5d73df1b3abae72e4ffe8b" openssl --if needs_openssl:1.0.2-3.x.x
install_package "openssl-3.5.4" "https://github.com/openssl/openssl/releases/download/openssl-3.5.4/openssl-3.5.4.tar.gz#967311f84955316969bdb1d8d4b983718ef42338639c621ec4c34fddef355e99" openssl --if needs_openssl:1.0.2-3.x.x
install_git "ruby-master" "https://github.com/ruby/ruby.git" "master" autoconf enable_shared standard_install_with_bundled_gems
2 changes: 1 addition & 1 deletion share/ruby-build/ruby-dev
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
install_package "openssl-3.0.18" "https://github.com/openssl/openssl/releases/download/openssl-3.0.18/openssl-3.0.18.tar.gz#d80c34f5cf902dccf1f1b5df5ebb86d0392e37049e5d73df1b3abae72e4ffe8b" openssl --if needs_openssl:1.0.2-3.x.x
install_package "openssl-3.5.4" "https://github.com/openssl/openssl/releases/download/openssl-3.5.4/openssl-3.5.4.tar.gz#967311f84955316969bdb1d8d4b983718ef42338639c621ec4c34fddef355e99" openssl --if needs_openssl:1.0.2-3.x.x
install_git "ruby-master" "https://github.com/ruby/ruby.git" "master" autoconf enable_shared standard_install_with_bundled_gems