mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-29 21:48:45 +02:00
N°8017 - Security - dependabot - Symfony's VarDumper vulnerable to un… (#731)
Upgrade all Symfony components to last security fix (~6.4.0)
This commit is contained in:
@@ -46,7 +46,7 @@ class Filesystem
|
||||
$this->mkdir(\dirname($targetFile));
|
||||
|
||||
$doCopy = true;
|
||||
if (!$overwriteNewerFiles && null === parse_url($originFile, \PHP_URL_HOST) && is_file($targetFile)) {
|
||||
if (!$overwriteNewerFiles && !parse_url($originFile, \PHP_URL_HOST) && is_file($targetFile)) {
|
||||
$doCopy = filemtime($originFile) > filemtime($targetFile);
|
||||
}
|
||||
|
||||
@@ -74,6 +74,9 @@ class Filesystem
|
||||
// Like `cp`, preserve executable permission bits
|
||||
self::box('chmod', $targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
|
||||
|
||||
// Like `cp`, preserve the file modification time
|
||||
self::box('touch', $targetFile, filemtime($originFile));
|
||||
|
||||
if ($bytesCopied !== $bytesOrigin = filesize($originFile)) {
|
||||
throw new IOException(sprintf('Failed to copy the whole content of "%s" to "%s" (%g of %g bytes copied).', $originFile, $targetFile, $bytesCopied, $bytesOrigin), 0, null, $originFile);
|
||||
}
|
||||
@@ -131,7 +134,7 @@ class Filesystem
|
||||
*
|
||||
* @throws IOException When touch fails
|
||||
*/
|
||||
public function touch(string|iterable $files, int $time = null, int $atime = null)
|
||||
public function touch(string|iterable $files, ?int $time = null, ?int $atime = null)
|
||||
{
|
||||
foreach ($this->toIterable($files) as $file) {
|
||||
if (!($time ? self::box('touch', $file, $time, $atime) : self::box('touch', $file))) {
|
||||
@@ -169,7 +172,7 @@ class Filesystem
|
||||
}
|
||||
} elseif (is_dir($file)) {
|
||||
if (!$isRecursive) {
|
||||
$tmpName = \dirname(realpath($file)).'/.'.strrev(strtr(base64_encode(random_bytes(2)), '/=', '-_'));
|
||||
$tmpName = \dirname(realpath($file)).'/.!'.strrev(strtr(base64_encode(random_bytes(2)), '/=', '-!'));
|
||||
|
||||
if (file_exists($tmpName)) {
|
||||
try {
|
||||
@@ -198,7 +201,7 @@ class Filesystem
|
||||
|
||||
throw new IOException(sprintf('Failed to remove directory "%s": ', $file).$lastError);
|
||||
}
|
||||
} elseif (!self::box('unlink', $file) && (str_contains(self::$lastError, 'Permission denied') || file_exists($file))) {
|
||||
} elseif (!self::box('unlink', $file) && ((self::$lastError && str_contains(self::$lastError, 'Permission denied')) || file_exists($file))) {
|
||||
throw new IOException(sprintf('Failed to remove file "%s": ', $file).self::$lastError);
|
||||
}
|
||||
}
|
||||
@@ -230,6 +233,10 @@ class Filesystem
|
||||
/**
|
||||
* Change the owner of an array of files or directories.
|
||||
*
|
||||
* This method always throws on Windows, as the underlying PHP function is not supported.
|
||||
*
|
||||
* @see https://www.php.net/chown
|
||||
*
|
||||
* @param string|int $user A user name or number
|
||||
* @param bool $recursive Whether change the owner recursively or not
|
||||
*
|
||||
@@ -258,6 +265,10 @@ class Filesystem
|
||||
/**
|
||||
* Change the group of an array of files or directories.
|
||||
*
|
||||
* This method always throws on Windows, as the underlying PHP function is not supported.
|
||||
*
|
||||
* @see https://www.php.net/chgrp
|
||||
*
|
||||
* @param string|int $group A group name or number
|
||||
* @param bool $recursive Whether change the group recursively or not
|
||||
*
|
||||
@@ -530,7 +541,7 @@ class Filesystem
|
||||
*
|
||||
* @throws IOException When file type is unknown
|
||||
*/
|
||||
public function mirror(string $originDir, string $targetDir, \Traversable $iterator = null, array $options = [])
|
||||
public function mirror(string $originDir, string $targetDir, ?\Traversable $iterator = null, array $options = [])
|
||||
{
|
||||
$targetDir = rtrim($targetDir, '/\\');
|
||||
$originDir = rtrim($originDir, '/\\');
|
||||
@@ -683,11 +694,15 @@ class Filesystem
|
||||
throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
|
||||
}
|
||||
|
||||
self::box('chmod', $tmpFile, file_exists($filename) ? fileperms($filename) : 0666 & ~umask());
|
||||
self::box('chmod', $tmpFile, self::box('fileperms', $filename) ?: 0666 & ~umask());
|
||||
|
||||
$this->rename($tmpFile, $filename, true);
|
||||
} finally {
|
||||
if (file_exists($tmpFile)) {
|
||||
if ('\\' === \DIRECTORY_SEPARATOR && !is_writable($tmpFile)) {
|
||||
self::box('chmod', $tmpFile, self::box('fileperms', $tmpFile) | 0200);
|
||||
}
|
||||
|
||||
self::box('unlink', $tmpFile);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user