Files
GitList/tests/RepositoryTest.php
Klaus Silveira 87b8c26b02 Fixed RCE in git grep.
A specific option in git grep could be added inside the
pattern to be searched for, resulting in possible RCE.

Thanks to Kacper Szurek (https://security.szurek.pl) for
catching this one!
2018-04-24 11:16:32 -04:00

29 lines
977 B
PHP

<?php
use GitList\Git\Client;
use GitList\Git\Repository;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
class RepositoryTest extends TestCase
{
public function testIsSanitizingSearchWithPager()
{
$client = $this->prophesize(Client::class);
$client->run(Argument::type(Repository::class), "grep -i --line-number -- '=sleep 5;' master")->shouldBeCalled();
$repository = new Repository('/tmp', $client->reveal());
$repository->searchTree('--open-files-in-pager=sleep 5;', 'master');
$repository->searchTree('-O=sleep 5;', 'master');
}
public function testIsSanitizingSearchWithAnyOption()
{
$client = $this->prophesize(Client::class);
$client->run(Argument::type(Repository::class), "grep -i --line-number -- 'foobar =bar;' foo")->shouldBeCalled();
$repository = new Repository('/tmp', $client->reveal());
$repository->searchTree('foobar --bar --foo=bar;', 'foo');
}
}