aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_tempfile.rb
Commit message (Collapse)AuthorAgeFilesLines
* Warn on access/modify of $SAFE, and remove effects of modifying $SAFEJeremy Evans2019-11-181-11/+0
| | | | | | | | | | | | | | | | | This removes the security features added by $SAFE = 1, and warns for access or modification of $SAFE from Ruby-level, as well as warning when calling all public C functions related to $SAFE. This modifies some internal functions that took a safe level argument to no longer take the argument. rb_require_safe now warns, rb_require_string has been added as a version that takes a VALUE and does not warn. One public C function that still takes a safe level argument and that this doesn't warn for is rb_eval_cmd. We may want to consider adding an alternative method that does not take a safe level argument, and warn for rb_eval_cmd.
* Fix tests for CVE-2018-6914Nobuyoshi Nakada2019-10-291-37/+27
| | | | | | | | | Since the current working directory is not involved in `Tempfile` and `Dir.mktmpdir` (except for the last resort), it is incorrect to derive the traversal path from it. Also, since the rubyspec temporary directory is created under the build directory, this is not involved in the target method. Fixed sporadic errors in test-spec.
* Fix keyword argument warnings in the tests from Class#newJeremy Evans2019-09-061-2/+2
| | | | This were previously hidden because calls from C were not warned.
* Windows simply causes an error to open invalid pathNAKAMURA Usaku2019-05-011-1/+19
|
* Failed to unlink before close on mswinkazu2018-07-111-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/test_{tempfile,tmpdir}: get rid of leftover filesnormal2018-07-111-1/+4
| | | | | | I ran out of inodes in $TMPDIR git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use `&.` instead of modifier if and remove needless closed?kazu2018-06-111-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/test_tempfile.rb (test_{new,create}_traversal_dir): should not assume `t`usa2018-04-041-2/+2
| | | | | | | | is always set. if `t` is nil, `NoMethodError` will be raised and the real cause will be hidden. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/test_tempfile.rb: close a file object created by Tempfile.createmame2018-04-041-1/+3
| | | | | | To stop a "Leaked file descriptor" warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Ignore file separator from tmpfile/tmpdir name.hsbt2018-03-281-1/+27
| | | | | | From: SHIBATA Hiroshi <hsbt@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* `$SAFE` as a process global state. [Feature #14250]ko12017-12-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * vm_core.h (rb_vm_t): move `rb_execution_context_t::safe_level` to `rb_vm_t::safe_level_` because `$SAFE` is a process (VM) global state. * vm_core.h (rb_proc_t): remove `rb_proc_t::safe_level` because `Proc` objects don't need to keep `$SAFE` at the creation. Also make `is_from_method` and `is_lambda` as 1 bit fields. * cont.c (cont_restore_thread): no need to keep `$SAFE` for Continuation. * eval.c (ruby_cleanup): use `rb_set_safe_level_force()` instead of access `vm->safe_level_` directly. * eval_jump.c: End procs `END{}` doesn't keep `$SAFE`. * proc.c (proc_dup): removed and introduce `rb_proc_dup` in vm.c. * safe.c (rb_set_safe_level): don't check `$SAFE` 1 -> 0 changes. * safe.c (safe_setter): use `rb_set_safe_level()`. * thread.c (rb_thread_safe_level): `Thread#safe_level` returns `$SAFE`. It should be obsolete. * transcode.c (load_transcoder_entry): `rb_safe_level()` only returns 0 or 1 so that this check is not needed. * vm.c (vm_proc_create_from_captured): don't need to keep `$SAFE` for Proc. * vm.c (rb_proc_create): renamed to `proc_create`. * vm.c (rb_proc_dup): moved from proc.c. * vm.c (vm_invoke_proc): do not need to set and restore `$SAFE` for `Proc#call`. * vm_eval.c (rb_eval_cmd): rename a local variable to represent clearer meaning. * lib/drb/drb.rb: restore `$SAFE`. * lib/erb.rb: restore `$SAFE`, too. * test/lib/leakchecker.rb: check `$SAFE == 0` at the end of tests. * test/rubygems/test_gem.rb: do not set `$SAFE = 1`. * bootstraptest/test_proc.rb: catch up this change. * spec/ruby/optional/capi/string_spec.rb: ditto. * test/bigdecimal/test_bigdecimal.rb: ditto. * test/fiddle/test_func.rb: ditto. * test/fiddle/test_handle.rb: ditto. * test/net/imap/test_imap_response_parser.rb: ditto. * test/pathname/test_pathname.rb: ditto. * test/readline/test_readline.rb: ditto. * test/ruby/test_file.rb: ditto. * test/ruby/test_optimization.rb: ditto. * test/ruby/test_proc.rb: ditto. * test/ruby/test_require.rb: ditto. * test/ruby/test_thread.rb: ditto. * test/rubygems/test_gem_specification.rb: ditto. * test/test_tempfile.rb: ditto. * test/test_tmpdir.rb: ditto. * test/win32ole/test_win32ole.rb: ditto. * test/win32ole/test_win32ole_event.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove unnecessary `require 'thread'`kazu2017-10-081-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Of course, opened file is not able to unlink on Windowsusa2017-05-191-0/+1
| | | | | | | | * test/test_tempfile.rb (test_create_with_block): close the tempfile before unlink. fixed a failure on Windows introduced at r58791. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* tempfile.rb: remove in Tempfile.createnobu2017-05-191-0/+6
| | | | | | | * lib/tempfile.rb (Tempfile.create): should not fail even if the temporary file has been removed in the block, just ignore. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix bug of Tempfile#size if nothing is written [Bug #13198]glass2017-03-141-0/+7
| | | | | | | | * lib/tempfile.rb (Tempfile#size): Fix its behavior when nothing is written. Tempfile#size should return 0 in this case. The patch is from nobu <nobu@ruby-lang.org>. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* leakchecker.rb: get rid of uninitialized Tempfilenobu2017-01-271-0/+4
| | | | | | | | * test/lib/leakchecker.rb (LeakChecker#find_tempfiles): get rid of errors on uninitialized Tempfile, which can be left when Dir.tmpdir failed or by Tempfile.allocate. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/tempfile.rb: Specify frozen_string_literal: true.kazu2017-01-211-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/tempfile.rb: provide default basename parametersonots2016-09-261-0/+9
| | | | | | | for Tempfile.create. [Feature #11965] Patch by Yuki Kurihara * test/test_tempfile.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use qualified namesnobu2016-08-301-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_tempfile.rb: use assert_filenobu2016-01-081-4/+4
| | | | | | | * test/test_tempfile.rb (test_create_with{,out}_block): use assert_file for descriptive failure messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add frozen_string_literal: false for all filesnaruse2015-12-161-0/+1
| | | | | | When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_tempfile.rb: use assert_predicatenobu2015-05-311-4/+4
| | | | | | | * test/test_tempfile.rb: use assert_predicate and assert_not_predicate for better failure messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_tempfile.rb: use assert_filenobu2015-05-311-5/+5
| | | | | | | * test/test_tempfile.rb: use assert_file for better failure messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/tempfile.rb (Remover#call): fixed wrong condition introduced atusa2015-05-301-1/+1
| | | | | | | r50682. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/test_tempfile.rb: use assert_file for more descriptive message.ayumin2015-01-041-5/+5
| | | | | | following r49131. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_tempfile.rb: assert_filenobu2015-01-041-1/+1
| | | | | | | * test/test_tempfile.rb (test_default_basename): use assert_file for more descriptive message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/tempfile.rb: provide default basename parameter.hsbt2015-01-041-0/+5
| | | | | | | [fix GH-523] Patch by @dissolved * test/test_tempfile.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/lib/envutil.rb: Moved from test/ruby/.akr2014-11-131-1/+0
| | | | | | | | | | | | | | * test/lib/find_executable.rb: Ditto. * test/lib/memory_status.rb: Ditto. * test/lib/test/unit.rb: require envutil. * test/: Don't require envutil in test files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* tempfile.rb: fix r47655nobu2014-09-211-0/+1
| | | | | | | | | | | | * lib/tempfile.rb (Tempfile#initialize, Tempfile.create): get rid of shadowing local variables. * lib/tmpdir.rb (Dir::Tmpname#make_tmpname): simlify argument splitting. * test/test_tempfile.rb: need thread library for ConditionVariable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_tempfile.rb: suppress warningsnobu2013-11-211-2/+1
| | | | | | | | | | * test/test_tempfile.rb (test_tempfile_is_unlinked_when_ruby_exits): no error should emit. * test/test_tempfile.rb (test_tempfile_encoding_ascii8bit): remove unused variable. * test/test_tempfile.rb (test_tempfile_encoding_ascii8bit2): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_tempfile.rb: fix test on Windowsnobu2013-10-061-0/+1
| | | | | | | * test/test_tempfile.rb (test_tempfile_finalizer_does_not_run_if_unlinked): open file cannot be deleted on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* tempfile.rb: undefine finalizer on unlinknobu2013-10-011-0/+14
| | | | | | | | * lib/tempfile.rb (Tempfile#unlink): finalizer is no longer needed after unlinking. patched by by normalperson (Eric Wong) at [ruby-core:56521] [Bug #8768] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/tempfile.rb (Tempfile.create): New method.akr2013-04-201-0/+21
| | | | | | | | | The method name is proposed by Shugo Maeda. [ruby-dev:47220] [ruby-core:41478] [Feature #5707] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/test_tempfile.rb: simply ignore platform depedent testcasesusa2011-04-041-8/+4
| | | | | | | instead of skipping. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/etc/etc.c (etc_systmpdir): assume system default tmpdirnobu2010-09-091-0/+4
| | | | | | safe. [ruby-dev:42089] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/test_tempfile.rb: skip some tests on Windows because unlinking is alwaysusa2010-05-261-0/+4
| | | | | | | delayed till closed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/test_tempfile.rb: fixed errors.nobu2010-05-011-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/tempfile.rb (Tempfile#size): stat by path name when it isnobu2010-05-011-8/+8
| | | | | | closed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/tempfile.rb (Tempfile#open): re-open with same mode andnobu2010-03-291-0/+2
| | | | | | options as initialize. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/tempfile.rb (Tempfile#initialize): option hash may not benobu2009-11-111-3/+17
| | | | | | | given. [ruby-core:26681] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/test_tempfile.rb: merged from Hongli Lai's fork.nobu2009-08-261-4/+257
| | | | | | | cf [ruby-core:25131]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add test for encoding option.xibbar2008-10-181-0/+21
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add tests.akr2008-01-071-0/+14
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e