Commit graph

740 commits

Author SHA1 Message Date
David Rodríguez
1e290c31f4 [rubygems/rubygems] Merge Gem::UriParser and Gem::PrintableUri into a Gem::Uri class
The new class is a wrapper on top of an URI. And then, when you want
credentials redacted, you call `#redacted` that returns a copy of itself,
but with credentials redacted.

9581c2740a
2021-08-31 19:06:14 +09:00
Daniel Niknam
1948ac20ce [rubygems/rubygems] Replacing clone with dup
30f5b3c027
2021-08-31 19:06:14 +09:00
Daniel Niknam
4715bbf7b3 [rubygems/rubygems] Remove returning self for Gem::PrintableUri#parse_uri
25c99d7f9d
2021-08-31 19:06:14 +09:00
Daniel Niknam
aa898b4206 [rubygems/rubygems] Remove @credential_redacted instance variable
c3bb52eb5c
2021-08-31 19:06:14 +09:00
Daniel Niknam
7067005f23 [rubygems/rubygems] Bring back the empty line that was removed previously by mistake
ffb480ca7a
2021-08-31 19:06:14 +09:00
Daniel Niknam
d73dc8e937 [rubygems/rubygems] Remove unused method
3a8486794e
2021-08-31 19:06:14 +09:00
Daniel Niknam
6d883b33ae [rubygems/rubygems] Remove ruby/uri requirement
For the purpose of this class, we need to make sure the return object by `Gem::UriParser.parse_uri` method will have the following method:
- user
- user=
- password
- password=
So we  can remove the the `uri` dependency and just look for the methods to exist.

241e093597
2021-08-31 19:06:14 +09:00
Daniel Niknam
589377fbdc [rubygems/rubygems] Refactor Gem::RemoteFetcher::FetchError.build back to its initialize method
21dcdd2dc5
2021-08-31 19:06:14 +09:00
Daniel Niknam
a508693f06 [rubygems/rubygems] Remove defensive guards
dba130cd80
2021-08-31 19:06:14 +09:00
Daniel Niknam
fafd9d280a [rubygems/rubygems] Rename Gem::PrintableUri#parsed_uri? to Gem::PrintableUri#valid_uri?
a5177709c9
2021-08-31 19:06:14 +09:00
Daniel Niknam
e3c319ad53 [rubygems/rubygems] Remove trailing if
5b6b649bba
2021-08-31 19:06:14 +09:00
Daniel Niknam
3adc141a79 [rubygems/rubygems] Refactor Gem::RemoteFetcher::FetchError initializer to build method
The `initialize` method is already doing a lot and by adding the `Gem::PrintableUri` to redact sensitive information, things are getting complicated and hard to read here. For the start, I have refactored the `initialize` method into a class method called `build`.

4312e8fdf5
2021-08-31 19:06:14 +09:00
Daniel Niknam
19e1d3cdce [rubygems/rubygems] Using Gem::PrintableUri in Gem::Request class
The `@uri` variable could be a source URI with a credential. Using `Gem::PrintableUri` to make sure we are redacting sensitive information from it when logging on verbose mode.

f566787211
2021-08-31 19:06:14 +09:00
Daniel Niknam
31c2e6c08e [rubygems/rubygems] Using Gem::PrintableUri in Gem::Commands::InstallCommand class
The `x.source.uri` could be a source URI with a credential. Using `Gem::PrintableUri` to make sure we are redacting sensitive information from it.

8755ee0aaa
2021-08-31 19:06:14 +09:00
Daniel Niknam
b41802421a [rubygems/rubygems] Introduce Gem::PrintableUri that would redact URIs to be used on outputs
We need to redact URI credential in several places and copy pasting the code into each part of it is not ideal. This class is responsible for parsing URI strings and redacting credential from it. Also, it will handle URI object in the same manner. We will be reusing this class whenever we need to print/display a URI to users.
URI with the following format will be redacted:
- Token: `http://my-secure-token@example.com` => `http://REDACTED@example.com`
- Username & Password: `http://my-username:my-secure-password@example.com` => `http://my-username:REDACTED@example.com`
- x-oauth-basic: `http://my-secure-token:x-oauth-basic@example.com` => `http://REDACTED:x-oauth-basic@example.com`

f1e45d3a89
2021-08-31 19:06:14 +09:00
Daniel Niknam
f212b9d4f2 [rubygems/rubygems] Refactor Ruby platform priority condition to its own method
The `Gem::Platform::RUBY ? -1 : 1` has been used multiple times in different places and could be refactored to a method (DRY).

9d43ca8f0c
2021-08-31 19:06:14 +09:00
Daniel Niknam
c71d1a26ef [rubygems/rubygems] Pick the last founded gems when fetching metadata
e3d150d822

Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
2021-08-31 19:06:14 +09:00
David Rodríguez
54ae3f587e [rubygems/rubygems] Prefer require_relative to require for internal requires
c74fc58695
2021-08-31 19:06:14 +09:00
David Rodríguez
d01c3111c2 [rubygems/rubygems] Remove MacOS specific extra GEM_PATH
They should properly configure `GEM_PATH` instead.

3bd9ae33ca
2021-08-31 19:06:14 +09:00
David Rodríguez
afabef5a5a [rubygems/rubygems] Remove MacOS specific gem layout
MacOS should properly configure Ruby. They should not expect us to
maintain a different layout just for them.

ecad900925
2021-08-31 19:06:14 +09:00
David Rodríguez
553ee573d4 [rubygems/rubygems] Don't use gemdeps on bundler binstub
320fdc1513
2021-08-31 19:06:14 +09:00
David Rodríguez
87dfb55c16 [rubygems/rubygems] Use Gem.use_gemdeps only from binstubs
The previous behavior was to automatically require `bundler/setup`
everytime `rubygems` was required, which I think was too much.

b25379a295
2021-08-31 19:06:14 +09:00
David Rodríguez
350f4a0b66
[rubygems/rubygems] Rubygems doesn't need to load the base64 library
fe723c0f7f
2021-07-27 09:25:56 +09:00
David Rodríguez
960023ff54
[rubygems/rubygems] Rubygems doesn't need to load the resolv library
8bf41f53cc
2021-07-27 09:25:56 +09:00
David Rodríguez
9cddc0ec94
[rubygems/rubygems] Lazily load shellwords library
e5532ef886
2021-07-27 09:25:56 +09:00
Nobuyoshi Nakada
803c60858e
[rubygems/rubygems] Check requirements classes
Mitigate the security risk:
https://devcraft.io/2021/01/07/universal-deserialisation-gadget-for-ruby-2-x-3-x.html

141c2f4388
2021-07-27 09:25:56 +09:00
David Rodríguez
88e46cf6b8
[rubygems/rubygems] Remove all syck traces from rubygems
After reading [this blog
post](https://blog.rubygems.org/2011/08/31/shaving-the-yaml-yak.html),
published almost 10 years ago already, my understanding is that this
problem could come up in two ways:

* Rubygems.org serving corrupted gemspecs". As far as I understand this
was fixed in rubygems.org a lot time ago, since
https://github.com/rubygems/rubygems.org/pull/331.

* Clients having a ten years old gemspec cache with some of these bad
gemspecs. In this case, there's no easy solution but I think ten years
is enough and rebuilding the cache should do the trick.

So, I think it's time we remove this.

afcb15d556
2021-07-27 09:25:56 +09:00
Masafumi Koba
650a65c6fc
[rubygems/rubygems] Add missing require 'fileutils' in Gem::ConfigFile
c4004fadd9
2021-07-16 15:40:08 +09:00
Jared Beck
bbaebbf529
[rubygems/rubygems] Fix contradictory message about deletion of default gem
[Fixes #4733]

fce7f3eb7d
2021-07-16 15:40:07 +09:00
Hiroshi SHIBATA
896bbb9fad Merge RubyGems/Bundler master from 8459ebd6ad65ce3397233416dc64083ae7572bb9 2021-07-14 10:48:07 +09:00
Hiroshi SHIBATA
c082c6eb7c Sync RubyGems and Bundler with upstream 2021-07-07 15:31:52 +09:00
David Rodríguez
6e2240a2f9 Sync latest bundler & rubygems development version 2021-07-07 13:30:20 +09:00
David Rodríguez
59c6820971 [rubygems/rubygems] Copy files specific to testing rubygems to test
aa390a3500
2021-05-28 11:52:57 +09:00
Hiroshi SHIBATA
f7d661e783
[rubygems/rubygems] Try fix ruby-core CI
* Port
8e91b969df
from ruby-core, and make it compatible with psych 3 & 4.
2021-05-28 11:52:32 +09:00
Hiroshi SHIBATA
b314885af0 [rubygems/rubygems] Update the link of minitest code with the commit hash.
e7280f8d30
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA
32d25660b9 [rubygems/rubygems] Removed the related code for minitest-bisect
83ebdec27a
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA
9620a30b1b [rubygems/rubygems] Fixed an intentional blank-line
795b572ac2
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA
655727ee1b [rubygems/rubygems] Added comment for Minitest::Mock
ae44b68d57
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA
129bc04ab7 [rubygems/rubygems] util/rubocop -a
a10ff97830
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA
3456335a9c [rubygems/rubygems] Removed minitest/mock from test/rubygems/test_gem_remote_fetcher.rb
f1af59fe02
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA
d5237c5d10 [rubygems/rubygems] Import capture_subprocess_io from minitest
8b2ca6df3a
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA
3948be3503 [rubygems/rubygems] Use assert_path_exist and assert_path_not_exist instead of assert_path_exists and refute_path_exists
a7c93558c3
2021-05-12 17:24:43 +09:00
Hiroshi SHIBATA
cddeee21e9 [rubygems/rubygems] Use test-unit instead of minitest
a8571524ad
2021-05-12 17:24:43 +09:00
David Rodríguez
5b0abba931 Sync bundler & rubygems 2021-05-11 11:29:41 +09:00
Hiroshi SHIBATA
96741765d8 Merge the master branch of RubyGems 2021-04-15 15:36:15 +09:00
David Rodríguez
53468cc111 Sync latest development version of bundler & rubygems 2021-03-08 13:47:35 +09:00
Nobuyoshi Nakada
fd6d5c803a Clear each test own temporary directories 2021-01-25 12:51:18 +09:00
Nobuyoshi Nakada
30f11e73c4
Revert "Remove temporary directory properly"
This reverts commit 80bad36989,
because a few CI machines fail continuously.
2021-01-24 23:26:11 +09:00
Nobuyoshi Nakada
80bad36989 Remove temporary directory properly
For each `make check`, rubygems test makes "tmp" directory and
some "gem_generate_index..." directories remain there.

* Do not create a (fixed name) directory in the current working
  directory
* Should remove its own temporary directory
2021-01-24 19:30:02 +09:00
Gannon McGibbon
1def8a6004 [rubygems/rubygems] Replace "iff" with "whether" and "if and only if"
iff means if and only if, but readers without that knowledge might
assume this to be a spelling mistake. To me, this seems like
exclusionary language that is unnecessary. Simply using "if and only if"
or "whether" should suffice.

88318ebc6d
2021-01-23 09:50:47 +09:00