Hello community, here is the log from the commit of package platformsh-cli for openSUSE:Leap:15.2 checked in at 2020-01-19 15:48:55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Leap:15.2/platformsh-cli (Old) and /work/SRC/openSUSE:Leap:15.2/.platformsh-cli.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "platformsh-cli" Sun Jan 19 15:48:55 2020 rev:37 rq:765556 version:3.51.3 Changes: -------- --- /work/SRC/openSUSE:Leap:15.2/platformsh-cli/platformsh-cli.changes 2020-01-17 12:06:08.920628431 +0100 +++ /work/SRC/openSUSE:Leap:15.2/.platformsh-cli.new.26092/platformsh-cli.changes 2020-01-19 15:50:29.977809819 +0100 @@ -1,0 +2,14 @@ +Fri Jan 17 20:44:18 UTC 2020 - ji...@boombatower.com + +- Update to version 3.51.3: + * Release v3.51.3 + * Release v3.51.2 + * Implement PKCE for browser login + * Avoid unnecessary HTTP exception message + * Allow PLATFORMSH_CLI_HOME variable to override the home directory (#886) + * Remove recommendations for auth:password-login command + * Fix gitlab example (#894) + * Fix proxy setting when there is more than 1 + * Allow PLATFORMSH_CLI_API_URL to override the base API URL + +------------------------------------------------------------------- Old: ---- platformsh-cli-3.51.1.tar.xz New: ---- platformsh-cli-3.51.3.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ platformsh-cli.spec ++++++ --- /var/tmp/diff_new_pack.GXaO9Z/_old 2020-01-19 15:50:30.429810087 +0100 +++ /var/tmp/diff_new_pack.GXaO9Z/_new 2020-01-19 15:50:30.433810089 +0100 @@ -17,7 +17,7 @@ Name: platformsh-cli -Version: 3.51.1 +Version: 3.51.3 Release: 0 Summary: Tool for managing Platform.sh services from the command line # See licenses.txt for dependency licenses. ++++++ _service ++++++ --- /var/tmp/diff_new_pack.GXaO9Z/_old 2020-01-19 15:50:30.449810098 +0100 +++ /var/tmp/diff_new_pack.GXaO9Z/_new 2020-01-19 15:50:30.449810098 +0100 @@ -2,7 +2,7 @@ <service name="tar_scm" mode="disabled"> <param name="versionformat">@PARENT_TAG@</param> <param name="versionrewrite-pattern">v(.*)</param> - <param name="revision">refs/tags/v3.51.1</param> + <param name="revision">refs/tags/v3.51.3</param> <param name="url">git://github.com/platformsh/platformsh-cli.git</param> <param name="scm">git</param> <param name="changesgenerate">enable</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.GXaO9Z/_old 2020-01-19 15:50:30.461810106 +0100 +++ /var/tmp/diff_new_pack.GXaO9Z/_new 2020-01-19 15:50:30.465810108 +0100 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">git://github.com/platformsh/platformsh-cli.git</param> - <param name="changesrevision">3a004ebc8d3264622cd66fb9585179f205093483</param> + <param name="changesrevision">d30ca740b27f5e6ec2e338b377a4c784d8eb3a68</param> </service> </servicedata> ++++++ platformsh-cli-3.51.1.tar.xz -> platformsh-cli-3.51.3.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/README.md new/platformsh-cli-3.51.3/README.md --- old/platformsh-cli-3.51.1/README.md 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/README.md 2020-01-17 16:36:13.000000000 +0100 @@ -91,7 +91,6 @@ auth:browser-login (login) Log in to Platform.sh via a browser auth:info Display your account information auth:logout (logout) Log out of Platform.sh - auth:password-login Log in to Platform.sh using a username and password backup backup:create (backup) Make a backup of an environment backup:list (backups) List available backups of an environment @@ -214,14 +213,15 @@ local server and a browser, allowing you to log in to Platform.sh via the normal login form, including via services like Bitbucket, GitHub and Google. -2. `platform auth:password-login`: this allows you to log in with a username and - password, and a two-factor token if applicable. - -3. [API tokens](https://docs.platform.sh/gettingstarted/cli/api-tokens.html): +2. [API tokens](https://docs.platform.sh/gettingstarted/cli/api-tokens.html): these allow non-interactive authentication. See [Customization](#customization) below for how to use an API token. Remember to use a separate machine account if you want to limit the token's access. +3. `platform auth:password-login`: this allows you to log in with a username and + password, and a two-factor token if applicable. This is deprecated, and will + be removed from the API in future. + ## Customization You can configure the CLI via the user configuration file `~/.platformsh/config.yaml`. @@ -268,6 +268,7 @@ * `PLATFORMSH_CLI_DEBUG`: set to 1 to enable cURL debugging. _Warning_: this will print all request information in the terminal, including sensitive access tokens. * `PLATFORMSH_CLI_DISABLE_CACHE`: set to 1 to disable caching +* `PLATFORMSH_CLI_HOME`: override the home directory (inside which the .platformsh directory is stored) * `PLATFORMSH_CLI_NO_COLOR`: set to 1 to disable colors in output * `PLATFORMSH_CLI_NO_INTERACTION`: set to 1 to disable interaction (useful for scripting). _Warning_: this will bypass any confirmation questions. * `PLATFORMSH_CLI_SESSION_ID`: change user session (default 'default') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/dist/installer.php new/platformsh-cli-3.51.3/dist/installer.php --- old/platformsh-cli-3.51.1/dist/installer.php 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/dist/installer.php 2020-01-17 16:36:13.000000000 +0100 @@ -47,6 +47,7 @@ } class Installer { + private $envPrefix; private $manifestUrl; private $configDir; private $executable; @@ -57,8 +58,9 @@ public function __construct(array $args = []) { $this->argv = !empty($args) ? $args : $GLOBALS['argv']; - if (getenv('PLATFORMSH_CLI_MANIFEST_URL') !== false) { - $this->manifestUrl = getenv('PLATFORMSH_CLI_MANIFEST_URL'); + $this->envPrefix = 'PLATFORMSH_CLI_'; + if (getenv($this->envPrefix . 'MANIFEST_URL') !== false) { + $this->manifestUrl = getenv($this->envPrefix . 'MANIFEST_URL'); } elseif ($manifestOption = $this->getOption('manifest')) { $this->manifestUrl = $manifestOption; } else { @@ -505,13 +507,13 @@ * The user's home directory as an absolute path, or false on failure. */ private function getHomeDirectory() { - if ($home = getenv('HOME')) { - return $home; - } - elseif ($userProfile = getenv('USERPROFILE')) { - return $userProfile; + $vars = [$this->envPrefix . 'HOME', 'HOME', 'USERPROFILE']; + foreach ($vars as $var) { + if ($home = getenv($var)) { + return realpath($home) ?: $home; + } } - elseif (!empty($_SERVER['HOMEDRIVE']) && !empty($_SERVER['HOMEPATH'])) { + if (!empty($_SERVER['HOMEDRIVE']) && !empty($_SERVER['HOMEPATH'])) { return $_SERVER['HOMEDRIVE'] . $_SERVER['HOMEPATH']; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/dist/manifest.json new/platformsh-cli-3.51.3/dist/manifest.json --- old/platformsh-cli-3.51.1/dist/manifest.json 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/dist/manifest.json 2020-01-17 16:36:13.000000000 +0100 @@ -17,10 +17,10 @@ }, { "name": "platform.phar", - "sha1": "88380dc17038a2ea65c16cba5870728fb4546b21", - "sha256": "bb5d18d3a820686288b5752982fc3e375accba4aa1adbbf5cb3c3450af4a10fb", - "url": "https://github.com/platformsh/platformsh-cli/releases/download/v3.51.1/platform.phar", - "version": "3.51.1", + "sha1": "8de789f62a8870893a794d3aa2c1ee8ec126a2d8", + "sha256": "0e368c04582107efc02caa56fdaf7df918f51855ec78ba4b05cb433d4b0d5cd1", + "url": "https://github.com/platformsh/platformsh-cli/releases/download/v3.51.3/platform.phar", + "version": "3.51.3", "php": { "min": "5.5.9" }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/resources/oauth-listener/index.php new/platformsh-cli-3.51.3/resources/oauth-listener/index.php --- old/platformsh-cli-3.51.1/resources/oauth-listener/index.php 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/resources/oauth-listener/index.php 2020-01-17 16:36:13.000000000 +0100 @@ -10,6 +10,7 @@ private $file; private $localUrl; private $response; + private $codeChallenge; public function __construct() { $required = [ @@ -17,6 +18,7 @@ 'CLI_OAUTH_AUTH_URL', 'CLI_OAUTH_CLIENT_ID', 'CLI_OAUTH_FILE', + 'CLI_OAUTH_CODE_CHALLENGE', ]; if ($missing = array_diff($required, array_keys($_ENV))) { throw new \RuntimeException('Invalid environment, missing: ' . implode(', ', $missing)); @@ -25,6 +27,7 @@ $this->authUrl = $_ENV['CLI_OAUTH_AUTH_URL']; $this->clientId = $_ENV['CLI_OAUTH_CLIENT_ID']; $this->file = $_ENV['CLI_OAUTH_FILE']; + $this->codeChallenge = $_ENV['CLI_OAUTH_CODE_CHALLENGE']; $this->localUrl = $localUrl = 'http://127.0.0.1:' . $_SERVER['SERVER_PORT']; $this->response = new Response(); } @@ -39,6 +42,8 @@ 'state' => $this->state, 'client_id' => $this->clientId, 'response_type' => 'code', + 'code_challenge' => $this->codeChallenge, + 'code_challenge_method' => 'S256', ], null, '&', PHP_QUERY_RFC3986); } @@ -53,6 +58,10 @@ $this->reportError('Invalid state parameter'); return; } + if (isset($_GET['code_challenge']) && $_GET['code_challenge'] !== $this->codeChallenge) { + $this->reportError('Invalid returned code_challenge parameter'); + return; + } if (!file_put_contents($this->file, $_GET['code'], LOCK_EX)) { $this->reportError('Failed to write authorization code to file'); return; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/src/Command/Auth/BrowserLoginCommand.php new/platformsh-cli-3.51.3/src/Command/Auth/BrowserLoginCommand.php --- old/platformsh-cli-3.51.1/src/Command/Auth/BrowserLoginCommand.php 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/src/Command/Auth/BrowserLoginCommand.php 2020-01-17 16:36:13.000000000 +0100 @@ -8,6 +8,7 @@ use Platformsh\Cli\Service\Filesystem; use Platformsh\Cli\Service\Url; use Platformsh\Cli\Util\PortUtil; +use Platformsh\Client\Exception\ApiResponseException; use Platformsh\Client\Session\SessionInterface; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -21,7 +22,6 @@ { $service = $this->config()->get('service.name'); $applicationName = $this->config()->get('application.name'); - $executable = $this->config()->get('application.executable'); $this->setName('auth:browser-login'); if ($this->config()->get('application.login_method') === 'browser') { @@ -32,9 +32,7 @@ ->addOption('force', 'f', InputOption::VALUE_NONE, 'Log in again, even if already logged in'); Url::configureInput($this->getDefinition()); - $help = 'Use this command to log in to the ' . $applicationName . ' using a browser.' - . "\n\nAlternatively, to log in with a username and password in the terminal, use:\n <info>" - . $executable . ' auth:password-login</info>'; + $help = 'Use this command to log in to the ' . $applicationName . ' using a browser.'; if ($aHelp = $this->getApiTokenHelp()) { $help .= "\n\n" . $aHelp; } @@ -132,9 +130,11 @@ '-t', $listenerDir ]); + $codeVerifier = $this->generateCodeVerifier(); $process->setEnv([ 'CLI_OAUTH_APP_NAME' => $this->config()->get('application.name'), - 'CLI_OAUTH_STATE' => $this->getRandomState(), + 'CLI_OAUTH_STATE' => $this->generateCodeVerifier(), // the state can just be any random string + 'CLI_OAUTH_CODE_CHALLENGE' => $this->convertVerifierToChallenge($codeVerifier), 'CLI_OAUTH_AUTH_URL' => $this->config()->get('api.oauth2_auth_url'), 'CLI_OAUTH_CLIENT_ID' => $this->config()->get('api.oauth2_client_id'), 'CLI_OAUTH_FILE' => $codeFile, @@ -170,9 +170,9 @@ $this->stdErr->writeln(''); $this->stdErr->writeln('<options=bold>Help:</>'); $this->stdErr->writeln(' Use Ctrl+C to quit this process.'); - $executable = $this->config()->get('application.executable'); - $this->stdErr->writeln(sprintf(' To log in within the terminal instead, quit and run: <info>%s auth:password-login</info>', $executable)); - $this->stdErr->writeln(sprintf(' For more info, quit and run: <info>%s help login</info>', $executable)); + if ($aHelp = $this->getApiTokenHelp()) { + $this->stdErr->writeln("\n" . preg_replace('/^/m', ' ', $aHelp)); + } $this->stdErr->writeln(''); // Wait for the file to be filled with an OAuth2 authorization code. @@ -204,7 +204,7 @@ // Using the authorization code, request an access token. $this->stdErr->writeln('Login information received. Verifying...'); - $token = $this->getAccessToken($code, $localUrl); + $token = $this->getAccessToken($code, $codeVerifier, $localUrl); // Finalize login: call logOut() on the old connector, clear the cache // and save the new credentials. @@ -271,35 +271,69 @@ * Exchange the authorization code for an access token. * * @param string $authCode + * @param string $codeVerifier * @param string $redirectUri * * @return array */ - private function getAccessToken($authCode, $redirectUri) + private function getAccessToken($authCode, $codeVerifier, $redirectUri) { - return (new Client())->post( - $this->config()->get('api.oauth2_token_url'), - [ - 'body' => [ - 'grant_type' => 'authorization_code', - 'code' => $authCode, - 'client_id' => $this->config()->get('api.oauth2_client_id'), - 'redirect_uri' => $redirectUri, - ], - 'auth' => false, - 'verify' => !$this->config()->get('api.skip_ssl'), - ] - )->json(); + $client = new Client(); + $request = $client->createRequest('post', $this->config()->get('api.oauth2_token_url'), [ + 'body' => [ + 'grant_type' => 'authorization_code', + 'code' => $authCode, + 'client_id' => $this->config()->get('api.oauth2_client_id'), + 'redirect_uri' => $redirectUri, + 'code_verifier' => $codeVerifier, + ], + 'auth' => false, + 'verify' => !$this->config()->get('api.skip_ssl'), + ]); + + try { + $response = $client->send($request); + + return $response->json(); + } catch (BadResponseException $e) { + throw ApiResponseException::create($request, $e->getResponse(), $e); + } } /** - * Get a random state to use with the OAuth2 code request. + * Get a PKCE code verifier to use with the OAuth2 code request. * * @return string */ - private function getRandomState() + private function generateCodeVerifier() { // This uses paragonie/random_compat as a polyfill for PHP < 7.0. - return bin2hex(random_bytes(128)); + return $this->base64UrlEncode(random_bytes(32)); + } + + /** + * Base64URL-encodes a string according to the PKCE spec. + * + * @see https://tools.ietf.org/html/rfc7636 + * + * @param string $data + * + * @return string + */ + private function base64UrlEncode($data) + { + return str_replace(['+', '/'], ['-', '_'], rtrim(base64_encode($data), '=')); + } + + /** + * Generates a PKCE code challenge using the S256 transformation on a verifier. + * + * @param string $verifier + * + * @return string + */ + private function convertVerifierToChallenge($verifier) + { + return $this->base64UrlEncode(hash('sha256', $verifier, true)); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/src/Command/Auth/PasswordLoginCommand.php new/platformsh-cli-3.51.3/src/Command/Auth/PasswordLoginCommand.php --- old/platformsh-cli-3.51.1/src/Command/Auth/PasswordLoginCommand.php 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/src/Command/Auth/PasswordLoginCommand.php 2020-01-17 16:36:13.000000000 +0100 @@ -10,6 +10,7 @@ class PasswordLoginCommand extends CommandBase { protected $stability = 'deprecated'; + protected $hiddenInList = true; protected function configure() { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/src/Command/Integration/IntegrationAddCommand.php new/platformsh-cli-3.51.3/src/Command/Integration/IntegrationAddCommand.php --- old/platformsh-cli-3.51.1/src/Command/Integration/IntegrationAddCommand.php 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/src/Command/Integration/IntegrationAddCommand.php 2020-01-17 16:36:13.000000000 +0100 @@ -24,7 +24,7 @@ ); $this->addExample( 'Add an integration with a GitLab repository', - '--type gitlab --repository mygroup/example-repo --token 22fe4d70dfbc20e4f668568a0b5422e2 --base-url https://gitlab.example.com' + '--type gitlab --server-project mygroup/example-repo --token 22fe4d70dfbc20e4f668568a0b5422e2 --base-url https://gitlab.example.com' ); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/src/Command/Self/SelfInstallCommand.php new/platformsh-cli-3.51.3/src/Command/Self/SelfInstallCommand.php --- old/platformsh-cli-3.51.1/src/Command/Self/SelfInstallCommand.php 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/src/Command/Self/SelfInstallCommand.php 2020-01-17 16:36:13.000000000 +0100 @@ -2,7 +2,6 @@ namespace Platformsh\Cli\Command\Self; use Platformsh\Cli\Command\CommandBase; -use Platformsh\Cli\Service\Filesystem; use Platformsh\Cli\Util\OsUtil; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -129,7 +128,7 @@ $configDirRelative = $this->config()->getUserConfigDir(false); $rcDestination = $configDirRelative . '/' . 'shell-config.rc'; - $suggestedShellConfig = 'HOME=${HOME:-' . escapeshellarg(Filesystem::getHomeDirectory()) . '}'; + $suggestedShellConfig = 'HOME=${HOME:-' . escapeshellarg($this->config()->getHomeDirectory()) . '}'; $suggestedShellConfig .= PHP_EOL . sprintf( 'export PATH=%s:"$PATH"', '"$HOME/"' . escapeshellarg($configDirRelative . '/bin') @@ -297,7 +296,7 @@ // Replace the home directory with ~, if not on Windows. if (DIRECTORY_SEPARATOR !== '\\') { $realpath = realpath($filename); - $homeDir = Filesystem::getHomeDirectory(); + $homeDir = $this->config()->getHomeDirectory(); if ($realpath && strpos($realpath, $homeDir) === 0) { $arg = '~/' . ltrim(substr($realpath, strlen($homeDir)), '/'); } @@ -326,7 +325,7 @@ if (getcwd() === dirname($filename)) { return basename($filename); } - $homeDir = Filesystem::getHomeDirectory(); + $homeDir = $this->config()->getHomeDirectory(); if (strpos($filename, $homeDir) === 0) { return str_replace($homeDir, '~', $filename); } @@ -348,7 +347,7 @@ $envPrefix = $this->config()->get('service.env_prefix'); if (getenv($envPrefix . 'PROJECT') !== false && getenv($envPrefix . 'APP_DIR') !== false - && getenv($envPrefix . 'APP_DIR') === Filesystem::getHomeDirectory()) { + && getenv($envPrefix . 'APP_DIR') === $this->config()->getHomeDirectory()) { return getenv($envPrefix . 'APP_DIR') . '/.environment'; } @@ -370,7 +369,7 @@ array_unshift($candidates, '.zprofile'); } - $homeDir = Filesystem::getHomeDirectory(); + $homeDir = $this->config()->getHomeDirectory(); foreach ($candidates as $candidate) { if (file_exists($homeDir . DIRECTORY_SEPARATOR . $candidate)) { $this->debug('Found existing config file: ' . $homeDir . DIRECTORY_SEPARATOR . $candidate); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/src/Command/SshKey/SshKeyAddCommand.php new/platformsh-cli-3.51.3/src/Command/SshKey/SshKeyAddCommand.php --- old/platformsh-cli-3.51.1/src/Command/SshKey/SshKeyAddCommand.php 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/src/Command/SshKey/SshKeyAddCommand.php 2020-01-17 16:36:13.000000000 +0100 @@ -30,9 +30,7 @@ $publicKeyPath = $input->getArgument('path'); if (empty($publicKeyPath)) { - /** @var \Platformsh\Cli\Service\Filesystem $fs */ - $fs = $this->getService('fs'); - $defaultKeyPath = $fs->getHomeDirectory() . '/.ssh/' . self::DEFAULT_BASENAME; + $defaultKeyPath = $this->config()->getHomeDirectory() . '/.ssh/' . self::DEFAULT_BASENAME; $defaultPublicKeyPath = $defaultKeyPath . '.pub'; // Look for an existing local key. @@ -180,9 +178,7 @@ ? str_replace('.key', '.' . $number . 'key', $basename) : $basename . '.' . $number; } - /** @var \Platformsh\Cli\Service\Filesystem $fs */ - $fs = $this->getService('fs'); - $filename = $fs->getHomeDirectory() . '/.ssh/' . $basename; + $filename = $this->config()->getHomeDirectory() . '/.ssh/' . $basename; if (file_exists($filename)) { return $this->getNewKeyPath(++$number); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/src/Console/EventSubscriber.php new/platformsh-cli-3.51.3/src/Console/EventSubscriber.php --- old/platformsh-cli-3.51.1/src/Console/EventSubscriber.php 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/src/Console/EventSubscriber.php 2020-01-17 16:36:13.000000000 +0100 @@ -88,9 +88,6 @@ $error )); $event->stopPropagation(); - } else { - $event->setError(new HttpException(null, $error)); - $event->stopPropagation(); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/src/Service/Api.php new/platformsh-cli-3.51.3/src/Service/Api.php --- old/platformsh-cli-3.51.1/src/Service/Api.php 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/src/Service/Api.php 2020-01-17 16:36:13.000000000 +0100 @@ -244,7 +244,7 @@ /** * Finds a proxy address based on the http_proxy or https_proxy environment variables. * - * @return string|null + * @return string|array|null */ private function getProxy() { // The proxy variables should be ignored in a non-CLI context. @@ -253,11 +253,11 @@ } $proxies = []; foreach (['https', 'http'] as $scheme) { - $proxies[$scheme] = str_replace('http://', 'tcp://', getenv($scheme . '_proxy')); + $proxies[$scheme] = str_replace($scheme . '://', 'tcp://', getenv($scheme . '_proxy')); } $proxies = array_filter($proxies); if (count($proxies)) { - return count($proxies) == 1 ? reset($proxies) : $proxies; + return count($proxies) === 1 ? reset($proxies) : $proxies; } return null; @@ -281,7 +281,13 @@ ], ]; $proxy = $this->getProxy(); - if ($proxy !== null) { + if (is_array($proxy)) { + if (isset($proxy['https'])) { + $opts['http']['proxy'] = $proxy['https']; + } elseif (isset($proxy['http'])) { + $opts['http']['proxy'] = $proxy['http']; + } + } elseif (is_string($proxy) && $proxy !== '') { $opts['http']['proxy'] = $proxy; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/src/Service/Config.php new/platformsh-cli-3.51.3/src/Service/Config.php --- old/platformsh-cli-3.51.1/src/Service/Config.php 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/src/Service/Config.php 2020-01-17 16:36:13.000000000 +0100 @@ -101,6 +101,32 @@ } /** + * @return string The absolute path to the user's home directory + */ + public function getHomeDirectory() + { + $prefix = isset(self::$config['application']['env_prefix']) ? self::$config['application']['env_prefix'] : ''; + $envVars = [$prefix . 'HOME', 'HOME', 'USERPROFILE']; + foreach ($envVars as $envVar) { + $value = getenv($envVar); + if (array_key_exists($envVar, $this->env)) { + $value = $this->env[$envVar]; + } + if (is_string($value) && $value !== '') { + if (!is_dir($value)) { + throw new \RuntimeException( + sprintf('Invalid environment variable %s: %s (not a directory)', $envVar, $value) + ); + } + + return realpath($value) ?: $value; + } + } + + throw new \RuntimeException(sprintf('Could not determine home directory. Set the %s environment variable.', $prefix . 'HOME')); + } + + /** * Get the directory where the CLI is normally installed and configured. * * @param bool $absolute Whether to return an absolute path. If false, @@ -112,7 +138,7 @@ { $path = $this->get('application.user_config_dir'); - return $absolute ? $this->fs()->getHomeDirectory() . '/' . $path : $path; + return $absolute ? $this->getHomeDirectory() . '/' . $path : $path; } /** @@ -186,6 +212,7 @@ 'DRUSH' => 'local.drush_executable', 'SESSION_ID' => 'api.session_id', 'SKIP_SSL' => 'api.skip_ssl', + 'API_URL' => 'api.base_url', 'ACCOUNTS_API' => 'api.accounts_api_url', 'ACCOUNTS_API_URL' => 'api.accounts_api_url', 'OAUTH2_AUTH_URL' => 'api.oauth2_auth_url', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/src/Service/Drush.php new/platformsh-cli-3.51.3/src/Service/Drush.php --- old/platformsh-cli-3.51.1/src/Service/Drush.php 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/src/Service/Drush.php 2020-01-17 16:36:13.000000000 +0100 @@ -67,7 +67,7 @@ public function getHomeDir() { - return $this->homeDir ?: Filesystem::getHomeDirectory(); + return $this->homeDir ?: $this->config->getHomeDirectory(); } /** diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/src/Service/Filesystem.php new/platformsh-cli-3.51.3/src/Service/Filesystem.php --- old/platformsh-cli-3.51.1/src/Service/Filesystem.php 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/src/Service/Filesystem.php 2020-01-17 16:36:13.000000000 +0100 @@ -117,26 +117,6 @@ } /** - * @return string The absolute path to the user's home directory - */ - public static function getHomeDirectory() - { - foreach (['HOME', 'USERPROFILE'] as $envVar) { - if ($value = getenv($envVar)) { - if (!is_dir($value)) { - throw new \RuntimeException( - sprintf('Invalid environment variable %s: %s (not a directory)', $envVar, $value) - ); - } - - return $value; - } - } - - throw new \RuntimeException('Could not determine home directory'); - } - - /** * @param string $dir * @param int $mode */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/src/Service/State.php new/platformsh-cli-3.51.3/src/Service/State.php --- old/platformsh-cli-3.51.1/src/Service/State.php 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/src/Service/State.php 2020-01-17 16:36:13.000000000 +0100 @@ -85,6 +85,6 @@ */ protected function getFilename() { - return Filesystem::getHomeDirectory() . '/' . $this->config->get('application.user_state_file'); + return $this->config->getHomeDirectory() . '/' . $this->config->get('application.user_state_file'); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/tests/ConfigTest.php new/platformsh-cli-3.51.3/tests/ConfigTest.php --- old/platformsh-cli-3.51.1/tests/ConfigTest.php 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/tests/ConfigTest.php 2020-01-17 16:36:13.000000000 +0100 @@ -18,6 +18,19 @@ $this->assertEquals(123, $config->getWithDefault('nonexistent', 123)); } + public function testGetHomeDirectory() + { + $homeDir = (new Config(['HOME' => '.']))->getHomeDirectory(); + $this->assertNotEmpty($homeDir, 'Home directory returned'); + $this->assertNotEquals('.', $homeDir, 'Home directory not relative'); + + $homeDir = (new Config(['PLATFORMSH_CLI_HOME' => __DIR__ . '/data', 'HOME' => __DIR__]))->getHomeDirectory(); + $this->assertEquals(__DIR__ . '/data', $homeDir, 'Home directory overridden'); + + $homeDir = (new Config(['PLATFORMSH_CLI_HOME' => '', 'HOME' => __DIR__]))->getHomeDirectory(); + $this->assertEquals(__DIR__, $homeDir, 'Empty value treated as nonexistent'); + } + /** * Test that selected environment variables can override initial config. */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/platformsh-cli-3.51.1/tests/Service/FilesystemServiceTest.php new/platformsh-cli-3.51.3/tests/Service/FilesystemServiceTest.php --- old/platformsh-cli-3.51.1/tests/Service/FilesystemServiceTest.php 2020-01-15 16:55:46.000000000 +0100 +++ new/platformsh-cli-3.51.3/tests/Service/FilesystemServiceTest.php 2020-01-17 16:36:13.000000000 +0100 @@ -34,16 +34,6 @@ } /** - * Test FilesystemHelper::getHomeDirectory(). - */ - public function testGetHomeDirectory() - { - $homeDir = $this->fs->getHomeDirectory(); - $this->assertNotEmpty($homeDir, 'Home directory returned'); - $this->assertNotEmpty(realpath($homeDir), 'Home directory exists'); - } - - /** * Test FilesystemHelper::remove() on directories. */ public function testRemoveDir() ++++++ platformsh-cli-vendor.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/autoload.php new/vendor/autoload.php --- old/vendor/autoload.php 2020-01-15 22:17:20.781516873 +0100 +++ new/vendor/autoload.php 2020-01-17 21:44:21.767464197 +0100 @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit39e92c99682824c4989cae75c4e9fb03::getLoader(); +return ComposerAutoloaderInitd8c966fdb01eb7066c738e0e8bfc76d7::getLoader(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/composer/autoload_real.php new/vendor/composer/autoload_real.php --- old/vendor/composer/autoload_real.php 2020-01-15 22:17:20.781516873 +0100 +++ new/vendor/composer/autoload_real.php 2020-01-17 21:44:21.767464197 +0100 @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit39e92c99682824c4989cae75c4e9fb03 +class ComposerAutoloaderInitd8c966fdb01eb7066c738e0e8bfc76d7 { private static $loader; @@ -19,15 +19,15 @@ return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit39e92c99682824c4989cae75c4e9fb03', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitd8c966fdb01eb7066c738e0e8bfc76d7', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInit39e92c99682824c4989cae75c4e9fb03', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitd8c966fdb01eb7066c738e0e8bfc76d7', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit39e92c99682824c4989cae75c4e9fb03::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitd8c966fdb01eb7066c738e0e8bfc76d7::getInitializer($loader)); } else { $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -48,19 +48,19 @@ $loader->register(true); if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit39e92c99682824c4989cae75c4e9fb03::$files; + $includeFiles = Composer\Autoload\ComposerStaticInitd8c966fdb01eb7066c738e0e8bfc76d7::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; } foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire39e92c99682824c4989cae75c4e9fb03($fileIdentifier, $file); + composerRequired8c966fdb01eb7066c738e0e8bfc76d7($fileIdentifier, $file); } return $loader; } } -function composerRequire39e92c99682824c4989cae75c4e9fb03($fileIdentifier, $file) +function composerRequired8c966fdb01eb7066c738e0e8bfc76d7($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { require $file; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/composer/autoload_static.php new/vendor/composer/autoload_static.php --- old/vendor/composer/autoload_static.php 2020-01-15 22:17:20.781516873 +0100 +++ new/vendor/composer/autoload_static.php 2020-01-17 21:44:21.767464197 +0100 @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit39e92c99682824c4989cae75c4e9fb03 +class ComposerStaticInitd8c966fdb01eb7066c738e0e8bfc76d7 { public static $files = array ( '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', @@ -193,9 +193,9 @@ public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit39e92c99682824c4989cae75c4e9fb03::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit39e92c99682824c4989cae75c4e9fb03::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit39e92c99682824c4989cae75c4e9fb03::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitd8c966fdb01eb7066c738e0e8bfc76d7::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitd8c966fdb01eb7066c738e0e8bfc76d7::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitd8c966fdb01eb7066c738e0e8bfc76d7::$classMap; }, null, ClassLoader::class); }