summaryrefslogtreecommitdiff
path: root/test/test_tempfile.rb
AgeCommit message (Collapse)Author
2019-11-18Warn on access/modify of $SAFE, and remove effects of modifying $SAFEJeremy Evans
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. Notes: Merged: https://github.com/ruby/ruby/pull/2476
2019-10-29Fix tests for CVE-2018-6914Nobuyoshi Nakada
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.
2019-09-06Fix keyword argument warnings in the tests from Class#newJeremy Evans
This were previously hidden because calls from C were not warned. Notes: Merged: https://github.com/ruby/ruby/pull/2432
2019-05-01Windows simply causes an error to open invalid pathNAKAMURA Usaku
2018-07-11Failed to unlink before close on mswinkazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-07-11test/test_{tempfile,tmpdir}: get rid of leftover filesnormal
I ran out of inodes in $TMPDIR git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-11Use `&.` instead of modifier if and remove needless closed?kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-04-04* test/test_tempfile.rb (test_{new,create}_traversal_dir): should not assume `t`usa
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
2018-04-04test/test_tempfile.rb: close a file object created by Tempfile.createmame
To stop a "Leaked file descriptor" warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-28Ignore file separator from tmpfile/tmpdir name.hsbt
From: SHIBATA Hiroshi <hsbt@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-28`$SAFE` as a process global state. [Feature #14250]ko1
* 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
2017-10-08Remove unnecessary `require 'thread'`kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Of course, opened file is not able to unlink on Windowsusa
* 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
2017-05-19tempfile.rb: remove in Tempfile.createnobu
* 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
2017-03-14Fix bug of Tempfile#size if nothing is written [Bug #13198]glass
* 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
2017-01-27leakchecker.rb: get rid of uninitialized Tempfilenobu
* 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
2017-01-21lib/tempfile.rb: Specify frozen_string_literal: true.kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-26* lib/tempfile.rb: provide default basename parametersonots
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
2016-08-30Use qualified namesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-01-08test_tempfile.rb: use assert_filenobu
* 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
2015-12-16Add frozen_string_literal: false for all filesnaruse
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
2015-05-31test_tempfile.rb: use assert_predicatenobu
* 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
2015-05-31test_tempfile.rb: use assert_filenobu
* 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
2015-05-30* lib/tempfile.rb (Remover#call): fixed wrong condition introduced atusa
r50682. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-04* test/test_tempfile.rb: use assert_file for more descriptive message.ayumin
following r49131. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-04test_tempfile.rb: assert_filenobu
* 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
2015-01-04* lib/tempfile.rb: provide default basename parameter.hsbt
[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
2014-11-13* test/lib/envutil.rb: Moved from test/ruby/.akr
* 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
2014-09-21tempfile.rb: fix r47655nobu
* 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
2013-11-21test_tempfile.rb: suppress warningsnobu
* 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
2013-10-06test_tempfile.rb: fix test on Windowsnobu
* 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
2013-10-01tempfile.rb: undefine finalizer on unlinknobu
* 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
2013-04-20* lib/tempfile.rb (Tempfile.create): New method.akr
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
2011-04-04* test/test_tempfile.rb: simply ignore platform depedent testcasesusa
instead of skipping. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-09-09* ext/etc/etc.c (etc_systmpdir): assume system default tmpdirnobu
safe. [ruby-dev:42089] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-26* test/test_tempfile.rb: skip some tests on Windows because unlinking is alwaysusa
delayed till closed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-01* test/test_tempfile.rb: fixed errors.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-01* lib/tempfile.rb (Tempfile#size): stat by path name when it isnobu
closed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-03-29* lib/tempfile.rb (Tempfile#open): re-open with same mode andnobu
options as initialize. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27086 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-11-11* lib/tempfile.rb (Tempfile#initialize): option hash may not benobu
given. [ruby-core:26681] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-08-26* test/test_tempfile.rb: merged from Hongli Lai's fork.nobu
cf [ruby-core:25131]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-18add test for encoding option.xibbar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-07add tests.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e