Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

[RubyGemsGemInstaller] Validate checksums from the compact index #4851

Merged
merged 6 commits into from
Aug 23, 2016

Conversation

segiddins
Copy link
Member

Closes #4464

@indirect
Copy link
Member

indirect commented Aug 8, 2016

woo @homu r+

@homu
Copy link
Contributor

homu commented Aug 8, 2016

📌 Commit 9231ceb has been approved by indirect

@indirect
Copy link
Member

indirect commented Aug 8, 2016

Ugh, of course now that I've approved it I realized that we should add a setting to disable this check, because some people will have existing gems with invalid checksums that they want to keep using.

@indirect
Copy link
Member

indirect commented Aug 8, 2016

@homu r-

@indirect
Copy link
Member

indirect commented Aug 8, 2016

I am super happy with this, though!

rescue
nil
end
CompactIndex::GemVersion.new(spec.version.version, spec.platform.to_s, checksum, nil,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just checksum = Digest::SHA256.file("#{GEM_REPO}/gems/#{spec.original_name}.gem").base64digest rescue nil? lots of lines super far indented makes me feel gross. 😝

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the modifier rescue and rubocop agrees with me :P

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about checksum = gem_checksum(spec) then?

@segiddins
Copy link
Member Author

@indirect added a setting to disable validation

@segiddins
Copy link
Member Author

This is failing because index.rubygems.org is inconsistent between hex & base64 encoding the checksums. Is it worth accounting for that or should we convert to one or the other server-side?

"the checksum given by the API. This means that the contents of the " \
"gem appear to be different from what was uploaded, and could be an indicator of a security issue.\n" \
"(The expected SHA256 checksum was #{checksum.inspect}, but the checksum for the downloaded gem was #{digest.inspect}.)\n" \
"Bundler cannot continue installing #{spec.name} (#{spec.version})."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the principle of empowering users to resolve their own errors, how do you feel about also printing the full path, suggesting deleting the gem with the bad checksum, and explaining that if they are sure they want to install this gem despite the checksum not matching, they can bundle config disable.checksum_validaiton true?

@indirect
Copy link
Member

The config key should probably also to be added to the bundle config manpage section about available config keys.

@indirect
Copy link
Member

Running a data migration right now to replace all checksums in the bundler-api database with the longer hex versions. I'm torn about what we should put in the actual index files, though... using base64 checksums would decrease the file size. :/

@homu
Copy link
Contributor

homu commented Aug 17, 2016

☔ The latest upstream changes (presumably #4869) made this pull request unmergeable. Please resolve the merge conflicts.

@segiddins segiddins force-pushed the seg-validate-checksums branch from 9660a1e to 12a3569 Compare August 17, 2016 00:21
@segiddins
Copy link
Member Author

Rebased

@segiddins segiddins force-pushed the seg-validate-checksums branch from 12a3569 to 54baa4e Compare August 17, 2016 00:28
@indirect
Copy link
Member

This should be good now that the checksums in the database are all consistent.

@homu r+

@homu
Copy link
Contributor

homu commented Aug 21, 2016

📌 Commit 54baa4e has been approved by indirect

@homu
Copy link
Contributor

homu commented Aug 21, 2016

⌛ Testing commit 54baa4e with merge a238b61...

@homu
Copy link
Contributor

homu commented Aug 21, 2016

💔 Test failed - status

@segiddins segiddins force-pushed the seg-validate-checksums branch from 54baa4e to dc2a61c Compare August 22, 2016 17:27
@segiddins
Copy link
Member Author

This should pass now

@segiddins segiddins force-pushed the seg-validate-checksums branch from c4f89cd to ae465eb Compare August 22, 2016 23:21
@indirect
Copy link
Member

@homu retry

@indirect
Copy link
Member

oops, @homu r+

@homu
Copy link
Contributor

homu commented Aug 23, 2016

📌 Commit ae465eb has been approved by indirect

homu added a commit that referenced this pull request Aug 23, 2016
[RubyGemsGemInstaller] Validate checksums from the compact index

Closes #4464
@homu
Copy link
Contributor

homu commented Aug 23, 2016

⌛ Testing commit ae465eb with merge cb24b6d...

@homu
Copy link
Contributor

homu commented Aug 23, 2016

☀️ Test successful - status

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants