commit
e022c07370
|
@ -51,6 +51,7 @@ class ProcessExecutor
|
||||||
|
|
||||||
return '://'.$m['user'].':***@';
|
return '://'.$m['user'].':***@';
|
||||||
}, $command);
|
}, $command);
|
||||||
|
$safeCommand = preg_replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
|
||||||
$this->io->writeError('Executing command ('.($cwd ?: 'CWD').'): '.$safeCommand);
|
$this->io->writeError('Executing command ('.($cwd ?: 'CWD').'): '.$safeCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,11 +61,25 @@ class ProcessExecutorTest extends TestCase
|
||||||
ProcessExecutor::setTimeout(60);
|
ProcessExecutor::setTimeout(60);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHidePasswords()
|
/**
|
||||||
|
* @dataProvider hidePasswordProvider
|
||||||
|
*/
|
||||||
|
public function testHidePasswords($command, $expectedCommandOutput)
|
||||||
{
|
{
|
||||||
$process = new ProcessExecutor($buffer = new BufferIO('', StreamOutput::VERBOSITY_DEBUG));
|
$process = new ProcessExecutor($buffer = new BufferIO('', StreamOutput::VERBOSITY_DEBUG));
|
||||||
$process->execute('echo https://foo:bar@example.org/ && echo http://foo@example.org && echo http://abcdef1234567890234578:x-oauth-token@github.com/', $output);
|
$process->execute($command, $output);
|
||||||
$this->assertEquals('Executing command (CWD): echo https://foo:***@example.org/ && echo http://foo@example.org && echo http://***:***@github.com/', trim($buffer->getOutput()));
|
$this->assertEquals('Executing command (CWD): ' . $expectedCommandOutput, trim($buffer->getOutput()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hidePasswordProvider()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('echo https://foo:bar@example.org/', 'echo https://foo:***@example.org/'),
|
||||||
|
array('echo http://foo@example.org', 'echo http://foo@example.org'),
|
||||||
|
array('echo http://abcdef1234567890234578:x-oauth-token@github.com/', 'echo http://***:***@github.com/'),
|
||||||
|
array("svn ls --verbose --non-interactive --username 'foo' --password 'bar' 'https://foo.example.org/svn/'", "svn ls --verbose --non-interactive --username 'foo' --password '***' 'https://foo.example.org/svn/'"),
|
||||||
|
array("svn ls --verbose --non-interactive --username 'foo' --password 'bar \'bar' 'https://foo.example.org/svn/'", "svn ls --verbose --non-interactive --username 'foo' --password '***' 'https://foo.example.org/svn/'"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDoesntHidePorts()
|
public function testDoesntHidePorts()
|
||||||
|
|
Loading…
Reference in New Issue