summaryrefslogtreecommitdiff
path: root/lib/bundler/lockfile_generator.rb
diff options
context:
space:
mode:
authorMercedes Bernard <mercedesrbernard@gmail.com>2023-02-10 13:34:30 -0600
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-10-23 13:59:01 +0900
commit69d7e9a12eb6e3dbfa1b1021b73c2afcbf7d4a46 (patch)
tree10e56a9112f606e866624095ec8acacce0500288 /lib/bundler/lockfile_generator.rb
parentad08674d8dc17c4ca031ce20760c4a4779c83e27 (diff)
[rubygems/rubygems] Use the server checksum, then calculate from gem on disk if possible
1. Use the checksum provided by the server if provided: provides security knowing if the gem you downloaded matches the gem on the server 2. Calculate the checksum from the gem on disk: provides security knowing if the gem has changed between installs 3. In some cases, neither is possible in which case we don't put anything in the checksum and we maintain functionality as it is today Add the checksums to specs in the index if we already have them Prior to checksums, we didn't lose any information when overwriting specs in the index with stubs. But now when we overwrite EndpointSpecifications or RemoteSpecifications with more generic specs, we could lose checksum info. This manually sets checksum info so we keep it in the index. https://github.com/rubygems/rubygems/commit/de00a4f153
Diffstat (limited to 'lib/bundler/lockfile_generator.rb')
-rw-r--r--lib/bundler/lockfile_generator.rb15
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/bundler/lockfile_generator.rb b/lib/bundler/lockfile_generator.rb
index 11e8e3f103..52b3b411aa 100644
--- a/lib/bundler/lockfile_generator.rb
+++ b/lib/bundler/lockfile_generator.rb
@@ -68,17 +68,14 @@ module Bundler
def add_checksums
out << "\nCHECKSUMS\n"
-
definition.resolve.sort_by(&:full_name).each do |spec|
checksum = spec.to_checksum if spec.respond_to?(:to_checksum)
-
- #if spec.is_a?(LazySpecification)
- #spec.materialize_for_checksum do
- #checksum ||= spec.to_checksum if spec.respond_to?(:to_checksum)
- #end
- #end
-
- checksum ||= definition.locked_checksums.find {|c| c.match_spec?(spec) }
+ if spec.is_a?(LazySpecification)
+ spec.materialize_for_checksum do |materialized_spec|
+ checksum ||= materialized_spec.to_checksum if materialized_spec&.respond_to?(:to_checksum)
+ end
+ end
+ checksum ||= definition.locked_checksums[spec.full_name]
out << checksum.to_lock if checksum
end