Skip to content

Commit

Permalink
add more entropy to generated classnames
Browse files Browse the repository at this point in the history
- use proxy destination filename to create and md5 salt
- apply fabbot patch
- inline salt generation
  • Loading branch information
xphere committed May 2, 2015
1 parent 3cdb539 commit afc39ee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
*/
class ProxyDumper implements DumperInterface
{
/**
* @var string
*/
private $salt;

/**
* @var LazyLoadingValueHolderGenerator
*/
Expand All @@ -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();
}
Expand Down Expand Up @@ -109,6 +117,6 @@ public function getProxyCode(Definition $definition)
*/
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;
}
}
4 changes: 2 additions & 2 deletions src/Symfony/Component/HttpKernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function getBundle($name, $first = true)
}

/**
* {@inheritDoc}
* {@inheritdoc}
*
* @throws \RuntimeException if a custom resource is hidden by a resource in a derived bundle
*/
Expand Down Expand Up @@ -683,7 +683,7 @@ protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container
$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));
Expand Down

0 comments on commit afc39ee

Please sign in to comment.