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

[2.0] Remove RubyGems Aggregate & support transitive source pinning#5792

Merged
bundlerbot merged 15 commits intomasterfrom
seg-remove-rubygems-aggregate
Jun 27, 2017
Merged

[2.0] Remove RubyGems Aggregate & support transitive source pinning#5792
bundlerbot merged 15 commits intomasterfrom
seg-remove-rubygems-aggregate

Conversation

@segiddins
Copy link
Copy Markdown
Contributor

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

The problem was that the resolver could resolve specs from any of the sources specified in the Gemfile, even if that source had nothing to do with the spec in question. This was such a large security vulnerability that, when discovered, it warranted a CVE and its own minor release of Bundler.

Closes #3671.
Closes #3696.
Closes #4059.

Was was your diagnosis of the problem?

My diagnosis was that we needed to get rid of the notion of a rubygems aggregate and enforce that specs could only come either from the source they were declared to come from (the top-level source if declared at the top-level of the Gemfile, else a scoped source), or a source that it transitively "inherited" from the gems that required it.

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

My fix is to disable multiple top-level sources in the Gemfile, remove the RubyGems aggregate, and filter the sources gems could come from as described above.

Why did you choose this fix out of the possible options?

I chose this fix because it allows doing the filtering in a reasonably performant manner, and refactors the way we handle sources to abstract some of the grossness in such a way that the machinations to make sure that all of the necessary gem info is downloaded is encapsulated into a single method, driven from the definition, rather than being specific to rubygems sources.

See #4714 and #4930 for the prior implementation.

@attritionorg
Copy link
Copy Markdown

@segiddins "it warranted a CVE and its own minor release of Bundler" I know the CVE, but don't think I ever saw the versions impacted and the first fixing version. Can you provide that info? Thanks!

@segiddins
Copy link
Copy Markdown
Contributor Author

but don't think I ever saw the versions impacted and the first fixing version

https://bundler.io/v1.7/whats_new.html

@indirect
Copy link
Copy Markdown

@bundlerbot r+

@bundlerbot
Copy link
Copy Markdown
Collaborator

📌 Commit 9181c06 has been approved by indirect

@segiddins
Copy link
Copy Markdown
Contributor Author

@bundlerbot r-
I'd like to get the specs running on 2.0 mode first, if that's ok with you? Since I have a hunch this change in particular might break tests

@indirect
Copy link
Copy Markdown

👍

@segiddins segiddins force-pushed the seg-remove-rubygems-aggregate branch 2 times, most recently from 96057e7 to 4e27808 Compare June 23, 2017 22:32
@segiddins segiddins force-pushed the seg-remove-rubygems-aggregate branch from 4e27808 to f243da6 Compare June 24, 2017 00:40
@segiddins
Copy link
Copy Markdown
Contributor Author

There's an off-chance this will pass now, so please review :)

Copy link
Copy Markdown

@indirect indirect left a comment

Choose a reason for hiding this comment

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

This is looking good, and I'm super happy with the metadata source 🙌🏻

o << "Could not find gem '#{printable_dep(conflict.requirement)}' "
end

o << if relevant_sources.empty?
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

please append inside the branches rather than indenting the whole conditional 👍🏻

@segiddins segiddins force-pushed the seg-remove-rubygems-aggregate branch from f243da6 to 4b0db68 Compare June 24, 2017 04:29
@segiddins
Copy link
Copy Markdown
Contributor Author

Passing for Bundler 1, down to 5 failures for Bundler 2 (I don't know how I keep on missing them locally, I'm sorry)

@colby-swandale
Copy link
Copy Markdown
Member

nothing to be sorry about 😄

Copy link
Copy Markdown
Contributor

@TimMoore TimMoore left a comment

Choose a reason for hiding this comment

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

Phew! Nice work!

@segiddins segiddins force-pushed the seg-remove-rubygems-aggregate branch from 4b0db68 to 4dcd333 Compare June 27, 2017 15:20
@segiddins
Copy link
Copy Markdown
Contributor Author

Have two 👍, so going to merge this.

@bundlerbot r+

@bundlerbot
Copy link
Copy Markdown
Collaborator

📌 Commit 4dcd333 has been approved by segiddins

@bundlerbot
Copy link
Copy Markdown
Collaborator

⌛ Testing commit 4dcd333 with merge 87352ed...

bundlerbot added a commit that referenced this pull request Jun 27, 2017
[2.0] Remove RubyGems Aggregate & support transitive source pinning

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

The problem was that the resolver could resolve specs from _any_ of the sources specified in the Gemfile, even if that source had nothing to do with the spec in question. This was such a large security vulnerability that, when discovered, it warranted a CVE and its own minor release of Bundler.

Closes #3671.
Closes #3696.
Closes #4059.

### Was was your diagnosis of the problem?

My diagnosis was that we needed to get rid of the notion of a `rubygems aggregate` and enforce that specs could only come either from the source they were declared to come from (the top-level source if declared at the top-level of the Gemfile, else a scoped source), or a source that it transitively "inherited" from the gems that required it.

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

My fix is to disable multiple top-level sources in the Gemfile, remove the RubyGems aggregate, and filter the sources gems could come from as described above.

### Why did you choose this fix out of the possible options?

I chose this fix because it allows doing the filtering in a reasonably performant manner, and refactors the way we handle sources to abstract some of the grossness in such a way that the machinations to make sure that all of the necessary gem info is downloaded is encapsulated into a single method, driven from the definition, rather than being specific to rubygems sources.

See #4714 and #4930 for the prior implementation.
@bundlerbot
Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-travis
Approved by: segiddins
Pushing 87352ed to master...

@bundlerbot bundlerbot merged commit 4dcd333 into master Jun 27, 2017
@segiddins segiddins deleted the seg-remove-rubygems-aggregate branch June 28, 2017 09:45
@segiddins segiddins restored the seg-remove-rubygems-aggregate branch July 1, 2017 15:23
@segiddins segiddins deleted the seg-remove-rubygems-aggregate branch July 1, 2017 15:23
@Benjamin-Dobell
Copy link
Copy Markdown

Benjamin-Dobell commented Jan 29, 2018

EDIT: My apologies, I'm running into issues with bundler 1.16.1, so I've removed the specifics of my issue (although related to transitive dependency source resolution). Knowing that I'll be moving to 2.0 once released, then I'd be happy to know the correct syntax to utilise for transitive dependency sources once 2.0 is released.

How would specify the preferred source for transitive dependencies?

e.g.

We have a dependency on some-gem, but some-gem has a dependency on private-gem. How do I ensure that Bundler correctly gets private-gem from my private Gem repository and not Rubygems?

Would something like the following work...?

source 'https://rubygems.org'

source 'https://myprivaterepository' do
  gem 'some-gem', git: 'https://myforkongithub'
end

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.

Bundler issues warning when a gem is on both the global source and a one-off source

7 participants