Adds gitea URL. Adds option to add changelog gh-813. Adds clone option to some areas. Fixed gh-784 to allow BASE64 filter selection.
This commit is contained in:
157
libraries/phpseclib/vendor/composer/ClassLoader.php
vendored
157
libraries/phpseclib/vendor/composer/ClassLoader.php
vendored
@ -37,57 +37,130 @@ namespace Composer\Autoload;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see http://www.php-fig.org/psr/psr-0/
|
||||
* @see http://www.php-fig.org/psr/psr-4/
|
||||
* @see https://www.php-fig.org/psr/psr-0/
|
||||
* @see https://www.php-fig.org/psr/psr-4/
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
/** @var ?string */
|
||||
private $vendorDir;
|
||||
|
||||
// PSR-4
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, int>>
|
||||
*/
|
||||
private $prefixLengthsPsr4 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<int, string>>
|
||||
*/
|
||||
private $prefixDirsPsr4 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, string[]>>
|
||||
*/
|
||||
private $prefixesPsr0 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
/** @var bool */
|
||||
private $useIncludePath = false;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $classMap = array();
|
||||
|
||||
/** @var bool */
|
||||
private $classMapAuthoritative = false;
|
||||
|
||||
/**
|
||||
* @var bool[]
|
||||
* @psalm-var array<string, bool>
|
||||
*/
|
||||
private $missingClasses = array();
|
||||
|
||||
/** @var ?string */
|
||||
private $apcuPrefix;
|
||||
|
||||
/**
|
||||
* @var self[]
|
||||
*/
|
||||
private static $registeredLoaders = array();
|
||||
|
||||
/**
|
||||
* @param ?string $vendorDir
|
||||
*/
|
||||
public function __construct($vendorDir = null)
|
||||
{
|
||||
$this->vendorDir = $vendorDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getPrefixes()
|
||||
{
|
||||
if (!empty($this->prefixesPsr0)) {
|
||||
return call_user_func_array('array_merge', $this->prefixesPsr0);
|
||||
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, array<int, string>>
|
||||
*/
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
return $this->prefixDirsPsr4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirsPsr0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
return $this->fallbackDirsPsr4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[] Array of classname => path
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $classMap Class to filename map
|
||||
* @param string[] $classMap Class to filename map
|
||||
* @psalm-param array<string, string> $classMap
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
@ -102,9 +175,11 @@ class ClassLoader
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
* @param string $prefix The prefix
|
||||
* @param string[]|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
@ -147,11 +222,13 @@ class ClassLoader
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param string[]|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
@ -195,8 +272,10 @@ class ClassLoader
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param array|string $paths The PSR-0 base directories
|
||||
* @param string $prefix The prefix
|
||||
* @param string[]|string $paths The PSR-0 base directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
@ -211,10 +290,12 @@ class ClassLoader
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param array|string $paths The PSR-4 base directories
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param string[]|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPsr4($prefix, $paths)
|
||||
{
|
||||
@ -234,6 +315,8 @@ class ClassLoader
|
||||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
@ -256,6 +339,8 @@ class ClassLoader
|
||||
* that have not been registered with the class map.
|
||||
*
|
||||
* @param bool $classMapAuthoritative
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||
{
|
||||
@ -276,6 +361,8 @@ class ClassLoader
|
||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||
*
|
||||
* @param string|null $apcuPrefix
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setApcuPrefix($apcuPrefix)
|
||||
{
|
||||
@ -296,25 +383,44 @@ class ClassLoader
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
|
||||
if (null === $this->vendorDir) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($prepend) {
|
||||
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
|
||||
} else {
|
||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||
self::$registeredLoaders[$this->vendorDir] = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
|
||||
if (null !== $this->vendorDir) {
|
||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return bool|null True if loaded, null otherwise
|
||||
* @return true|null True if loaded, null otherwise
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
@ -323,6 +429,8 @@ class ClassLoader
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -367,6 +475,21 @@ class ClassLoader
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently registered loaders indexed by their corresponding vendor directories.
|
||||
*
|
||||
* @return self[]
|
||||
*/
|
||||
public static function getRegisteredLoaders()
|
||||
{
|
||||
return self::$registeredLoaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param string $ext
|
||||
* @return string|false
|
||||
*/
|
||||
private function findFileWithExtension($class, $ext)
|
||||
{
|
||||
// PSR-4 lookup
|
||||
@ -438,6 +561,10 @@ class ClassLoader
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*
|
||||
* @param string $file
|
||||
* @return void
|
||||
* @private
|
||||
*/
|
||||
function includeFile($file)
|
||||
{
|
||||
|
350
libraries/phpseclib/vendor/composer/InstalledVersions.php
vendored
Normal file
350
libraries/phpseclib/vendor/composer/InstalledVersions.php
vendored
Normal file
@ -0,0 +1,350 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer;
|
||||
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use Composer\Semver\VersionParser;
|
||||
|
||||
/**
|
||||
* This class is copied in every Composer installed project and available to all
|
||||
*
|
||||
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
||||
*
|
||||
* To require its presence, you can require `composer-runtime-api ^2.0`
|
||||
*/
|
||||
class InstalledVersions
|
||||
{
|
||||
/**
|
||||
* @var mixed[]|null
|
||||
* @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
|
||||
*/
|
||||
private static $installed;
|
||||
|
||||
/**
|
||||
* @var bool|null
|
||||
*/
|
||||
private static $canGetVendors;
|
||||
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
||||
*/
|
||||
private static $installedByVendor = array();
|
||||
|
||||
/**
|
||||
* Returns a list of all package names which are present, either by being installed, replaced or provided
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return list<string>
|
||||
*/
|
||||
public static function getInstalledPackages()
|
||||
{
|
||||
$packages = array();
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
$packages[] = array_keys($installed['versions']);
|
||||
}
|
||||
|
||||
if (1 === \count($packages)) {
|
||||
return $packages[0];
|
||||
}
|
||||
|
||||
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all package names with a specific type e.g. 'library'
|
||||
*
|
||||
* @param string $type
|
||||
* @return string[]
|
||||
* @psalm-return list<string>
|
||||
*/
|
||||
public static function getInstalledPackagesByType($type)
|
||||
{
|
||||
$packagesByType = array();
|
||||
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
foreach ($installed['versions'] as $name => $package) {
|
||||
if (isset($package['type']) && $package['type'] === $type) {
|
||||
$packagesByType[] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $packagesByType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given package is installed
|
||||
*
|
||||
* This also returns true if the package name is provided or replaced by another package
|
||||
*
|
||||
* @param string $packageName
|
||||
* @param bool $includeDevRequirements
|
||||
* @return bool
|
||||
*/
|
||||
public static function isInstalled($packageName, $includeDevRequirements = true)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (isset($installed['versions'][$packageName])) {
|
||||
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given package satisfies a version constraint
|
||||
*
|
||||
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
|
||||
*
|
||||
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
|
||||
*
|
||||
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
|
||||
* @param string $packageName
|
||||
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
|
||||
* @return bool
|
||||
*/
|
||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||
{
|
||||
$constraint = $parser->parseConstraints($constraint);
|
||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||
|
||||
return $provided->matches($constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a version constraint representing all the range(s) which are installed for a given package
|
||||
*
|
||||
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
|
||||
* whether a given version of a package is installed, and not just whether it exists
|
||||
*
|
||||
* @param string $packageName
|
||||
* @return string Version constraint usable with composer/semver
|
||||
*/
|
||||
public static function getVersionRanges($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ranges = array();
|
||||
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
||||
}
|
||||
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
||||
}
|
||||
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
||||
}
|
||||
|
||||
return implode(' || ', $ranges);
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||
*/
|
||||
public static function getVersion($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['version'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||
*/
|
||||
public static function getPrettyVersion($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
|
||||
*/
|
||||
public static function getReference($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['reference'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['reference'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
||||
*/
|
||||
public static function getInstallPath($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
|
||||
*/
|
||||
public static function getRootPackage()
|
||||
{
|
||||
$installed = self::getInstalled();
|
||||
|
||||
return $installed[0]['root'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw installed.php data for custom implementations
|
||||
*
|
||||
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
||||
* @return array[]
|
||||
* @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
|
||||
*/
|
||||
public static function getRawData()
|
||||
{
|
||||
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
|
||||
|
||||
if (null === self::$installed) {
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
self::$installed = include __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
|
||||
return self::$installed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
||||
*
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
||||
*/
|
||||
public static function getAllRawData()
|
||||
{
|
||||
return self::getInstalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets you reload the static array from another file
|
||||
*
|
||||
* This is only useful for complex integrations in which a project needs to use
|
||||
* this class but then also needs to execute another project's autoloader in process,
|
||||
* and wants to ensure both projects have access to their version of installed.php.
|
||||
*
|
||||
* A typical case would be PHPUnit, where it would need to make sure it reads all
|
||||
* the data it needs from this class, then call reload() with
|
||||
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
|
||||
* the project in which it runs can then also use this class safely, without
|
||||
* interference between PHPUnit's dependencies and the project's dependencies.
|
||||
*
|
||||
* @param array[] $data A vendor/composer/installed.php data set
|
||||
* @return void
|
||||
*
|
||||
* @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
|
||||
*/
|
||||
public static function reload($data)
|
||||
{
|
||||
self::$installed = $data;
|
||||
self::$installedByVendor = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
||||
*/
|
||||
private static function getInstalled()
|
||||
{
|
||||
if (null === self::$canGetVendors) {
|
||||
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
||||
}
|
||||
|
||||
$installed = array();
|
||||
|
||||
if (self::$canGetVendors) {
|
||||
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir];
|
||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
||||
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||
self::$installed = $installed[count($installed) - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null === self::$installed) {
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
self::$installed = require __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
$installed[] = self::$installed;
|
||||
|
||||
return $installed;
|
||||
}
|
||||
}
|
2
libraries/phpseclib/vendor/composer/LICENSE
vendored
2
libraries/phpseclib/vendor/composer/LICENSE
vendored
@ -1,3 +1,4 @@
|
||||
|
||||
Copyright (c) Nils Adermann, Jordi Boggiano
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@ -17,3 +18,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
@ -6,4 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||
);
|
||||
|
@ -22,13 +22,15 @@ class ComposerAutoloaderInit10d22a526bd476954b93748a871e7ad4
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
require __DIR__ . '/platform_check.php';
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit10d22a526bd476954b93748a871e7ad4', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit10d22a526bd476954b93748a871e7ad4', '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';
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit10d22a526bd476954b93748a871e7ad4::getInitializer($loader));
|
||||
} else {
|
||||
|
@ -24,11 +24,16 @@ class ComposerStaticInit10d22a526bd476954b93748a871e7ad4
|
||||
),
|
||||
);
|
||||
|
||||
public static $classMap = array (
|
||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||
);
|
||||
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit10d22a526bd476954b93748a871e7ad4::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit10d22a526bd476954b93748a871e7ad4::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit10d22a526bd476954b93748a871e7ad4::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
221
libraries/phpseclib/vendor/composer/installed.json
vendored
221
libraries/phpseclib/vendor/composer/installed.json
vendored
@ -1,109 +1,114 @@
|
||||
[
|
||||
{
|
||||
"name": "phpseclib/phpseclib",
|
||||
"version": "2.0.32",
|
||||
"version_normalized": "2.0.32.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpseclib/phpseclib.git",
|
||||
"reference": "f5c4c19880d45d0be3e7d24ae8ac434844a898cd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/f5c4c19880d45d0be3e7d24ae8ac434844a898cd",
|
||||
"reference": "f5c4c19880d45d0be3e7d24ae8ac434844a898cd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phing/phing": "~2.7",
|
||||
"phpunit/phpunit": "^4.8.35|^5.7|^6.0|^9.4",
|
||||
"squizlabs/php_codesniffer": "~2.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
|
||||
"ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.",
|
||||
"ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.",
|
||||
"ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations."
|
||||
},
|
||||
"time": "2021-06-12T12:12:59+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"phpseclib/bootstrap.php"
|
||||
{
|
||||
"packages": [
|
||||
{
|
||||
"name": "phpseclib/phpseclib",
|
||||
"version": "2.0.35",
|
||||
"version_normalized": "2.0.35.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpseclib/phpseclib.git",
|
||||
"reference": "4e16cf3f5f927a7d3f5317820af795c0366c0420"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/4e16cf3f5f927a7d3f5317820af795c0366c0420",
|
||||
"reference": "4e16cf3f5f927a7d3f5317820af795c0366c0420",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phing/phing": "~2.7",
|
||||
"phpunit/phpunit": "^4.8.35|^5.7|^6.0|^9.4",
|
||||
"squizlabs/php_codesniffer": "~2.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
|
||||
"ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.",
|
||||
"ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.",
|
||||
"ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations."
|
||||
},
|
||||
"time": "2021-11-28T23:30:39+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"files": [
|
||||
"phpseclib/bootstrap.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"phpseclib\\": "phpseclib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"psr-4": {
|
||||
"phpseclib\\": "phpseclib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jim Wigginton",
|
||||
"email": "terrafrost@php.net",
|
||||
"role": "Lead Developer"
|
||||
},
|
||||
{
|
||||
"name": "Patrick Monnerat",
|
||||
"email": "pm@datasphere.ch",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Andreas Fischer",
|
||||
"email": "bantu@phpbb.com",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Hans-Jürgen Petrich",
|
||||
"email": "petrich@tronic-media.com",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Graham Campbell",
|
||||
"email": "graham@alt-three.com",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.",
|
||||
"homepage": "http://phpseclib.sourceforge.net",
|
||||
"keywords": [
|
||||
"BigInteger",
|
||||
"aes",
|
||||
"asn.1",
|
||||
"asn1",
|
||||
"blowfish",
|
||||
"crypto",
|
||||
"cryptography",
|
||||
"encryption",
|
||||
"rsa",
|
||||
"security",
|
||||
"sftp",
|
||||
"signature",
|
||||
"signing",
|
||||
"ssh",
|
||||
"twofish",
|
||||
"x.509",
|
||||
"x509"
|
||||
],
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/terrafrost",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://www.patreon.com/phpseclib",
|
||||
"type": "patreon"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib",
|
||||
"type": "tidelift"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jim Wigginton",
|
||||
"email": "terrafrost@php.net",
|
||||
"role": "Lead Developer"
|
||||
},
|
||||
{
|
||||
"name": "Patrick Monnerat",
|
||||
"email": "pm@datasphere.ch",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Andreas Fischer",
|
||||
"email": "bantu@phpbb.com",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Hans-Jürgen Petrich",
|
||||
"email": "petrich@tronic-media.com",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Graham Campbell",
|
||||
"email": "graham@alt-three.com",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.",
|
||||
"homepage": "http://phpseclib.sourceforge.net",
|
||||
"keywords": [
|
||||
"BigInteger",
|
||||
"aes",
|
||||
"asn.1",
|
||||
"asn1",
|
||||
"blowfish",
|
||||
"crypto",
|
||||
"cryptography",
|
||||
"encryption",
|
||||
"rsa",
|
||||
"security",
|
||||
"sftp",
|
||||
"signature",
|
||||
"signing",
|
||||
"ssh",
|
||||
"twofish",
|
||||
"x.509",
|
||||
"x509"
|
||||
],
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/terrafrost",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://www.patreon.com/phpseclib",
|
||||
"type": "patreon"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"install-path": "../phpseclib/phpseclib"
|
||||
}
|
||||
],
|
||||
"dev": true,
|
||||
"dev-package-names": []
|
||||
}
|
||||
|
32
libraries/phpseclib/vendor/composer/installed.php
vendored
Normal file
32
libraries/phpseclib/vendor/composer/installed.php
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?php return array(
|
||||
'root' => array(
|
||||
'pretty_version' => '1.0.0+no-version-set',
|
||||
'version' => '1.0.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => NULL,
|
||||
'name' => '__root__',
|
||||
'dev' => true,
|
||||
),
|
||||
'versions' => array(
|
||||
'__root__' => array(
|
||||
'pretty_version' => '1.0.0+no-version-set',
|
||||
'version' => '1.0.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => NULL,
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'phpseclib/phpseclib' => array(
|
||||
'pretty_version' => '2.0.35',
|
||||
'version' => '2.0.35.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../phpseclib/phpseclib',
|
||||
'aliases' => array(),
|
||||
'reference' => '4e16cf3f5f927a7d3f5317820af795c0366c0420',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
),
|
||||
);
|
26
libraries/phpseclib/vendor/composer/platform_check.php
vendored
Normal file
26
libraries/phpseclib/vendor/composer/platform_check.php
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
// platform_check.php @generated by Composer
|
||||
|
||||
$issues = array();
|
||||
|
||||
if (!(PHP_VERSION_ID >= 50303)) {
|
||||
$issues[] = 'Your Composer dependencies require a PHP version ">= 5.3.3". You are running ' . PHP_VERSION . '.';
|
||||
}
|
||||
|
||||
if ($issues) {
|
||||
if (!headers_sent()) {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
}
|
||||
if (!ini_get('display_errors')) {
|
||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
|
||||
} elseif (!headers_sent()) {
|
||||
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
@ -5,4 +5,5 @@ phpseclib ongoing development is made possible by [Tidelift](https://tidelift.co
|
||||
## Backers
|
||||
|
||||
- Zane Hooper
|
||||
- [Setasign](https://www.setasign.com/)
|
||||
- [Setasign](https://www.setasign.com/)
|
||||
- Allan Simon
|
@ -66,6 +66,12 @@ Need Support?
|
||||
* [Create a Support Ticket on GitHub](https://github.com/phpseclib/phpseclib/issues/new)
|
||||
* [Browse the Support Forum](http://www.frostjedi.com/phpbb/viewforum.php?f=46) (no longer in use)
|
||||
|
||||
## Special Thanks
|
||||
|
||||
Special Thanks to our Patreon sponsors!:
|
||||
|
||||
- Allan Simon
|
||||
|
||||
## Contributing
|
||||
|
||||
1. Fork the Project
|
||||
|
@ -878,9 +878,9 @@ class RSA
|
||||
);
|
||||
$key = "openssh-key-v1\0$key";
|
||||
|
||||
return "-----BEGIN OPENSSH PRIVATE KEY-----\r\n" .
|
||||
chunk_split(base64_encode($key), 70) .
|
||||
"-----END OPENSSH PRIVATE KEY-----";
|
||||
return "-----BEGIN OPENSSH PRIVATE KEY-----\n" .
|
||||
chunk_split(base64_encode($key), 70, "\n") .
|
||||
"-----END OPENSSH PRIVATE KEY-----\n";
|
||||
default: // eg. self::PRIVATE_FORMAT_PKCS1
|
||||
$components = array();
|
||||
foreach ($raw as $name => $value) {
|
||||
|
@ -234,6 +234,9 @@ class ASN1
|
||||
{
|
||||
$current = array('start' => $start);
|
||||
|
||||
if (!isset($encoded[$encoded_pos])) {
|
||||
return false;
|
||||
}
|
||||
$type = ord($encoded[$encoded_pos++]);
|
||||
$startOffset = 1;
|
||||
|
||||
@ -244,6 +247,9 @@ class ASN1
|
||||
$tag = 0;
|
||||
// process septets (since the eighth bit is ignored, it's not an octet)
|
||||
do {
|
||||
if (!isset($encoded[$encoded_pos])) {
|
||||
return false;
|
||||
}
|
||||
$temp = ord($encoded[$encoded_pos++]);
|
||||
$startOffset++;
|
||||
$loop = $temp >> 7;
|
||||
@ -260,6 +266,9 @@ class ASN1
|
||||
$start+= $startOffset;
|
||||
|
||||
// Length, as discussed in paragraph 8.1.3 of X.690-0207.pdf#page=13
|
||||
if (!isset($encoded[$encoded_pos])) {
|
||||
return false;
|
||||
}
|
||||
$length = ord($encoded[$encoded_pos++]);
|
||||
$start++;
|
||||
if ($length == 0x80) { // indefinite length
|
||||
|
@ -1622,7 +1622,6 @@ class X509
|
||||
$id = $extensions[$i]['extnId'];
|
||||
$value = &$extensions[$i]['extnValue'];
|
||||
$value = base64_decode($value);
|
||||
$decoded = $asn1->decodeBER($value);
|
||||
/* [extnValue] contains the DER encoding of an ASN.1 value
|
||||
corresponding to the extension type identified by extnID */
|
||||
$map = $this->_getMapping($id);
|
||||
@ -1630,6 +1629,7 @@ class X509
|
||||
$decoder = $id == 'id-ce-nameConstraints' ?
|
||||
array($this, '_decodeNameConstraintIP') :
|
||||
array($this, '_decodeIP');
|
||||
$decoded = $asn1->decodeBER($value);
|
||||
$mapped = $asn1->asn1map($decoded[0], $map, array('iPAddress' => $decoder));
|
||||
$value = $mapped === false ? $decoded[0] : $mapped;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -61,6 +61,23 @@ use phpseclib\Crypt\Twofish;
|
||||
use phpseclib\Math\BigInteger; // Used to do Diffie-Hellman key exchange and DSA/RSA signature verification.
|
||||
use phpseclib\System\SSH\Agent;
|
||||
|
||||
/**#@+
|
||||
* @access private
|
||||
*/
|
||||
/**
|
||||
* No compression
|
||||
*/
|
||||
define('NET_SSH2_COMPRESSION_NONE', 1);
|
||||
/**
|
||||
* zlib compression
|
||||
*/
|
||||
define('NET_SSH2_COMPRESSION_ZLIB', 2);
|
||||
/**
|
||||
* zlib@openssh.com
|
||||
*/
|
||||
define('NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH', 3);
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* Pure-PHP implementation of SSHv2.
|
||||
*
|
||||
@ -975,8 +992,65 @@ class SSH2
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc4252#section-5.1
|
||||
* @var array|null
|
||||
* @access private
|
||||
*/
|
||||
private $auth_methods_to_continue = null;
|
||||
var $auth_methods_to_continue = null;
|
||||
|
||||
/**
|
||||
* Compression method
|
||||
*
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
var $compress = NET_SSH2_COMPRESSION_NONE;
|
||||
|
||||
/**
|
||||
* Decompression method
|
||||
*
|
||||
* @var resource|object
|
||||
* @access private
|
||||
*/
|
||||
var $decompress = NET_SSH2_COMPRESSION_NONE;
|
||||
|
||||
/**
|
||||
* Compression context
|
||||
*
|
||||
* @var int
|
||||
* @access private
|
||||
*/
|
||||
var $compress_context;
|
||||
|
||||
/**
|
||||
* Decompression context
|
||||
*
|
||||
* @var resource|object
|
||||
* @access private
|
||||
*/
|
||||
var $decompress_context;
|
||||
|
||||
/**
|
||||
* Regenerate Compression Context
|
||||
*
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
var $regenerate_compression_context = false;
|
||||
|
||||
/**
|
||||
* Regenerate Decompression Context
|
||||
*
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
var $regenerate_decompression_context = false;
|
||||
|
||||
/**
|
||||
* Smart multi-factor authentication flag
|
||||
*
|
||||
* @var bool
|
||||
* @access private
|
||||
*/
|
||||
var $smartMFA = true;
|
||||
|
||||
/**
|
||||
* Default Constructor.
|
||||
@ -1569,19 +1643,25 @@ class SSH2
|
||||
return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED);
|
||||
}
|
||||
|
||||
$compression_map = array(
|
||||
'none' => NET_SSH2_COMPRESSION_NONE,
|
||||
'zlib' => NET_SSH2_COMPRESSION_ZLIB,
|
||||
'zlib@openssh.com' => NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH
|
||||
);
|
||||
|
||||
$compression_algorithm_out = $this->_array_intersect_first($c2s_compression_algorithms, $this->compression_algorithms_client_to_server);
|
||||
if ($compression_algorithm_out === false) {
|
||||
user_error('No compatible client to server compression algorithms found');
|
||||
return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED);
|
||||
}
|
||||
//$this->decompress = $compression_algorithm_out == 'zlib';
|
||||
$this->compress = $compression_map[$compression_algorithm_out];
|
||||
|
||||
$compression_algorithm_in = $this->_array_intersect_first($s2c_compression_algorithms, $this->compression_algorithms_client_to_server);
|
||||
$compression_algorithm_in = $this->_array_intersect_first($s2c_compression_algorithms, $this->compression_algorithms_server_to_client);
|
||||
if ($compression_algorithm_in === false) {
|
||||
user_error('No compatible server to client compression algorithms found');
|
||||
return $this->_disconnect(NET_SSH2_DISCONNECT_KEY_EXCHANGE_FAILED);
|
||||
}
|
||||
//$this->compress = $compression_algorithm_in == 'zlib';
|
||||
$this->decompress = $compression_map[$compression_algorithm_in];
|
||||
|
||||
// Only relevant in diffie-hellman-group-exchange-sha{1,256}, otherwise empty.
|
||||
$exchange_hash_rfc4419 = '';
|
||||
@ -2014,6 +2094,8 @@ class SSH2
|
||||
}
|
||||
$this->hmac_check->setKey(substr($key, 0, $checkKeyLength));
|
||||
|
||||
$this->regenerate_compression_context = $this->regenerate_decompression_context = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2142,7 +2224,7 @@ class SSH2
|
||||
|
||||
// try logging with 'none' as an authentication method first since that's what
|
||||
// PuTTY does
|
||||
if (substr($this->server_identifier, 0, 13) != 'SSH-2.0-CoreFTP' && $this->auth_methods_to_continue === null) {
|
||||
if (substr($this->server_identifier, 0, 15) != 'SSH-2.0-CoreFTP' && $this->auth_methods_to_continue === null) {
|
||||
if ($this->_login($username)) {
|
||||
return true;
|
||||
}
|
||||
@ -2174,9 +2256,57 @@ class SSH2
|
||||
return $this->_login_helper($username);
|
||||
}
|
||||
|
||||
foreach ($args as $arg) {
|
||||
if ($this->_login_helper($username, $arg)) {
|
||||
return true;
|
||||
while (count($args)) {
|
||||
if (!$this->auth_methods_to_continue || !$this->smartMFA) {
|
||||
$newargs = $args;
|
||||
$args = array();
|
||||
} else {
|
||||
$newargs = array();
|
||||
foreach ($this->auth_methods_to_continue as $method) {
|
||||
switch ($method) {
|
||||
case 'publickey':
|
||||
foreach ($args as $key => $arg) {
|
||||
if (is_object($arg)) {
|
||||
$newargs[] = $arg;
|
||||
unset($args[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'keyboard-interactive':
|
||||
$hasArray = $hasString = false;
|
||||
foreach ($args as $arg) {
|
||||
if ($hasArray || is_array($arg)) {
|
||||
$hasArray = true;
|
||||
break;
|
||||
}
|
||||
if ($hasString || is_string($arg)) {
|
||||
$hasString = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($hasArray && $hasString) {
|
||||
foreach ($args as $key => $arg) {
|
||||
if (is_array($arg)) {
|
||||
$newargs[] = $arg;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
case 'password':
|
||||
foreach ($args as $key => $arg) {
|
||||
$newargs[] = $arg;
|
||||
unset($args[$key]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($newargs as $arg) {
|
||||
if ($this->_login_helper($username, $arg)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -2814,26 +2944,12 @@ class SSH2
|
||||
return false;
|
||||
}
|
||||
|
||||
$response = $this->_get_binary_packet();
|
||||
if ($response === false) {
|
||||
$this->bitmap = 0;
|
||||
user_error('Connection closed by server');
|
||||
return false;
|
||||
$this->channel_status[self::CHANNEL_EXEC] = NET_SSH2_MSG_CHANNEL_REQUEST;
|
||||
if (!$this->_get_channel_packet(self::CHANNEL_EXEC)) {
|
||||
user_error('Unable to request pseudo-terminal');
|
||||
return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION);
|
||||
}
|
||||
|
||||
if (!strlen($response)) {
|
||||
return false;
|
||||
}
|
||||
list(, $type) = unpack('C', $this->_string_shift($response, 1));
|
||||
|
||||
switch ($type) {
|
||||
case NET_SSH2_MSG_CHANNEL_SUCCESS:
|
||||
break;
|
||||
case NET_SSH2_MSG_CHANNEL_FAILURE:
|
||||
default:
|
||||
user_error('Unable to request pseudo-terminal');
|
||||
return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION);
|
||||
}
|
||||
$this->in_request_pty_exec = true;
|
||||
}
|
||||
|
||||
@ -2954,6 +3070,13 @@ class SSH2
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->channel_status[self::CHANNEL_SHELL] = NET_SSH2_MSG_CHANNEL_REQUEST;
|
||||
|
||||
if (!$this->_get_channel_packet(self::CHANNEL_SHELL)) {
|
||||
user_error('Unable to request pseudo-terminal');
|
||||
return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION);
|
||||
}
|
||||
|
||||
$packet = pack(
|
||||
'CNNa*C',
|
||||
NET_SSH2_MSG_CHANNEL_REQUEST,
|
||||
@ -2966,7 +3089,12 @@ class SSH2
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->channel_status[self::CHANNEL_SHELL] = NET_SSH2_MSG_IGNORE;
|
||||
$response = $this->_get_channel_packet(self::CHANNEL_SHELL);
|
||||
if ($response === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->channel_status[self::CHANNEL_SHELL] = NET_SSH2_MSG_CHANNEL_DATA;
|
||||
|
||||
$this->bitmap |= self::MASK_SHELL;
|
||||
|
||||
@ -3384,7 +3512,7 @@ class SSH2
|
||||
|
||||
if (!is_resource($this->fsock) || feof($this->fsock)) {
|
||||
$this->bitmap = 0;
|
||||
user_error('Connection closed prematurely');
|
||||
user_error('Connection closed (by server) prematurely ' . $elapsed . 's');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3392,7 +3520,8 @@ class SSH2
|
||||
$raw = stream_get_contents($this->fsock, $this->decrypt_block_size);
|
||||
|
||||
if (!strlen($raw)) {
|
||||
return '';
|
||||
user_error('No data received from server');
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->decrypt !== false) {
|
||||
@ -3455,9 +3584,41 @@ class SSH2
|
||||
}
|
||||
}
|
||||
|
||||
//if ($this->decompress) {
|
||||
// $payload = gzinflate(substr($payload, 2));
|
||||
//}
|
||||
switch ($this->decompress) {
|
||||
case NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH:
|
||||
if (!$this->isAuthenticated()) {
|
||||
break;
|
||||
}
|
||||
case NET_SSH2_COMPRESSION_ZLIB:
|
||||
if ($this->regenerate_decompression_context) {
|
||||
$this->regenerate_decompression_context = false;
|
||||
|
||||
$cmf = ord($payload[0]);
|
||||
$cm = $cmf & 0x0F;
|
||||
if ($cm != 8) { // deflate
|
||||
user_error("Only CM = 8 ('deflate') is supported ($cm)");
|
||||
}
|
||||
$cinfo = ($cmf & 0xF0) >> 4;
|
||||
if ($cinfo > 7) {
|
||||
user_error("CINFO above 7 is not allowed ($cinfo)");
|
||||
}
|
||||
$windowSize = 1 << ($cinfo + 8);
|
||||
|
||||
$flg = ord($payload[1]);
|
||||
//$fcheck = $flg && 0x0F;
|
||||
if ((($cmf << 8) | $flg) % 31) {
|
||||
user_error('fcheck failed');
|
||||
}
|
||||
$fdict = boolval($flg & 0x20);
|
||||
$flevel = ($flg & 0xC0) >> 6;
|
||||
|
||||
$this->decompress_context = inflate_init(ZLIB_ENCODING_RAW, array('window' => $cinfo + 8));
|
||||
$payload = substr($payload, 2);
|
||||
}
|
||||
if ($this->decompress_context) {
|
||||
$payload = inflate_add($this->decompress_context, $payload, ZLIB_PARTIAL_FLUSH);
|
||||
}
|
||||
}
|
||||
|
||||
$this->get_seq_no++;
|
||||
|
||||
@ -3737,7 +3898,20 @@ class SSH2
|
||||
function _get_channel_packet($client_channel, $skip_extended = false)
|
||||
{
|
||||
if (!empty($this->channel_buffers[$client_channel])) {
|
||||
return array_shift($this->channel_buffers[$client_channel]);
|
||||
switch ($this->channel_status[$client_channel]) {
|
||||
case NET_SSH2_MSG_CHANNEL_REQUEST:
|
||||
foreach ($this->channel_buffers[$client_channel] as $i => $packet) {
|
||||
switch (ord($packet[0])) {
|
||||
case NET_SSH2_MSG_CHANNEL_SUCCESS:
|
||||
case NET_SSH2_MSG_CHANNEL_FAILURE:
|
||||
unset($this->channel_buffers[$client_channel][$i]);
|
||||
return substr($packet, 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return substr(array_shift($this->channel_buffers[$client_channel]), 1);
|
||||
}
|
||||
}
|
||||
|
||||
while (true) {
|
||||
@ -3811,10 +3985,7 @@ class SSH2
|
||||
if ($client_channel == $channel && $this->channel_status[$channel] == NET_SSH2_MSG_CHANNEL_DATA) {
|
||||
return $data;
|
||||
}
|
||||
if (!isset($this->channel_buffers[$channel])) {
|
||||
$this->channel_buffers[$channel] = array();
|
||||
}
|
||||
$this->channel_buffers[$channel][] = $data;
|
||||
$this->channel_buffers[$channel][] = chr($type) . $data;
|
||||
|
||||
continue 2;
|
||||
case NET_SSH2_MSG_CHANNEL_REQUEST:
|
||||
@ -3893,20 +4064,15 @@ class SSH2
|
||||
$result = $client_channel == $channel ? true : $this->_get_channel_packet($client_channel, $skip_extended);
|
||||
$this->_on_channel_open();
|
||||
return $result;
|
||||
//case NET_SSH2_MSG_CHANNEL_OPEN_FAILURE:
|
||||
default:
|
||||
case NET_SSH2_MSG_CHANNEL_OPEN_FAILURE:
|
||||
user_error('Unable to open channel');
|
||||
return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION);
|
||||
}
|
||||
break;
|
||||
case NET_SSH2_MSG_IGNORE:
|
||||
switch ($type) {
|
||||
case NET_SSH2_MSG_CHANNEL_SUCCESS:
|
||||
//$this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_DATA;
|
||||
continue 3;
|
||||
case NET_SSH2_MSG_CHANNEL_FAILURE:
|
||||
user_error('Error opening channel');
|
||||
return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION);
|
||||
default:
|
||||
if ($client_channel == $channel) {
|
||||
user_error('Unexpected response to open request');
|
||||
return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION);
|
||||
}
|
||||
return $this->_get_channel_packet($client_channel, $skip_extended);
|
||||
}
|
||||
break;
|
||||
case NET_SSH2_MSG_CHANNEL_REQUEST:
|
||||
@ -3915,6 +4081,14 @@ class SSH2
|
||||
return true;
|
||||
case NET_SSH2_MSG_CHANNEL_FAILURE:
|
||||
return false;
|
||||
case NET_SSH2_MSG_CHANNEL_DATA:
|
||||
if (strlen($response) < 4) {
|
||||
return false;
|
||||
}
|
||||
extract(unpack('Nlength', $this->_string_shift($response, 4)));
|
||||
$data = $this->_string_shift($response, $length);
|
||||
$this->channel_buffers[$channel][] = chr($type) . $data;
|
||||
return $this->_get_channel_packet($client_channel, $skip_extended);
|
||||
default:
|
||||
user_error('Unable to fulfill channel request');
|
||||
return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION);
|
||||
@ -3928,10 +4102,6 @@ class SSH2
|
||||
|
||||
switch ($type) {
|
||||
case NET_SSH2_MSG_CHANNEL_DATA:
|
||||
//if ($this->channel_status[$channel] == NET_SSH2_MSG_IGNORE) {
|
||||
// $this->channel_status[$channel] = NET_SSH2_MSG_CHANNEL_DATA;
|
||||
//}
|
||||
|
||||
/*
|
||||
if ($channel == self::CHANNEL_EXEC) {
|
||||
// SCP requires null packets, such as this, be sent. further, in the case of the ssh.com SSH server
|
||||
@ -3958,10 +4128,7 @@ class SSH2
|
||||
if ($client_channel == $channel) {
|
||||
return $data;
|
||||
}
|
||||
if (!isset($this->channel_buffers[$channel])) {
|
||||
$this->channel_buffers[$channel] = array();
|
||||
}
|
||||
$this->channel_buffers[$channel][] = $data;
|
||||
$this->channel_buffers[$channel][] = chr($type) . $data;
|
||||
break;
|
||||
case NET_SSH2_MSG_CHANNEL_CLOSE:
|
||||
$this->curTimeout = 5;
|
||||
@ -3980,7 +4147,7 @@ class SSH2
|
||||
case NET_SSH2_MSG_CHANNEL_EOF:
|
||||
break;
|
||||
default:
|
||||
user_error('Error reading channel data');
|
||||
user_error("Error reading channel data ($type)");
|
||||
return $this->_disconnect(NET_SSH2_DISCONNECT_BY_APPLICATION);
|
||||
}
|
||||
}
|
||||
@ -4005,11 +4172,27 @@ class SSH2
|
||||
return false;
|
||||
}
|
||||
|
||||
//if ($this->compress) {
|
||||
// // the -4 removes the checksum:
|
||||
// // http://php.net/function.gzcompress#57710
|
||||
// $data = substr(gzcompress($data), 0, -4);
|
||||
//}
|
||||
if (!isset($logged)) {
|
||||
$logged = $data;
|
||||
}
|
||||
|
||||
switch ($this->compress) {
|
||||
case NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH:
|
||||
if (!$this->isAuthenticated()) {
|
||||
break;
|
||||
}
|
||||
case NET_SSH2_COMPRESSION_ZLIB:
|
||||
if (!$this->regenerate_compression_context) {
|
||||
$header = '';
|
||||
} else {
|
||||
$this->regenerate_compression_context = false;
|
||||
$this->compress_context = deflate_init(ZLIB_ENCODING_RAW, ['window' => 15]);
|
||||
$header = "\x78\x9C";
|
||||
}
|
||||
if ($this->compress_context) {
|
||||
$data = $header . deflate_add($this->compress_context, $data, ZLIB_PARTIAL_FLUSH);
|
||||
}
|
||||
}
|
||||
|
||||
// 4 (packet length) + 1 (padding length) + 4 (minimal padding amount) == 9
|
||||
$packet_length = strlen($data) + 9;
|
||||
@ -4037,10 +4220,10 @@ class SSH2
|
||||
|
||||
if (defined('NET_SSH2_LOGGING')) {
|
||||
$current = microtime(true);
|
||||
$message_number = isset($this->message_numbers[ord($data[0])]) ? $this->message_numbers[ord($data[0])] : 'UNKNOWN (' . ord($data[0]) . ')';
|
||||
$message_number = isset($this->message_numbers[ord($logged[0])]) ? $this->message_numbers[ord($logged[0])] : 'UNKNOWN (' . ord($logged[0]) . ')';
|
||||
$message_number = '-> ' . $message_number .
|
||||
' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)';
|
||||
$this->_append_log($message_number, isset($logged) ? $logged : $data);
|
||||
$this->_append_log($message_number, $logged);
|
||||
$this->last_packet = $current;
|
||||
}
|
||||
|
||||
@ -4735,10 +4918,12 @@ class SSH2
|
||||
*/
|
||||
function getSupportedCompressionAlgorithms()
|
||||
{
|
||||
return array(
|
||||
'none' // REQUIRED no compression
|
||||
//'zlib' // OPTIONAL ZLIB (LZ77) compression
|
||||
);
|
||||
$algos = array('none'); // REQUIRED no compression
|
||||
if (function_exists('deflate_init')) {
|
||||
$algos[] = 'zlib@openssh.com'; // https://datatracker.ietf.org/doc/html/draft-miller-secsh-compression-delayed
|
||||
$algos[] = 'zlib';
|
||||
}
|
||||
return $algos;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4753,18 +4938,24 @@ class SSH2
|
||||
{
|
||||
$this->_connect();
|
||||
|
||||
$compression_map = array(
|
||||
NET_SSH2_COMPRESSION_NONE => 'none',
|
||||
NET_SSH2_COMPRESSION_ZLIB => 'zlib',
|
||||
NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH => 'zlib@openssh.com'
|
||||
);
|
||||
|
||||
return array(
|
||||
'kex' => $this->kex_algorithm,
|
||||
'hostkey' => $this->signature_format,
|
||||
'client_to_server' => array(
|
||||
'crypt' => $this->encrypt->name,
|
||||
'mac' => $this->hmac_create->name,
|
||||
'comp' => 'none',
|
||||
'comp' => $compression_map[$this->compress],
|
||||
),
|
||||
'server_to_client' => array(
|
||||
'crypt' => $this->decrypt->name,
|
||||
'mac' => $this->hmac_check->name,
|
||||
'comp' => 'none',
|
||||
'comp' => $compression_map[$this->decompress],
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -5173,8 +5364,24 @@ class SSH2
|
||||
* @see https://tools.ietf.org/html/rfc4252#section-5.1
|
||||
* @return array|null
|
||||
*/
|
||||
public function getAuthMethodsToContinue()
|
||||
function getAuthMethodsToContinue()
|
||||
{
|
||||
return $this->auth_methods_to_continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables "smart" multi-factor authentication (MFA)
|
||||
*/
|
||||
function enableSmartMFA()
|
||||
{
|
||||
$this->smartMFA = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables "smart" multi-factor authentication (MFA)
|
||||
*/
|
||||
function disableSmartMFA()
|
||||
{
|
||||
$this->smartMFA = false;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,8 @@
|
||||
|
||||
if (extension_loaded('mbstring')) {
|
||||
// 2 - MB_OVERLOAD_STRING
|
||||
if (ini_get('mbstring.func_overload') & 2) {
|
||||
// mbstring.func_overload is deprecated in php 7.2 and removed in php 8.0.
|
||||
if (version_compare(PHP_VERSION, '8.0.0') < 0 && ini_get('mbstring.func_overload') & 2) {
|
||||
throw new \UnexpectedValueException(
|
||||
'Overloading of string functions using mbstring.func_overload ' .
|
||||
'is not supported by phpseclib.'
|
||||
|
Reference in New Issue
Block a user