From afc39ee11f28c133e20c6e331991fff8ac8fa5af Mon Sep 17 00:00:00 2001 From: Berny Cantos Date: Sat, 2 May 2015 20:46:11 +0200 Subject: [PATCH] add more entropy to generated classnames - use proxy destination filename to create and md5 salt - apply fabbot patch - inline salt generation --- .../ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php | 12 ++++++++++-- src/Symfony/Component/HttpKernel/Kernel.php | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php index 2865879ec1..bba5055d00 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php @@ -26,6 +26,11 @@ use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface; */ class ProxyDumper implements DumperInterface { + /** + * @var string + */ + private $salt; + /** * @var LazyLoadingValueHolderGenerator */ @@ -38,9 +43,12 @@ class ProxyDumper implements DumperInterface /** * Constructor. + * + * @param string $salt */ - public function __construct() + public function __construct($salt = '') { + $this->salt = $salt; $this->proxyGenerator = new LazyLoadingValueHolderGenerator(); $this->classGenerator = new BaseGeneratorStrategy(); } @@ -109,6 +117,6 @@ EOF; */ private function getProxyClassName(Definition $definition) { - return str_replace('\\', '', $definition->getClass()).'_'.spl_object_hash($definition); + return str_replace('\\', '', $definition->getClass()).'_'.spl_object_hash($definition).$this->salt; } } diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 42a3f3b3f6..e021cf2704 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -243,7 +243,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface } /** - * {@inheritDoc} + * {@inheritdoc} * * @throws \RuntimeException if a custom resource is hidden by a resource in a derived bundle */ @@ -683,7 +683,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface $dumper = new PhpDumper($container); if (class_exists('ProxyManager\Configuration')) { - $dumper->setProxyDumper(new ProxyDumper()); + $dumper->setProxyDumper(new ProxyDumper(md5((string) $cache))); } $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => (string) $cache));