Skip to content

Commit ec172c8

Browse files
committed
Don't add/manage default gems
Unless we have a good reason to, we don't want to include default gems in ones that we ship. It's hacky to replace the version shipped with the Ruby version, and we should only do it to address a CVE that has not yet been addressed by a new Ruby version.
1 parent 0470306 commit ec172c8

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

tasks/update_gems.rake

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,82 @@ GEM_TYPE = /^\s*#\s*GEM\s+TYPE:\s*(?<platform>[A-Za-z0-9\-_.]+)\s*$/
2323
PROJ_COMPONENT = /^\s*proj\.component\s+(?<quote>['"]?)(?<component>rubygem-[^'"\s]+)\k<quote>\s*$/
2424

2525
TARGET_RUBY_VER = ENV['TARGET_RUBY']&.strip || '3.2'
26+
# Update this list when targeting a new Ruby version
27+
DEFAULT_GEMS = [
28+
'abbrev',
29+
'base64',
30+
'benchmark',
31+
'bigdecimal',
32+
'bundler',
33+
'cgi',
34+
'csv',
35+
'date',
36+
'delegate',
37+
'did_you_mean',
38+
'digest',
39+
'drb',
40+
'english',
41+
'erb',
42+
'error_highlight',
43+
'etc',
44+
'fcntl',
45+
'fiddle',
46+
'fileutils',
47+
'find',
48+
'forwardable',
49+
'getoptlong',
50+
'io-console',
51+
'io-nonblock',
52+
'io-wait',
53+
'ipaddr',
54+
'irb',
55+
'json',
56+
'logger',
57+
'mutex_m',
58+
'net-http',
59+
'net-protocol',
60+
'nkf',
61+
'observer',
62+
'open3',
63+
'openssl',
64+
'open-uri',
65+
'optparse',
66+
'ostruct',
67+
'pathname',
68+
'pp',
69+
'prettyprint',
70+
'pstore',
71+
'psych',
72+
'racc',
73+
'rdoc',
74+
'readline',
75+
'readline-ext',
76+
'reline',
77+
'resolv',
78+
'resolv-replace',
79+
'rinda',
80+
'ruby2_keywords',
81+
'rubygems',
82+
'securerandom',
83+
'set',
84+
'shellwords',
85+
'singleton',
86+
'stringio',
87+
'strscan',
88+
'syslog',
89+
'syntax_suggest',
90+
'tempfile',
91+
'time',
92+
'timeout',
93+
'tmpdir',
94+
'tsort',
95+
'un',
96+
'uri',
97+
'weakref',
98+
'win32ole',
99+
'yaml',
100+
'zlib'
101+
].freeze
26102
@versions_cache = {}
27103

28104
@component_deps = {} # gem_name => [dep gem names]
@@ -100,6 +176,8 @@ def get_metadata(name:, version: nil, platforms: ['ruby'])
100176

101177
shas = platforms.to_h { |platform| [platform, find_sha(name, version, platform)] }
102178
deps = get_version_details(name, version).dig('dependencies', 'runtime') || []
179+
# Remove any default gems as we don't want to manage them unless specifically needed
180+
deps.reject! { |d| DEFAULT_GEMS.include?(d['name']) }
103181
{ 'version' => version, 'shas' => shas, 'dependencies' => deps }
104182
end
105183

0 commit comments

Comments
 (0)