From 086802321689134c309d3ca303eac7681e19ab07 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Fri, 10 Dec 2021 07:39:19 -0600 Subject: [PATCH 1/3] Travis: add PHP 8.1.0 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ef659a19..6521abde 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,8 @@ matrix: dist: xenial - php: 8.0 dist: bionic + - php: 8.1.0 + dist: bionic before_install: true From 624f328c88560e2ee6aa5f1ef8264cd318579c24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4fer?= Date: Tue, 14 Dec 2021 13:18:33 +0100 Subject: [PATCH 2/3] Remove define() from SSH2 and use class constants instead --- phpseclib/Net/SSH2.php | 60 ++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 6d0c4762..6863ebb2 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -61,23 +61,6 @@ 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. * @@ -87,6 +70,25 @@ define('NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH', 3); */ class SSH2 { + /**#@+ + * Compression Types + * + * @access private + */ + /** + * No compression + */ + const NET_SSH2_COMPRESSION_NONE = 1; + /** + * zlib compression + */ + const NET_SSH2_COMPRESSION_ZLIB = 2; + /** + * zlib@openssh.com + */ + const NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH = 3; + /**#@-*/ + /**#@+ * Execution Bitmap Masks * @@ -1002,7 +1004,7 @@ class SSH2 * @var int * @access private */ - var $compress = NET_SSH2_COMPRESSION_NONE; + var $compress = self::NET_SSH2_COMPRESSION_NONE; /** * Decompression method @@ -1010,7 +1012,7 @@ class SSH2 * @var resource|object * @access private */ - var $decompress = NET_SSH2_COMPRESSION_NONE; + var $decompress = self::NET_SSH2_COMPRESSION_NONE; /** * Compression context @@ -1644,9 +1646,9 @@ class SSH2 } $compression_map = array( - 'none' => NET_SSH2_COMPRESSION_NONE, - 'zlib' => NET_SSH2_COMPRESSION_ZLIB, - 'zlib@openssh.com' => NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH + 'none' => self::NET_SSH2_COMPRESSION_NONE, + 'zlib' => self::NET_SSH2_COMPRESSION_ZLIB, + 'zlib@openssh.com' => self::NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH ); $compression_algorithm_out = $this->_array_intersect_first($c2s_compression_algorithms, $this->compression_algorithms_client_to_server); @@ -3589,11 +3591,11 @@ class SSH2 } switch ($this->decompress) { - case NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH: + case self::NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH: if (!$this->isAuthenticated()) { break; } - case NET_SSH2_COMPRESSION_ZLIB: + case self::NET_SSH2_COMPRESSION_ZLIB: if ($this->regenerate_decompression_context) { $this->regenerate_decompression_context = false; @@ -4181,11 +4183,11 @@ class SSH2 } switch ($this->compress) { - case NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH: + case self::NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH: if (!$this->isAuthenticated()) { break; } - case NET_SSH2_COMPRESSION_ZLIB: + case self::NET_SSH2_COMPRESSION_ZLIB: if (!$this->regenerate_compression_context) { $header = ''; } else { @@ -4943,9 +4945,9 @@ 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' + self::NET_SSH2_COMPRESSION_NONE => 'none', + self::NET_SSH2_COMPRESSION_ZLIB => 'zlib', + self::NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH => 'zlib@openssh.com' ); return array( From d71522d8aa2aa7d66554321f9ecb0d3502933f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4fer?= Date: Tue, 14 Dec 2021 16:34:41 +0100 Subject: [PATCH 3/3] Remove define() from SSH2 and use class constants instead (3.0 branch) --- phpseclib/Net/SSH2.php | 60 ++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 023f1468..12cb300f 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -73,23 +73,6 @@ use phpseclib3\Exception\InsufficientSetupException; use phpseclib3\Common\Functions\Strings; use phpseclib3\Crypt\Common\AsymmetricKey; -/**#@+ - * @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. * @@ -99,6 +82,25 @@ define('NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH', 3); */ class SSH2 { + /**#@+ + * Compression Types + * + * @access private + */ + /** + * No compression + */ + const NET_SSH2_COMPRESSION_NONE = 1; + /** + * zlib compression + */ + const NET_SSH2_COMPRESSION_ZLIB = 2; + /** + * zlib@openssh.com + */ + const NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH = 3; + /**#@-*/ + // Execution Bitmap Masks const MASK_CONSTRUCTOR = 0x00000001; const MASK_CONNECTED = 0x00000002; @@ -1055,7 +1057,7 @@ class SSH2 * @var int * @access private */ - private $compress = NET_SSH2_COMPRESSION_NONE; + private $compress = self::NET_SSH2_COMPRESSION_NONE; /** * Decompression method @@ -1063,7 +1065,7 @@ class SSH2 * @var resource|object * @access private */ - private $decompress = NET_SSH2_COMPRESSION_NONE; + private $decompress = self::NET_SSH2_COMPRESSION_NONE; /** * Compression context @@ -1618,9 +1620,9 @@ class SSH2 } $compression_map = [ - 'none' => NET_SSH2_COMPRESSION_NONE, - 'zlib' => NET_SSH2_COMPRESSION_ZLIB, - 'zlib@openssh.com' => NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH + 'none' => self::NET_SSH2_COMPRESSION_NONE, + 'zlib' => self::NET_SSH2_COMPRESSION_ZLIB, + 'zlib@openssh.com' => self::NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH ]; $compression_algorithm_in = self::array_intersect_first($s2c_compression_algorithms, $this->compression_algorithms_server_to_client); @@ -3474,11 +3476,11 @@ class SSH2 } switch ($this->decompress) { - case NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH: + case self::NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH: if (!$this->isAuthenticated()) { break; } - case NET_SSH2_COMPRESSION_ZLIB: + case self::NET_SSH2_COMPRESSION_ZLIB: if ($this->regenerate_decompression_context) { $this->regenerate_decompression_context = false; @@ -4064,11 +4066,11 @@ class SSH2 } switch ($this->compress) { - case NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH: + case self::NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH: if (!$this->isAuthenticated()) { break; } - case NET_SSH2_COMPRESSION_ZLIB: + case self::NET_SSH2_COMPRESSION_ZLIB: if (!$this->regenerate_compression_context) { $header = ''; } else { @@ -4777,9 +4779,9 @@ class SSH2 $this->connect(); $compression_map = [ - NET_SSH2_COMPRESSION_NONE => 'none', - NET_SSH2_COMPRESSION_ZLIB => 'zlib', - NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH => 'zlib@openssh.com' + self::NET_SSH2_COMPRESSION_NONE => 'none', + self::NET_SSH2_COMPRESSION_ZLIB => 'zlib', + self::NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH => 'zlib@openssh.com' ]; return [