Commit graph

15017 commits

Author SHA1 Message Date
Hiroshi SHIBATA
55cd3e4ebf Removed dbm from ruby repo 2021-05-25 15:18:31 +09:00
Hiroshi SHIBATA
ab3266ea5c Removed tracer from ruby repo 2021-05-25 13:13:52 +09:00
aycabta
f57968e329 Set USE_COLORIZE to the default value in a test 2021-05-24 12:13:46 +09:00
jethrodaniel
d06d4560a1 [ruby/irb] update test/irb/test_init.rb to avoid useless eval
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

2dfdc031ec
2021-05-24 11:56:05 +09:00
Mark Delk
b8ffb1c46f [ruby/irb] respect NO_COLOR environment variable
When `NO_COLOR` is set to any non-nil value, output is not colorized.

See https://no-color.org/

401d0916fe
2021-05-24 11:55:58 +09:00
aycabta
c264d30261 Use YAML.safe_load to use the permitted_classes option 2021-05-21 21:45:03 +09:00
Nobuyoshi Nakada
c4162a4cb8
Refined portability of test for [Bug #17739]
The order of arguments to callback of qsort is not defined.
That means `a` may not be 3 at all.
2021-05-22 14:34:23 +09:00
Jeremy Evans
8b00bfb7c2
Do not allow array modifications after freeze inside sort!
If freezing an array inside sort!, previously the array could be
modified after the freeze.  This checks whether the receiver is
frozen after every yield and potential call to #> or #<,
preventing modifications if the receiver is frozen inside the
block or by the #> or #< call.

Fixes [Bug #17739]
2021-05-21 18:33:56 -07:00
Alan Wu
b2fc592c30
Build CDHASH properly when loading iseq from binary
Before this change, CDHASH operands were built as plain hashes when
loaded from binary. Without setting up the hash with the correct
st_table type, the hash can sometimes be an ar_table. When the hash is
an ar_table, lookups can call the `eql?` method on keys of the hash,
which makes the `opt_case_dispatch` instruction not "leaf" as it
implicitly declares.

The following script trips the stack canary for checking the leaf
attribute for `opt_case_dispatch` on VM_CHECK_MODE > 0 (enabled by
default with RUBY_DEBUG).

    rb_vm_iseq = RubyVM::InstructionSequence

    iseq = rb_vm_iseq.compile(<<-EOF)
      case Class.new(String).new("foo")
      when "foo"
        42
      end
    EOF

    puts rb_vm_iseq.load_from_binary(iseq.to_binary).eval

This commit changes the binary loading logic to build CDHASH with the
right st_table type. The dumping logic and the dump format stays the
same
2021-05-21 12:13:55 -04:00
Alan Wu
636d4f7eb9 Avoid setting the visibility of refinement method entries
Since refinement search is always performed, these entries should always
be public. The method entry that the refinement search returns decides
the visibility.

Fixes [Bug #17822]
2021-05-21 12:12:31 -04:00
Nobuyoshi Nakada
50a534a152 ripper: wrap endless method in bodystmt [Bug #17869] 2021-05-21 18:28:24 +09:00
Nobuyoshi Nakada
050bb06e66 ripper: assertions for rescue/ensure in method body 2021-05-21 18:28:24 +09:00
Nobuyoshi Nakada
e9974a466a
Get rid of sporadic WSAEACCES on Windows [ruby-dev:42661] 2021-05-21 18:26:07 +09:00
Koichi Sasada
817764bd82 simple rescue+while+break should not use throw
609de71f04 fixes the issue by using
`throw` insn if `ensure` is used. However, that patch introduce
additional `throw` even if it is not needed. This patch solves
the issue.

This issue is pointed by @mame.
2021-05-21 18:12:14 +09:00
Nobuyoshi Nakada
59b327aa58
[ruby/rdoc] Drop support for Ruby 2.4
f480b970cc
2021-05-21 15:53:34 +09:00
Nobuyoshi Nakada
f18a0b7654
[ruby/rdoc] Follow-up rubygems
Use test-unit assertions instead of minitest.

d6a6209d7f
2021-05-21 15:53:34 +09:00
Nobuyoshi Nakada
10e63f3f56
[ruby/rdoc] Vertical-bar is disallowed in path names on Windows
No risk of remote code execution, when the file cannot be created.

2565343916 (step):5:58
```
Error: test_remove_unparseable_CVE_2021_31799(TestRDocRDoc): Errno::EINVAL: Invalid argument @ utime_failed - | touch evil.txt && echo tags
D:/rubyinstaller-head-x64/lib/ruby/3.1.0/fileutils.rb:1142:in `utime'
D:/rubyinstaller-head-x64/lib/ruby/3.1.0/fileutils.rb:1142:in `block in touch'
D:/rubyinstaller-head-x64/lib/ruby/3.1.0/fileutils.rb:1139:in `each'
D:/rubyinstaller-head-x64/lib/ruby/3.1.0/fileutils.rb:1139:in `touch'
D:/a/rdoc/rdoc/test/rdoc/test_rdoc_rdoc.rb:463:in `block (2 levels) in test_remove_unparseable_CVE_2021_31799'
     460:     temp_dir do
     461:       file_list = ['| touch evil.txt && echo tags']
     462:       file_list.each do |f|
  => 463:         FileUtils.touch f
     464:       end
     465:
     466:       assert_equal file_list, @rdoc.remove_unparseable(file_list)
```

a7df7dc8fa
2021-05-21 15:53:34 +09:00
Nobuyoshi Nakada
a298bdf860
[ruby/rdoc] Dir.children is 2.5+
RDoc seems still supporting outdated 2.4.

2565344070 (step):5:64
```
Error: test_remove_unparseable_CVE_2021_31799(TestRDocRDoc): NoMethodError: undefined method `children' for Dir:Class
/home/runner/work/rdoc/rdoc/test/rdoc/test_rdoc_rdoc.rb:467:in `block in test_remove_unparseable_CVE_2021_31799'
     464:       end
     465:
     466:       assert_equal file_list, @rdoc.remove_unparseable(file_list)
  => 467:       assert_equal file_list, Dir.children('.')
     468:     end
     469:   end
     470:
```

5a4a64dc0f
2021-05-21 15:53:34 +09:00
aycabta
b1c73f239f [ruby/rdoc] Use File.open to fix the OS Command Injection vulnerability in CVE-2021-31799
a7f5d6ab88
2021-05-21 13:42:24 +09:00
Nobuyoshi Nakada
c711093559 Get rid of sporadic WSAEACCES on Windows [ruby-dev:42661] 2021-05-20 21:56:58 +09:00
Yusuke Endoh
5026f9a5d5 compile.c: stop the jump-jump optimization if the second has any event
Fixes [Bug #17868]
2021-05-20 19:13:39 +09:00
Hiroshi SHIBATA
adcbae8d49
Removed minitest/mock 2021-05-19 14:24:01 +09:00
Yusuke Endoh
ceea1ea8af test/rubygems/test_gem_commands_open_command.rb: prevent a warning
20210518T093002Z.log.html.gz
```
[ 9396/21186] TestGemCommandsOpenCommand#test_execute-e:1: warning: possibly useless use of a literal in void context
 = 0.06 s
```
2021-05-18 19:06:48 +09:00
Yusuke Endoh
837cbea64b test/psych/test_coder.rb: Suppress non-parenthesis warnings
20210518T093002Z.log.html.gz
```
/home/chkbuild/chkbuild/tmp/build/20210518T093002Z/ruby/test/psych/test_coder.rb:277: warning: ambiguity between regexp and two divisions: wrap regexp in parentheses or add a space after `/' operator
```
2021-05-18 19:01:27 +09:00
Nobuyoshi Nakada
34bc8210ed
test/irb/test_raise_no_backtrace_exception.rb: fix test file path
Create a file for test under the temporary directory.
2021-05-18 16:04:37 +09:00
Jeremy Evans
2579593a56 [ruby/fiddle] Do not use a libdir for glibc, it breaks Linux PPC64 (#70)
Fixes [Bug #12666]

a267a40be7
2021-05-18 12:48:40 +09:00
Sutou Kouhei
ab5212b3c9 [ruby/fiddle] Add support for "const" in type
GitHub: fix #68

Reported by kojix2. Thanks!!!

d7322c234a
2021-05-18 12:48:40 +09:00
Sutou Kouhei
881b2dc898 [ruby/fiddle] closure: add support for const char *
GitHub: fix GH-62

Reported by Cody Krieger. Thanks!!!

284b820f2d
2021-05-18 12:48:40 +09:00
Sutou Kouhei
b2de5999d8 [ruby/fiddle] closure: accept symbol as type
dc2da6633e
2021-05-18 12:48:40 +09:00
Hiroshi SHIBATA
e36da7ba18
Revert an accidentally commits at df86a13cc1 2021-05-17 15:28:47 +09:00
Yusuke Endoh
31a757a442 Make the test pass with the old libyaml
I have no idea what result is right, but it fails with libyaml 0.1.7
(bundled with Ubuntu 18.04) anyway.
2021-05-17 14:31:34 +09:00
Yusuke Endoh
f367b4ffe7 assert_equal accepts an expected value as the first argument 2021-05-17 14:31:34 +09:00
Yusuke Endoh
ffdf0232ef lib/rdoc/rdoc.rb: Allow only RDoc::Options in .rdoc_options
Follow-up of d8fd92f620. Instead of using
unsafe_load blindly, RDoc::Options is only supposed to be allowed.
2021-05-17 12:53:42 +09:00
Hiroshi SHIBATA
d8fd92f620
Workaround with fbb4e3f96c in rdoc 2021-05-17 12:04:40 +09:00
Hiroshi SHIBATA
8e91b969df
Workaround with fbb4e3f96c 2021-05-17 12:00:05 +09:00
Yusuke Endoh
da5b283963 test/ostruct/test_ostruct.rb: Use YAML.unsafe_load instead of YAML.load
Follow-up of fbb4e3f96c
2021-05-17 11:36:16 +09:00
Aaron Patterson
42b20bdbfe
[ruby/psych] remove deprecated interface
0767227051
2021-05-17 11:20:46 +09:00
Aaron Patterson
c7c2ad5749
[ruby/psych] Introduce Psych.unsafe_load
In future versions of Psych, the `load` method will be mostly the same
as the `safe_load` method.  In other words, the `load` method won't
allow arbitrary object deserialization (which can be used to escalate to
an RCE).  People that need to load *trusted* documents can use the
`unsafe_load` method.

This commit introduces the `unsafe_load` method so that people can
incrementally upgrade.  For example, if they try to upgrade to 4.0.0 and
something breaks, they can downgrade, audit callsites, change to
`safe_load` or `unsafe_load` as required, and then upgrade to 4.0.0
smoothly.

cb50aa8d3f
2021-05-17 11:20:45 +09:00
Hiroshi SHIBATA
bcaa6aecea
[ruby/psych] Removed needless platform detection
57d704fd63
2021-05-17 11:20:45 +09:00
Hiroshi SHIBATA
df86a13cc1
[ruby/psych] Import test assertions from ruby/ruby
01dda86681
2021-05-17 11:20:45 +09:00
Jean Boussier
a3ceed50b8
[ruby/psych] Fix symabolize_name with non-string keys
1c5c29e81f
2021-05-17 11:20:45 +09:00
Jeremy Ebler
830778db95
[ruby/psych] feat: allow scalars and sequences to be styled when dumped
546154ddb7
2021-05-17 11:20:45 +09:00
Gabriel Nagy
229cb0fcdb
[Win32] long path name support [Bug #12551]
Implement long path support on Windows by applying Microsoft's
recommended application manifest.

To make this work on both Visual C++ and MinGW, include the manifest as
a resource when generating the resource files. This way it will be
embedded into the executables generated by both compilers.

It's important for the manifest resource to have ID 1, otherwise GCC
will embed a default manifest.

Note that in addition to this, the user needs to have [long paths enabled]
either by modifying the registry or by enabling a group policy.

[long paths enabled]: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd#enable-long-paths-in-windows-10-version-1607-and-later

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2021-05-17 08:33:08 +09:00
Yusuke Endoh
f210d456a8 test/objspace/test_objspace.rb: check stderr before stdout
When `require "objspace/trace"` fails, previously the failure says:
```
  1) Failure:
TestObjSpace#test_objspace_trace [/tmp/ruby/v3/src/trunk-mjit/test/objspace/test_objspace.rb:621]:
<3> expected but was
<0>.
```
but this is hard to debug.
2021-05-14 18:07:58 +09:00
Yusuke Endoh
702961a88b test/ruby/test_refinement.rb: prevent "assigned but unused variable" 2021-05-14 15:44:13 +09:00
Yusuke Endoh
cf1e1879f1 ext/objspace/lib/objspace/trace.rb: Added
This file, when require'ed, starts tracing the object allocations, and
redefines `Kernel#p` to show the allocation site.

This commit is experimental; the library name and APIs may change.

[Feature #17762]
2021-05-14 13:40:32 +09:00
Nobuyoshi Nakada
110f242ef9
Also \U after control/meta is invalid [Bug #17861]
As well as `\u`, `\U` should be invalid there too.
And highlight including `u`/`U` not only the backslash before it.
2021-05-13 12:54:56 +09:00
Jeremy Evans
9ce29c94d8 Avoid improper optimization of case statements mixed integer/rational/complex
Fixes [Bug #17857]
2021-05-12 19:30:05 -07:00
Jeremy Evans
11ae581a4a Fix handling of control/meta escapes in literal regexps
Ruby uses a recursive algorithm for handling control/meta escapes
in strings (read_escape).  However, the equivalent code for regexps
(tokadd_escape) in did not use a recursive algorithm.  Due to this,
Handling of control/meta escapes in regexp did not have the same
behavior as in strings, leading to behavior such as the following
returning nil:

```ruby
/\c\xFF/ =~ "\c\xFF"
```

Switch the code for handling \c, \C and \M in literal regexps to
use the same code as for strings (read_escape), to keep behavior
consistent between the two.

Fixes [Bug #14367]
2021-05-12 18:55:43 -07:00
Yusuke Endoh
9484f9ebdf [rubygems/rubygems] Use Time.stub :now to avoid a random failure
Essentially this reverts 45464bfcbdf9f9cfb440950bc57a27d237627a17.
The commit removed a mock of Time.now, which caused a random failure.

20210512T123004Z.fail.html.gz
```
  1) Failure:
TestGemPackageTarWriter#test_add_file_signer [/home/chkbuild/chkbuild/tmp/build/20210512T123004Z/ruby/test/rubygems/test_gem_package_tar_writer.rb:117]:
Field mtime of the tar header differs..
<"14046746312\u0000"> expected but was
<"14046746311\x00">.
```

Object#stub is defined at f1af59fe02ef2cc58f13e2742e4cc6cf8c2a1a20, so
now `Time.stub :now` works.

85f60a9ed0
2021-05-13 09:26:13 +09:00