box icon indicating copy to clipboard operation
box copied to clipboard

/tmp/box gets wiped without a confirmation or a warning

Open sanmai opened this issue 4 years ago • 3 comments

Bug report

Question Answer
Box version 3.8.0@e7d8df3
PHP version 7.3.8-1
Platform with version Linux
Github Repo n/a

I had a directory I created for my own purposes named /tmp/box (I've mounted an external drive there by occasion also named "box", hence the directory to mount it). Next I start unit tests for the box itself, only to find moments later that my external drive was made sparkling clean. Empty just like new. I had my backups, but if I didn't, that's will be very painful.

Box should not delete files it does not own and create during either normal functioning or testing, or even better - not to write to an existing directory by means of using a temporary directory with a random name.

sanmai avatar Sep 23 '19 06:09 sanmai

Steps to reproduce:

cd /tmp
git clone --depth=1 https://github.com/humbug/box
cd box/
composer install
./vendor/phpunit/phpunit/phpunit

Expected output: no error.

Actual output:

PHP Fatal error:  Uncaught Error: Class 'PHPUnit\Framework\Error\Warning' not found in /tmp/box/vendor/phpunit/phpunit/src/Util/ErrorHandler.php:101

The last tests were:

Test 'KevinGH\Box\Compactor\PlaceholderTest::test_it_is_serializable' started
Test 'KevinGH\Box\Compactor\PlaceholderTest::test_it_is_serializable' ended
Test 'KevinGH\Box\Composer\ComposerConfigurationTest::test_it_returns_an_empty_list_when_trying_to_retrieve_the_list_of_dev_packages_when_no_composer_json_file_is_found with data set #0 (true)' started

sanmai avatar Sep 23 '19 07:09 sanmai

How would you determine that the directory was created by Box itself or someone else? The offending code is here.

Maybe I can just change box to something else, but I originally wanted to keep it recognisable to easily know what were the tmp files created by the tests

theofidry avatar Sep 23 '19 07:09 theofidry

One option is to don't clean up. It'll get cleaned anyway by a reboot or something.

Other option is only to remove files matching the pattern which make_tmp_dir uses.

sanmai avatar Sep 23 '19 08:09 sanmai