Commit graph

12164 commits

Author SHA1 Message Date
Hiroshi SHIBATA
6beb755d81 [ruby/prettyprint] Expose PrettyPrint::VERSION
c6f3947e96
2023-04-14 01:52:08 +00:00
Hiroshi SHIBATA
3f8756484f [ruby/pp] Expose PP::VERSION
3d0e65e79f
2023-04-14 01:49:51 +00:00
Hiroshi SHIBATA
652f273308 [ruby/resolv] Expose Resolv::VERSION
6ab2385e89
2023-04-14 01:46:38 +00:00
Hiroshi SHIBATA
ebe620def6 [ruby/securerandom] Expose SecureRandom::VERSION
2e6434331d
2023-04-14 01:43:47 +00:00
卜部昌平
64e503eb62 avoid seeding
OpenSSL's man page previously stated that "the application is
responsible for seeding the PRNG by calling RAND_add" (see [1]).
So we had this code.  However things changed.  They no longer
say so, instead "manual (re-)seeding of the default OpenSSL
random generator is not necessary" now (see [2]).  It seems all
OpenSSL versions that we support now already behaves like this.
Let's follow that.

[1]: https://www.openssl.org/docs/man1.0.2/man3/RAND_add.html
[2]: https://www.openssl.org/docs/manmaster/man3/RAND_add.html
2023-04-13 19:50:00 +09:00
Hiroshi SHIBATA
f09638fe25 [ruby/time] Expose Time::VERSION
32793b56b7
2023-04-13 18:51:18 +09:00
Hiroshi SHIBATA
cf77f7b5e7 [ruby/time] Bump version to 0.2.2
5f080cf700
2023-04-13 18:51:18 +09:00
Hiroshi SHIBATA
8b924ebdf2 [ruby/tempfile] Expose Tempfile::VERSION
6aa1f37dc4
2023-04-13 09:49:14 +00:00
Hiroshi SHIBATA
84d11498c2 [ruby/shellwords] Expose Shellwords::VERSION
e38b8b026a
2023-04-13 09:48:55 +00:00
Hiroshi SHIBATA
61bd69470a [ruby/open-uri] Expose OpenURI::VERSION
666768d960
2023-04-13 09:47:40 +00:00
Hiroshi SHIBATA
76aaaf6434 [ruby/un] Expose UN::VERSION
47bcad1804
2023-04-13 09:47:22 +00:00
John Hawthorn
be08e1b14c RJIT: argc check in known cfuncs 2023-04-12 17:48:34 -07:00
Marcin Rozmus
c8d8207aea [rubygems/rubygems] Fix broken hyperlinks in bundle cache documentation
1ff3e7450a
2023-04-12 20:27:39 +00:00
Ashley Ellis Pierce
851344965a
Ensure api_key is sent if basic auth not provided on webauthn_verification_url
Co-authored-by: Jenny Shen <jenny.shen@shopify.com>
2023-04-12 12:00:25 +09:00
Eric Herscovich
1b1485ae4d
Add message for otp bypass
Update tests

Fix wording of message
2023-04-12 11:59:18 +09:00
Jenny Shen
b909ca94bd
Terminate interaction after wait for otp thread completes to support jruby 2023-04-12 11:58:03 +09:00
Jenny Shen
c7a8d63df8
Terminate interaction when rescuing WebauthnVerificationError during wait_for_otp
Co-authored-by: Betty Li <makewithbetty@gmail.com>
2023-04-12 11:57:43 +09:00
Jenny Shen
cd60113faa
Use Webauthn Listener in wait_for_otp 2023-04-12 11:57:15 +09:00
Jenny Shen
b6e860ba1b
Add wait for webauthn otp when fetching otp
Co-authored-by: Jacques Chester <jacques.chester@shopify.com>
2023-04-12 11:57:11 +09:00
Ashley Ellis Pierce
774d1f1a00
Merge lines 2023-04-12 11:56:33 +09:00
Jenny Shen
096f6eec3e [rubygems/rubygems] Refactor Webauthn listener response - Makes the response class a wrapper around Net::HTTPResponse - Builds a Net::HTTPResponse upon initialization - to_s returns a string representation of the response to send - Adds a Socket Responder class to send responses given a socket
7513c220b6

Co-authored-by: Jacques Chester <jacques.chester@shopify.com>
2023-04-12 11:51:07 +09:00
Jenny Shen
ef85b6de42 [rubygems/rubygems] Add access control headers for all requests to allow RubyGems.org to render the response
22b329eb60
2023-04-12 11:51:06 +09:00
Jenny Shen
353f9adccc [rubygems/rubygems] Add otp command tests
c494112063
2023-04-12 11:51:05 +09:00
Jenny Shen
6e7bf0677d [rubygems/rubygems] Add WebauthnListener class
d42ddbb73c

Co-authored-by: Ashley Ellis Pierce <anellis12@gmail.com>
Co-authored-by: Jacques Chester <jacques.chester@shopify.com>
2023-04-12 11:51:04 +09:00
Jenny Shen
354a5c646e [rubygems/rubygems] Add WebauthnVerificationError Exception
932c111f2c
2023-04-12 11:51:03 +09:00
Jenny Shen
332c4b6726 [rubygems/rubygems] Add WebauthnListener response classes
0e9a26acb1
2023-04-12 11:51:03 +09:00
Ashley Ellis Pierce
ea95ec5443 [rubygems/rubygems] Clarify message
d94173be49
2023-04-12 11:51:02 +09:00
Ashley Ellis Pierce
6275284f02 [rubygems/rubygems] Ask user to otp at webauthn verification url
004eadb0c5
2023-04-12 11:51:01 +09:00
Hiroshi SHIBATA
d89cc317c6
util/rubocop -A --only Style/NumericLiteralPrefix 2023-04-11 19:12:28 +09:00
ima1zumi
f7c8d3bf96 [ruby/irb] Bump version to 1.6.4
(https://github.com/ruby/irb/pull/560)

01328da9b6
2023-04-09 13:44:12 +00:00
Kasumi Hanazuki
957595f218 [ruby/resolv] Do not compress domain name in SRV RDATA
[RFC2782] prohibits use of name compression for the target host name
in the RDATA of a SRV record.

[RFC2782]: https://datatracker.ietf.org/doc/rfc2782/

Closes: https://github.com/ruby/resolv/issues/29

ac85724e17
2023-04-08 14:16:59 +00:00
Stan Lo
e7f77e1e89 [ruby/irb] Simplify command method definition
(https://github.com/ruby/irb/pull/559)

* Remove unnecessary command argument generation code

Now that all the supported Ruby versions handle splat args and splat kwargs,
we don't need that args generation code anymore.

* Remove unused command definition code

If we look at `@EXTEND_COMMANDS`, all commands are defined in a file, which
means the `if load_file` branch is always executed. Therefore we can drop
the else branch of that condition.

* Avoid defining unnecessary command methods

There's no need to define another command method just to call `Command.execute`.
2023-04-08 10:11:50 +00:00
David Rodríguez
4df7c3946a [rubygems/rubygems] Remove one fallback to full indexes on big gemfiles
If Gemfile has a lot of dependencies, we have an optimization that uses
the full index in that case, assuming it's going to be faster.

I think this is an old optimization that predates compact index API
times, I believe we no longer need it these days.

Also, since a few releases ago we check for circular dependencies when
resolving by looping through all versions of each name and removing
those that have circular dependencies that would trip up the resolver.

This loop becomes actually very slow when full indexes are used because
to find dependencies of a gemspec, we need to explicitly fetch the
marshaled gemspec (`gemspec.rz` endpoint) for it, so the optimization
has the opposite effect of making things very slow.

2f46289bd3
2023-04-07 13:53:00 +00:00
Hiroshi SHIBATA
250e97c0fb [rubygems/rubygems] util/rubocop -A --only Style/FormatString
132a56569d
2023-04-07 05:13:05 +00:00
Hiroshi SHIBATA
fb822076d7 [rubygems/rubygems] util/rubocop -A --only Style/LineEndConcatenation
67ece7b8b6
2023-04-06 23:33:20 +00:00
Hiroshi SHIBATA
70371aa071
Revert accidentally commit of wrong file
Revert "[ruby/syntax_suggest] Remove unnecessary `--color` option"

  This reverts commit 588dd44d41.
2023-04-06 16:30:00 +09:00
schneems
7ab640d9dd
v1.0.4 2023-04-06 15:49:26 +09:00
schneems
8d72d6159c
v1.0.3
Fix a CI error and add a test to ensure we're testing the current version:

```
Run bundle exec rake test
bundler: failed to load command: rake (/home/runner/work/syntax_suggest/syntax_suggest/vendor/bundle/ruby/3.2.0/bin/rake)
/opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:309:in `check_for_activated_spec!': You have already activated syntax_suggest 1.0.2, but your Gemfile requires syntax_suggest 1.0.3. Since syntax_suggest is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports syntax_suggest as a default gem. (Gem::LoadError)
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:25:in `block in setup'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/spec_set.rb:138:in `each'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/spec_set.rb:138:in `each'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:24:in `map'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/runtime.rb:24:in `setup'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler.rb:151:in `setup'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/setup.rb:20:in `block in <top (required)>'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/ui/shell.rb:136:in `with_level'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/ui/shell.rb:88:in `silence'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/setup.rb:20:in `<top (required)>'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/cli/exec.rb:56:in `require_relative'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/cli/exec.rb:56:in `kernel_load'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/cli/exec.rb:23:in `run'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/cli.rb:483:in `exec'
	from /opt/hostedtoolcache/Ruby/3.2.1/x64/lib/ruby/gems/3.2.0/gems/bundler-2.3.14/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
```
2023-04-06 15:47:04 +09:00
Yusuke Endoh
d511e6960f [ruby/syntax_suggest] The annotation must end with a new line
syntax_suggest did not work great when there is no new line at the end
of the input file.

Input:
```
def foo
end
end # No newline at end of file
```

Previous output:
```
$ ruby test.rb
test.rb: --> test.rb
Unmatched `end', missing keyword (`do', `def`, `if`, etc.) ?
> 1  def foo
> 2  end
> 3  end # No newline at end of filetest.rb:3: syntax error, unexpected `end' (SyntaxError)
end # No newline at end of file
^~~
```

Note that "test.rb:3: ..." is appended to the last line of the
annotation.

This change makes sure that the annotation ends with a new line.

New output:
```
$ ruby test.rb
test.rb: --> test.rb
Unmatched `end', missing keyword (`do', `def`, `if`, etc.) ?
> 1  def foo
> 2  end
> 3  end # No newline at end of file
test.rb:3: syntax error, unexpected `end' (SyntaxError)
end # No newline at end of file
^~~
```

db4cf9147d
2023-04-06 15:45:30 +09:00
schneems
63ea6b0cf2 [ruby/syntax_suggest] Rollback comment indentation behavior
Originally I fixed https://github.com/ruby/syntax_suggest/pull/177 by making the process of comment removal indentation aware. The next commit is the more general fix and means we don't need to carry that additional logic/overhead.

Also: Update syntax via linter
2023-04-06 15:45:29 +09:00
schneems
2acbcec056 [ruby/syntax_suggest] Add comments and refactor AroundBlockScan methods
cecd12292c
2023-04-06 15:45:29 +09:00
schneems
5487ee4fe8 [ruby/syntax_suggest] Fix sibling bug to #177
While #177 is reported as being caused by a comment, the underlying behavior is a problem due to the newline that we generated (from a comment). The prior commit fixed that problem by preserving whitespace before the comment. That guarantees that a block will form there from the frontier before it will be expanded there via a "neighbors" method. Since empty lines are valid ruby code, it will be hidden and be safe.

## Problem setup

This failure mode is not fixed by the prior commit, because the indentation is 0. To provide good results, we must make the algorithm less greedy. One heuristic/signal to follow is developer added newlines. If a developer puts a newline between code, it's more likely they're unrelated. For example:

```
port = rand(1000...9999)
stub_request(:any, "localhost:#{port}")

query = Cutlass::FunctionQuery.new(
  port: port
).call

expect(WebMock).to have_requested(:post, "localhost:#{port}").
  with(body: "{}")
```

This code is split into three chunks by the developer. Each are likely (but not guaranteed) to be intended to stand on their own (in terms of syntax). This behavior is good for scanning neighbors (same indent or higher) within a method, but bad for parsing neighbors across methods.

## Problem

Code is expanded to capture all neighbors, and then it decreases indent level which allows it to capture surrounding scope (think moving from within the method to also capturing the `def/end` definition. Once the indentation level has been increased, we go back to scanning neighbors, but now neighbors also contain keywords.

For example:

```
  1 def bark
  2
  3 end
  4
  5 def sit
  6 end
```

In this case if lines 4, 5, and 6 are in a block when it tries to expand neighbors it will expand up. If it stops after line 2 or 3 it may cause problems since there's a valid kw/end pair, but the block will be checked without it.

TLDR; It's good to stop scanning code after hitting a newline when you're in a method...it causes a problem scanning code between methods when everything inside of one of the methods is an empty line.

In this case it grabs the end on line 3 and since the problem was an extra end, the program now compiles correctly. It incorrectly assumes that the block it captured was causing the problem.

## Extra bit of context

One other technical detail is that after we've decided to stop scanning code for a new neighbor block expansion, we look around the block and grab any empty newlines. Basically adding empty newlines before of after a code block do not affect the parsing of that block.

## The fix

Since we know that this problem only happens when there's a newline inside of a method and we know this particular failure mode is due to having an invalid block (capturing an extra end, but not it's keyword) we have all the metadata we need to detect this scenario and correct it.

We know that the next line above our block must be code or empty (since we grabbed extra newlines). Same for code below it. We can count all the keywords and ends in the block. If they are balanced, it's likely (but not guaranteed) we formed the block correctly. If they're imbalanced, look above or below (depending on the nature of the imbalance), check to see if adding that line would balance the count.

This concept of balance and "leaning" comes from work in https://github.com/ruby/syntax_suggest/pull/152 and has proven useful, but not been formally introduced into the main branch.

## Outcome

Adding this extra check introduced no regressions and fixed the test case. It might be possible there's a mirror or similar problem that we're not handling. That will come out in time. It might also be possible that this causes a worse case in some code not under test. That too would come out in time.

One other possible concern to adding logic in this area (which is a hot codepath), is performance. This extra count check will be performed for every block. In general the two most helpful performance strategies I've found are reducing total number of blocks (therefore reducing overall N internal iterations) and making better matches (the parser to determine if a close block is valid or not is a major bottleneck. If we can split valid code into valid blocks, then it's only evaluated by the parser once, where as invalid code must be continuously re-checked by the parser until it becomes valid, or is determined to be the cause of the core problem.

This extra logic should very rarely result in a change, but when it does it should tend to produce slightly larger blocks (by one line) and more accurate blocks.

Informally it seems to have no impact on performance:

``
This branch:
DEBUG_DISPLAY=1 bundle exec rspec spec/ --format=failures  3.01s user 1.62s system 113% cpu 4.076 total
```

```
On main:
DEBUG_DISPLAY=1 bundle exec rspec spec/ --format=failures  3.02s user 1.64s system 113% cpu 4.098 total
```

13739c6946
2023-04-06 15:45:28 +09:00
schneems
e5236471c3 [ruby/syntax_suggest] Preserve whitespace in front of comments
When removing comments I previously replaced them with a newline. This loses some context and may affect the order of the indent search which in turn affects the final result. By preserving whitespace in front of the comment, we preserve the "natural" indentation order of the line while also allowing the parser/lexer to see and join naturally consecutive (method chain) lines.

close https://github.com/ruby/syntax_suggest/pull/177
2023-04-06 15:45:28 +09:00
schneems
33cfd262fc [ruby/syntax_suggest] Handle alias already exists when debugging
When `tmp/alias` already exists, I'm now getting phantom folders in the directory pointing at older aliases which is distracting/confusing. By checking and removing that alias before symlinking we can prevent this strange behavior (possibly caused by newer Mac OS?).
2023-04-06 15:45:27 +09:00
Nobuyoshi Nakada
588dd44d41 [ruby/syntax_suggest] Remove unnecessary --color option
It is enabled automatically if possible.  Forcing this option makes
https://github.com/rspec/rspec-core/pull/3017 useless.

8e7141b472
2023-04-06 15:45:27 +09:00
Vít Ondruch
69460791cc
[rubygems/rubygems] Improve comment explaining the neccessity of write_default_spec method.
The intention is not obvious from the commit log and it might avoid
temptation to remove the method without further consideration.

8e17c50f64
2023-04-06 13:07:16 +09:00
David Rodríguez
f3d69bed62
[rubygems/rubygems] Fix resolver hangs when dealing with an incomplete lockfile
While working on locking multiple platforms by default, I got an
infinite resolution loop in one of our resolver specs.

The culprit ended up being that when dealing with lockfile specs with
incomplete dependencies (spec appears in lockfile, but its dependencies
don't), those specs were not being properly expired and that tripped up
resolution.

The issue for some reason only manifests when dealing with multiple
lockfile platforms, that's why it only manifested when working on
locking multiple platforms by default.

4ca72913bb
2023-04-06 13:07:16 +09:00
David Rodríguez
c257380965
Revert "Refactor incomplete specs handling"
This reverts commit 69580f8b72f41c58cae57d1ada4db909922b3891.
2023-04-06 13:07:16 +09:00
David Rodríguez
192a3a6bfb
[rubygems/rubygems] Revert "Reuse SpecSet#materialize logic"
This reverts commit a20585b451.

aa9102659e
2023-04-06 13:07:16 +09:00
Stan Lo
2f8e5c80e6 [ruby/irb] Drop Ruby 2.6 support
(https://github.com/ruby/irb/pull/555)

* Remove all Ruby 2.6 support

* Drop Ruby 2.6 specific testing conditions

* Only run Ruby 2.7+ on CI

* Bump Ruby requirement to 2.7+

3f714b616c
2023-04-05 21:40:40 +00:00