diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000000..60990950bf --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,10 @@ +Security Policy +=============== + +If you found any issues that might have security implications, +please send a report to security[at]symfony.com +DO NOT PUBLISH SECURITY REPORTS PUBLICLY. + +The full [Security Policy][1] is described in the official documentation. + + [1]: https://symfony.com/security diff --git a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php index 69f8ffe777..410f202871 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php @@ -138,7 +138,7 @@ class ProfilerController $url = null; try { - $url = $this->generator->generate('_profiler', ['token' => $token]); + $url = $this->generator->generate('_profiler', ['token' => $token], UrlGeneratorInterface::ABSOLUTE_URL); } catch (\Exception $e) { // the profiler is not enabled } diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig index 69872418cf..d81e877977 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_item.html.twig @@ -1,5 +1,5 @@
- {% if link is not defined or link %}{% endif %} + {% if link is not defined or link %}{% endif %}
{{ icon|default('') }}
{% if link|default(false) %}
{% endif %}
{{ text|default('') }}
diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php index 2030d3774c..a41f6905cf 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ServiceLocatorTagPass.php @@ -108,7 +108,11 @@ final class ServiceLocatorTagPass extends AbstractRecursivePass ->setPublic(false) ->addTag('container.service_locator'); - if (!$container->has($id = '.service_locator.'.ContainerBuilder::hash($locator))) { + if (null !== $callerId && $container->hasDefinition($callerId)) { + $locator->setBindings($container->getDefinition($callerId)->getBindings()); + } + + if (!$container->hasDefinition($id = '.service_locator.'.ContainerBuilder::hash($locator))) { $container->setDefinition($id, $locator); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php index d7e5586e0a..27ee7db533 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ServiceLocatorTagPassTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; use PHPUnit\Framework\TestCase; +use Symfony\Component\DependencyInjection\Argument\BoundArgument; use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; @@ -128,4 +129,19 @@ class ServiceLocatorTagPassTest extends TestCase $this->assertSame(TestDefinition1::class, \get_class($locator('bar'))); } + + public function testBindingsAreCopied() + { + $container = new ContainerBuilder(); + + $container->register('foo') + ->setBindings(['foo' => 'foo']); + + $locator = ServiceLocatorTagPass::register($container, ['foo' => new Reference('foo')], 'foo'); + $locator = $container->getDefinition($locator); + $locator = $container->getDefinition($locator->getFactory()[0]); + + $this->assertSame(['foo'], array_keys($locator->getBindings())); + $this->assertInstanceOf(BoundArgument::class, $locator->getBindings()['foo']); + } } diff --git a/src/Symfony/Component/Finder/Iterator/SortableIterator.php b/src/Symfony/Component/Finder/Iterator/SortableIterator.php index f95341f355..eda093fa2c 100644 --- a/src/Symfony/Component/Finder/Iterator/SortableIterator.php +++ b/src/Symfony/Component/Finder/Iterator/SortableIterator.php @@ -42,7 +42,7 @@ class SortableIterator implements \IteratorAggregate if (self::SORT_BY_NAME === $sort) { $this->sort = function ($a, $b) use ($order) { - return $order * strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname()); + return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname()); }; } elseif (self::SORT_BY_NAME_NATURAL === $sort) { $this->sort = function ($a, $b) use ($order) { @@ -56,7 +56,7 @@ class SortableIterator implements \IteratorAggregate return $order; } - return $order * strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname()); + return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname()); }; } elseif (self::SORT_BY_ACCESSED_TIME === $sort) { $this->sort = function ($a, $b) use ($order) { diff --git a/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php b/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php index 7354000b16..17865203f2 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Log/LoggerTest.php @@ -34,7 +34,7 @@ class LoggerTest extends TestCase protected function setUp() { - $this->tmpFile = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'log'; + $this->tmpFile = tempnam(sys_get_temp_dir(), 'log'); $this->logger = new Logger(LogLevel::DEBUG, $this->tmpFile); } diff --git a/src/Symfony/Component/Ldap/Exception/ConnectionException.php b/src/Symfony/Component/Ldap/Exception/ConnectionException.php index cded4cf2a3..7fa8e89f6f 100644 --- a/src/Symfony/Component/Ldap/Exception/ConnectionException.php +++ b/src/Symfony/Component/Ldap/Exception/ConnectionException.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Ldap\Exception; /** - * ConnectionException is throw if binding to ldap can not be established. + * ConnectionException is thrown if binding to ldap can not be established. * * @author Grégoire Pineau */ diff --git a/src/Symfony/Component/Ldap/Exception/DriverNotFoundException.php b/src/Symfony/Component/Ldap/Exception/DriverNotFoundException.php index 40258435bb..382cdf5ca6 100644 --- a/src/Symfony/Component/Ldap/Exception/DriverNotFoundException.php +++ b/src/Symfony/Component/Ldap/Exception/DriverNotFoundException.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Ldap\Exception; /** - * LdapException is throw if php ldap module is not loaded. + * LdapException is thrown if php ldap module is not loaded. * * @author Charles Sarrazin */ diff --git a/src/Symfony/Component/Ldap/Exception/LdapException.php b/src/Symfony/Component/Ldap/Exception/LdapException.php index 4045f32cf4..df8eabfbcb 100644 --- a/src/Symfony/Component/Ldap/Exception/LdapException.php +++ b/src/Symfony/Component/Ldap/Exception/LdapException.php @@ -12,7 +12,7 @@ namespace Symfony\Component\Ldap\Exception; /** - * LdapException is throw if php ldap module is not loaded. + * LdapException is thrown if php ldap module is not loaded. * * @author Grégoire Pineau */ diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 55dd0112a6..5e3993d788 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -419,6 +419,7 @@ class Process implements \IteratorAggregate } while ($running); while ($this->isRunning()) { + $this->checkTimeout(); usleep(1000); } diff --git a/src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php b/src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php new file mode 100755 index 0000000000..c37aeb5c8f --- /dev/null +++ b/src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Process\Tests; + +use Symfony\Component\Process\Exception\ProcessTimedOutException; +use Symfony\Component\Process\Process; + +require \dirname(__DIR__).'/vendor/autoload.php'; + +list('e' => $php) = getopt('e:') + ['e' => 'php']; + +try { + $process = new Process("exec $php -r \"echo 'ready'; trigger_error('error', E_USER_ERROR);\""); + $process->start(); + $process->setTimeout(0.5); + while (false === strpos($process->getOutput(), 'ready')) { + usleep(1000); + } + $process->signal(SIGSTOP); + $process->wait(); + + return $process->getExitCode(); +} catch (ProcessTimedOutException $t) { + echo $t->getMessage().PHP_EOL; + + return 1; +} diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 476456d1b0..8ae8d4ca94 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -1511,6 +1511,25 @@ EOTXT; $this->assertSame($env, $p->getEnv()); } + public function testWaitStoppedDeadProcess() + { + $process = $this->getProcess(self::$phpBin.' '.__DIR__.'/ErrorProcessInitiator.php -e '.self::$phpBin); + $process->start(); + $process->setTimeout(2); + $process->wait(); + $this->assertFalse($process->isRunning()); + } + + /** + * @param string $commandline + * @param string|null $cwd + * @param array|null $env + * @param string|null $input + * @param int $timeout + * @param array $options + * + * @return Process + */ private function getProcess($commandline, string $cwd = null, array $env = null, $input = null, ?int $timeout = 60): Process { if (\is_string($commandline)) { diff --git a/src/Symfony/Component/Security/Http/Authorization/AccessDeniedHandlerInterface.php b/src/Symfony/Component/Security/Http/Authorization/AccessDeniedHandlerInterface.php index aea901181f..871c877f57 100644 --- a/src/Symfony/Component/Security/Http/Authorization/AccessDeniedHandlerInterface.php +++ b/src/Symfony/Component/Security/Http/Authorization/AccessDeniedHandlerInterface.php @@ -26,7 +26,7 @@ interface AccessDeniedHandlerInterface /** * Handles an access denied failure. * - * @return Response may return null + * @return Response|null */ public function handle(Request $request, AccessDeniedException $accessDeniedException); }