From a7f2e71d60dc9e4b13550098d1e4a013df63ff2b Mon Sep 17 00:00:00 2001 From: Alex Dalitz Date: Fri, 22 Aug 2025 13:18:49 +0100 Subject: [PATCH 1/6] require Ruby > 2.7.0 --- dnsruby.gemspec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dnsruby.gemspec b/dnsruby.gemspec index a618a06..346e468 100644 --- a/dnsruby.gemspec +++ b/dnsruby.gemspec @@ -15,7 +15,10 @@ SPEC = Gem::Specification.new do |s| stub resolver. It aims to comply with all DNS RFCs, including DNSSEC NSEC3 support.' s.license = "Apache License, Version 2.0" - + + # Add explicit Ruby version requirement + s.required_ruby_version = '>= 2.7.0' + s.files = `git ls-files -z`.split("\x0") s.post_install_message = \ From 0c73791d8537341129aea892fcd12d3eddce621c Mon Sep 17 00:00:00 2001 From: Alex Dalitz Date: Fri, 22 Aug 2025 13:19:27 +0100 Subject: [PATCH 2/6] Use Timeout::Error not TimeoutError for ResolvTimeout --- lib/dnsruby.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/dnsruby.rb b/lib/dnsruby.rb index 867506b..a31abdb 100644 --- a/lib/dnsruby.rb +++ b/lib/dnsruby.rb @@ -158,7 +158,12 @@ class ResolvError < StandardError end # A timeout error raised while querying for a resource - class ResolvTimeout < Timeout::Error + if defined?(Timeout::Error) + class ResolvTimeout < Timeout::Error + end + else + class ResolvTimeout < ::TimeoutError + end end # The requested domain does not exist From eefd8e26718f02dad45510335e262e228a396221 Mon Sep 17 00:00:00 2001 From: Alex Dalitz Date: Fri, 22 Aug 2025 13:19:40 +0100 Subject: [PATCH 3/6] untaint --- lib/dnsruby/config.rb | 2 +- lib/dnsruby/hosts.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/dnsruby/config.rb b/lib/dnsruby/config.rb index 359a46d..9119842 100644 --- a/lib/dnsruby/config.rb +++ b/lib/dnsruby/config.rb @@ -320,7 +320,7 @@ def Config.parse_resolv_conf(filename) #:nodoc: all keyword, *args = line.split(/\s+/) if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.8") args.each { |arg| - arg.untaint + arg = arg.respond_to?(:untaint) ? arg.untaint : input } end next unless keyword diff --git a/lib/dnsruby/hosts.rb b/lib/dnsruby/hosts.rb index 9d1f11c..f1ed6b4 100644 --- a/lib/dnsruby/hosts.rb +++ b/lib/dnsruby/hosts.rb @@ -58,8 +58,8 @@ def lazy_initialize# :nodoc: addr, hostname, *aliases = line.split(/\s+/) next unless addr if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.8") - addr.untaint - hostname.untaint + addr = addr.respond_to?(:untaint) ? addr.untaint : input + hostname = hostname.respond_to?(:untaint) ? hostname.untaint : input end @addr2name[addr] = [] unless @addr2name.include? addr @addr2name[addr] << hostname @@ -68,7 +68,7 @@ def lazy_initialize# :nodoc: @name2addr[hostname] << addr aliases.each {|n| if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.8") - n.untaint + n = n.respond_to?(:untaint) ? n.untaint : input end @name2addr[n] = [] unless @name2addr.include? n @name2addr[n] << addr From 12b0568c4dee6a7ec16adc5916043da1768fee0c Mon Sep 17 00:00:00 2001 From: Alex Dalitz Date: Mon, 1 Sep 2025 15:37:48 +0100 Subject: [PATCH 4/6] remove untaint calls and timeout::Error --- lib/dnsruby.rb | 7 +------ lib/dnsruby/config.rb | 5 ----- lib/dnsruby/hosts.rb | 7 ------- 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/lib/dnsruby.rb b/lib/dnsruby.rb index a31abdb..2ecb115 100644 --- a/lib/dnsruby.rb +++ b/lib/dnsruby.rb @@ -158,12 +158,7 @@ class ResolvError < StandardError end # A timeout error raised while querying for a resource - if defined?(Timeout::Error) - class ResolvTimeout < Timeout::Error - end - else - class ResolvTimeout < ::TimeoutError - end + class ResolvTimeout < ::TimeoutError end # The requested domain does not exist diff --git a/lib/dnsruby/config.rb b/lib/dnsruby/config.rb index 9119842..6dce381 100644 --- a/lib/dnsruby/config.rb +++ b/lib/dnsruby/config.rb @@ -318,11 +318,6 @@ def Config.parse_resolv_conf(filename) #:nodoc: all f.each {|line| line.sub!(/[#;].*/, '') keyword, *args = line.split(/\s+/) - if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.8") - args.each { |arg| - arg = arg.respond_to?(:untaint) ? arg.untaint : input - } - end next unless keyword case keyword when 'port' diff --git a/lib/dnsruby/hosts.rb b/lib/dnsruby/hosts.rb index f1ed6b4..479327f 100644 --- a/lib/dnsruby/hosts.rb +++ b/lib/dnsruby/hosts.rb @@ -57,19 +57,12 @@ def lazy_initialize# :nodoc: line.sub!(/#.*/, '') addr, hostname, *aliases = line.split(/\s+/) next unless addr - if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.8") - addr = addr.respond_to?(:untaint) ? addr.untaint : input - hostname = hostname.respond_to?(:untaint) ? hostname.untaint : input - end @addr2name[addr] = [] unless @addr2name.include? addr @addr2name[addr] << hostname @addr2name[addr] += aliases @name2addr[hostname] = [] unless @name2addr.include? hostname @name2addr[hostname] << addr aliases.each {|n| - if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.8") - n = n.respond_to?(:untaint) ? n.untaint : input - end @name2addr[n] = [] unless @name2addr.include? n @name2addr[n] << addr } From a3cc9a6e5853330e18e6c67b2f1f8837b73ed3f8 Mon Sep 17 00:00:00 2001 From: Alex Dalitz Date: Mon, 1 Sep 2025 15:44:09 +0100 Subject: [PATCH 5/6] Up oldest supported Ruby to 2.8.0 --- dnsruby.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dnsruby.gemspec b/dnsruby.gemspec index 346e468..df1bd20 100644 --- a/dnsruby.gemspec +++ b/dnsruby.gemspec @@ -17,7 +17,7 @@ DNSSEC NSEC3 support.' s.license = "Apache License, Version 2.0" # Add explicit Ruby version requirement - s.required_ruby_version = '>= 2.7.0' + s.required_ruby_version = '>= 2.8.0' s.files = `git ls-files -z`.split("\x0") From 302f1c7b51f42276475c044e4f6468aa05c25979 Mon Sep 17 00:00:00 2001 From: Alex Dalitz Date: Mon, 1 Sep 2025 15:51:27 +0100 Subject: [PATCH 6/6] Fix Timeout::Error --- lib/dnsruby.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/dnsruby.rb b/lib/dnsruby.rb index 2ecb115..867506b 100644 --- a/lib/dnsruby.rb +++ b/lib/dnsruby.rb @@ -158,7 +158,7 @@ class ResolvError < StandardError end # A timeout error raised while querying for a resource - class ResolvTimeout < ::TimeoutError + class ResolvTimeout < Timeout::Error end # The requested domain does not exist