Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sha256 checksum to rake build:checksum #6022

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

pboling
Copy link
Contributor

@pboling pboling commented Oct 27, 2022

… in addition to the existing SHA512

What was the end-user or developer problem that led to this PR?

  • Until now Rubygems.org has publicly displayed SHA256 checksum for published gems, but has only created the SHA512 checksum for the package via rake build:checksum task
  • This will allow more gem authors to easily verify integrity of published gems with an existing Rubygems.org feature
  • See Security discrepancies between rake task and documentation #5942 for details on the problem

What is your fix for the problem, implemented in this PR?

Create a SHA256 checksum, in addition to the current SHA512 checksum.

Note that I've changed the Gem helper method from build_checksum to build_checksums. Certainly could keep it the same if that's a problem, but it felt good to be grammatically correct with it. Not sure if internal or external API.

Make sure the following tasks are checked

@welcome
Copy link

welcome bot commented Oct 27, 2022

Thanks for opening a pull request and helping make RubyGems and Bundler better! Someone from the RubyGems team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality.

We use GitHub Actions to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of GitHub Actions in the PR status window below.

If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #rubygems or #bundler channel on Slack.

For more information about contributing to the RubyGems project feel free to review our CONTRIBUTING guide

… SHA512

- Until now Rubygems.org has publicly displayed SHA256 checksum for published gems, but has only created the SHA512 checksum for the package via rake build:checksum task
- This will allow more gem authors to easily verify integrity of published gems with an existing Rubygems.org feature
previously inconsistent platform discrepancies are normalized to include the following for all:
  x86_64-darwin-19
  x86_64-darwin-20
  x86_64-darwin-21
@pboling pboling force-pushed the add-SHA512-checksum branch from 690ec12 to 06f312d Compare October 27, 2022 11:15
@pboling pboling force-pushed the add-SHA512-checksum branch from 06f312d to 1c707cc Compare October 27, 2022 11:21
@pboling
Copy link
Contributor Author

pboling commented Oct 27, 2022

I am working on a PR updating rubygems.org documentation to be concordant with rake build:checksum to address the other parts of #5942 .

Copy link
Member

@deivid-rodriguez deivid-rodriguez left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this, @pboling! I just have one request regarding lazily loading digest/sha, so that it's only loaded when this task is used.

bundler/lib/bundler/gem_helper.rb Outdated Show resolved Hide resolved
- address code review feedback
Copy link
Member

@deivid-rodriguez deivid-rodriguez left a comment

Choose a reason for hiding this comment

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

Just to small additional comments, but it's most ready from my side. Thanks so much for working on this!

require "digest/sha2"
checksum = ::Digest::SHA512.file(built_gem_path).hexdigest
CHECKSUMS.each do |extension, digest_klass|
Copy link
Member

Choose a reason for hiding this comment

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

Super minor but I'm thinking, do you think the CHECKSUMS constant buys us much, over

write_checksum(built_gem_path, "sha256", Digest::SHA256)
write_checksum(built_gem_path, "sha512", Digest::SHA512)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't get us much, agreed.

built_gem_path ||= build_gem
SharedHelpers.filesystem_access(File.join(base, "checksums")) {|p| FileUtils.mkdir_p(p) }
Copy link
Member

Choose a reason for hiding this comment

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

Why was this moved inside the write_checksums method? It should be enough to run it just once I think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Oversight.

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

Successfully merging this pull request may close these issues.

2 participants