From ca65362b9be2839782557c6246c6b062d3bd654f Mon Sep 17 00:00:00 2001 From: thewilkybarkid Date: Tue, 16 Sep 2014 19:36:21 +0100 Subject: [PATCH 1/4] Make sure HttpCache is a trusted proxy --- .../HttpKernel/HttpCache/HttpCache.php | 6 +++++ .../Tests/HttpCache/HttpCacheTest.php | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 871b3a87fc..4463db27b9 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -462,6 +462,12 @@ class HttpCache implements HttpKernelInterface, TerminableInterface // is always called from the same process as the backend. $request->server->set('REMOTE_ADDR', '127.0.0.1'); + // make sure HttpCache is a trusted proxy + if (!in_array('127.0.0.1', $trustedProxies = Request::getTrustedProxies())) { + $trustedProxies[] = '127.0.0.1'; + Request::setTrustedProxies($trustedProxies); + } + // always a "master" request (as the real master request can be in cache) $response = $this->kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, $catch); // FIXME: we probably need to also catch exceptions if raw === true diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index 71cdd37aa7..5b950ea3e7 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -1155,6 +1155,28 @@ class HttpCacheTest extends HttpCacheTestCase $this->assertEquals('127.0.0.1', $this->kernel->getBackendRequest()->server->get('REMOTE_ADDR')); } + /** + * @dataProvider getTrustedProxyData + */ + public function testHttpCacheIsSetAsATrustedProxy(array $existing, array $expected) + { + Request::setTrustedProxies($existing); + + $this->setNextResponse(); + $this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1')); + + $this->assertEquals($expected, Request::getTrustedProxies()); + } + + public function getTrustedProxyData() + { + return array( + array(array(), array('127.0.0.1')), + array(array('10.0.0.2'), array('10.0.0.2', '127.0.0.1')), + array(array('10.0.0.2', '127.0.0.1'), array('10.0.0.2', '127.0.0.1')), + ); + } + /** * @dataProvider getXForwardedForData */ From b63926b24666798e8e20030b7c4f9b29ae7b7f09 Mon Sep 17 00:00:00 2001 From: Daniel Beyer Date: Sat, 20 Sep 2014 16:09:40 +0200 Subject: [PATCH 2/4] [Finder] Escape location for regex searches --- .../Finder/Adapter/AbstractFindAdapter.php | 4 +-- .../Component/Finder/Tests/FinderTest.php | 26 ++++++++++++++----- .../Fixtures/r+e.g?e*x[c]a(r)s/dir/bar.dat | 0 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 src/Symfony/Component/Finder/Tests/Fixtures/r+e.g?e*x[c]a(r)s/dir/bar.dat diff --git a/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php b/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php index 7f2a52fbcd..4d73b32c34 100644 --- a/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php +++ b/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php @@ -216,7 +216,7 @@ abstract class AbstractFindAdapter extends AbstractAdapter // Fixes 'not search' regex problems. if ($expr->isRegex()) { $regex = $expr->getRegex(); - $regex->prepend($regex->hasStartFlag() ? $dir.DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag()); + $regex->prepend($regex->hasStartFlag() ? preg_quote($dir).DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag()); } else { $expr->prepend('*')->append('*'); } @@ -247,7 +247,7 @@ abstract class AbstractFindAdapter extends AbstractAdapter $command->add('-size -'.($size->getTarget() + 1).'c'); break; case '>=': - $command->add('-size +'. ($size->getTarget() - 1).'c'); + $command->add('-size +'.($size->getTarget() - 1).'c'); break; case '>': $command->add('-size +'.$size->getTarget().'c'); diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index 598821d24f..924c67bd89 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -569,6 +569,20 @@ class FinderTest extends Iterator\RealIteratorTestCase } } + /** + * @dataProvider getAdaptersTestData + */ + public function testRegexSpecialCharsLocationWithPathRestrictionContainingStartFlag(Adapter\AdapterInterface $adapter) + { + $finder = $this->buildFinder($adapter); + $finder->in(__DIR__.DIRECTORY_SEPARATOR.'Fixtures'.DIRECTORY_SEPARATOR.'r+e.g?e*x[c]a(r)s') + ->path('/^dir/'); + + $expected = array('r+e.g?e*x[c]a(r)s'.DIRECTORY_SEPARATOR.'dir', + 'r+e.g?e*x[c]a(r)s'.DIRECTORY_SEPARATOR.'dir'.DIRECTORY_SEPARATOR.'bar.dat',); + $this->assertIterator($this->toAbsoluteFixtures($expected), $finder); + } + public function testAdaptersOrdering() { $finder = Finder::create() @@ -673,7 +687,7 @@ class FinderTest extends Iterator\RealIteratorTestCase $tests = array( array('', '', array()), array('/^A\/B\/C/', '/C$/', - array('A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat') + array('A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat'), ), array('/^A\/B/', 'foobar', array( @@ -681,7 +695,7 @@ class FinderTest extends Iterator\RealIteratorTestCase 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C', 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat', 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat', - ) + ), ), array('A/B/C', 'foobar', array( @@ -689,7 +703,7 @@ class FinderTest extends Iterator\RealIteratorTestCase 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat', 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C', 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat.copy', - ) + ), ), array('A/B', 'foobar', array( @@ -703,12 +717,12 @@ class FinderTest extends Iterator\RealIteratorTestCase 'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat', 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'ab.dat.copy', 'copy'.DIRECTORY_SEPARATOR.'A'.DIRECTORY_SEPARATOR.'B'.DIRECTORY_SEPARATOR.'C'.DIRECTORY_SEPARATOR.'abc.dat.copy', - ) + ), ), array('/^with space\//', 'foobar', array( 'with space'.DIRECTORY_SEPARATOR.'foo.txt', - ) + ), ), ); @@ -808,7 +822,7 @@ class FinderTest extends Iterator\RealIteratorTestCase array( new Adapter\BsdFindAdapter(), new Adapter\GnuFindAdapter(), - new Adapter\PhpAdapter() + new Adapter\PhpAdapter(), ), function (Adapter\AdapterInterface $adapter) { return $adapter->isSupported(); diff --git a/src/Symfony/Component/Finder/Tests/Fixtures/r+e.g?e*x[c]a(r)s/dir/bar.dat b/src/Symfony/Component/Finder/Tests/Fixtures/r+e.g?e*x[c]a(r)s/dir/bar.dat new file mode 100644 index 0000000000..e69de29bb2 From 37dc57bda25029d96d1c01a76998dd5822a3fba8 Mon Sep 17 00:00:00 2001 From: znerol Date: Mon, 22 Sep 2014 15:00:09 +0200 Subject: [PATCH 3/4] Fix @return docs on HttpCache::restoreResponseBody() --- src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index e16ee6f311..ee5f8d4188 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php @@ -601,8 +601,6 @@ class HttpCache implements HttpKernelInterface, TerminableInterface * * @param Request $request A Request instance * @param Response $response A Response instance - * - * @return Response A Response instance */ private function restoreResponseBody(Request $request, Response $response) { From 3b02af9f7985c745927366aadd5b1d2770153172 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Sun, 6 Jul 2014 16:36:42 +0200 Subject: [PATCH 4/4] [2.3] Add missing development dependencies --- .travis.yml | 14 +++++++++++--- src/Symfony/Bridge/Doctrine/composer.json | 2 +- src/Symfony/Bridge/ProxyManager/composer.json | 3 +++ src/Symfony/Bundle/FrameworkBundle/composer.json | 8 ++++++-- src/Symfony/Bundle/SecurityBundle/composer.json | 3 +++ .../Tests/Controller/ProfilerControllerTest.php | 3 +-- src/Symfony/Bundle/WebProfilerBundle/composer.json | 1 + src/Symfony/Component/Form/composer.json | 3 ++- src/Symfony/Component/Routing/composer.json | 1 + src/Symfony/Component/Translation/composer.json | 1 + 10 files changed, 30 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 14c7704c4c..cecdc9500c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,9 +11,16 @@ php: matrix: allow_failures: - php: hhvm-nightly + include: + - php: 5.5 + env: components=yes services: mongodb +env: + global: + - components=no + before_install: - travis_retry sudo apt-get install parallel - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm-nightly" ]; then echo "" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini; fi;' @@ -25,8 +32,9 @@ before_install: # - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "5.3.3" ]; then phpunit --self-update; fi;' install: - - COMPOSER_ROOT_VERSION=dev-master composer --prefer-source install + - sh -c 'if [ "$components" = "no" ]; then sh -c "COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install"; fi;' script: - - ls -d src/Symfony/*/* | parallel --gnu --keep-order 'echo "Running {} tests"; phpunit --exclude-group tty,benchmark {};' - - echo "Running tests requiring tty"; phpunit --group tty + - sh -c 'if [ "$components" = "no" ]; then sh -c "ls -d src/Symfony/*/* | parallel --gnu --keep-order '\''echo \"Running {} tests\"; phpunit --exclude-group tty,benchmark {};'\''"; fi;' + - sh -c 'if [ "$components" = "no" ]; then sh -c "echo "\""Running tests requiring tty"\""; phpunit --group tty"; fi;' + - sh -c 'if [ "$components" = "yes" ]; then sh -c "find src/Symfony -mindepth 3 -type f -name '\''phpunit.xml.dist'\'' | sed '\''s#\(.*\)/.*#\1#'\'' | parallel --gnu --keep-order '\''echo \"Running {} tests\"; cd {}; COMPOSER_ROOT_VERSION=dev-master composer --prefer-source --dev install; phpunit --exclude-group tty,benchmark;'\''"; fi;' diff --git a/src/Symfony/Bridge/Doctrine/composer.json b/src/Symfony/Bridge/Doctrine/composer.json index e657db70d1..30f4586427 100644 --- a/src/Symfony/Bridge/Doctrine/composer.json +++ b/src/Symfony/Bridge/Doctrine/composer.json @@ -25,7 +25,7 @@ "symfony/form": "~2.2", "symfony/http-kernel": "~2.2", "symfony/security": "~2.2", - "symfony/validator": "~2.2", + "symfony/validator": "~2.3.0", "doctrine/data-fixtures": "1.0.*", "doctrine/dbal": "~2.2", "doctrine/orm": "~2.2,>=2.2.3" diff --git a/src/Symfony/Bridge/ProxyManager/composer.json b/src/Symfony/Bridge/ProxyManager/composer.json index 4d3abb6048..c4a59154ce 100644 --- a/src/Symfony/Bridge/ProxyManager/composer.json +++ b/src/Symfony/Bridge/ProxyManager/composer.json @@ -20,6 +20,9 @@ "symfony/dependency-injection": "~2.3", "ocramius/proxy-manager": ">=0.3.1,<0.4-dev" }, + "require-dev": { + "symfony/config": "2.3" + }, "autoload": { "psr-0": { "Symfony\\Bridge\\ProxyManager\\": "" diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index daa1eee38b..8fc450f7da 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -29,11 +29,15 @@ "doctrine/common": "~2.2" }, "require-dev": { + "symfony/browser-kit": "~2.3", + "symfony/console": "~2.0", "symfony/finder": "~2.0", "symfony/security": "~2.3", - "symfony/form": "~2.3", + "symfony/form": "~2.3.0", "symfony/class-loader": "~2.1", - "symfony/validator": "~2.1" + "symfony/process": "~2.0", + "symfony/validator": "~2.1", + "symfony/yaml": "~2.0" }, "suggest": { "symfony/console": "", diff --git a/src/Symfony/Bundle/SecurityBundle/composer.json b/src/Symfony/Bundle/SecurityBundle/composer.json index 776f590bc8..a41dff51c1 100644 --- a/src/Symfony/Bundle/SecurityBundle/composer.json +++ b/src/Symfony/Bundle/SecurityBundle/composer.json @@ -21,9 +21,12 @@ "symfony/http-kernel": "~2.2" }, "require-dev": { + "symfony/browser-kit": "~2.3", + "symfony/form": "~2.3", "symfony/framework-bundle": "~2.2", "symfony/twig-bundle": "~2.2", "symfony/form": "~2.1", + "symfony/process": "~2.0", "symfony/validator": "~2.2", "symfony/yaml": "~2.0" }, diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php index bff1919aa9..c10449d323 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php @@ -11,12 +11,11 @@ namespace Symfony\Bundle\WebProfilerBundle\Tests\Controller; -use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\WebProfilerBundle\Controller\ProfilerController; use Symfony\Component\HttpKernel\Profiler\Profile; use Symfony\Component\HttpFoundation\Request; -class ProfilerControllerTest extends TestCase +class ProfilerControllerTest extends \PHPUnit_Framework_TestCase { /** * @dataProvider getEmptyTokenCases diff --git a/src/Symfony/Bundle/WebProfilerBundle/composer.json b/src/Symfony/Bundle/WebProfilerBundle/composer.json index c3f20e87e7..e384965bf4 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/composer.json +++ b/src/Symfony/Bundle/WebProfilerBundle/composer.json @@ -23,6 +23,7 @@ }, "require-dev": { "symfony/config": "~2.2", + "symfony/console": "~2.3", "symfony/dependency-injection": "~2.0", "symfony/stopwatch": "~2.2" }, diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index 14f9dadce4..f55a042086 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -23,7 +23,8 @@ "symfony/property-access": "~2.3" }, "require-dev": { - "symfony/validator": "~2.2", + "doctrine/collections": "~1.0", + "symfony/validator": "~2.3.0", "symfony/http-foundation": "~2.2" }, "suggest": { diff --git a/src/Symfony/Component/Routing/composer.json b/src/Symfony/Component/Routing/composer.json index 9a737c6b02..18c06d3501 100644 --- a/src/Symfony/Component/Routing/composer.json +++ b/src/Symfony/Component/Routing/composer.json @@ -20,6 +20,7 @@ }, "require-dev": { "symfony/config": "~2.2", + "symfony/http-foundation": "~2.3", "symfony/yaml": "~2.0", "doctrine/common": "~2.2", "psr/log": "~1.0" diff --git a/src/Symfony/Component/Translation/composer.json b/src/Symfony/Component/Translation/composer.json index 96a8e662a8..e65668b43f 100644 --- a/src/Symfony/Component/Translation/composer.json +++ b/src/Symfony/Component/Translation/composer.json @@ -20,6 +20,7 @@ }, "require-dev": { "symfony/config": "~2.0", + "symfony/intl": "~2.3", "symfony/yaml": "~2.2" }, "suggest": {