1
0
Fork 0

Remove fulluri checks and tidy diagnose output

pull/9374/head
johnstevenson 2020-10-28 20:11:22 +00:00
parent ec5f020186
commit 095d133d6b
1 changed files with 6 additions and 81 deletions

View File

@ -105,10 +105,6 @@ EOT
if (!empty($opts['http']['proxy'])) { if (!empty($opts['http']['proxy'])) {
$io->write('Checking HTTP proxy: ', false); $io->write('Checking HTTP proxy: ', false);
$this->outputResult($this->checkHttpProxy()); $this->outputResult($this->checkHttpProxy());
$io->write('Checking HTTP proxy support for request_fulluri: ', false);
$this->outputResult($this->checkHttpProxyFullUriRequestParam());
$io->write('Checking HTTPS proxy support for request_fulluri: ', false);
$this->outputResult($this->checkHttpsProxyFullUriRequestParam());
} }
if ($oauth = $config->get('github-oauth')) { if ($oauth = $config->get('github-oauth')) {
@ -220,26 +216,19 @@ EOT
return $result; return $result;
} }
$disableTls = false;
$result = array(); $result = array();
if ($proto === 'https' && $config->get('disable-tls') === true) { if ($proto === 'https' && $config->get('disable-tls') === true) {
$disableTls = true; $tlsWarning = '<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>';
$result[] = '<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>';
}
if ($proto === 'https' && !extension_loaded('openssl') && !$disableTls) {
$result[] = '<error>Composer is configured to use SSL/TLS protection but the openssl extension is not available.</error>';
} }
try { try {
$this->httpDownloader->get($proto . '://repo.packagist.org/packages.json'); $this->httpDownloader->get($proto . '://repo.packagist.org/packages.json');
} catch (TransportException $e) { } catch (TransportException $e) {
if (false !== strpos($e->getMessage(), 'cafile')) {
$result[] = '<error>[' . get_class($e) . '] ' . $e->getMessage() . '</error>'; $result[] = '<error>[' . get_class($e) . '] ' . $e->getMessage() . '</error>';
$result[] = '<error>Unable to locate a valid CA certificate file. You must set a valid \'cafile\' option.</error>';
$result[] = '<error>You can alternatively disable this error, at your own risk, by enabling the \'disable-tls\' option.</error>';
} else {
array_unshift($result, '[' . get_class($e) . '] ' . $e->getMessage());
} }
if (isset($tlsWarning)) {
$result[] = $tlsWarning;
} }
if (count($result) > 0) { if (count($result) > 0) {
@ -274,70 +263,6 @@ EOT
return true; return true;
} }
/**
* Due to various proxy servers configurations, some servers can't handle non-standard HTTP "http_proxy_request_fulluri" parameter,
* and will return error 500/501 (as not implemented), see discussion @ https://github.com/composer/composer/pull/1825.
* This method will test, if you need to disable this parameter via setting extra environment variable in your system.
*
* @return bool|string
*/
private function checkHttpProxyFullUriRequestParam()
{
$result = $this->checkConnectivity();
if ($result !== true) {
return $result;
}
$url = 'http://repo.packagist.org/packages.json';
try {
$this->httpDownloader->get($url);
} catch (TransportException $e) {
try {
$this->httpDownloader->get($url, array('http' => array('request_fulluri' => false)));
} catch (TransportException $e) {
return 'Unable to assess the situation, maybe packagist.org is down ('.$e->getMessage().')';
}
return 'It seems there is a problem with your proxy server, try setting the "HTTP_PROXY_REQUEST_FULLURI" and "HTTPS_PROXY_REQUEST_FULLURI" environment variables to "false"';
}
return true;
}
/**
* Due to various proxy servers configurations, some servers can't handle non-standard HTTP "http_proxy_request_fulluri" parameter,
* and will return error 500/501 (as not implemented), see discussion @ https://github.com/composer/composer/pull/1825.
* This method will test, if you need to disable this parameter via setting extra environment variable in your system.
*
* @return bool|string
*/
private function checkHttpsProxyFullUriRequestParam()
{
$result = $this->checkConnectivity();
if ($result !== true) {
return $result;
}
if (!extension_loaded('openssl')) {
return 'You need the openssl extension installed for this check';
}
$url = 'https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0';
try {
$this->httpDownloader->get($url);
} catch (TransportException $e) {
try {
$this->httpDownloader->get($url, array('http' => array('request_fulluri' => false)));
} catch (TransportException $e) {
return 'Unable to assess the situation, maybe github is down ('.$e->getMessage().')';
}
return 'It seems there is a problem with your proxy server, try setting the "HTTPS_PROXY_REQUEST_FULLURI" environment variable to "false"';
}
return true;
}
private function checkGithubOauth($domain, $token) private function checkGithubOauth($domain, $token)
{ {
$result = $this->checkConnectivity(); $result = $this->checkConnectivity();