1
0
Fork 0

Avoid displaying passwords in git exceptions, fixes #1199

pull/1200/head
Jordi Boggiano 2012-10-10 23:47:53 +02:00
parent a8171f5be0
commit 55bff36be1
1 changed files with 10 additions and 5 deletions

View File

@ -201,7 +201,7 @@ class GitDownloader extends VcsDownloader
if (empty($newReference)) {
// no matching branch found, find the previous commit by date in all commits
if (0 !== $this->process->execute(sprintf($guessTemplate, $date, '--all'), $output, $path)) {
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
throw new \RuntimeException('Failed to execute ' . $this->sanitizeUrl($command) . "\n\n" . $this->process->getErrorOutput());
}
$newReference = trim($output);
}
@ -215,7 +215,7 @@ class GitDownloader extends VcsDownloader
}
}
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
throw new \RuntimeException('Failed to execute ' . $this->sanitizeUrl($command) . "\n\n" . $this->process->getErrorOutput());
}
/**
@ -249,7 +249,7 @@ class GitDownloader extends VcsDownloader
}
// failed to checkout, first check git accessibility
$this->throwException('Failed to clone ' . $url .' via git, https and http protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
$this->throwException('Failed to clone ' . $this->sanitizeUrl($url) .' via git, https and http protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
}
$command = call_user_func($commandCallable, $url);
@ -285,7 +285,7 @@ class GitDownloader extends VcsDownloader
if (null !== $path) {
$this->filesystem->removeDirectory($path);
}
$this->throwException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput(), $url);
$this->throwException('Failed to execute ' . $this->sanitizeUrl($command) . "\n\n" . $this->process->getErrorOutput(), $url);
}
}
@ -302,12 +302,17 @@ class GitDownloader extends VcsDownloader
protected function throwException($message, $url)
{
if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
throw new \RuntimeException('Failed to clone '.$url.', git was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput());
throw new \RuntimeException('Failed to clone '.$this->sanitizeUrl($url).', git was not found, check that it is installed and in your PATH env.' . "\n\n" . $this->process->getErrorOutput());
}
throw new \RuntimeException($message);
}
protected function sanitizeUrl($message)
{
return preg_match('{://(.+?):.+?@}', '://$1:***@', $message);
}
protected function setPushUrl(PackageInterface $package, $path)
{
// set push url for github projects