[rubygems/rubygems] Add a lockfile_checksums configuration to include checksums in fresh lockfiles

https://github.com/rubygems/rubygems/commit/50b9ef8589
This commit is contained in:
David Rodríguez 2024-11-07 14:05:08 +01:00 committed by git
parent 8672e88cd2
commit db0c7be642
6 changed files with 49 additions and 1 deletions

View File

@ -117,7 +117,7 @@ module Bundler
@originally_locked_specs = @locked_specs
@locked_sources = []
@locked_platforms = []
@locked_checksums = Bundler.feature_flag.bundler_3_mode?
@locked_checksums = Bundler.feature_flag.lockfile_checksums?
end
locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }

View File

@ -33,6 +33,7 @@ module Bundler
settings_flag(:default_install_uses_path) { bundler_3_mode? }
settings_flag(:forget_cli_options) { bundler_3_mode? }
settings_flag(:global_gem_cache) { bundler_3_mode? }
settings_flag(:lockfile_checksums) { bundler_3_mode? }
settings_flag(:path_relative_to_cwd) { bundler_3_mode? }
settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
settings_flag(:print_only_version_number) { bundler_3_mode? }

View File

@ -149,6 +149,8 @@ The following is a list of all configuration keys and their purpose\. You can le
.IP "\(bu" 4
\fBjobs\fR (\fBBUNDLE_JOBS\fR): The number of gems Bundler can install in parallel\. Defaults to the number of available processors\.
.IP "\(bu" 4
\fBlockfile_checksums\fR (\fBBUNDLE_LOCKFILE_CHECKSUMS\fR): Whether Bundler should include a checksums section in new lockfiles, to protect from compromised gem sources\.
.IP "\(bu" 4
\fBno_install\fR (\fBBUNDLE_NO_INSTALL\fR): Whether \fBbundle package\fR should skip installing gems\.
.IP "\(bu" 4
\fBno_prune\fR (\fBBUNDLE_NO_PRUNE\fR): Whether Bundler should leave outdated gems unpruned when caching\.

View File

@ -217,6 +217,8 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
* `jobs` (`BUNDLE_JOBS`):
The number of gems Bundler can install in parallel. Defaults to the number of
available processors.
* `lockfile_checksums` (`BUNDLE_LOCKFILE_CHECKSUMS`):
Whether Bundler should include a checksums section in new lockfiles, to protect from compromised gem sources.
* `no_install` (`BUNDLE_NO_INSTALL`):
Whether `bundle package` should skip installing gems.
* `no_prune` (`BUNDLE_NO_PRUNE`):

View File

@ -32,6 +32,7 @@ module Bundler
ignore_messages
init_gems_rb
inline
lockfile_checksums
no_install
no_prune
path_relative_to_cwd

View File

@ -1832,6 +1832,48 @@ RSpec.describe "bundle lock" do
L
end
it "generates checksums by default if configured to do so" do
build_repo4 do
build_gem "nokogiri", "1.14.2"
build_gem "nokogiri", "1.14.2" do |s|
s.platform = "x86_64-linux"
end
end
bundle "config lockfile_checksums true"
simulate_platform "x86_64-linux" do
install_gemfile <<-G
source "https://gem.repo4"
gem "nokogiri"
G
end
checksums = checksums_section do |c|
c.checksum gem_repo4, "nokogiri", "1.14.2"
c.checksum gem_repo4, "nokogiri", "1.14.2", "x86_64-linux"
end
expect(lockfile).to eq <<~L
GEM
remote: https://gem.repo4/
specs:
nokogiri (1.14.2)
nokogiri (1.14.2-x86_64-linux)
PLATFORMS
ruby
x86_64-linux
DEPENDENCIES
nokogiri
#{checksums}
BUNDLED WITH
#{Bundler::VERSION}
L
end
context "when re-resolving to include prereleases" do
before do
build_repo4 do