Explorar o código

Fail hard if anything attempts to wipe the entire filesystem/partition, fixes #2409

Jordi Boggiano %!s(int64=12) %!d(string=hai) anos
pai
achega
dff5e3c542
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      src/Composer/Util/Filesystem.php

+ 4 - 0
src/Composer/Util/Filesystem.php

@@ -69,6 +69,10 @@ class Filesystem
             return true;
         }
 
+        if (preg_match('{^(?:[a-z]:)?[/\\\\]+$}i', $directory)) {
+            throw new \RuntimeException('Aborting an attempted deletion of '.$directory.', this was probably not intended, if it is a real use case please report it.');
+        }
+
         if (!function_exists('proc_open')) {
             return $this->removeDirectoryPhp($directory);
         }