Skip to content

Commit ee90bf3

Browse files
committed
Constrain minitar gem version and fix require
This should be just specifying `"~> 1.0"`, but backlevel support has been added because Berkshelf still claims to support Ruby 2.7+ and Minitar 1.0 (which is the only supported branch as of 20204-08-07) has explicitly dropped support for any Ruby version 3.0 or older. Minitar v0.12 is the last of the versions for that line and all users are encouraged to upgrade to v1.0 (no one should be running anything older than Ruby 3.1). This is a fairly critical update as users of berkshelf are unable to install or use it without this change. I would strongly recommend that other dependencies like `thor` and `chef` itself where there is an unconstrained `>=` specification be reviewed. This is a potential security or incompatibility hole for all of your users. Resolves: #26 Signed-off-by: Austin Ziegler <[email protected]>
1 parent 4d34215 commit ee90bf3

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

berkshelf.gemspec

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,17 @@ Gem::Specification.new do |s|
3333
"changelog_uri" => "https://github.com/chef/berkshelf/blob/main/CHANGELOG.md",
3434
}
3535

36+
ruby_version = Gem::Version.new(RUBY_VERSION)
37+
3638
s.add_dependency "mixlib-shellout", ">= 2.0", "< 4.0"
3739
s.add_dependency "cleanroom", "~> 1.0"
38-
s.add_dependency "minitar", ">= 0.6"
40+
41+
if ruby_version >= "3.1"
42+
s.add_dependency "minitar", "~> 1.0"
43+
else
44+
s.add_dependency "minitar", "~> 0.12"
45+
end
46+
3947
s.add_dependency "retryable", ">= 2.0", "< 4.0"
4048
s.add_dependency "solve", "~> 4.0"
4149
s.add_dependency "thor", ">= 0.20"
@@ -44,8 +52,8 @@ Gem::Specification.new do |s|
4452
s.add_dependency "concurrent-ruby", "~> 1.0"
4553
if RUBY_VERSION.match?(/3.0/)
4654
s.add_dependency "chef", "~> 17.0" # needed for --skip-syntax-check
47-
elsif
48-
s.add_dependency "chef", ">= 15.7.32"
55+
elsif
56+
s.add_dependency "chef", ">= 15.7.32"
4957
end
5058
s.add_dependency "chef-config"
5159
# this is required for Mixlib::Config#from_json

lib/berkshelf/packager.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require "archive/tar/minitar"
1+
require "minitar"
22
require "find" unless defined?(Find)
33
require "zlib" unless defined?(Zlib)
44

@@ -47,7 +47,7 @@ def run(source)
4747
Find.find(source) do |entry|
4848
next if source == entry
4949

50-
Archive::Tar::Minitar.pack_file(entry, tar)
50+
Minitar.pack_file(entry, tar)
5151
end
5252
ensure
5353
tar.close
@@ -79,12 +79,12 @@ def validate!
7979
# @return [String]
8080
attr_reader :filename
8181

82-
# A private decorator for Archive::Tar::Minitar::Writer that
82+
# A private decorator for Minitar::Writer that
8383
# turns absolute paths into relative ones.
8484
class RelativeTarWriter < SimpleDelegator # :nodoc:
8585
def initialize(io, base_path)
8686
@base_path = Pathname.new(base_path)
87-
super(Archive::Tar::Minitar::Writer.new(io))
87+
super(Minitar::Writer.new(io))
8888
end
8989

9090
%w{add_file add_file_simple mkdir}.each do |method|

0 commit comments

Comments
 (0)