Skip to content

Commit 3e9c307

Browse files
committed
(PA-6881) Adding rexml gem to agent-runtime-main for CVE-2024-41123 and CVE-2024-41946
1 parent 38fc20b commit 3e9c307

5 files changed

+18
-14
lines changed

configs/components/_base-rubygem.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@
4040
# If a gem needs more command line options to install set the :gem_install_options
4141
# in its component file rubygem-<compoment>, before the instance_eval of this file.
4242
gem_install_options = settings["#{pkg.get_name}_gem_install_options".to_sym]
43-
if gem_install_options.nil?
44-
pkg.install do
45-
"#{settings[:gem_install]} #{name}-#{version}.gem"
46-
end
47-
else
48-
pkg.install do
49-
"#{settings[:gem_install]} #{name}-#{version}.gem #{gem_install_options}"
50-
end
43+
remove_older_versions = settings["#{pkg.get_name}_remove_older_versions".to_sym]
44+
pkg.install do
45+
steps = []
46+
steps << "#{settings[:gem_uninstall]} #{name}" if remove_older_versions
47+
steps << if gem_install_options.nil?
48+
"#{settings[:gem_install]} #{name}-#{version}.gem"
49+
else
50+
"#{settings[:gem_install]} #{name}-#{version}.gem #{gem_install_options}"
51+
end
5152
end
52-

configs/components/rubygem-rexml.rb

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
pkg.version '3.3.4'
33
pkg.md5sum 'b7411377f3c1a9cbe65e862f74067f91'
44

5+
settings["#{pkg.get_name}_remove_older_versions".to_sym] = true
6+
57
# If the platform is solaris with sparc architecture in agent-runtime-7.x project, we want to gem install rexml
68
# ignoring the dependencies, this is because the pl-ruby version used in these platforms is ancient so it gets
79
# confused when installing rexml. It tries to install rexml's dependency 'strscan' by building native extensions

configs/projects/_shared-agent-components.rb

+6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@
6262
proj.component 'rubygem-fast_gettext'
6363
proj.component 'rubygem-ffi'
6464

65+
# We add rexml explicitly in here because even though ruby 3 ships with rexml as its default gem, the version
66+
# of rexml it ships with contains CVE-2024-41946, CVE-2024-41123, CVE-2024-35176 and CVE-2024-39908.
67+
# So, we add it here to update to a higher version
68+
# free from the CVEs.
69+
proj.component 'rubygem-rexml'
70+
6571
if platform.is_windows? || platform.is_solaris? || platform.is_aix?
6672
proj.component 'rubygem-minitar'
6773
end

configs/projects/_shared-agent-settings.rb

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
end
132132

133133
proj.setting(:gem_install, "#{proj.host_gem} install --no-rdoc --no-ri --local ")
134+
proj.setting(:gem_uninstall, "#{proj.host_gem} uninstall --all --ignore-dependencies ")
134135

135136
# For AIX, we use the triple to install a better rbconfig
136137
if platform.is_aix?

configs/projects/agent-runtime-7.x.rb

-5
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,6 @@
6161
proj.component 'rubygem-thor'
6262
proj.component 'rubygem-scanf'
6363

64-
# We add rexml explicitly in here because even though ruby 2 ships with rexml as its default gem, the version
65-
# of rexml it ships with contains CVE-2024-35176 and CVE-2024-39908. So, we add it here to update to a higher version
66-
# free from the CVEs.
67-
proj.component 'rubygem-rexml'
68-
6964
if platform.is_linux?
7065
proj.component "virt-what"
7166
proj.component "dmidecode" unless platform.architecture =~ /ppc64/

0 commit comments

Comments
 (0)