Update composer dependencies

This commit is contained in:
Kijin Sung 2021-04-30 19:57:32 +09:00
parent f99b38192b
commit 49dde388fe
163 changed files with 1765 additions and 5676 deletions

View file

@ -20,8 +20,11 @@ use Symfony\Component\Process\PhpProcess;
*/
class CaBundle
{
/** @var string|null */
private static $caPath;
/** @var array<string, bool> */
private static $caFileValidity = array();
/** @var bool|null */
private static $useOpensslParse;
/**
@ -68,7 +71,6 @@ class CaBundle
}
$caBundlePaths = array();
// If SSL_CERT_FILE env variable points to a valid certificate/bundle, use that.
// This mimics how OpenSSL uses the SSL_CERT_FILE env variable.
$caBundlePaths[] = self::getEnvVariable('SSL_CERT_FILE');
@ -102,11 +104,11 @@ class CaBundle
$caBundlePaths = array_merge($caBundlePaths, $otherLocations);
foreach ($caBundlePaths as $caBundle) {
if (self::caFileUsable($caBundle, $logger)) {
if ($caBundle && self::caFileUsable($caBundle, $logger)) {
return self::$caPath = $caBundle;
}
if (self::caDirUsable($caBundle)) {
if ($caBundle && self::caDirUsable($caBundle)) {
return self::$caPath = $caBundle;
}
}
@ -128,8 +130,13 @@ class CaBundle
// cURL does not understand 'phar://' paths
// see https://github.com/composer/ca-bundle/issues/10
if (0 === strpos($caBundleFile, 'phar://')) {
$tempCaBundleFile = tempnam(sys_get_temp_dir(), 'openssl-ca-bundle-');
if (false === $tempCaBundleFile) {
throw new \RuntimeException('Could not create a temporary file to store the bundled CA file');
}
file_put_contents(
$tempCaBundleFile = tempnam(sys_get_temp_dir(), 'openssl-ca-bundle-'),
$tempCaBundleFile,
file_get_contents($caBundleFile)
);
@ -173,9 +180,16 @@ class CaBundle
}
$isValid = !empty($contents);
} else {
} elseif (is_string($contents) && strlen($contents) > 0) {
$contents = preg_replace("/^(\\-+(?:BEGIN|END))\\s+TRUSTED\\s+(CERTIFICATE\\-+)\$/m", '$1 $2', $contents);
$isValid = (bool) openssl_x509_parse($contents);
if (null === $contents) {
// regex extraction failed
$isValid = false;
} else {
$isValid = (bool) openssl_x509_parse($contents);
}
} else {
$isValid = false;
}
if ($logger) {
@ -210,7 +224,7 @@ class CaBundle
if (
(PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50328)
|| (PHP_VERSION_ID < 50500 && PHP_VERSION_ID >= 50423)
|| (PHP_VERSION_ID < 50600 && PHP_VERSION_ID >= 50507)
|| PHP_VERSION_ID >= 50507
) {
// This version of PHP has the fix for CVE-2013-6420 applied.
return self::$useOpensslParse = true;
@ -277,7 +291,8 @@ EOT;
$errorOutput = trim($process->getErrorOutput());
if (
count($output) === 3
is_array($output)
&& count($output) === 3
&& $output[0] === sprintf('string(%d) "%s"', strlen(PHP_VERSION), PHP_VERSION)
&& $output[1] === 'string(27) "stefan.esser@sektioneins.de"'
&& $output[2] === 'int(-1)'
@ -292,6 +307,7 @@ EOT;
/**
* Resets the static caches
* @return void
*/
public static function reset()
{
@ -300,6 +316,10 @@ EOT;
self::$useOpensslParse = null;
}
/**
* @param string $name
* @return string|false
*/
private static function getEnvVariable($name)
{
if (isset($_SERVER[$name])) {
@ -313,11 +333,19 @@ EOT;
return false;
}
/**
* @param string|false $certFile
* @return bool
*/
private static function caFileUsable($certFile, LoggerInterface $logger = null)
{
return $certFile && @is_file($certFile) && @is_readable($certFile) && static::validateCaFile($certFile, $logger);
}
/**
* @param string|false $certDir
* @return bool
*/
private static function caDirUsable($certDir)
{
return $certDir && @is_dir($certDir) && @is_readable($certDir) && glob($certDir . '/*');