Differential D18769 Diff 45041 src/applications/diffusion/protocol/__tests__/DiffusionCommandEngineTestCase.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/protocol/__tests__/DiffusionCommandEngineTestCase.php
Show First 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | $this->assertCommandEngineFormat( | ||||
array( | array( | ||||
'LANG' => 'en_US.UTF-8', | 'LANG' => 'en_US.UTF-8', | ||||
), | ), | ||||
array( | array( | ||||
'vcs' => $type_svn, | 'vcs' => $type_svn, | ||||
'argv' => 'xyz', | 'argv' => 'xyz', | ||||
'protocol' => 'https', | 'protocol' => 'https', | ||||
)); | )); | ||||
// Test that filtering defenses for "--config" and "--debugger" flag | |||||
// injections in Mercurial are functional. See T13012. | |||||
$caught = null; | |||||
try { | |||||
$this->assertCommandEngineFormat( | |||||
'', | |||||
array(), | |||||
array( | |||||
'vcs' => $type_hg, | |||||
'argv' => '--debugger', | |||||
)); | |||||
} catch (DiffusionMercurialFlagInjectionException $ex) { | |||||
$caught = $ex; | |||||
} | |||||
$this->assertTrue( | |||||
($caught instanceof DiffusionMercurialFlagInjectionException), | |||||
pht('Expected "--debugger" injection in Mercurial to throw.')); | |||||
$caught = null; | |||||
try { | |||||
$this->assertCommandEngineFormat( | |||||
'', | |||||
array(), | |||||
array( | |||||
'vcs' => $type_hg, | |||||
'argv' => '--config=x', | |||||
)); | |||||
} catch (DiffusionMercurialFlagInjectionException $ex) { | |||||
$caught = $ex; | |||||
} | |||||
$this->assertTrue( | |||||
($caught instanceof DiffusionMercurialFlagInjectionException), | |||||
pht('Expected "--config" injection in Mercurial to throw.')); | |||||
$caught = null; | |||||
try { | |||||
$this->assertCommandEngineFormat( | |||||
'', | |||||
array(), | |||||
array( | |||||
'vcs' => $type_hg, | |||||
'argv' => (string)csprintf('%s', '--config=x'), | |||||
)); | |||||
} catch (DiffusionMercurialFlagInjectionException $ex) { | |||||
$caught = $ex; | |||||
} | |||||
$this->assertTrue( | |||||
($caught instanceof DiffusionMercurialFlagInjectionException), | |||||
pht('Expected quoted "--config" injection in Mercurial to throw.')); | |||||
} | } | ||||
private function assertCommandEngineFormat( | private function assertCommandEngineFormat( | ||||
$command, | $command, | ||||
array $env, | array $env, | ||||
array $inputs) { | array $inputs) { | ||||
$repository = id(new PhabricatorRepository()) | $repository = id(new PhabricatorRepository()) | ||||
Show All 22 Lines |