From 702ade7d1274b03aa5fdef3dd956e06464d61297 Mon Sep 17 00:00:00 2001 From: phonzie Date: Wed, 20 Nov 2013 15:02:04 -0500 Subject: [PATCH 01/39] SFTP: Removed dead code variable: $initialize = true, ironically - is initialized but never used. Feel free to deny if this is reserved for future implementation(s). --- phpseclib/Net/SFTP.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index ab17deb4..867adec0 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -1506,8 +1506,6 @@ class Net_SFTP extends Net_SSH2 { return false; } - $initialize = true; - // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.2.3 if ($mode & NET_SFTP_LOCAL_FILE) { if (!is_file($data)) { From e0cbaedccffe4fe2d2a9de15e0b13a5df20fc8f1 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 20 Nov 2013 21:18:51 +0100 Subject: [PATCH 02/39] Require PHP 5.3 in composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 79c92b52..657539f0 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ } ], "require": { - "php": ">=5.0.0" + "php": ">=5.3.0" }, "suggest": { "ext-mcrypt": "Install the Mcrypt extension in order to speed up a wide variety of cryptographic operations.", From 6b1a817bbed29f33b8919505ce63fd8855b2e80c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 20 Nov 2013 21:20:35 +0100 Subject: [PATCH 03/39] Remove the PHP 5.2 travis environment. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6a319dd6..b4e1871a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.2 - 5.3.3 - 5.3 - 5.4 From 3afa655f579bc9b31e3608bb7e15d48c201b37b2 Mon Sep 17 00:00:00 2001 From: phonzie Date: Wed, 20 Nov 2013 16:17:23 -0500 Subject: [PATCH 04/39] SSH2: Continue Subsystem Implementation. Removed unused piece of code @2352. Added $this->_get_interactive_channel() to reset(). Unless we don't want to close the subsystem channel?? Leaving that decision up to you. --- phpseclib/Net/SSH2.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index dad03697..9e1dcb53 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -2349,7 +2349,6 @@ class Net_SSH2 { return false; } - $channel = $this->in_request_pty_exec ? NET_SSH2_CHANNEL_EXEC : NET_SSH2_CHANNEL_SHELL; return $this->_send_channel_packet($this->_get_interactive_channel(), $cmd); } @@ -2430,8 +2429,7 @@ class Net_SSH2 { */ function reset() { - $channel = $this->in_request_pty_exec ? NET_SSH2_CHANNEL_EXEC : NET_SSH2_CHANNEL_SHELL; - $this->_close_channel($channel); + $this->_close_channel($this->_get_interactive_channel()); } /** From 3bfd8848139305c3acf64af4f6d0f62496801f8e Mon Sep 17 00:00:00 2001 From: Marc Philip Scholten Date: Sat, 23 Nov 2013 19:21:06 +0100 Subject: [PATCH 05/39] Removed vim comments Reformated files --- phpseclib/Crypt/AES.php | 3 --- phpseclib/Crypt/Base.php | 3 --- phpseclib/Crypt/Blowfish.php | 3 --- phpseclib/Crypt/DES.php | 3 --- phpseclib/Crypt/Hash.php | 1 - phpseclib/Crypt/RC2.php | 3 --- phpseclib/Crypt/RC4.php | 3 --- phpseclib/Crypt/RSA.php | 1 - phpseclib/Crypt/Random.php | 1 - phpseclib/Crypt/Rijndael.php | 3 --- phpseclib/Crypt/TripleDES.php | 3 --- phpseclib/Crypt/Twofish.php | 3 --- phpseclib/File/ANSI.php | 1 - phpseclib/File/ASN1.php | 1 - phpseclib/File/X509.php | 1 - phpseclib/Math/BigInteger.php | 1 - phpseclib/Net/SCP.php | 1 - phpseclib/Net/SFTP.php | 1 - phpseclib/Net/SFTP/Stream.php | 1 - phpseclib/Net/SSH1.php | 1 - phpseclib/Net/SSH2.php | 1 - 21 files changed, 39 deletions(-) diff --git a/phpseclib/Crypt/AES.php b/phpseclib/Crypt/AES.php index 81fa2fea..e9724ea1 100644 --- a/phpseclib/Crypt/AES.php +++ b/phpseclib/Crypt/AES.php @@ -1,5 +1,4 @@ Date: Sat, 23 Nov 2013 19:46:04 +0100 Subject: [PATCH 06/39] Add people from AUTHORS to composer.json. --- composer.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/composer.json b/composer.json index 79c92b52..5e288660 100644 --- a/composer.json +++ b/composer.json @@ -25,6 +25,21 @@ { "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" } ], From fa229bb18662a079f3cea3a8a0dc80bd1d2bb74f Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 23 Nov 2013 20:00:44 +0100 Subject: [PATCH 07/39] Use branch name as a subfolder for code coverage reports. --- tests/code_coverage_upload.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/code_coverage_upload.sh b/tests/code_coverage_upload.sh index 7ab9494b..5e9ba9f2 100755 --- a/tests/code_coverage_upload.sh +++ b/tests/code_coverage_upload.sh @@ -24,11 +24,11 @@ fi # Workaround for rsync not creating target directories with depth > 1 mv "$LDIRNAME" "x$LDIRNAME" -mkdir -p "$RDIRNAME/$TRAVIS_BUILD_NUMBER" -mv "x$LDIRNAME" "$RDIRNAME/$TRAVIS_BUILD_NUMBER/PHP-$TRAVIS_PHP_VERSION/" +mkdir -p "$RDIRNAME/$TRAVIS_BRANCH/$TRAVIS_BUILD_NUMBER" +mv "x$LDIRNAME" "$RDIRNAME/$TRAVIS_BRANCH/$TRAVIS_BUILD_NUMBER/PHP-$TRAVIS_PHP_VERSION/" # Update latest symlink -ln -s "$TRAVIS_BUILD_NUMBER" "$RDIRNAME/latest" +ln -s "$TRAVIS_BUILD_NUMBER" "$RDIRNAME/$TRAVIS_BRANCH/latest" # Stop complaints about world-readable key file. chmod 600 "$ID_RSA" From de16c37c82e492109cff3bd38966c2fb826c0e1b Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 23 Nov 2013 20:02:41 +0100 Subject: [PATCH 08/39] Use a variable for subfolder string. --- tests/code_coverage_upload.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/code_coverage_upload.sh b/tests/code_coverage_upload.sh index 5e9ba9f2..3231d9a5 100755 --- a/tests/code_coverage_upload.sh +++ b/tests/code_coverage_upload.sh @@ -24,8 +24,9 @@ fi # Workaround for rsync not creating target directories with depth > 1 mv "$LDIRNAME" "x$LDIRNAME" -mkdir -p "$RDIRNAME/$TRAVIS_BRANCH/$TRAVIS_BUILD_NUMBER" -mv "x$LDIRNAME" "$RDIRNAME/$TRAVIS_BRANCH/$TRAVIS_BUILD_NUMBER/PHP-$TRAVIS_PHP_VERSION/" +RROOT="$RDIRNAME/$TRAVIS_BRANCH/$TRAVIS_BUILD_NUMBER" +mkdir -p "$RROOT" +mv "x$LDIRNAME" "$RROOT/PHP-$TRAVIS_PHP_VERSION/" # Update latest symlink ln -s "$TRAVIS_BUILD_NUMBER" "$RDIRNAME/$TRAVIS_BRANCH/latest" From e74744c6202ab48c62ad10e2a5c584adf20a2c8d Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 23 Nov 2013 20:29:27 +0100 Subject: [PATCH 09/39] Add CodeSniffer as composer development dependency. --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 79c92b52..e67550c3 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,9 @@ "require": { "php": ">=5.0.0" }, + "require-dev": { + "squizlabs/php_codesniffer": "1.*" + }, "suggest": { "ext-mcrypt": "Install the Mcrypt extension in order to speed up a wide variety of cryptographic operations.", "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", From 6ed4e3c92ec21d6b01e098794026405b03835c27 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 23 Nov 2013 20:31:06 +0100 Subject: [PATCH 10/39] Add composer.lock file. --- composer.lock | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 composer.lock diff --git a/composer.lock b/composer.lock new file mode 100644 index 00000000..2bdf3602 --- /dev/null +++ b/composer.lock @@ -0,0 +1,96 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + ], + "hash": "e692359d277b10176319a11c2aef51aa", + "packages": [ + + ], + "packages-dev": [ + { + "name": "squizlabs/php_codesniffer", + "version": "1.4.7", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "df764a1604607ea61c4eeea5410666e27cb37a8b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/df764a1604607ea61c4eeea5410666e27cb37a8b", + "reference": "df764a1604607ea61c4eeea5410666e27cb37a8b", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.1.2" + }, + "suggest": { + "phpunit/php-timer": "dev-master" + }, + "bin": [ + "scripts/phpcs" + ], + "type": "library", + "autoload": { + "classmap": [ + "CodeSniffer.php", + "CodeSniffer/CLI.php", + "CodeSniffer/Exception.php", + "CodeSniffer/File.php", + "CodeSniffer/MultiFileSniff.php", + "CodeSniffer/Report.php", + "CodeSniffer/Reporting.php", + "CodeSniffer/Sniff.php", + "CodeSniffer/Tokens.php", + "CodeSniffer/Reports/", + "CodeSniffer/CommentParser/", + "CodeSniffer/Tokenizers/", + "CodeSniffer/DocGenerators/", + "CodeSniffer/Standards/AbstractPatternSniff.php", + "CodeSniffer/Standards/AbstractScopeSniff.php", + "CodeSniffer/Standards/AbstractVariableSniff.php", + "CodeSniffer/Standards/IncorrectPatternException.php", + "CodeSniffer/Standards/Generic/Sniffs/", + "CodeSniffer/Standards/MySource/Sniffs/", + "CodeSniffer/Standards/PEAR/Sniffs/", + "CodeSniffer/Standards/PSR1/Sniffs/", + "CodeSniffer/Standards/PSR2/Sniffs/", + "CodeSniffer/Standards/Squiz/Sniffs/", + "CodeSniffer/Standards/Zend/Sniffs/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenises PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "http://www.squizlabs.com/php-codesniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2013-09-26 00:08:21" + } + ], + "aliases": [ + + ], + "minimum-stability": "stable", + "stability-flags": [ + + ], + "platform": { + "php": ">=5.0.0" + }, + "platform-dev": [ + + ] +} From 021ca1b9adbb7631028b1c581c63d5a9c186b2a2 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 23 Nov 2013 20:31:50 +0100 Subject: [PATCH 11/39] The composer.lock file belongs to the repository. Do not ignore. --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7fdbeb4c..c9d0896d 100644 --- a/.gitignore +++ b/.gitignore @@ -48,4 +48,3 @@ publish # local files vendor composer.phar -composer.lock From 79d3709defdcd8f5eb0097b4f41b74f3530d93d1 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 23 Nov 2013 20:32:44 +0100 Subject: [PATCH 12/39] Remove all ignores that belong to users global .gitignore file. --- .gitignore | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) diff --git a/.gitignore b/.gitignore index c9d0896d..d26d6c2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,50 +1,2 @@ -# Numerous always-ignore extensions -*.diff -*.err -*.orig -*.log -*.rej -*.swo -*.swp -*.vi -*~ -*.sass-cache - -# OS or Editor folders -.DS_Store -._* -Thumbs.db -.cache -.project -.settings -.tmproj -nbproject -*.sublime-project -*.sublime-workspace - -# Dreamweaver added files -_notes -dwsync.xml - -# Komodo -*.komodoproject -.komodotools - -# Espresso -*.esproj -*.espressostorage - -# Rubinius -*.rbc - -# Folders to ignore -.hg -.svn -.CVS -intermediate -publish -.idea - -# local files vendor composer.phar From 6f16e5ae8e3d99ba2c442c3f4de494ea6e53a30a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 23 Nov 2013 20:33:37 +0100 Subject: [PATCH 13/39] Only apply git ignores relative to repository root. --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index d26d6c2b..1469fe60 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -vendor -composer.phar +/vendor +/composer.phar From c2d183d2237775ef9e380791a9f4c74cb8b59fab Mon Sep 17 00:00:00 2001 From: mpscholten Date: Sat, 23 Nov 2013 20:37:06 +0100 Subject: [PATCH 14/39] Removed Php_Compat note in composer.json because we dropped php4 support --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 79c92b52..58c23072 100644 --- a/composer.json +++ b/composer.json @@ -33,8 +33,7 @@ }, "suggest": { "ext-mcrypt": "Install the Mcrypt extension in order to speed up a wide variety of cryptographic operations.", - "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", - "pear-pear/PHP_Compat": "Install PHP_Compat to get phpseclib working on PHP >= 4.3.3." + "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations." }, "include-path": ["phpseclib/"], "autoload": { From f0dcc74c29314191aa1c4031695374f63855d591 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 23 Nov 2013 20:38:11 +0100 Subject: [PATCH 15/39] Install composer dependencies on Travis CI. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6a319dd6..8c524332 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ env: before_script: - git clone git://github.com/zenovich/runkit.git && cd runkit && phpize && ./configure && make && make install && cd .. - echo "extension=runkit.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` + - composer install --dev --no-interaction script: - phpunit --verbose --coverage-text --coverage-html code_coverage/ From dc0fc84bd00223f1a0bfae46751f4d9b4a276047 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 23 Nov 2013 21:01:26 +0100 Subject: [PATCH 16/39] Add ruleset for phpseclib coding standard. --- tests/code_sniffer_ruleset.xml | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 tests/code_sniffer_ruleset.xml diff --git a/tests/code_sniffer_ruleset.xml b/tests/code_sniffer_ruleset.xml new file mode 100644 index 00000000..e321c7d4 --- /dev/null +++ b/tests/code_sniffer_ruleset.xml @@ -0,0 +1,45 @@ + + + + phpseclib coding standard + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From e6be743fe2ab5b91b6817899257a3781f33ab06a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 23 Nov 2013 21:02:23 +0100 Subject: [PATCH 17/39] Run code sniffer on PHP 5.5 environment on Travis CI. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 8c524332..8110adc8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ before_script: - composer install --dev --no-interaction script: + - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then vendor/bin/phpcs -s --extensions=php --standard=tests/code_sniffer_ruleset.xml phpseclib/; fi" - phpunit --verbose --coverage-text --coverage-html code_coverage/ after_success: From 552459d55e74996bd2d1b7330135447f88bb24e9 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 23 Nov 2013 21:08:37 +0100 Subject: [PATCH 18/39] Only install composer dependencies in PHP 5.5 environment. There is currently no point in installing in any other environment. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8110adc8..d028aa13 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ env: before_script: - git clone git://github.com/zenovich/runkit.git && cd runkit && phpize && ./configure && make && make install && cd .. - echo "extension=runkit.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` - - composer install --dev --no-interaction + - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then composer install --dev --no-interaction; fi" script: - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then vendor/bin/phpcs -s --extensions=php --standard=tests/code_sniffer_ruleset.xml phpseclib/; fi" From 0a7c5f90d0324dc2ae5ea68d57bcf4795d567b65 Mon Sep 17 00:00:00 2001 From: mpscholten Date: Sat, 23 Nov 2013 21:18:24 +0100 Subject: [PATCH 19/39] Updated LICENSE --- LICENSE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LICENSE b/LICENSE index 6ecd9b9b..75f6b204 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2007-2012 TerraFrost and other contributors +Copyright 2007-2013 TerraFrost and other contributors http://phpseclib.sourceforge.net/ Permission is hereby granted, free of charge, to any person obtaining @@ -18,4 +18,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 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. \ No newline at end of file +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 28b2ae7849b482de38b22f6c0665029416690ad5 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 23 Nov 2013 21:25:26 +0100 Subject: [PATCH 20/39] Add Blowfish and Twofish as composer keywords. --- composer.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/composer.json b/composer.json index 79c92b52..a660afa5 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,8 @@ "signing", "rsa", "aes", + "blowfish", + "twofish", "ssh", "sftp", "x509", From 82c0bb4b9d2c1139c594caad69179ef0cf0848bf Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 23 Nov 2013 21:59:15 +0100 Subject: [PATCH 21/39] Correct "Code Coverage Report" link to include branch name (master). --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e90b12f4..1c1e1f1e 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ AES, Blowfish, Twofish, SSH-1, SSH-2, SFTP, and X.509 * [Browse Git](https://github.com/phpseclib/phpseclib) * [Documentation](http://phpseclib.sourceforge.net/) * [Support](http://www.frostjedi.com/phpbb/viewforum.php?f=46) -* [Code Coverage Report](http://phpseclib.bantux.org/code_coverage/latest/) +* [Code Coverage Report](http://phpseclib.bantux.org/code_coverage/master/latest/) PEAR Channel PEAR Channel: [phpseclib.sourceforge.net](http://phpseclib.sourceforge.net/pear.htm) From 07c9f91cc681287a44187905da5eec106aa1998c Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 23 Nov 2013 22:00:01 +0100 Subject: [PATCH 22/39] Adjust "Code Coverage Report" branch in link: master -> php5 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c1e1f1e..0867910c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ AES, Blowfish, Twofish, SSH-1, SSH-2, SFTP, and X.509 * [Browse Git](https://github.com/phpseclib/phpseclib) * [Documentation](http://phpseclib.sourceforge.net/) * [Support](http://www.frostjedi.com/phpbb/viewforum.php?f=46) -* [Code Coverage Report](http://phpseclib.bantux.org/code_coverage/master/latest/) +* [Code Coverage Report](http://phpseclib.bantux.org/code_coverage/php5/latest/) PEAR Channel PEAR Channel: [phpseclib.sourceforge.net](http://phpseclib.sourceforge.net/pear.htm) From 2f3b6e364679323c007187f424b05106a0122b3a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 26 Nov 2013 21:06:28 +0100 Subject: [PATCH 23/39] Update Travis CI build status image branch name to php5. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0867910c..420fe577 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # phpseclib - PHP Secure Communications Library -[![Build Status](https://secure.travis-ci.org/phpseclib/phpseclib.png?branch=master)](http://travis-ci.org/phpseclib/phpseclib) +[![Build Status](https://secure.travis-ci.org/phpseclib/phpseclib.png?branch=php5)](http://travis-ci.org/phpseclib/phpseclib) MIT-licensed pure-PHP implementations of an arbitrary-precision integer arithmetic library, fully PKCS#1 (v2.1) compliant RSA, DES, 3DES, RC4, Rijndael, From fccf3e8c8affa507e863553d11247a36a3ab84f1 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 29 Nov 2013 09:22:08 +0100 Subject: [PATCH 24/39] Set the default timezone in tests bootstrap file. --- tests/bootstrap.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 13a8e81b..7db5b570 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -5,6 +5,8 @@ * @license http://www.opensource.org/licenses/mit-license.html MIT License */ +date_default_timezone_set('UTC'); + // Set up include path accordingly. This is especially required because some // class files of phpseclib require() other dependencies. set_include_path(implode(PATH_SEPARATOR, array( From 8ef3a01b6ed4630a01c52b7046885bc23062ccf4 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 1 Dec 2013 03:30:43 +0100 Subject: [PATCH 25/39] Base CodeSniffer ruleset on PEAR ruleset. --- tests/code_sniffer_ruleset.xml | 62 ++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/tests/code_sniffer_ruleset.xml b/tests/code_sniffer_ruleset.xml index e321c7d4..58e32dd7 100644 --- a/tests/code_sniffer_ruleset.xml +++ b/tests/code_sniffer_ruleset.xml @@ -3,6 +3,50 @@ phpseclib coding standard + + + + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + @@ -12,24 +56,6 @@ - - - - - - - - - - - - - - - - - - From ca9c8b107b89828989b9ca0143bbfefb1c26c255 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 3 Dec 2013 18:54:43 +0100 Subject: [PATCH 26/39] CodeSniffer: Fix Generic.PHP.LowerCaseConstant.Found sniff. --- phpseclib/Crypt/RSA.php | 4 +- phpseclib/File/ASN1.php | 44 ++++++++++---------- phpseclib/File/X509.php | 76 +++++++++++++++++----------------- phpseclib/Net/SFTP.php | 10 ++--- phpseclib/Net/SSH1.php | 2 +- phpseclib/Net/SSH2.php | 10 ++--- tests/code_sniffer_ruleset.xml | 1 - 7 files changed, 73 insertions(+), 74 deletions(-) diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index 36609d90..d36c5f74 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -432,7 +432,7 @@ class Crypt_RSA { /** * OpenSSL configuration file name. * - * Set to NULL to use system configuration file. + * Set to null to use system configuration file. * @see Crypt_RSA::createKey() * @var Mixed * @Access public @@ -554,7 +554,7 @@ class Crypt_RSA { $config['config'] = $this->configFile; } $rsa = openssl_pkey_new(array('private_key_bits' => $bits) + $config); - openssl_pkey_export($rsa, $privatekey, NULL, $config); + openssl_pkey_export($rsa, $privatekey, null, $config); $publickey = openssl_pkey_get_details($rsa); $publickey = $publickey['key']; diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index bee3fab8..37199d26 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -544,13 +544,13 @@ class File_ASN1 { return array($key => $value); } } - return NULL; + return null; case isset($mapping['implicit']): case isset($mapping['explicit']): case $decoded['type'] == $mapping['type']: break; default: - return NULL; + return null; } if (isset($mapping['implicit'])) { @@ -565,8 +565,8 @@ class File_ASN1 { if (isset($mapping['min']) && isset($mapping['max'])) { $child = $mapping['children']; foreach ($decoded['content'] as $content) { - if (($map[] = $this->asn1map($content, $child, $special)) === NULL) { - return NULL; + if (($map[] = $this->asn1map($content, $child, $special)) === null) { + return null; } } @@ -584,7 +584,7 @@ class File_ASN1 { if ($child['type'] != FILE_ASN1_TYPE_CHOICE) { // Get the mapping and input class & constant. $childClass = $tempClass = FILE_ASN1_CLASS_UNIVERSAL; - $constant = NULL; + $constant = null; if (isset($temp['constant'])) { $tempClass = isset($temp['class']) ? $temp['class'] : FILE_ASN1_CLASS_CONTEXT_SPECIFIC; } @@ -610,7 +610,7 @@ class File_ASN1 { if ($maymatch) { // Attempt submapping. $candidate = $this->asn1map($temp, $child, $special); - $maymatch = $candidate !== NULL; + $maymatch = $candidate !== null; } if ($maymatch) { @@ -623,12 +623,12 @@ class File_ASN1 { } elseif (isset($child['default'])) { $map[$key] = $child['default']; // Use default. } elseif (!isset($child['optional'])) { - return NULL; // Syntax error. + return null; // Syntax error. } } // Fail mapping if all input items have not been consumed. - return $i < $n? NULL: $map; + return $i < $n? null: $map; // the main diff between sets and sequences is the encapsulation of the foreach in another for loop case FILE_ASN1_TYPE_SET: @@ -638,8 +638,8 @@ class File_ASN1 { if (isset($mapping['min']) && isset($mapping['max'])) { $child = $mapping['children']; foreach ($decoded['content'] as $content) { - if (($map[] = $this->asn1map($content, $child, $special)) === NULL) { - return NULL; + if (($map[] = $this->asn1map($content, $child, $special)) === null) { + return null; } } @@ -660,7 +660,7 @@ class File_ASN1 { $maymatch = true; if ($child['type'] != FILE_ASN1_TYPE_CHOICE) { $childClass = FILE_ASN1_CLASS_UNIVERSAL; - $constant = NULL; + $constant = null; if (isset($child['class'])) { $childClass = $child['class']; $constant = $child['cast']; @@ -682,7 +682,7 @@ class File_ASN1 { if ($maymatch) { // Attempt submapping. $candidate = $this->asn1map($temp, $child, $special); - $maymatch = $candidate !== NULL; + $maymatch = $candidate !== null; } if (!$maymatch) { @@ -703,7 +703,7 @@ class File_ASN1 { if (isset($child['default'])) { $map[$key] = $child['default']; } elseif (!isset($child['optional'])) { - return NULL; + return null; } } } @@ -796,7 +796,7 @@ class File_ASN1 { function encodeDER($source, $mapping, $special = array()) { $this->location = array(); - return $this->_encode_der($source, $mapping, NULL, $special); + return $this->_encode_der($source, $mapping, null, $special); } /** @@ -818,7 +818,7 @@ class File_ASN1 { * @return String * @access private */ - function _encode_der($source, $mapping, $idx = NULL, $special = array()) + function _encode_der($source, $mapping, $idx = null, $special = array()) { if (is_object($source) && strtolower(get_class($source)) == 'file_asn1_element') { return $source->element; @@ -849,7 +849,7 @@ class File_ASN1 { $child = $mapping['children']; foreach ($source as $content) { - $temp = $this->_encode_der($content, $child, NULL, $special); + $temp = $this->_encode_der($content, $child, null, $special); if ($temp === false) { return false; } @@ -1029,19 +1029,19 @@ class File_ASN1 { switch (true) { case !isset($source): - return $this->_encode_der(NULL, array('type' => FILE_ASN1_TYPE_NULL) + $mapping, NULL, $special); + return $this->_encode_der(null, array('type' => FILE_ASN1_TYPE_NULL) + $mapping, null, $special); case is_int($source): case is_object($source) && strtolower(get_class($source)) == 'math_biginteger': - return $this->_encode_der($source, array('type' => FILE_ASN1_TYPE_INTEGER) + $mapping, NULL, $special); + return $this->_encode_der($source, array('type' => FILE_ASN1_TYPE_INTEGER) + $mapping, null, $special); case is_float($source): - return $this->_encode_der($source, array('type' => FILE_ASN1_TYPE_REAL) + $mapping, NULL, $special); + return $this->_encode_der($source, array('type' => FILE_ASN1_TYPE_REAL) + $mapping, null, $special); case is_bool($source): - return $this->_encode_der($source, array('type' => FILE_ASN1_TYPE_BOOLEAN) + $mapping, NULL, $special); + return $this->_encode_der($source, array('type' => FILE_ASN1_TYPE_BOOLEAN) + $mapping, null, $special); case is_array($source) && count($source) == 1: $typename = implode('', array_keys($source)); $outtype = array_search($typename, $this->ANYmap, true); if ($outtype !== false) { - return $this->_encode_der($source[$typename], array('type' => $outtype) + $mapping, NULL, $special); + return $this->_encode_der($source[$typename], array('type' => $outtype) + $mapping, null, $special); } } @@ -1057,7 +1057,7 @@ class File_ASN1 { user_error('No filters defined for ' . implode('/', $loc)); return false; } - return $this->_encode_der($source, $filters + $mapping, NULL, $special); + return $this->_encode_der($source, $filters + $mapping, null, $special); case FILE_ASN1_TYPE_NULL: $value = ''; break; diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index 963308eb..3408165e 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -1430,7 +1430,7 @@ class File_X509 { $this->currentCert = $cert; $currentKeyIdentifier = $this->getExtension('id-ce-subjectKeyIdentifier'); - $this->currentKeyIdentifier = is_string($currentKeyIdentifier) ? $currentKeyIdentifier : NULL; + $this->currentKeyIdentifier = is_string($currentKeyIdentifier) ? $currentKeyIdentifier : null; unset($this->signatureSubject); @@ -1468,7 +1468,7 @@ class File_X509 { $this->dn = $x509['tbsCertificate']['subject']; $currentKeyIdentifier = $this->getExtension('id-ce-subjectKeyIdentifier'); - $this->currentKeyIdentifier = is_string($currentKeyIdentifier) ? $currentKeyIdentifier : NULL; + $this->currentKeyIdentifier = is_string($currentKeyIdentifier) ? $currentKeyIdentifier : null; return $x509; } @@ -1962,7 +1962,7 @@ class File_X509 { * @param Integer $date optional * @access public */ - function validateDate($date = NULL) + function validateDate($date = null) { if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) { return false; @@ -1991,7 +1991,7 @@ class File_X509 { * Validate a signature * * Works on X.509 certs, CSR's and CRL's. - * Returns true if the signature is verified, false if it is not correct or NULL on error + * Returns true if the signature is verified, false if it is not correct or null on error * * By default returns false for self-signed certs. Call validateSignature(false) to make this support * self-signed. @@ -2005,7 +2005,7 @@ class File_X509 { function validateSignature($caonly = true) { if (!is_array($this->currentCert) || !isset($this->signatureSubject)) { - return NULL; + return null; } /* TODO: @@ -2106,7 +2106,7 @@ class File_X509 { /** * Validates a signature * - * Returns true if the signature is verified, false if it is not correct or NULL on error + * Returns true if the signature is verified, false if it is not correct or null on error * * @param String $publicKeyAlgorithm * @param String $publicKey @@ -2141,11 +2141,11 @@ class File_X509 { } break; default: - return NULL; + return null; } break; default: - return NULL; + return null; } return true; @@ -2366,7 +2366,7 @@ class File_X509 { * @return Mixed * @access public */ - function getDNProp($propName, $dn = NULL, $withType = false) + function getDNProp($propName, $dn = null, $withType = false) { if (!isset($dn)) { $dn = $this->dn; @@ -2420,7 +2420,7 @@ class File_X509 { function setDN($dn, $merge = false, $type = 'utf8String') { if (!$merge) { - $this->dn = NULL; + $this->dn = null; } if (is_array($dn)) { @@ -2459,7 +2459,7 @@ class File_X509 { * @access public * @return Boolean */ - function getDN($format = FILE_X509_DN_ARRAY, $dn = NULL) + function getDN($format = FILE_X509_DN_ARRAY, $dn = null) { if (!isset($dn)) { $dn = isset($this->currentCert['tbsCertList']) ? $this->currentCert['tbsCertList']['issuer'] : $this->dn; @@ -2675,7 +2675,7 @@ class File_X509 { { switch (true) { case !empty($this->dn): - return $this->getDNProp($propName, NULL, $withType); + return $this->getDNProp($propName, null, $withType); case !isset($this->currentCert) || !is_array($this->currentCert): break; case isset($this->currentCert['tbsCertificate']): @@ -2871,10 +2871,10 @@ class File_X509 { $this->publicKey->setPublicKey(); break; default: - $this->publicKey = NULL; + $this->publicKey = null; } - $this->currentKeyIdentifier = NULL; + $this->currentKeyIdentifier = null; $this->currentCert = $csr; return $csr; @@ -2996,10 +2996,10 @@ class File_X509 { $this->publicKey->setPublicKey(); break; default: - $this->publicKey = NULL; + $this->publicKey = null; } - $this->currentKeyIdentifier = NULL; + $this->currentKeyIdentifier = null; $this->currentCert = $spkac; return $spkac; @@ -3054,7 +3054,7 @@ class File_X509 { } } - $this->currentKeyIdentifier = NULL; + $this->currentKeyIdentifier = null; $this->currentCert = $crl; return $crl; @@ -3138,8 +3138,8 @@ class File_X509 { return false; } - $currentCert = isset($this->currentCert) ? $this->currentCert : NULL; - $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: NULL; + $currentCert = isset($this->currentCert) ? $this->currentCert : null; + $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: null; if (isset($subject->currentCert) && is_array($subject->currentCert) && isset($subject->currentCert['tbsCertificate'])) { $this->currentCert = $subject->currentCert; @@ -3311,8 +3311,8 @@ class File_X509 { } $this->publicKey = $origPublicKey; - $currentCert = isset($this->currentCert) ? $this->currentCert : NULL; - $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: NULL; + $currentCert = isset($this->currentCert) ? $this->currentCert : null; + $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: null; if (isset($this->currentCert) && is_array($this->currentCert) && isset($this->currentCert['certificationRequestInfo'])) { $this->currentCert['signatureAlgorithm']['algorithm'] = @@ -3365,8 +3365,8 @@ class File_X509 { return false; } - $currentCert = isset($this->currentCert) ? $this->currentCert : NULL; - $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : NULL; + $currentCert = isset($this->currentCert) ? $this->currentCert : null; + $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject : null; $thisUpdate = !empty($this->startDate) ? $this->startDate : @date('D, d M y H:i:s O'); if (isset($crl->currentCert) && is_array($crl->currentCert) && isset($crl->currentCert['tbsCertList'])) { @@ -3402,7 +3402,7 @@ class File_X509 { } else { $crlNumber = $this->getExtension('id-ce-cRLNumber'); - $crlNumber = $crlNumber !== false ? $crlNumber->add(new Math_BigInteger(1)) : NULL; + $crlNumber = $crlNumber !== false ? $crlNumber->add(new Math_BigInteger(1)) : null; } $this->removeExtension('id-ce-authorityKeyIdentifier'); @@ -3612,7 +3612,7 @@ class File_X509 { * @access private * @return array ref or false */ - function &_extensions(&$root, $path = NULL, $create = false) + function &_extensions(&$root, $path = null, $create = false) { if (!isset($root)) { $root = $this->currentCert; @@ -3666,7 +3666,7 @@ class File_X509 { * @access private * @return Boolean */ - function _removeExtension($id, $path = NULL) + function _removeExtension($id, $path = null) { $extensions = &$this->_extensions($this->currentCert, $path); @@ -3697,7 +3697,7 @@ class File_X509 { * @access private * @return Mixed */ - function _getExtension($id, $cert = NULL, $path = NULL) + function _getExtension($id, $cert = null, $path = null) { $extensions = $this->_extensions($cert, $path); @@ -3722,7 +3722,7 @@ class File_X509 { * @access private * @return Array */ - function _getExtensions($cert = NULL, $path = NULL) + function _getExtensions($cert = null, $path = null) { $exts = $this->_extensions($cert, $path); $extensions = array(); @@ -3747,7 +3747,7 @@ class File_X509 { * @access private * @return Boolean */ - function _setExtension($id, $value, $critical = false, $replace = true, $path = NULL) + function _setExtension($id, $value, $critical = false, $replace = true, $path = null) { $extensions = &$this->_extensions($this->currentCert, $path, true); @@ -3794,7 +3794,7 @@ class File_X509 { * @access public * @return Mixed */ - function getExtension($id, $cert = NULL) + function getExtension($id, $cert = null) { return $this->_getExtension($id, $cert); } @@ -3806,7 +3806,7 @@ class File_X509 { * @access public * @return Array */ - function getExtensions($cert = NULL) + function getExtensions($cert = null) { return $this->_getExtensions($cert); } @@ -3885,7 +3885,7 @@ class File_X509 { * @access public * @return Mixed */ - function getAttribute($id, $disposition = FILE_X509_ATTR_ALL, $csr = NULL) + function getAttribute($id, $disposition = FILE_X509_ATTR_ALL, $csr = null) { if (empty($csr)) { $csr = $this->currentCert; @@ -3925,7 +3925,7 @@ class File_X509 { * @access public * @return Array */ - function getAttributes($csr = NULL) + function getAttributes($csr = null) { if (empty($csr)) { $csr = $this->currentCert; @@ -4034,7 +4034,7 @@ class File_X509 { * @access public * @return String binary key identifier */ - function computeKeyIdentifier($key = NULL, $method = 1) + function computeKeyIdentifier($key = null, $method = 1) { if (is_null($key)) { $key = $this; @@ -4227,7 +4227,7 @@ class File_X509 { * @access public * @return Boolean */ - function revoke($serial, $date = NULL) + function revoke($serial, $date = null) { if (isset($this->currentCert['tbsCertList'])) { if (is_array($rclist = &$this->_subArray($this->currentCert, 'tbsCertList/revokedCertificates', true))) { @@ -4292,7 +4292,7 @@ class File_X509 { * @access public * @return array */ - function listRevoked($crl = NULL) + function listRevoked($crl = null) { if (!isset($crl)) { $crl = $this->currentCert; @@ -4343,7 +4343,7 @@ class File_X509 { * @access public * @return Mixed */ - function getRevokedCertificateExtension($serial, $id, $crl = NULL) + function getRevokedCertificateExtension($serial, $id, $crl = null) { if (!isset($crl)) { $crl = $this->currentCert; @@ -4366,7 +4366,7 @@ class File_X509 { * @access public * @return Array */ - function getRevokedCertificateExtensions($serial, $crl = NULL) + function getRevokedCertificateExtensions($serial, $crl = null) { if (!isset($crl)) { $crl = $this->currentCert; diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index f5eb4056..a73850c5 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -1057,7 +1057,7 @@ class Net_SFTP extends Net_SSH2 { * @return Boolean * @access public */ - function touch($filename, $time = NULL, $atime = NULL) + function touch($filename, $time = null, $atime = null) { if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) { return false; @@ -1100,7 +1100,7 @@ class Net_SFTP extends Net_SSH2 { /** * Changes file or directory owner * - * Returns TRUE on success or FALSE on error. + * Returns true on success or false on error. * * @param String $filename * @param Integer $uid @@ -1120,7 +1120,7 @@ class Net_SFTP extends Net_SSH2 { /** * Changes file or directory group * - * Returns TRUE on success or FALSE on error. + * Returns true on success or false on error. * * @param String $filename * @param Integer $gid @@ -1138,8 +1138,8 @@ class Net_SFTP extends Net_SSH2 { /** * Set permissions on a file. * - * Returns the new file permissions on success or FALSE on error. - * If $recursive is true than this just returns TRUE or FALSE. + * Returns the new file permissions on success or false on error. + * If $recursive is true than this just returns true or false. * * @param Integer $mode * @param String $filename diff --git a/phpseclib/Net/SSH1.php b/phpseclib/Net/SSH1.php index a64d06d4..46f4dba9 100644 --- a/phpseclib/Net/SSH1.php +++ b/phpseclib/Net/SSH1.php @@ -1016,7 +1016,7 @@ class Net_SSH1 { if ($this->curTimeout) { $read = array($this->fsock); - $write = $except = NULL; + $write = $except = null; $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 $sec = floor($this->curTimeout); diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index e8f1c935..e9d11319 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -860,7 +860,7 @@ class Net_SSH2 { } $read = array($this->fsock); - $write = $except = NULL; + $write = $except = null; $sec = floor($timeout); $usec = 1000000 * ($timeout - $sec); @@ -1756,7 +1756,7 @@ class Net_SSH2 { // remove the username and password from the logged packet if (!defined('NET_SSH2_LOGGING')) { - $logged = NULL; + $logged = null; } else { $logged = pack('CNa*Na*Na*CNa*', NET_SSH2_MSG_USERAUTH_REQUEST, strlen('username'), 'username', strlen('ssh-connection'), 'ssh-connection', @@ -2074,7 +2074,7 @@ class Net_SSH2 { * @return String * @access public */ - function exec($command, $callback = NULL) + function exec($command, $callback = null) { $this->curTimeout = $this->timeout; $this->is_timeout = false; @@ -2721,7 +2721,7 @@ class Net_SSH2 { } $read = array($this->fsock); - $write = $except = NULL; + $write = $except = null; $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 $sec = floor($this->curTimeout); @@ -2904,7 +2904,7 @@ class Net_SSH2 { * @return Boolean * @access private */ - function _send_binary_packet($data, $logged = NULL) + function _send_binary_packet($data, $logged = null) { if (!is_resource($this->fsock) || feof($this->fsock)) { user_error('Connection closed prematurely'); diff --git a/tests/code_sniffer_ruleset.xml b/tests/code_sniffer_ruleset.xml index 58e32dd7..3a7633a2 100644 --- a/tests/code_sniffer_ruleset.xml +++ b/tests/code_sniffer_ruleset.xml @@ -11,7 +11,6 @@ 0 0 0 - 0 0 0 0 From e09f1b730ea59bb86628d7bd916d746aba186112 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 3 Dec 2013 19:34:41 +0100 Subject: [PATCH 27/39] CodeSniffer: Fix PEAR.Classes.ClassDeclaration.OpenBraceNewLine sniff. --- phpseclib/Crypt/AES.php | 3 ++- phpseclib/Crypt/Base.php | 3 ++- phpseclib/Crypt/Blowfish.php | 3 ++- phpseclib/Crypt/DES.php | 3 ++- phpseclib/Crypt/Hash.php | 3 ++- phpseclib/Crypt/RC2.php | 3 ++- phpseclib/Crypt/RC4.php | 3 ++- phpseclib/Crypt/RSA.php | 3 ++- phpseclib/Crypt/Rijndael.php | 3 ++- phpseclib/Crypt/TripleDES.php | 3 ++- phpseclib/Crypt/Twofish.php | 3 ++- phpseclib/File/ANSI.php | 3 ++- phpseclib/File/ASN1.php | 6 ++++-- phpseclib/File/X509.php | 3 ++- phpseclib/Math/BigInteger.php | 3 ++- phpseclib/Net/SCP.php | 3 ++- phpseclib/Net/SFTP.php | 3 ++- phpseclib/Net/SFTP/Stream.php | 3 ++- phpseclib/Net/SSH1.php | 3 ++- phpseclib/Net/SSH2.php | 3 ++- tests/code_sniffer_ruleset.xml | 1 - 21 files changed, 42 insertions(+), 22 deletions(-) diff --git a/phpseclib/Crypt/AES.php b/phpseclib/Crypt/AES.php index e9724ea1..7313e640 100644 --- a/phpseclib/Crypt/AES.php +++ b/phpseclib/Crypt/AES.php @@ -129,7 +129,8 @@ define('CRYPT_AES_MODE_MCRYPT', CRYPT_MODE_MCRYPT); * @access public * @package Crypt_AES */ -class Crypt_AES extends Crypt_Rijndael { +class Crypt_AES extends Crypt_Rijndael +{ /** * The namespace used by the cipher for its constants. * diff --git a/phpseclib/Crypt/Base.php b/phpseclib/Crypt/Base.php index 213ffbec..6c7136cc 100644 --- a/phpseclib/Crypt/Base.php +++ b/phpseclib/Crypt/Base.php @@ -120,7 +120,8 @@ define('CRYPT_MODE_MCRYPT', 2); * @access public * @package Crypt_Base */ -class Crypt_Base { +class Crypt_Base +{ /** * The Encryption Mode * diff --git a/phpseclib/Crypt/Blowfish.php b/phpseclib/Crypt/Blowfish.php index 5f5aebaa..00e06a26 100644 --- a/phpseclib/Crypt/Blowfish.php +++ b/phpseclib/Crypt/Blowfish.php @@ -125,7 +125,8 @@ define('CRYPT_BLOWFISH_MODE_MCRYPT', CRYPT_MODE_MCRYPT); * @access public * @package Crypt_Blowfish */ -class Crypt_Blowfish extends Crypt_Base { +class Crypt_Blowfish extends Crypt_Base +{ /** * Block Length of the cipher * diff --git a/phpseclib/Crypt/DES.php b/phpseclib/Crypt/DES.php index 2236f75e..d8d15893 100644 --- a/phpseclib/Crypt/DES.php +++ b/phpseclib/Crypt/DES.php @@ -143,7 +143,8 @@ define('CRYPT_DES_MODE_MCRYPT', CRYPT_MODE_MCRYPT); * @access public * @package Crypt_DES */ -class Crypt_DES extends Crypt_Base { +class Crypt_DES extends Crypt_Base +{ /** * Block Length of the cipher * diff --git a/phpseclib/Crypt/Hash.php b/phpseclib/Crypt/Hash.php index 165ab0ad..4abae510 100644 --- a/phpseclib/Crypt/Hash.php +++ b/phpseclib/Crypt/Hash.php @@ -80,7 +80,8 @@ define('CRYPT_HASH_MODE_HASH', 3); * @access public * @package Crypt_Hash */ -class Crypt_Hash { +class Crypt_Hash +{ /** * Hash Parameter * diff --git a/phpseclib/Crypt/RC2.php b/phpseclib/Crypt/RC2.php index 736ffa61..872d96cc 100755 --- a/phpseclib/Crypt/RC2.php +++ b/phpseclib/Crypt/RC2.php @@ -120,7 +120,8 @@ define('CRYPT_RC2_MODE_MCRYPT', CRYPT_MODE_MCRYPT); * @access public * @package Crypt_RC2 */ -class Crypt_RC2 extends Crypt_Base { +class Crypt_RC2 extends Crypt_Base +{ /** * Block Length of the cipher * diff --git a/phpseclib/Crypt/RC4.php b/phpseclib/Crypt/RC4.php index c156d596..38e778cf 100644 --- a/phpseclib/Crypt/RC4.php +++ b/phpseclib/Crypt/RC4.php @@ -99,7 +99,8 @@ define('CRYPT_RC4_DECRYPT', 1); * @access public * @package Crypt_RC4 */ -class Crypt_RC4 extends Crypt_Base { +class Crypt_RC4 extends Crypt_Base +{ /** * Block Length of the cipher * diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index d36c5f74..0ae214d2 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -244,7 +244,8 @@ define('CRYPT_RSA_PUBLIC_FORMAT_PKCS1', 7); * @access public * @package Crypt_RSA */ -class Crypt_RSA { +class Crypt_RSA +{ /** * Precomputed Zero * diff --git a/phpseclib/Crypt/Rijndael.php b/phpseclib/Crypt/Rijndael.php index 206528a8..9e77f056 100644 --- a/phpseclib/Crypt/Rijndael.php +++ b/phpseclib/Crypt/Rijndael.php @@ -140,7 +140,8 @@ define('CRYPT_RIJNDAEL_MODE_MCRYPT', CRYPT_MODE_MCRYPT); * @access public * @package Crypt_Rijndael */ -class Crypt_Rijndael extends Crypt_Base { +class Crypt_Rijndael extends Crypt_Base +{ /** * The default password key_size used by setPassword() * diff --git a/phpseclib/Crypt/TripleDES.php b/phpseclib/Crypt/TripleDES.php index 738497b3..8eb69005 100644 --- a/phpseclib/Crypt/TripleDES.php +++ b/phpseclib/Crypt/TripleDES.php @@ -81,7 +81,8 @@ define('CRYPT_DES_MODE_CBC3', CRYPT_DES_MODE_CBC); * @access public * @package Crypt_TripleDES */ -class Crypt_TripleDES extends Crypt_DES { +class Crypt_TripleDES extends Crypt_DES +{ /** * The default password key_size used by setPassword() * diff --git a/phpseclib/Crypt/Twofish.php b/phpseclib/Crypt/Twofish.php index 07ec9851..6c0cb181 100644 --- a/phpseclib/Crypt/Twofish.php +++ b/phpseclib/Crypt/Twofish.php @@ -125,7 +125,8 @@ define('CRYPT_TWOFISH_MODE_MCRYPT', CRYPT_MODE_MCRYPT); * @access public * @package Crypt_Twofish */ -class Crypt_Twofish extends Crypt_Base { +class Crypt_Twofish extends Crypt_Base +{ /** * The namespace used by the cipher for its constants. * diff --git a/phpseclib/File/ANSI.php b/phpseclib/File/ANSI.php index b64ea5aa..4649c0cd 100644 --- a/phpseclib/File/ANSI.php +++ b/phpseclib/File/ANSI.php @@ -44,7 +44,8 @@ * @access public * @package File_ANSI */ -class File_ANSI { +class File_ANSI +{ /** * Max Width * diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 37199d26..a0457341 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -115,7 +115,8 @@ define('FILE_ASN1_TYPE_ANY', -2); * @access public * @package File_ASN1 */ -class File_ASN1_Element { +class File_ASN1_Element +{ /** * Raw element value * @@ -145,7 +146,8 @@ class File_ASN1_Element { * @access public * @package File_ASN1 */ -class File_ASN1 { +class File_ASN1 +{ /** * ASN.1 object identifier * diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index 3408165e..7d93a3a3 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -128,7 +128,8 @@ define('FILE_X509_ATTR_REPLACE', -3); // Clear first, then add a value. * @access public * @package File_X509 */ -class File_X509 { +class File_X509 +{ /** * ASN.1 syntax for X.509 certificates * diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index 0348e8bb..215a9a85 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -178,7 +178,8 @@ define('MATH_BIGINTEGER_KARATSUBA_CUTOFF', 25); * @access public * @package Math_BigInteger */ -class Math_BigInteger { +class Math_BigInteger +{ /** * Holds the BigInteger's value. * diff --git a/phpseclib/Net/SCP.php b/phpseclib/Net/SCP.php index 11bdd53b..77c98750 100644 --- a/phpseclib/Net/SCP.php +++ b/phpseclib/Net/SCP.php @@ -86,7 +86,8 @@ define('NET_SCP_SSH2', 2); * @access public * @package Net_SCP */ -class Net_SCP { +class Net_SCP +{ /** * SSH Object * diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index a73850c5..86b71650 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -120,7 +120,8 @@ define('NET_SFTP_RESUME_START', 8); * @access public * @package Net_SFTP */ -class Net_SFTP extends Net_SSH2 { +class Net_SFTP extends Net_SSH2 +{ /** * Packet Types * diff --git a/phpseclib/Net/SFTP/Stream.php b/phpseclib/Net/SFTP/Stream.php index 7339df22..1bc8c6cc 100644 --- a/phpseclib/Net/SFTP/Stream.php +++ b/phpseclib/Net/SFTP/Stream.php @@ -41,7 +41,8 @@ * @access public * @package Net_SFTP_Stream */ -class Net_SFTP_Stream { +class Net_SFTP_Stream +{ /** * SFTP instances * diff --git a/phpseclib/Net/SSH1.php b/phpseclib/Net/SSH1.php index 46f4dba9..4098b3fa 100644 --- a/phpseclib/Net/SSH1.php +++ b/phpseclib/Net/SSH1.php @@ -230,7 +230,8 @@ define('NET_SSH1_READ_REGEX', 2); * @access public * @package Net_SSH1 */ -class Net_SSH1 { +class Net_SSH1 +{ /** * The SSH identifier * diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index e9d11319..c0c2def4 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -148,7 +148,8 @@ define('NET_SSH2_LOG_MAX_SIZE', 1024 * 1024); * @access public * @package Net_SSH2 */ -class Net_SSH2 { +class Net_SSH2 +{ /** * The SSH identifier * diff --git a/tests/code_sniffer_ruleset.xml b/tests/code_sniffer_ruleset.xml index 3a7633a2..8a39c0ca 100644 --- a/tests/code_sniffer_ruleset.xml +++ b/tests/code_sniffer_ruleset.xml @@ -13,7 +13,6 @@ 0 0 0 - 0 0 0 0 From 9ca5f83dec353653909661479074808dbd7106fb Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 3 Dec 2013 20:49:22 +0100 Subject: [PATCH 28/39] CS: Fix Generic.Functions.FunctionCallArgumentSpacing.NoSpaceAfterComma sniff. --- phpseclib/File/ASN1.php | 56 +++++++++++++++++----------------- phpseclib/File/X509.php | 4 +-- tests/code_sniffer_ruleset.xml | 1 - 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index a0457341..20b33c5c 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -57,21 +57,21 @@ define('FILE_ASN1_CLASS_PRIVATE', 3); * @access private * @link http://www.obj-sys.com/asn1tutorial/node124.html */ -define('FILE_ASN1_TYPE_BOOLEAN', 1); -define('FILE_ASN1_TYPE_INTEGER', 2); -define('FILE_ASN1_TYPE_BIT_STRING', 3); -define('FILE_ASN1_TYPE_OCTET_STRING', 4); -define('FILE_ASN1_TYPE_NULL', 5); -define('FILE_ASN1_TYPE_OBJECT_IDENTIFIER',6); -//define('FILE_ASN1_TYPE_OBJECT_DESCRIPTOR',7); -//define('FILE_ASN1_TYPE_INSTANCE_OF', 8); // EXTERNAL -define('FILE_ASN1_TYPE_REAL', 9); -define('FILE_ASN1_TYPE_ENUMERATED', 10); -//define('FILE_ASN1_TYPE_EMBEDDED', 11); -define('FILE_ASN1_TYPE_UTF8_STRING', 12); -//define('FILE_ASN1_TYPE_RELATIVE_OID', 13); -define('FILE_ASN1_TYPE_SEQUENCE', 16); // SEQUENCE OF -define('FILE_ASN1_TYPE_SET', 17); // SET OF +define('FILE_ASN1_TYPE_BOOLEAN', 1); +define('FILE_ASN1_TYPE_INTEGER', 2); +define('FILE_ASN1_TYPE_BIT_STRING', 3); +define('FILE_ASN1_TYPE_OCTET_STRING', 4); +define('FILE_ASN1_TYPE_NULL', 5); +define('FILE_ASN1_TYPE_OBJECT_IDENTIFIER', 6); +//define('FILE_ASN1_TYPE_OBJECT_DESCRIPTOR', 7); +//define('FILE_ASN1_TYPE_INSTANCE_OF', 8); // EXTERNAL +define('FILE_ASN1_TYPE_REAL', 9); +define('FILE_ASN1_TYPE_ENUMERATED', 10); +//define('FILE_ASN1_TYPE_EMBEDDED', 11); +define('FILE_ASN1_TYPE_UTF8_STRING', 12); +//define('FILE_ASN1_TYPE_RELATIVE_OID', 13); +define('FILE_ASN1_TYPE_SEQUENCE', 16); // SEQUENCE OF +define('FILE_ASN1_TYPE_SET', 17); // SET OF /**#@-*/ /**#@+ * More Tag Classes @@ -79,19 +79,19 @@ define('FILE_ASN1_TYPE_SET', 17); // SET OF * @access private * @link http://www.obj-sys.com/asn1tutorial/node10.html */ -define('FILE_ASN1_TYPE_NUMERIC_STRING', 18); -define('FILE_ASN1_TYPE_PRINTABLE_STRING',19); -define('FILE_ASN1_TYPE_TELETEX_STRING', 20); // T61String -define('FILE_ASN1_TYPE_VIDEOTEX_STRING', 21); -define('FILE_ASN1_TYPE_IA5_STRING', 22); -define('FILE_ASN1_TYPE_UTC_TIME', 23); -define('FILE_ASN1_TYPE_GENERALIZED_TIME',24); -define('FILE_ASN1_TYPE_GRAPHIC_STRING', 25); -define('FILE_ASN1_TYPE_VISIBLE_STRING', 26); // ISO646String -define('FILE_ASN1_TYPE_GENERAL_STRING', 27); -define('FILE_ASN1_TYPE_UNIVERSAL_STRING',28); -//define('FILE_ASN1_TYPE_CHARACTER_STRING',29); -define('FILE_ASN1_TYPE_BMP_STRING', 30); +define('FILE_ASN1_TYPE_NUMERIC_STRING', 18); +define('FILE_ASN1_TYPE_PRINTABLE_STRING', 19); +define('FILE_ASN1_TYPE_TELETEX_STRING', 20); // T61String +define('FILE_ASN1_TYPE_VIDEOTEX_STRING', 21); +define('FILE_ASN1_TYPE_IA5_STRING', 22); +define('FILE_ASN1_TYPE_UTC_TIME', 23); +define('FILE_ASN1_TYPE_GENERALIZED_TIME', 24); +define('FILE_ASN1_TYPE_GRAPHIC_STRING', 25); +define('FILE_ASN1_TYPE_VISIBLE_STRING', 26); // ISO646String +define('FILE_ASN1_TYPE_GENERAL_STRING', 27); +define('FILE_ASN1_TYPE_UNIVERSAL_STRING', 28); +//define('FILE_ASN1_TYPE_CHARACTER_STRING', 29); +define('FILE_ASN1_TYPE_BMP_STRING', 30); /**#@-*/ /**#@+ diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index 7d93a3a3..f8d86bc5 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -3048,7 +3048,7 @@ class File_X509 $this->signatureSubject = substr($orig, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']); $this->_mapInExtensions($crl, 'tbsCertList/crlExtensions', $asn1); - $rclist = &$this->_subArray($crl,'tbsCertList/revokedCertificates'); + $rclist = &$this->_subArray($crl, 'tbsCertList/revokedCertificates'); if (is_array($rclist)) { foreach ($rclist as $i => $extension) { $this->_mapInExtensions($rclist, "$i/crlEntryExtensions", $asn1); @@ -3098,7 +3098,7 @@ class File_X509 $asn1->loadFilters($filters); $this->_mapOutExtensions($crl, 'tbsCertList/crlExtensions', $asn1); - $rclist = &$this->_subArray($crl,'tbsCertList/revokedCertificates'); + $rclist = &$this->_subArray($crl, 'tbsCertList/revokedCertificates'); if (is_array($rclist)) { foreach ($rclist as $i => $extension) { $this->_mapOutExtensions($rclist, "$i/crlEntryExtensions", $asn1); diff --git a/tests/code_sniffer_ruleset.xml b/tests/code_sniffer_ruleset.xml index 8a39c0ca..36f6545f 100644 --- a/tests/code_sniffer_ruleset.xml +++ b/tests/code_sniffer_ruleset.xml @@ -10,7 +10,6 @@ 0 0 - 0 0 0 0 From 161bb7d3620e3eb397b8cfe170478d53d7a15e19 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 3 Dec 2013 21:02:00 +0100 Subject: [PATCH 29/39] CS: Fix PEAR.ControlStructures.ControlSignature sniff. --- phpseclib/Crypt/Blowfish.php | 3 +-- phpseclib/File/ASN1.php | 6 ++---- phpseclib/File/X509.php | 9 +++------ tests/code_sniffer_ruleset.xml | 1 - 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/phpseclib/Crypt/Blowfish.php b/phpseclib/Crypt/Blowfish.php index 00e06a26..8fedee0e 100644 --- a/phpseclib/Crypt/Blowfish.php +++ b/phpseclib/Crypt/Blowfish.php @@ -418,8 +418,7 @@ class Crypt_Blowfish extends Crypt_Base if (!$keylength) { $key = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; - } - elseif ($keylength > 56) { + } elseif ($keylength > 56) { $key = substr($key, 0, 56); } diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 20b33c5c..3750f9f1 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -593,8 +593,7 @@ class File_ASN1 if (isset($child['class'])) { $childClass = $child['class']; $constant = $child['cast']; - } - elseif (isset($child['constant'])) { + } elseif (isset($child['constant'])) { $childClass = FILE_ASN1_CLASS_CONTEXT_SPECIFIC; $constant = $child['constant']; } @@ -666,8 +665,7 @@ class File_ASN1 if (isset($child['class'])) { $childClass = $child['class']; $constant = $child['cast']; - } - elseif (isset($child['constant'])) { + } elseif (isset($child['constant'])) { $childClass = FILE_ASN1_CLASS_CONTEXT_SPECIFIC; $constant = $child['constant']; } diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index f8d86bc5..d6fe7906 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -1715,8 +1715,7 @@ class File_X509 if ($map === false) { user_error($id . ' is not a currently supported attribute', E_USER_NOTICE); unset($attributes[$i]); - } - elseif (is_array($attributes[$i]['value'])) { + } elseif (is_array($attributes[$i]['value'])) { $values = &$attributes[$i]['value']; for ($j = 0; $j < count($values); $j++) { switch ($id) { @@ -3400,8 +3399,7 @@ class File_X509 if (!empty($this->serialNumber)) { $crlNumber = $this->serialNumber; - } - else { + } else { $crlNumber = $this->getExtension('id-ce-cRLNumber'); $crlNumber = $crlNumber !== false ? $crlNumber->add(new Math_BigInteger(1)) : null; } @@ -3414,8 +3412,7 @@ class File_X509 if (!$version) { if (!empty($tbsCertList['crlExtensions'])) { $version = 1; // v2. - } - elseif (!empty($tbsCertList['revokedCertificates'])) { + } elseif (!empty($tbsCertList['revokedCertificates'])) { foreach ($tbsCertList['revokedCertificates'] as $cert) { if (!empty($cert['crlEntryExtensions'])) { $version = 1; // v2. diff --git a/tests/code_sniffer_ruleset.xml b/tests/code_sniffer_ruleset.xml index 36f6545f..1838e1b5 100644 --- a/tests/code_sniffer_ruleset.xml +++ b/tests/code_sniffer_ruleset.xml @@ -29,7 +29,6 @@ 0 0 0 - 0 0 0 0 From ef2c50f9e0a0e252076eb643754347835bfb03cb Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 3 Dec 2013 21:02:30 +0100 Subject: [PATCH 30/39] Ignore coding style for "HAC 4.49" block in Math/BigInteger.php. --- phpseclib/Math/BigInteger.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index 215a9a85..91a917f0 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -3299,6 +3299,7 @@ class Math_BigInteger if (!$t) { // see HAC 4.49 "Note (controlling the error probability)" + // @codingStandardsIgnoreStart if ($length >= 163) { $t = 2; } // floor(1300 / 8) else if ($length >= 106) { $t = 3; } // floor( 850 / 8) else if ($length >= 81 ) { $t = 4; } // floor( 650 / 8) @@ -3311,6 +3312,7 @@ class Math_BigInteger else if ($length >= 25 ) { $t = 15; } // floor( 200 / 8) else if ($length >= 18 ) { $t = 18; } // floor( 150 / 8) else { $t = 27; } + // @codingStandardsIgnoreEnd } // ie. gmp_testbit($this, 0) From d6c70a76d94049c157567f3a929d71fb825a65c9 Mon Sep 17 00:00:00 2001 From: Marc Philip Scholten Date: Thu, 5 Dec 2013 18:46:46 +0100 Subject: [PATCH 31/39] Replaced php4 hack for microtime(true) with real microtime(true) --- phpseclib/Net/SSH2.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index e8f1c935..f2cac814 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -773,7 +773,7 @@ class Net_SSH2 { require_once('Crypt/Hash.php'); } - $this->last_packet = strtok(microtime(), ' ') + strtok(''); // == microtime(true) in PHP5 + $this->last_packet = microtime(true); $this->message_numbers = array( 1 => 'NET_SSH2_MSG_DISCONNECT', 2 => 'NET_SSH2_MSG_IGNORE', @@ -844,13 +844,13 @@ class Net_SSH2 { 61 => 'NET_SSH2_MSG_USERAUTH_INFO_RESPONSE') ); - $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 + $start = microtime(true); $this->fsock = @fsockopen($host, $port, $errno, $errstr, $timeout); if (!$this->fsock) { user_error(rtrim("Cannot connect to $host. Error $errno. $errstr")); return; } - $elapsed = strtok(microtime(), ' ') + strtok('') - $start; + $elapsed = microtime(true) - $start; $timeout-= $elapsed; @@ -2496,7 +2496,7 @@ class Net_SSH2 { return false; } - $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 + $start = microtime(true); $raw = fread($this->fsock, $this->decrypt_block_size); if (!strlen($raw)) { @@ -2529,7 +2529,7 @@ class Net_SSH2 { $buffer.= $temp; $remaining_length-= strlen($temp); } - $stop = strtok(microtime(), ' ') + strtok(''); + $stop = microtime(true); if (strlen($buffer)) { $raw.= $this->decrypt !== false ? $this->decrypt->decrypt($buffer) : $buffer; } @@ -2552,7 +2552,7 @@ class Net_SSH2 { $this->get_seq_no++; if (defined('NET_SSH2_LOGGING')) { - $current = strtok(microtime(), ' ') + strtok(''); + $current = microtime(true); $message_number = isset($this->message_numbers[ord($payload[0])]) ? $this->message_numbers[ord($payload[0])] : 'UNKNOWN (' . ord($payload[0]) . ')'; $message_number = '<- ' . $message_number . ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; @@ -2723,7 +2723,7 @@ class Net_SSH2 { $read = array($this->fsock); $write = $except = NULL; - $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 + $start = microtime(true); $sec = floor($this->curTimeout); $usec = 1000000 * ($this->curTimeout - $sec); // on windows this returns a "Warning: Invalid CRT parameters detected" error @@ -2731,7 +2731,7 @@ class Net_SSH2 { $this->is_timeout = true; return true; } - $elapsed = strtok(microtime(), ' ') + strtok('') - $start; + $elapsed = microtime(true) - $start; $this->curTimeout-= $elapsed; } @@ -2938,12 +2938,12 @@ class Net_SSH2 { $packet.= $hmac; - $start = strtok(microtime(), ' ') + strtok(''); // http://php.net/microtime#61838 + $start = microtime(true); $result = strlen($packet) == fputs($this->fsock, $packet); - $stop = strtok(microtime(), ' ') + strtok(''); + $stop = microtime(true); if (defined('NET_SSH2_LOGGING')) { - $current = strtok(microtime(), ' ') + strtok(''); + $current = microtime(true); $message_number = isset($this->message_numbers[ord($data[0])]) ? $this->message_numbers[ord($data[0])] : 'UNKNOWN (' . ord($data[0]) . ')'; $message_number = '-> ' . $message_number . ' (since last: ' . round($current - $this->last_packet, 4) . ', network: ' . round($stop - $start, 4) . 's)'; From bc6ff962927e09c4cec160fd0a1830d7eb4e5b88 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 5 Dec 2013 23:17:40 +0100 Subject: [PATCH 32/39] Fix "PEAR.Files.IncludingFile.BracketsNotRequired" sniff. --- phpseclib/Crypt/AES.php | 2 +- phpseclib/Crypt/Base.php | 2 +- phpseclib/Crypt/Blowfish.php | 2 +- phpseclib/Crypt/DES.php | 2 +- phpseclib/Crypt/Hash.php | 2 +- phpseclib/Crypt/RC2.php | 2 +- phpseclib/Crypt/RC4.php | 2 +- phpseclib/Crypt/RSA.php | 24 +++++++++---------- phpseclib/Crypt/Rijndael.php | 2 +- phpseclib/Crypt/TripleDES.php | 2 +- phpseclib/Crypt/Twofish.php | 2 +- phpseclib/File/ASN1.php | 2 +- phpseclib/File/X509.php | 18 +++++++------- phpseclib/Net/SFTP.php | 2 +- phpseclib/Net/SFTP/Stream.php | 2 +- phpseclib/Net/SSH1.php | 10 ++++---- phpseclib/Net/SSH2.php | 44 +++++++++++++++++----------------- tests/code_sniffer_ruleset.xml | 1 - 18 files changed, 61 insertions(+), 62 deletions(-) diff --git a/phpseclib/Crypt/AES.php b/phpseclib/Crypt/AES.php index 7313e640..7fbff79d 100644 --- a/phpseclib/Crypt/AES.php +++ b/phpseclib/Crypt/AES.php @@ -65,7 +65,7 @@ * Include Crypt_Rijndael */ if (!class_exists('Crypt_Rijndael')) { - require_once('Rijndael.php'); + require_once 'Rijndael.php'; } /**#@+ diff --git a/phpseclib/Crypt/Base.php b/phpseclib/Crypt/Base.php index 6c7136cc..2c9002a0 100644 --- a/phpseclib/Crypt/Base.php +++ b/phpseclib/Crypt/Base.php @@ -582,7 +582,7 @@ class Crypt_Base case !function_exists('hash_algos'): case !in_array($hash, hash_algos()): if (!class_exists('Crypt_Hash')) { - require_once('Crypt/Hash.php'); + require_once 'Crypt/Hash.php'; } $i = 1; while (strlen($key) < $dkLen) { diff --git a/phpseclib/Crypt/Blowfish.php b/phpseclib/Crypt/Blowfish.php index 8fedee0e..40389980 100644 --- a/phpseclib/Crypt/Blowfish.php +++ b/phpseclib/Crypt/Blowfish.php @@ -60,7 +60,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once('Base.php'); + require_once 'Base.php'; } /**#@+ diff --git a/phpseclib/Crypt/DES.php b/phpseclib/Crypt/DES.php index d8d15893..167a4128 100644 --- a/phpseclib/Crypt/DES.php +++ b/phpseclib/Crypt/DES.php @@ -64,7 +64,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once('Base.php'); + require_once 'Base.php'; } /**#@+ diff --git a/phpseclib/Crypt/Hash.php b/phpseclib/Crypt/Hash.php index 4abae510..a2ba4b11 100644 --- a/phpseclib/Crypt/Hash.php +++ b/phpseclib/Crypt/Hash.php @@ -581,7 +581,7 @@ class Crypt_Hash function _sha512($m) { if (!class_exists('Math_BigInteger')) { - require_once('Math/BigInteger.php'); + require_once 'Math/BigInteger.php'; } static $init384, $init512, $k; diff --git a/phpseclib/Crypt/RC2.php b/phpseclib/Crypt/RC2.php index 872d96cc..629f80d3 100755 --- a/phpseclib/Crypt/RC2.php +++ b/phpseclib/Crypt/RC2.php @@ -57,7 +57,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once('Base.php'); + require_once 'Base.php'; } /**#@+ diff --git a/phpseclib/Crypt/RC4.php b/phpseclib/Crypt/RC4.php index 38e778cf..75919717 100644 --- a/phpseclib/Crypt/RC4.php +++ b/phpseclib/Crypt/RC4.php @@ -66,7 +66,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once('Base.php'); + require_once 'Base.php'; } /**#@+ diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index 0ae214d2..2df9c431 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -75,14 +75,14 @@ // call function_exists() a second time to stop the require_once from being called outside // of the auto loader if (!function_exists('crypt_random_string')) { - require_once('Random.php'); + require_once 'Random.php'; } /** * Include Crypt_Hash */ if (!class_exists('Crypt_Hash')) { - require_once('Hash.php'); + require_once 'Hash.php'; } /**#@+ @@ -461,7 +461,7 @@ class Crypt_RSA function Crypt_RSA() { if (!class_exists('Math_BigInteger')) { - require_once('Math/BigInteger.php'); + require_once 'Math/BigInteger.php'; } $this->configFile = CRYPT_RSA_OPENSSL_CONFIG; @@ -773,7 +773,7 @@ class Crypt_RSA $private.= crypt_random_string(16 - (strlen($private) & 15)); $source.= pack('Na*', strlen($private), $private); if (!class_exists('Crypt_AES')) { - require_once('Crypt/AES.php'); + require_once 'Crypt/AES.php'; } $sequence = 0; $symkey = ''; @@ -794,7 +794,7 @@ class Crypt_RSA $key.= 'Private-Lines: ' . ((strlen($private) + 63) >> 6) . "\r\n"; $key.= chunk_split($private, 64); if (!class_exists('Crypt_Hash')) { - require_once('Crypt/Hash.php'); + require_once 'Crypt/Hash.php'; } $hash = new Crypt_Hash('sha1'); $hash->setKey(pack('H*', sha1($hashkey))); @@ -834,7 +834,7 @@ class Crypt_RSA $symkey = pack('H*', md5($this->password . $iv)); // symkey is short for symmetric key $symkey.= substr(pack('H*', md5($symkey . $this->password . $iv)), 0, 8); if (!class_exists('Crypt_TripleDES')) { - require_once('Crypt/TripleDES.php'); + require_once 'Crypt/TripleDES.php'; } $des = new Crypt_TripleDES(); $des->setKey($symkey); @@ -1000,33 +1000,33 @@ class Crypt_RSA switch ($matches[1]) { case 'AES-256-CBC': if (!class_exists('Crypt_AES')) { - require_once('Crypt/AES.php'); + require_once 'Crypt/AES.php'; } $crypto = new Crypt_AES(); break; case 'AES-128-CBC': if (!class_exists('Crypt_AES')) { - require_once('Crypt/AES.php'); + require_once 'Crypt/AES.php'; } $symkey = substr($symkey, 0, 16); $crypto = new Crypt_AES(); break; case 'DES-EDE3-CFB': if (!class_exists('Crypt_TripleDES')) { - require_once('Crypt/TripleDES.php'); + require_once 'Crypt/TripleDES.php'; } $crypto = new Crypt_TripleDES(CRYPT_DES_MODE_CFB); break; case 'DES-EDE3-CBC': if (!class_exists('Crypt_TripleDES')) { - require_once('Crypt/TripleDES.php'); + require_once 'Crypt/TripleDES.php'; } $symkey = substr($symkey, 0, 24); $crypto = new Crypt_TripleDES(); break; case 'DES-CBC': if (!class_exists('Crypt_DES')) { - require_once('Crypt/DES.php'); + require_once 'Crypt/DES.php'; } $crypto = new Crypt_DES(); break; @@ -1240,7 +1240,7 @@ class Crypt_RSA switch ($encryption) { case 'aes256-cbc': if (!class_exists('Crypt_AES')) { - require_once('Crypt/AES.php'); + require_once 'Crypt/AES.php'; } $symkey = ''; $sequence = 0; diff --git a/phpseclib/Crypt/Rijndael.php b/phpseclib/Crypt/Rijndael.php index 9e77f056..884fa8a2 100644 --- a/phpseclib/Crypt/Rijndael.php +++ b/phpseclib/Crypt/Rijndael.php @@ -76,7 +76,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once('Base.php'); + require_once 'Base.php'; } /**#@+ diff --git a/phpseclib/Crypt/TripleDES.php b/phpseclib/Crypt/TripleDES.php index 8eb69005..84c10e16 100644 --- a/phpseclib/Crypt/TripleDES.php +++ b/phpseclib/Crypt/TripleDES.php @@ -56,7 +56,7 @@ * Include Crypt_DES */ if (!class_exists('Crypt_DES')) { - require_once('DES.php'); + require_once 'DES.php'; } /** diff --git a/phpseclib/Crypt/Twofish.php b/phpseclib/Crypt/Twofish.php index 6c0cb181..68d5c0d9 100644 --- a/phpseclib/Crypt/Twofish.php +++ b/phpseclib/Crypt/Twofish.php @@ -60,7 +60,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once('Base.php'); + require_once 'Base.php'; } /**#@+ diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 3750f9f1..bce5c80e 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -253,7 +253,7 @@ class File_ASN1 if (!$static_init) { $static_init = true; if (!class_exists('Math_BigInteger')) { - require_once('Math/BigInteger.php'); + require_once 'Math/BigInteger.php'; } } } diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index d6fe7906..e392839e 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -46,7 +46,7 @@ * Include File_ASN1 */ if (!class_exists('File_ASN1')) { - require_once('ASN1.php'); + require_once 'ASN1.php'; } /** @@ -307,7 +307,7 @@ class File_X509 function File_X509() { if (!class_exists('Math_BigInteger')) { - require_once('Math/BigInteger.php'); + require_once 'Math/BigInteger.php'; } // Explicitly Tagged Module, 1988 Syntax @@ -2121,7 +2121,7 @@ class File_X509 switch ($publicKeyAlgorithm) { case 'rsaEncryption': if (!class_exists('Crypt_RSA')) { - require_once('Crypt/RSA.php'); + require_once 'Crypt/RSA.php'; } $rsa = new Crypt_RSA(); $rsa->loadKey($publicKey); @@ -2523,7 +2523,7 @@ class File_X509 case FILE_X509_DN_HASH: $dn = $this->getDN(FILE_X509_DN_CANON, $dn); if (!class_exists('Crypt_Hash')) { - require_once('Crypt/Hash.php'); + require_once 'Crypt/Hash.php'; } $hash = new Crypt_Hash('sha1'); $hash = $hash->hash($dn); @@ -2791,7 +2791,7 @@ class File_X509 switch ($keyinfo['algorithm']['algorithm']) { case 'rsaEncryption': if (!class_exists('Crypt_RSA')) { - require_once('Crypt/RSA.php'); + require_once 'Crypt/RSA.php'; } $publicKey = new Crypt_RSA(); $publicKey->loadKey($key); @@ -2864,7 +2864,7 @@ class File_X509 switch ($algorithm) { case 'rsaEncryption': if (!class_exists('Crypt_RSA')) { - require_once('Crypt/RSA.php'); + require_once 'Crypt/RSA.php'; } $this->publicKey = new Crypt_RSA(); $this->publicKey->loadKey($key); @@ -2989,7 +2989,7 @@ class File_X509 switch ($algorithm) { case 'rsaEncryption': if (!class_exists('Crypt_RSA')) { - require_once('Crypt/RSA.php'); + require_once 'Crypt/RSA.php'; } $this->publicKey = new Crypt_RSA(); $this->publicKey->loadKey($key); @@ -4061,7 +4061,7 @@ class File_X509 $raw = base64_decode($raw); // If the key is private, compute identifier from its corresponding public key. if (!class_exists('Crypt_RSA')) { - require_once('Crypt/RSA.php'); + require_once 'Crypt/RSA.php'; } $key = new Crypt_RSA(); if (!$key->loadKey($raw)) { @@ -4093,7 +4093,7 @@ class File_X509 // Now we have the key string: compute its sha-1 sum. if (!class_exists('Crypt_Hash')) { - require_once('Crypt/Hash.php'); + require_once 'Crypt/Hash.php'; } $hash = new Crypt_Hash('sha1'); $hash = $hash->hash($key); diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 86b71650..9dfb35ee 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -57,7 +57,7 @@ * Include Net_SSH2 */ if (!class_exists('Net_SSH2')) { - require_once('SSH2.php'); + require_once 'SSH2.php'; } /**#@+ diff --git a/phpseclib/Net/SFTP/Stream.php b/phpseclib/Net/SFTP/Stream.php index 1bc8c6cc..14ce6286 100644 --- a/phpseclib/Net/SFTP/Stream.php +++ b/phpseclib/Net/SFTP/Stream.php @@ -139,7 +139,7 @@ class Net_SFTP_Stream } if (!class_exists('Net_SFTP')) { - require_once('Net/SFTP.php'); + require_once 'Net/SFTP.php'; } } diff --git a/phpseclib/Net/SSH1.php b/phpseclib/Net/SSH1.php index 4098b3fa..682b4455 100644 --- a/phpseclib/Net/SSH1.php +++ b/phpseclib/Net/SSH1.php @@ -449,7 +449,7 @@ class Net_SSH1 function Net_SSH1($host, $port = 22, $timeout = 10, $cipher = NET_SSH1_CIPHER_3DES) { if (!class_exists('Math_BigInteger')) { - require_once('Math/BigInteger.php'); + require_once 'Math/BigInteger.php'; } // Include Crypt_Random @@ -458,7 +458,7 @@ class Net_SSH1 // call function_exists() a second time to stop the require_once from being called outside // of the auto loader if (!function_exists('crypt_random_string') && !class_exists('Crypt_Random') && !function_exists('crypt_random_string')) { - require_once('Crypt/Random.php'); + require_once 'Crypt/Random.php'; } $this->protocol_flags = array( @@ -603,7 +603,7 @@ class Net_SSH1 // break; case NET_SSH1_CIPHER_DES: if (!class_exists('Crypt_DES')) { - require_once('Crypt/DES.php'); + require_once 'Crypt/DES.php'; } $this->crypto = new Crypt_DES(); $this->crypto->disablePadding(); @@ -612,7 +612,7 @@ class Net_SSH1 break; case NET_SSH1_CIPHER_3DES: if (!class_exists('Crypt_TripleDES')) { - require_once('Crypt/TripleDES.php'); + require_once 'Crypt/TripleDES.php'; } $this->crypto = new Crypt_TripleDES(CRYPT_DES_MODE_3CBC); $this->crypto->disablePadding(); @@ -1253,7 +1253,7 @@ class Net_SSH1 { /* if (!class_exists('Crypt_RSA')) { - require_once('Crypt/RSA.php'); + require_once 'Crypt/RSA.php'; } $rsa = new Crypt_RSA(); diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index c0c2def4..4204ffe8 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -763,15 +763,15 @@ class Net_SSH2 // Include Math_BigInteger // Used to do Diffie-Hellman key exchange and DSA/RSA signature verification. if (!class_exists('Math_BigInteger')) { - require_once('Math/BigInteger.php'); + require_once 'Math/BigInteger.php'; } if (!function_exists('crypt_random_string')) { - require_once('Crypt/Random.php'); + require_once 'Crypt/Random.php'; } if (!class_exists('Crypt_Hash')) { - require_once('Crypt/Hash.php'); + require_once 'Crypt/Hash.php'; } $this->last_packet = strtok(microtime(), ' ') + strtok(''); // == microtime(true) in PHP5 @@ -1353,14 +1353,14 @@ class Net_SSH2 switch ($encrypt) { case '3des-cbc': if (!class_exists('Crypt_TripleDES')) { - require_once('Crypt/TripleDES.php'); + require_once 'Crypt/TripleDES.php'; } $this->encrypt = new Crypt_TripleDES(); // $this->encrypt_block_size = 64 / 8 == the default break; case '3des-ctr': if (!class_exists('Crypt_TripleDES')) { - require_once('Crypt/TripleDES.php'); + require_once 'Crypt/TripleDES.php'; } $this->encrypt = new Crypt_TripleDES(CRYPT_DES_MODE_CTR); // $this->encrypt_block_size = 64 / 8 == the default @@ -1369,7 +1369,7 @@ class Net_SSH2 case 'aes192-cbc': case 'aes128-cbc': if (!class_exists('Crypt_Rijndael')) { - require_once('Crypt/Rijndael.php'); + require_once 'Crypt/Rijndael.php'; } $this->encrypt = new Crypt_Rijndael(); $this->encrypt_block_size = 16; // eg. 128 / 8 @@ -1378,21 +1378,21 @@ class Net_SSH2 case 'aes192-ctr': case 'aes128-ctr': if (!class_exists('Crypt_Rijndael')) { - require_once('Crypt/Rijndael.php'); + require_once 'Crypt/Rijndael.php'; } $this->encrypt = new Crypt_Rijndael(CRYPT_RIJNDAEL_MODE_CTR); $this->encrypt_block_size = 16; // eg. 128 / 8 break; case 'blowfish-cbc': if (!class_exists('Crypt_Blowfish')) { - require_once('Crypt/Blowfish.php'); + require_once 'Crypt/Blowfish.php'; } $this->encrypt = new Crypt_Blowfish(); $this->encrypt_block_size = 8; break; case 'blowfish-ctr': if (!class_exists('Crypt_Blowfish')) { - require_once('Crypt/Blowfish.php'); + require_once 'Crypt/Blowfish.php'; } $this->encrypt = new Crypt_Blowfish(CRYPT_BLOWFISH_MODE_CTR); $this->encrypt_block_size = 8; @@ -1402,7 +1402,7 @@ class Net_SSH2 case 'twofish256-cbc': case 'twofish-cbc': if (!class_exists('Crypt_Twofish')) { - require_once('Crypt/Twofish.php'); + require_once 'Crypt/Twofish.php'; } $this->encrypt = new Crypt_Twofish(); $this->encrypt_block_size = 16; @@ -1411,7 +1411,7 @@ class Net_SSH2 case 'twofish192-ctr': case 'twofish256-ctr': if (!class_exists('Crypt_Twofish')) { - require_once('Crypt/Twofish.php'); + require_once 'Crypt/Twofish.php'; } $this->encrypt = new Crypt_Twofish(CRYPT_TWOFISH_MODE_CTR); $this->encrypt_block_size = 16; @@ -1420,7 +1420,7 @@ class Net_SSH2 case 'arcfour128': case 'arcfour256': if (!class_exists('Crypt_RC4')) { - require_once('Crypt/RC4.php'); + require_once 'Crypt/RC4.php'; } $this->encrypt = new Crypt_RC4(); break; @@ -1431,13 +1431,13 @@ class Net_SSH2 switch ($decrypt) { case '3des-cbc': if (!class_exists('Crypt_TripleDES')) { - require_once('Crypt/TripleDES.php'); + require_once 'Crypt/TripleDES.php'; } $this->decrypt = new Crypt_TripleDES(); break; case '3des-ctr': if (!class_exists('Crypt_TripleDES')) { - require_once('Crypt/TripleDES.php'); + require_once 'Crypt/TripleDES.php'; } $this->decrypt = new Crypt_TripleDES(CRYPT_DES_MODE_CTR); break; @@ -1445,7 +1445,7 @@ class Net_SSH2 case 'aes192-cbc': case 'aes128-cbc': if (!class_exists('Crypt_Rijndael')) { - require_once('Crypt/Rijndael.php'); + require_once 'Crypt/Rijndael.php'; } $this->decrypt = new Crypt_Rijndael(); $this->decrypt_block_size = 16; @@ -1454,21 +1454,21 @@ class Net_SSH2 case 'aes192-ctr': case 'aes128-ctr': if (!class_exists('Crypt_Rijndael')) { - require_once('Crypt/Rijndael.php'); + require_once 'Crypt/Rijndael.php'; } $this->decrypt = new Crypt_Rijndael(CRYPT_RIJNDAEL_MODE_CTR); $this->decrypt_block_size = 16; break; case 'blowfish-cbc': if (!class_exists('Crypt_Blowfish')) { - require_once('Crypt/Blowfish.php'); + require_once 'Crypt/Blowfish.php'; } $this->decrypt = new Crypt_Blowfish(); $this->decrypt_block_size = 8; break; case 'blowfish-ctr': if (!class_exists('Crypt_Blowfish')) { - require_once('Crypt/Blowfish.php'); + require_once 'Crypt/Blowfish.php'; } $this->decrypt = new Crypt_Blowfish(CRYPT_BLOWFISH_MODE_CTR); $this->decrypt_block_size = 8; @@ -1478,7 +1478,7 @@ class Net_SSH2 case 'twofish256-cbc': case 'twofish-cbc': if (!class_exists('Crypt_Twofish')) { - require_once('Crypt/Twofish.php'); + require_once 'Crypt/Twofish.php'; } $this->decrypt = new Crypt_Twofish(); $this->decrypt_block_size = 16; @@ -1487,7 +1487,7 @@ class Net_SSH2 case 'twofish192-ctr': case 'twofish256-ctr': if (!class_exists('Crypt_Twofish')) { - require_once('Crypt/Twofish.php'); + require_once 'Crypt/Twofish.php'; } $this->decrypt = new Crypt_Twofish(CRYPT_TWOFISH_MODE_CTR); $this->decrypt_block_size = 16; @@ -1496,7 +1496,7 @@ class Net_SSH2 case 'arcfour128': case 'arcfour256': if (!class_exists('Crypt_RC4')) { - require_once('Crypt/RC4.php'); + require_once 'Crypt/RC4.php'; } $this->decrypt = new Crypt_RC4(); break; @@ -3503,7 +3503,7 @@ class Net_SSH2 $signature = $this->_string_shift($signature, $temp['length']); if (!class_exists('Crypt_RSA')) { - require_once('Crypt/RSA.php'); + require_once 'Crypt/RSA.php'; } $rsa = new Crypt_RSA(); diff --git a/tests/code_sniffer_ruleset.xml b/tests/code_sniffer_ruleset.xml index 1838e1b5..047b3229 100644 --- a/tests/code_sniffer_ruleset.xml +++ b/tests/code_sniffer_ruleset.xml @@ -29,7 +29,6 @@ 0 0 0 - 0 0 0 0 From 6d1fb9f7dbbb962ac0cfb01942bcd1f26f946097 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 6 Dec 2013 01:03:34 +0100 Subject: [PATCH 33/39] CS: Fix "PEAR.Files.IncludingFile.UseIncludeOnce" sniff. --- phpseclib/Crypt/AES.php | 2 +- phpseclib/Crypt/Base.php | 2 +- phpseclib/Crypt/Blowfish.php | 2 +- phpseclib/Crypt/DES.php | 2 +- phpseclib/Crypt/Hash.php | 2 +- phpseclib/Crypt/RC2.php | 2 +- phpseclib/Crypt/RC4.php | 2 +- phpseclib/Crypt/RSA.php | 26 ++++++++++---------- phpseclib/Crypt/Rijndael.php | 2 +- phpseclib/Crypt/TripleDES.php | 2 +- phpseclib/Crypt/Twofish.php | 2 +- phpseclib/File/ASN1.php | 2 +- phpseclib/File/X509.php | 18 +++++++------- phpseclib/Net/SFTP.php | 2 +- phpseclib/Net/SFTP/Stream.php | 2 +- phpseclib/Net/SSH1.php | 14 +++++------ phpseclib/Net/SSH2.php | 44 +++++++++++++++++----------------- tests/code_sniffer_ruleset.xml | 1 - 18 files changed, 64 insertions(+), 65 deletions(-) diff --git a/phpseclib/Crypt/AES.php b/phpseclib/Crypt/AES.php index 7fbff79d..5977ad8c 100644 --- a/phpseclib/Crypt/AES.php +++ b/phpseclib/Crypt/AES.php @@ -65,7 +65,7 @@ * Include Crypt_Rijndael */ if (!class_exists('Crypt_Rijndael')) { - require_once 'Rijndael.php'; + include_once 'Rijndael.php'; } /**#@+ diff --git a/phpseclib/Crypt/Base.php b/phpseclib/Crypt/Base.php index 2c9002a0..ebf5fdde 100644 --- a/phpseclib/Crypt/Base.php +++ b/phpseclib/Crypt/Base.php @@ -582,7 +582,7 @@ class Crypt_Base case !function_exists('hash_algos'): case !in_array($hash, hash_algos()): if (!class_exists('Crypt_Hash')) { - require_once 'Crypt/Hash.php'; + include_once 'Crypt/Hash.php'; } $i = 1; while (strlen($key) < $dkLen) { diff --git a/phpseclib/Crypt/Blowfish.php b/phpseclib/Crypt/Blowfish.php index 40389980..3e2bcf16 100644 --- a/phpseclib/Crypt/Blowfish.php +++ b/phpseclib/Crypt/Blowfish.php @@ -60,7 +60,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once 'Base.php'; + include_once 'Base.php'; } /**#@+ diff --git a/phpseclib/Crypt/DES.php b/phpseclib/Crypt/DES.php index 167a4128..637bae2c 100644 --- a/phpseclib/Crypt/DES.php +++ b/phpseclib/Crypt/DES.php @@ -64,7 +64,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once 'Base.php'; + include_once 'Base.php'; } /**#@+ diff --git a/phpseclib/Crypt/Hash.php b/phpseclib/Crypt/Hash.php index a2ba4b11..221ba8cf 100644 --- a/phpseclib/Crypt/Hash.php +++ b/phpseclib/Crypt/Hash.php @@ -581,7 +581,7 @@ class Crypt_Hash function _sha512($m) { if (!class_exists('Math_BigInteger')) { - require_once 'Math/BigInteger.php'; + include_once 'Math/BigInteger.php'; } static $init384, $init512, $k; diff --git a/phpseclib/Crypt/RC2.php b/phpseclib/Crypt/RC2.php index 629f80d3..9975319b 100755 --- a/phpseclib/Crypt/RC2.php +++ b/phpseclib/Crypt/RC2.php @@ -57,7 +57,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once 'Base.php'; + include_once 'Base.php'; } /**#@+ diff --git a/phpseclib/Crypt/RC4.php b/phpseclib/Crypt/RC4.php index 75919717..e023f101 100644 --- a/phpseclib/Crypt/RC4.php +++ b/phpseclib/Crypt/RC4.php @@ -66,7 +66,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once 'Base.php'; + include_once 'Base.php'; } /**#@+ diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index 2df9c431..184cf93d 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -72,17 +72,17 @@ */ // the class_exists() will only be called if the crypt_random_string function hasn't been defined and // will trigger a call to __autoload() if you're wanting to auto-load classes -// call function_exists() a second time to stop the require_once from being called outside +// call function_exists() a second time to stop the include_once from being called outside // of the auto loader if (!function_exists('crypt_random_string')) { - require_once 'Random.php'; + include_once 'Random.php'; } /** * Include Crypt_Hash */ if (!class_exists('Crypt_Hash')) { - require_once 'Hash.php'; + include_once 'Hash.php'; } /**#@+ @@ -461,7 +461,7 @@ class Crypt_RSA function Crypt_RSA() { if (!class_exists('Math_BigInteger')) { - require_once 'Math/BigInteger.php'; + include_once 'Math/BigInteger.php'; } $this->configFile = CRYPT_RSA_OPENSSL_CONFIG; @@ -773,7 +773,7 @@ class Crypt_RSA $private.= crypt_random_string(16 - (strlen($private) & 15)); $source.= pack('Na*', strlen($private), $private); if (!class_exists('Crypt_AES')) { - require_once 'Crypt/AES.php'; + include_once 'Crypt/AES.php'; } $sequence = 0; $symkey = ''; @@ -794,7 +794,7 @@ class Crypt_RSA $key.= 'Private-Lines: ' . ((strlen($private) + 63) >> 6) . "\r\n"; $key.= chunk_split($private, 64); if (!class_exists('Crypt_Hash')) { - require_once 'Crypt/Hash.php'; + include_once 'Crypt/Hash.php'; } $hash = new Crypt_Hash('sha1'); $hash->setKey(pack('H*', sha1($hashkey))); @@ -834,7 +834,7 @@ class Crypt_RSA $symkey = pack('H*', md5($this->password . $iv)); // symkey is short for symmetric key $symkey.= substr(pack('H*', md5($symkey . $this->password . $iv)), 0, 8); if (!class_exists('Crypt_TripleDES')) { - require_once 'Crypt/TripleDES.php'; + include_once 'Crypt/TripleDES.php'; } $des = new Crypt_TripleDES(); $des->setKey($symkey); @@ -1000,33 +1000,33 @@ class Crypt_RSA switch ($matches[1]) { case 'AES-256-CBC': if (!class_exists('Crypt_AES')) { - require_once 'Crypt/AES.php'; + include_once 'Crypt/AES.php'; } $crypto = new Crypt_AES(); break; case 'AES-128-CBC': if (!class_exists('Crypt_AES')) { - require_once 'Crypt/AES.php'; + include_once 'Crypt/AES.php'; } $symkey = substr($symkey, 0, 16); $crypto = new Crypt_AES(); break; case 'DES-EDE3-CFB': if (!class_exists('Crypt_TripleDES')) { - require_once 'Crypt/TripleDES.php'; + include_once 'Crypt/TripleDES.php'; } $crypto = new Crypt_TripleDES(CRYPT_DES_MODE_CFB); break; case 'DES-EDE3-CBC': if (!class_exists('Crypt_TripleDES')) { - require_once 'Crypt/TripleDES.php'; + include_once 'Crypt/TripleDES.php'; } $symkey = substr($symkey, 0, 24); $crypto = new Crypt_TripleDES(); break; case 'DES-CBC': if (!class_exists('Crypt_DES')) { - require_once 'Crypt/DES.php'; + include_once 'Crypt/DES.php'; } $crypto = new Crypt_DES(); break; @@ -1240,7 +1240,7 @@ class Crypt_RSA switch ($encryption) { case 'aes256-cbc': if (!class_exists('Crypt_AES')) { - require_once 'Crypt/AES.php'; + include_once 'Crypt/AES.php'; } $symkey = ''; $sequence = 0; diff --git a/phpseclib/Crypt/Rijndael.php b/phpseclib/Crypt/Rijndael.php index 884fa8a2..4718062a 100644 --- a/phpseclib/Crypt/Rijndael.php +++ b/phpseclib/Crypt/Rijndael.php @@ -76,7 +76,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once 'Base.php'; + include_once 'Base.php'; } /**#@+ diff --git a/phpseclib/Crypt/TripleDES.php b/phpseclib/Crypt/TripleDES.php index 84c10e16..9239fa37 100644 --- a/phpseclib/Crypt/TripleDES.php +++ b/phpseclib/Crypt/TripleDES.php @@ -56,7 +56,7 @@ * Include Crypt_DES */ if (!class_exists('Crypt_DES')) { - require_once 'DES.php'; + include_once 'DES.php'; } /** diff --git a/phpseclib/Crypt/Twofish.php b/phpseclib/Crypt/Twofish.php index 68d5c0d9..31424f66 100644 --- a/phpseclib/Crypt/Twofish.php +++ b/phpseclib/Crypt/Twofish.php @@ -60,7 +60,7 @@ * Base cipher class */ if (!class_exists('Crypt_Base')) { - require_once 'Base.php'; + include_once 'Base.php'; } /**#@+ diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index bce5c80e..8e0898f2 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -253,7 +253,7 @@ class File_ASN1 if (!$static_init) { $static_init = true; if (!class_exists('Math_BigInteger')) { - require_once 'Math/BigInteger.php'; + include_once 'Math/BigInteger.php'; } } } diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index e392839e..446fc815 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -46,7 +46,7 @@ * Include File_ASN1 */ if (!class_exists('File_ASN1')) { - require_once 'ASN1.php'; + include_once 'ASN1.php'; } /** @@ -307,7 +307,7 @@ class File_X509 function File_X509() { if (!class_exists('Math_BigInteger')) { - require_once 'Math/BigInteger.php'; + include_once 'Math/BigInteger.php'; } // Explicitly Tagged Module, 1988 Syntax @@ -2121,7 +2121,7 @@ class File_X509 switch ($publicKeyAlgorithm) { case 'rsaEncryption': if (!class_exists('Crypt_RSA')) { - require_once 'Crypt/RSA.php'; + include_once 'Crypt/RSA.php'; } $rsa = new Crypt_RSA(); $rsa->loadKey($publicKey); @@ -2523,7 +2523,7 @@ class File_X509 case FILE_X509_DN_HASH: $dn = $this->getDN(FILE_X509_DN_CANON, $dn); if (!class_exists('Crypt_Hash')) { - require_once 'Crypt/Hash.php'; + include_once 'Crypt/Hash.php'; } $hash = new Crypt_Hash('sha1'); $hash = $hash->hash($dn); @@ -2791,7 +2791,7 @@ class File_X509 switch ($keyinfo['algorithm']['algorithm']) { case 'rsaEncryption': if (!class_exists('Crypt_RSA')) { - require_once 'Crypt/RSA.php'; + include_once 'Crypt/RSA.php'; } $publicKey = new Crypt_RSA(); $publicKey->loadKey($key); @@ -2864,7 +2864,7 @@ class File_X509 switch ($algorithm) { case 'rsaEncryption': if (!class_exists('Crypt_RSA')) { - require_once 'Crypt/RSA.php'; + include_once 'Crypt/RSA.php'; } $this->publicKey = new Crypt_RSA(); $this->publicKey->loadKey($key); @@ -2989,7 +2989,7 @@ class File_X509 switch ($algorithm) { case 'rsaEncryption': if (!class_exists('Crypt_RSA')) { - require_once 'Crypt/RSA.php'; + include_once 'Crypt/RSA.php'; } $this->publicKey = new Crypt_RSA(); $this->publicKey->loadKey($key); @@ -4061,7 +4061,7 @@ class File_X509 $raw = base64_decode($raw); // If the key is private, compute identifier from its corresponding public key. if (!class_exists('Crypt_RSA')) { - require_once 'Crypt/RSA.php'; + include_once 'Crypt/RSA.php'; } $key = new Crypt_RSA(); if (!$key->loadKey($raw)) { @@ -4093,7 +4093,7 @@ class File_X509 // Now we have the key string: compute its sha-1 sum. if (!class_exists('Crypt_Hash')) { - require_once 'Crypt/Hash.php'; + include_once 'Crypt/Hash.php'; } $hash = new Crypt_Hash('sha1'); $hash = $hash->hash($key); diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 9dfb35ee..17321d35 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -57,7 +57,7 @@ * Include Net_SSH2 */ if (!class_exists('Net_SSH2')) { - require_once 'SSH2.php'; + include_once 'SSH2.php'; } /**#@+ diff --git a/phpseclib/Net/SFTP/Stream.php b/phpseclib/Net/SFTP/Stream.php index 14ce6286..294532ff 100644 --- a/phpseclib/Net/SFTP/Stream.php +++ b/phpseclib/Net/SFTP/Stream.php @@ -139,7 +139,7 @@ class Net_SFTP_Stream } if (!class_exists('Net_SFTP')) { - require_once 'Net/SFTP.php'; + include_once 'Net/SFTP.php'; } } diff --git a/phpseclib/Net/SSH1.php b/phpseclib/Net/SSH1.php index 682b4455..ef3492d7 100644 --- a/phpseclib/Net/SSH1.php +++ b/phpseclib/Net/SSH1.php @@ -449,16 +449,16 @@ class Net_SSH1 function Net_SSH1($host, $port = 22, $timeout = 10, $cipher = NET_SSH1_CIPHER_3DES) { if (!class_exists('Math_BigInteger')) { - require_once 'Math/BigInteger.php'; + include_once 'Math/BigInteger.php'; } // Include Crypt_Random // the class_exists() will only be called if the crypt_random_string function hasn't been defined and // will trigger a call to __autoload() if you're wanting to auto-load classes - // call function_exists() a second time to stop the require_once from being called outside + // call function_exists() a second time to stop the include_once from being called outside // of the auto loader if (!function_exists('crypt_random_string') && !class_exists('Crypt_Random') && !function_exists('crypt_random_string')) { - require_once 'Crypt/Random.php'; + include_once 'Crypt/Random.php'; } $this->protocol_flags = array( @@ -603,7 +603,7 @@ class Net_SSH1 // break; case NET_SSH1_CIPHER_DES: if (!class_exists('Crypt_DES')) { - require_once 'Crypt/DES.php'; + include_once 'Crypt/DES.php'; } $this->crypto = new Crypt_DES(); $this->crypto->disablePadding(); @@ -612,7 +612,7 @@ class Net_SSH1 break; case NET_SSH1_CIPHER_3DES: if (!class_exists('Crypt_TripleDES')) { - require_once 'Crypt/TripleDES.php'; + include_once 'Crypt/TripleDES.php'; } $this->crypto = new Crypt_TripleDES(CRYPT_DES_MODE_3CBC); $this->crypto->disablePadding(); @@ -621,7 +621,7 @@ class Net_SSH1 break; //case NET_SSH1_CIPHER_RC4: // if (!class_exists('Crypt_RC4')) { - // require_once('Crypt/RC4.php'); + // include_once('Crypt/RC4.php'); // } // $this->crypto = new Crypt_RC4(); // $this->crypto->enableContinuousBuffer(); @@ -1253,7 +1253,7 @@ class Net_SSH1 { /* if (!class_exists('Crypt_RSA')) { - require_once 'Crypt/RSA.php'; + include_once 'Crypt/RSA.php'; } $rsa = new Crypt_RSA(); diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 4204ffe8..8454df06 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -763,15 +763,15 @@ class Net_SSH2 // Include Math_BigInteger // Used to do Diffie-Hellman key exchange and DSA/RSA signature verification. if (!class_exists('Math_BigInteger')) { - require_once 'Math/BigInteger.php'; + include_once 'Math/BigInteger.php'; } if (!function_exists('crypt_random_string')) { - require_once 'Crypt/Random.php'; + include_once 'Crypt/Random.php'; } if (!class_exists('Crypt_Hash')) { - require_once 'Crypt/Hash.php'; + include_once 'Crypt/Hash.php'; } $this->last_packet = strtok(microtime(), ' ') + strtok(''); // == microtime(true) in PHP5 @@ -1353,14 +1353,14 @@ class Net_SSH2 switch ($encrypt) { case '3des-cbc': if (!class_exists('Crypt_TripleDES')) { - require_once 'Crypt/TripleDES.php'; + include_once 'Crypt/TripleDES.php'; } $this->encrypt = new Crypt_TripleDES(); // $this->encrypt_block_size = 64 / 8 == the default break; case '3des-ctr': if (!class_exists('Crypt_TripleDES')) { - require_once 'Crypt/TripleDES.php'; + include_once 'Crypt/TripleDES.php'; } $this->encrypt = new Crypt_TripleDES(CRYPT_DES_MODE_CTR); // $this->encrypt_block_size = 64 / 8 == the default @@ -1369,7 +1369,7 @@ class Net_SSH2 case 'aes192-cbc': case 'aes128-cbc': if (!class_exists('Crypt_Rijndael')) { - require_once 'Crypt/Rijndael.php'; + include_once 'Crypt/Rijndael.php'; } $this->encrypt = new Crypt_Rijndael(); $this->encrypt_block_size = 16; // eg. 128 / 8 @@ -1378,21 +1378,21 @@ class Net_SSH2 case 'aes192-ctr': case 'aes128-ctr': if (!class_exists('Crypt_Rijndael')) { - require_once 'Crypt/Rijndael.php'; + include_once 'Crypt/Rijndael.php'; } $this->encrypt = new Crypt_Rijndael(CRYPT_RIJNDAEL_MODE_CTR); $this->encrypt_block_size = 16; // eg. 128 / 8 break; case 'blowfish-cbc': if (!class_exists('Crypt_Blowfish')) { - require_once 'Crypt/Blowfish.php'; + include_once 'Crypt/Blowfish.php'; } $this->encrypt = new Crypt_Blowfish(); $this->encrypt_block_size = 8; break; case 'blowfish-ctr': if (!class_exists('Crypt_Blowfish')) { - require_once 'Crypt/Blowfish.php'; + include_once 'Crypt/Blowfish.php'; } $this->encrypt = new Crypt_Blowfish(CRYPT_BLOWFISH_MODE_CTR); $this->encrypt_block_size = 8; @@ -1402,7 +1402,7 @@ class Net_SSH2 case 'twofish256-cbc': case 'twofish-cbc': if (!class_exists('Crypt_Twofish')) { - require_once 'Crypt/Twofish.php'; + include_once 'Crypt/Twofish.php'; } $this->encrypt = new Crypt_Twofish(); $this->encrypt_block_size = 16; @@ -1411,7 +1411,7 @@ class Net_SSH2 case 'twofish192-ctr': case 'twofish256-ctr': if (!class_exists('Crypt_Twofish')) { - require_once 'Crypt/Twofish.php'; + include_once 'Crypt/Twofish.php'; } $this->encrypt = new Crypt_Twofish(CRYPT_TWOFISH_MODE_CTR); $this->encrypt_block_size = 16; @@ -1420,7 +1420,7 @@ class Net_SSH2 case 'arcfour128': case 'arcfour256': if (!class_exists('Crypt_RC4')) { - require_once 'Crypt/RC4.php'; + include_once 'Crypt/RC4.php'; } $this->encrypt = new Crypt_RC4(); break; @@ -1431,13 +1431,13 @@ class Net_SSH2 switch ($decrypt) { case '3des-cbc': if (!class_exists('Crypt_TripleDES')) { - require_once 'Crypt/TripleDES.php'; + include_once 'Crypt/TripleDES.php'; } $this->decrypt = new Crypt_TripleDES(); break; case '3des-ctr': if (!class_exists('Crypt_TripleDES')) { - require_once 'Crypt/TripleDES.php'; + include_once 'Crypt/TripleDES.php'; } $this->decrypt = new Crypt_TripleDES(CRYPT_DES_MODE_CTR); break; @@ -1445,7 +1445,7 @@ class Net_SSH2 case 'aes192-cbc': case 'aes128-cbc': if (!class_exists('Crypt_Rijndael')) { - require_once 'Crypt/Rijndael.php'; + include_once 'Crypt/Rijndael.php'; } $this->decrypt = new Crypt_Rijndael(); $this->decrypt_block_size = 16; @@ -1454,21 +1454,21 @@ class Net_SSH2 case 'aes192-ctr': case 'aes128-ctr': if (!class_exists('Crypt_Rijndael')) { - require_once 'Crypt/Rijndael.php'; + include_once 'Crypt/Rijndael.php'; } $this->decrypt = new Crypt_Rijndael(CRYPT_RIJNDAEL_MODE_CTR); $this->decrypt_block_size = 16; break; case 'blowfish-cbc': if (!class_exists('Crypt_Blowfish')) { - require_once 'Crypt/Blowfish.php'; + include_once 'Crypt/Blowfish.php'; } $this->decrypt = new Crypt_Blowfish(); $this->decrypt_block_size = 8; break; case 'blowfish-ctr': if (!class_exists('Crypt_Blowfish')) { - require_once 'Crypt/Blowfish.php'; + include_once 'Crypt/Blowfish.php'; } $this->decrypt = new Crypt_Blowfish(CRYPT_BLOWFISH_MODE_CTR); $this->decrypt_block_size = 8; @@ -1478,7 +1478,7 @@ class Net_SSH2 case 'twofish256-cbc': case 'twofish-cbc': if (!class_exists('Crypt_Twofish')) { - require_once 'Crypt/Twofish.php'; + include_once 'Crypt/Twofish.php'; } $this->decrypt = new Crypt_Twofish(); $this->decrypt_block_size = 16; @@ -1487,7 +1487,7 @@ class Net_SSH2 case 'twofish192-ctr': case 'twofish256-ctr': if (!class_exists('Crypt_Twofish')) { - require_once 'Crypt/Twofish.php'; + include_once 'Crypt/Twofish.php'; } $this->decrypt = new Crypt_Twofish(CRYPT_TWOFISH_MODE_CTR); $this->decrypt_block_size = 16; @@ -1496,7 +1496,7 @@ class Net_SSH2 case 'arcfour128': case 'arcfour256': if (!class_exists('Crypt_RC4')) { - require_once 'Crypt/RC4.php'; + include_once 'Crypt/RC4.php'; } $this->decrypt = new Crypt_RC4(); break; @@ -3503,7 +3503,7 @@ class Net_SSH2 $signature = $this->_string_shift($signature, $temp['length']); if (!class_exists('Crypt_RSA')) { - require_once 'Crypt/RSA.php'; + include_once 'Crypt/RSA.php'; } $rsa = new Crypt_RSA(); diff --git a/tests/code_sniffer_ruleset.xml b/tests/code_sniffer_ruleset.xml index 047b3229..41aca9f1 100644 --- a/tests/code_sniffer_ruleset.xml +++ b/tests/code_sniffer_ruleset.xml @@ -29,7 +29,6 @@ 0 0 0 - 0 0 0 0 From cee0f3343ba39593547db6ed10434967792bb37d Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 7 Dec 2013 20:47:30 +0100 Subject: [PATCH 34/39] CS: Fix "PEAR.Formatting.MultiLineAssignment.EqualSignLine" sniff. --- phpseclib/Crypt/DES.php | 14 ++++--- phpseclib/File/X509.php | 67 +++++++++++++++++----------------- tests/code_sniffer_ruleset.xml | 1 - 3 files changed, 42 insertions(+), 40 deletions(-) diff --git a/phpseclib/Crypt/DES.php b/phpseclib/Crypt/DES.php index 637bae2c..b14f32ee 100644 --- a/phpseclib/Crypt/DES.php +++ b/phpseclib/Crypt/DES.php @@ -1336,12 +1336,14 @@ class Crypt_DES extends Crypt_Base $pc2mapd3[($d >> 8) & 0xFF] | $pc2mapd4[ $d & 0xFF]; // Reorder: odd bytes/even bytes. Push the result in key schedule. - $keys[$des_round][CRYPT_DES_ENCRYPT][ ] = - $keys[$des_round][CRYPT_DES_DECRYPT][$ki - 1] = ( $cp & 0xFF000000) | (($cp << 8) & 0x00FF0000) | - (($dp >> 16) & 0x0000FF00) | (($dp >> 8) & 0x000000FF); - $keys[$des_round][CRYPT_DES_ENCRYPT][ ] = - $keys[$des_round][CRYPT_DES_DECRYPT][$ki ] = (($cp << 8) & 0xFF000000) | (($cp << 16) & 0x00FF0000) | - (($dp >> 8) & 0x0000FF00) | ( $dp & 0x000000FF); + $val1 = ( $cp & 0xFF000000) | (($cp << 8) & 0x00FF0000) | + (($dp >> 16) & 0x0000FF00) | (($dp >> 8) & 0x000000FF); + $val2 = (($cp << 8) & 0xFF000000) | (($cp << 16) & 0x00FF0000) | + (($dp >> 8) & 0x0000FF00) | ( $dp & 0x000000FF); + $keys[$des_round][CRYPT_DES_ENCRYPT][ ] = $val1; + $keys[$des_round][CRYPT_DES_DECRYPT][$ki - 1] = $val1; + $keys[$des_round][CRYPT_DES_ENCRYPT][ ] = $val2; + $keys[$des_round][CRYPT_DES_DECRYPT][$ki ] = $val2; } } diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index 446fc815..be7914b6 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -1496,33 +1496,33 @@ class File_X509 default: switch ($algorithm) { case 'rsaEncryption': - $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'] = - base64_encode("\0" . base64_decode(preg_replace('#-.+-|[\r\n]#', '', $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']))); + $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey'] + = base64_encode("\0" . base64_decode(preg_replace('#-.+-|[\r\n]#', '', $cert['tbsCertificate']['subjectPublicKeyInfo']['subjectPublicKey']))); } } $asn1 = new File_ASN1(); - $asn1->loadOIDs($this->oids); $filters = array(); - $filters['tbsCertificate']['signature']['parameters'] = - $filters['tbsCertificate']['signature']['issuer']['rdnSequence']['value'] = - $filters['tbsCertificate']['issuer']['rdnSequence']['value'] = - $filters['tbsCertificate']['subject']['rdnSequence']['value'] = - $filters['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['parameters'] = - $filters['signatureAlgorithm']['parameters'] = - $filters['authorityCertIssuer']['directoryName']['rdnSequence']['value'] = - //$filters['policyQualifiers']['qualifier'] = - $filters['distributionPoint']['fullName']['directoryName']['rdnSequence']['value'] = - $filters['directoryName']['rdnSequence']['value'] = - array('type' => FILE_ASN1_TYPE_UTF8_STRING); + $type_utf8_string = array('type' => FILE_ASN1_TYPE_UTF8_STRING); + $filters['tbsCertificate']['signature']['parameters'] = $type_utf8_string; + $filters['tbsCertificate']['signature']['issuer']['rdnSequence']['value'] = $type_utf8_string; + $filters['tbsCertificate']['issuer']['rdnSequence']['value'] = $type_utf8_string; + $filters['tbsCertificate']['subject']['rdnSequence']['value'] = $type_utf8_string; + $filters['tbsCertificate']['subjectPublicKeyInfo']['algorithm']['parameters'] = $type_utf8_string; + $filters['signatureAlgorithm']['parameters'] = $type_utf8_string; + $filters['authorityCertIssuer']['directoryName']['rdnSequence']['value'] = $type_utf8_string; + //$filters['policyQualifiers']['qualifier'] = $type_utf8_string; + $filters['distributionPoint']['fullName']['directoryName']['rdnSequence']['value'] = $type_utf8_string; + $filters['directoryName']['rdnSequence']['value'] = $type_utf8_string; + /* in the case of policyQualifiers/qualifier, the type has to be FILE_ASN1_TYPE_IA5_STRING. FILE_ASN1_TYPE_PRINTABLE_STRING will cause OpenSSL's X.509 parser to spit out random characters. */ - $filters['policyQualifiers']['qualifier'] = - array('type' => FILE_ASN1_TYPE_IA5_STRING); + $filters['policyQualifiers']['qualifier'] + = array('type' => FILE_ASN1_TYPE_IA5_STRING); $asn1->loadFilters($filters); @@ -2901,8 +2901,8 @@ class File_X509 default: switch ($algorithm) { case 'rsaEncryption': - $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'] = - base64_encode("\0" . base64_decode(preg_replace('#-.+-|[\r\n]#', '', $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']))); + $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'] + = base64_encode("\0" . base64_decode(preg_replace('#-.+-|[\r\n]#', '', $csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey']))); } } @@ -2911,8 +2911,8 @@ class File_X509 $asn1->loadOIDs($this->oids); $filters = array(); - $filters['certificationRequestInfo']['subject']['rdnSequence']['value'] = - array('type' => FILE_ASN1_TYPE_UTF8_STRING); + $filters['certificationRequestInfo']['subject']['rdnSequence']['value'] + = array('type' => FILE_ASN1_TYPE_UTF8_STRING); $asn1->loadFilters($filters); @@ -3079,19 +3079,21 @@ class File_X509 $asn1->loadOIDs($this->oids); $filters = array(); - $filters['tbsCertList']['issuer']['rdnSequence']['value'] = - $filters['tbsCertList']['signature']['parameters'] = - $filters['signatureAlgorithm']['parameters'] = - array('type' => FILE_ASN1_TYPE_UTF8_STRING); + $filters['tbsCertList']['issuer']['rdnSequence']['value'] + = array('type' => FILE_ASN1_TYPE_UTF8_STRING); + $filters['tbsCertList']['signature']['parameters'] + = array('type' => FILE_ASN1_TYPE_UTF8_STRING); + $filters['signatureAlgorithm']['parameters'] + = array('type' => FILE_ASN1_TYPE_UTF8_STRING); if (empty($crl['tbsCertList']['signature']['parameters'])) { - $filters['tbsCertList']['signature']['parameters'] = - array('type' => FILE_ASN1_TYPE_NULL); + $filters['tbsCertList']['signature']['parameters'] + = array('type' => FILE_ASN1_TYPE_NULL); } if (empty($crl['signatureAlgorithm']['parameters'])) { - $filters['signatureAlgorithm']['parameters'] = - array('type' => FILE_ASN1_TYPE_NULL); + $filters['signatureAlgorithm']['parameters'] + = array('type' => FILE_ASN1_TYPE_NULL); } $asn1->loadFilters($filters); @@ -3143,9 +3145,9 @@ class File_X509 if (isset($subject->currentCert) && is_array($subject->currentCert) && isset($subject->currentCert['tbsCertificate'])) { $this->currentCert = $subject->currentCert; - $this->currentCert['tbsCertificate']['signature']['algorithm'] = - $this->currentCert['signatureAlgorithm']['algorithm'] = - $signatureAlgorithm; + $this->currentCert['tbsCertificate']['signature']['algorithm'] = $signatureAlgorithm; + $this->currentCert['signatureAlgorithm']['algorithm'] = $signatureAlgorithm; + if (!empty($this->startDate)) { $this->currentCert['tbsCertificate']['validity']['notBefore']['generalTime'] = $this->startDate; unset($this->currentCert['tbsCertificate']['validity']['notBefore']['utcTime']); @@ -3315,8 +3317,7 @@ class File_X509 $signatureSubject = isset($this->signatureSubject) ? $this->signatureSubject: null; if (isset($this->currentCert) && is_array($this->currentCert) && isset($this->currentCert['certificationRequestInfo'])) { - $this->currentCert['signatureAlgorithm']['algorithm'] = - $signatureAlgorithm; + $this->currentCert['signatureAlgorithm']['algorithm'] = $signatureAlgorithm; if (!empty($this->dn)) { $this->currentCert['certificationRequestInfo']['subject'] = $this->dn; } diff --git a/tests/code_sniffer_ruleset.xml b/tests/code_sniffer_ruleset.xml index 41aca9f1..724aed33 100644 --- a/tests/code_sniffer_ruleset.xml +++ b/tests/code_sniffer_ruleset.xml @@ -29,7 +29,6 @@ 0 0 0 - 0 0 0 0 From 3db1fbb0726f5187d72b1505f491f2c898f015b4 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 10 Dec 2013 20:10:37 +0100 Subject: [PATCH 35/39] CS: Fix "PEAR.Commenting.FileComment.TagIndent" sniff. --- phpseclib/Crypt/AES.php | 12 ++++++------ phpseclib/Crypt/Base.php | 16 ++++++++-------- phpseclib/Crypt/Blowfish.php | 16 ++++++++-------- phpseclib/Crypt/DES.php | 12 ++++++------ phpseclib/Crypt/Hash.php | 12 ++++++------ phpseclib/Crypt/RC2.php | 10 +++++----- phpseclib/Crypt/RC4.php | 12 ++++++------ phpseclib/Crypt/RSA.php | 12 ++++++------ phpseclib/Crypt/Random.php | 12 ++++++------ phpseclib/Crypt/Rijndael.php | 12 ++++++------ phpseclib/Crypt/TripleDES.php | 12 ++++++------ phpseclib/Crypt/Twofish.php | 16 ++++++++-------- phpseclib/File/ANSI.php | 12 ++++++------ phpseclib/File/ASN1.php | 12 ++++++------ phpseclib/File/X509.php | 12 ++++++------ phpseclib/Math/BigInteger.php | 12 ++++++------ phpseclib/Net/SCP.php | 12 ++++++------ phpseclib/Net/SFTP.php | 12 ++++++------ phpseclib/Net/SFTP/Stream.php | 12 ++++++------ phpseclib/Net/SSH1.php | 12 ++++++------ phpseclib/Net/SSH2.php | 12 ++++++------ tests/code_sniffer_ruleset.xml | 1 - 22 files changed, 131 insertions(+), 132 deletions(-) diff --git a/phpseclib/Crypt/AES.php b/phpseclib/Crypt/AES.php index 5977ad8c..206dc978 100644 --- a/phpseclib/Crypt/AES.php +++ b/phpseclib/Crypt/AES.php @@ -53,12 +53,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Crypt - * @package Crypt_AES - * @author Jim Wigginton - * @copyright MMVIII Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category Crypt + * @package Crypt_AES + * @author Jim Wigginton + * @copyright MMVIII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /** diff --git a/phpseclib/Crypt/Base.php b/phpseclib/Crypt/Base.php index ebf5fdde..a1de3aec 100644 --- a/phpseclib/Crypt/Base.php +++ b/phpseclib/Crypt/Base.php @@ -43,14 +43,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Crypt - * @package Crypt_Base - * @author Jim Wigginton - * @author Hans-Juergen Petrich - * @copyright MMVII Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @version 1.0.1 - * @link http://phpseclib.sourceforge.net + * @category Crypt + * @package Crypt_Base + * @author Jim Wigginton + * @author Hans-Juergen Petrich + * @copyright MMVII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @version 1.0.1 + * @link http://phpseclib.sourceforge.net */ /**#@+ diff --git a/phpseclib/Crypt/Blowfish.php b/phpseclib/Crypt/Blowfish.php index 3e2bcf16..5c52b1f6 100644 --- a/phpseclib/Crypt/Blowfish.php +++ b/phpseclib/Crypt/Blowfish.php @@ -44,14 +44,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Crypt - * @package Crypt_Blowfish - * @author Jim Wigginton - * @author Hans-Juergen Petrich - * @copyright MMVII Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @version 1.0 - * @link http://phpseclib.sourceforge.net + * @category Crypt + * @package Crypt_Blowfish + * @author Jim Wigginton + * @author Hans-Juergen Petrich + * @copyright MMVII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @version 1.0 + * @link http://phpseclib.sourceforge.net */ /** diff --git a/phpseclib/Crypt/DES.php b/phpseclib/Crypt/DES.php index b14f32ee..36611767 100644 --- a/phpseclib/Crypt/DES.php +++ b/phpseclib/Crypt/DES.php @@ -50,12 +50,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Crypt - * @package Crypt_DES - * @author Jim Wigginton - * @copyright MMVII Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category Crypt + * @package Crypt_DES + * @author Jim Wigginton + * @copyright MMVII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /** diff --git a/phpseclib/Crypt/Hash.php b/phpseclib/Crypt/Hash.php index 221ba8cf..0b1ca08a 100644 --- a/phpseclib/Crypt/Hash.php +++ b/phpseclib/Crypt/Hash.php @@ -46,12 +46,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Crypt - * @package Crypt_Hash - * @author Jim Wigginton - * @copyright MMVII Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category Crypt + * @package Crypt_Hash + * @author Jim Wigginton + * @copyright MMVII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /**#@+ diff --git a/phpseclib/Crypt/RC2.php b/phpseclib/Crypt/RC2.php index 9975319b..ed3548f3 100755 --- a/phpseclib/Crypt/RC2.php +++ b/phpseclib/Crypt/RC2.php @@ -44,11 +44,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Crypt - * @package Crypt_RC2 - * @author Patrick Monnerat - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category Crypt + * @package Crypt_RC2 + * @author Patrick Monnerat + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /** diff --git a/phpseclib/Crypt/RC4.php b/phpseclib/Crypt/RC4.php index e023f101..deb6884f 100644 --- a/phpseclib/Crypt/RC4.php +++ b/phpseclib/Crypt/RC4.php @@ -52,12 +52,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Crypt - * @package Crypt_RC4 - * @author Jim Wigginton - * @copyright MMVII Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category Crypt + * @package Crypt_RC4 + * @author Jim Wigginton + * @copyright MMVII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /** diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index 184cf93d..b54f95ab 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -59,12 +59,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Crypt - * @package Crypt_RSA - * @author Jim Wigginton - * @copyright MMIX Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category Crypt + * @package Crypt_RSA + * @author Jim Wigginton + * @copyright MMIX Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /** diff --git a/phpseclib/Crypt/Random.php b/phpseclib/Crypt/Random.php index 9570f2ea..0808aa34 100644 --- a/phpseclib/Crypt/Random.php +++ b/phpseclib/Crypt/Random.php @@ -32,12 +32,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Crypt - * @package Crypt_Random - * @author Jim Wigginton - * @copyright MMVII Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category Crypt + * @package Crypt_Random + * @author Jim Wigginton + * @copyright MMVII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /** diff --git a/phpseclib/Crypt/Rijndael.php b/phpseclib/Crypt/Rijndael.php index 4718062a..54a8e48c 100644 --- a/phpseclib/Crypt/Rijndael.php +++ b/phpseclib/Crypt/Rijndael.php @@ -62,12 +62,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Crypt - * @package Crypt_Rijndael - * @author Jim Wigginton - * @copyright MMVIII Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category Crypt + * @package Crypt_Rijndael + * @author Jim Wigginton + * @copyright MMVIII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /** diff --git a/phpseclib/Crypt/TripleDES.php b/phpseclib/Crypt/TripleDES.php index 9239fa37..baac8aa4 100644 --- a/phpseclib/Crypt/TripleDES.php +++ b/phpseclib/Crypt/TripleDES.php @@ -44,12 +44,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Crypt - * @package Crypt_TripleDES - * @author Jim Wigginton - * @copyright MMVII Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category Crypt + * @package Crypt_TripleDES + * @author Jim Wigginton + * @copyright MMVII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /** diff --git a/phpseclib/Crypt/Twofish.php b/phpseclib/Crypt/Twofish.php index 31424f66..220ee948 100644 --- a/phpseclib/Crypt/Twofish.php +++ b/phpseclib/Crypt/Twofish.php @@ -44,14 +44,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Crypt - * @package Crypt_Twofish - * @author Jim Wigginton - * @author Hans-Juergen Petrich - * @copyright MMVII Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @version 1.0 - * @link http://phpseclib.sourceforge.net + * @category Crypt + * @package Crypt_Twofish + * @author Jim Wigginton + * @author Hans-Juergen Petrich + * @copyright MMVII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @version 1.0 + * @link http://phpseclib.sourceforge.net */ /** diff --git a/phpseclib/File/ANSI.php b/phpseclib/File/ANSI.php index 4649c0cd..cf87617f 100644 --- a/phpseclib/File/ANSI.php +++ b/phpseclib/File/ANSI.php @@ -28,12 +28,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category File - * @package File_ANSI - * @author Jim Wigginton - * @copyright MMXII Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category File + * @package File_ANSI + * @author Jim Wigginton + * @copyright MMXII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /** diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index 8e0898f2..c099ca36 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -31,12 +31,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category File - * @package File_ASN1 - * @author Jim Wigginton - * @copyright MMXII Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category File + * @package File_ASN1 + * @author Jim Wigginton + * @copyright MMXII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /**#@+ diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index be7914b6..ef19281b 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -34,12 +34,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category File - * @package File_X509 - * @author Jim Wigginton - * @copyright MMXII Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category File + * @package File_X509 + * @author Jim Wigginton + * @copyright MMXII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /** diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index 91a917f0..de25da2a 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -64,12 +64,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Math - * @package Math_BigInteger - * @author Jim Wigginton - * @copyright MMVI Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://pear.php.net/package/Math_BigInteger + * @category Math + * @package Math_BigInteger + * @author Jim Wigginton + * @copyright MMVI Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://pear.php.net/package/Math_BigInteger */ /**#@+ diff --git a/phpseclib/Net/SCP.php b/phpseclib/Net/SCP.php index 77c98750..c519fdd7 100644 --- a/phpseclib/Net/SCP.php +++ b/phpseclib/Net/SCP.php @@ -41,12 +41,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Net - * @package Net_SCP - * @author Jim Wigginton - * @copyright MMX Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category Net + * @package Net_SCP + * @author Jim Wigginton + * @copyright MMX Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /**#@+ diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 17321d35..4baf3aa1 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -45,12 +45,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Net - * @package Net_SFTP - * @author Jim Wigginton - * @copyright MMIX Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category Net + * @package Net_SFTP + * @author Jim Wigginton + * @copyright MMIX Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /** diff --git a/phpseclib/Net/SFTP/Stream.php b/phpseclib/Net/SFTP/Stream.php index 294532ff..2f14d03c 100644 --- a/phpseclib/Net/SFTP/Stream.php +++ b/phpseclib/Net/SFTP/Stream.php @@ -25,12 +25,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Net - * @package Net_SFTP_Stream - * @author Jim Wigginton - * @copyright MMXIII Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category Net + * @package Net_SFTP_Stream + * @author Jim Wigginton + * @copyright MMXIII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /** diff --git a/phpseclib/Net/SSH1.php b/phpseclib/Net/SSH1.php index ef3492d7..2513eefd 100644 --- a/phpseclib/Net/SSH1.php +++ b/phpseclib/Net/SSH1.php @@ -56,12 +56,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Net - * @package Net_SSH1 - * @author Jim Wigginton - * @copyright MMVII Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category Net + * @package Net_SSH1 + * @author Jim Wigginton + * @copyright MMVII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /**#@+ diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 8454df06..53c0743b 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -58,12 +58,12 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * - * @category Net - * @package Net_SSH2 - * @author Jim Wigginton - * @copyright MMVII Jim Wigginton - * @license http://www.opensource.org/licenses/mit-license.html MIT License - * @link http://phpseclib.sourceforge.net + * @category Net + * @package Net_SSH2 + * @author Jim Wigginton + * @copyright MMVII Jim Wigginton + * @license http://www.opensource.org/licenses/mit-license.html MIT License + * @link http://phpseclib.sourceforge.net */ /**#@+ diff --git a/tests/code_sniffer_ruleset.xml b/tests/code_sniffer_ruleset.xml index 724aed33..032b8749 100644 --- a/tests/code_sniffer_ruleset.xml +++ b/tests/code_sniffer_ruleset.xml @@ -17,7 +17,6 @@ 0 0 0 - 0 0 0 0 From f0f029b2c176808c23d025d97c3cc48229994c41 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Wed, 11 Dec 2013 18:33:18 +0100 Subject: [PATCH 36/39] CS: Fix "PEAR.Commenting.ClassComment.WrongTagOrder" sniff. --- phpseclib/Crypt/AES.php | 2 +- phpseclib/Crypt/Base.php | 2 +- phpseclib/Crypt/Blowfish.php | 2 +- phpseclib/Crypt/DES.php | 2 +- phpseclib/Crypt/Hash.php | 2 +- phpseclib/Crypt/RC2.php | 2 +- phpseclib/Crypt/RC4.php | 2 +- phpseclib/Crypt/RSA.php | 2 +- phpseclib/Crypt/Rijndael.php | 2 +- phpseclib/Crypt/TripleDES.php | 2 +- phpseclib/Crypt/Twofish.php | 2 +- phpseclib/File/ANSI.php | 2 +- phpseclib/File/ASN1.php | 4 ++-- phpseclib/File/X509.php | 2 +- phpseclib/Math/BigInteger.php | 2 +- phpseclib/Net/SCP.php | 2 +- phpseclib/Net/SFTP.php | 2 +- phpseclib/Net/SFTP/Stream.php | 2 +- phpseclib/Net/SSH1.php | 2 +- phpseclib/Net/SSH2.php | 2 +- tests/code_sniffer_ruleset.xml | 1 - 21 files changed, 21 insertions(+), 22 deletions(-) diff --git a/phpseclib/Crypt/AES.php b/phpseclib/Crypt/AES.php index 206dc978..a00b2a9b 100644 --- a/phpseclib/Crypt/AES.php +++ b/phpseclib/Crypt/AES.php @@ -124,10 +124,10 @@ define('CRYPT_AES_MODE_MCRYPT', CRYPT_MODE_MCRYPT); /** * Pure-PHP implementation of AES. * + * @package Crypt_AES * @author Jim Wigginton * @version 0.1.0 * @access public - * @package Crypt_AES */ class Crypt_AES extends Crypt_Rijndael { diff --git a/phpseclib/Crypt/Base.php b/phpseclib/Crypt/Base.php index a1de3aec..c458f267 100644 --- a/phpseclib/Crypt/Base.php +++ b/phpseclib/Crypt/Base.php @@ -114,11 +114,11 @@ define('CRYPT_MODE_MCRYPT', 2); /** * Base Class for all Crypt_* cipher classes * + * @package Crypt_Base * @author Jim Wigginton * @author Hans-Juergen Petrich * @version 1.0.0 * @access public - * @package Crypt_Base */ class Crypt_Base { diff --git a/phpseclib/Crypt/Blowfish.php b/phpseclib/Crypt/Blowfish.php index 5c52b1f6..67593e5a 100644 --- a/phpseclib/Crypt/Blowfish.php +++ b/phpseclib/Crypt/Blowfish.php @@ -119,11 +119,11 @@ define('CRYPT_BLOWFISH_MODE_MCRYPT', CRYPT_MODE_MCRYPT); /** * Pure-PHP implementation of Blowfish. * + * @package Crypt_Blowfish * @author Jim Wigginton * @author Hans-Juergen Petrich * @version 1.0 * @access public - * @package Crypt_Blowfish */ class Crypt_Blowfish extends Crypt_Base { diff --git a/phpseclib/Crypt/DES.php b/phpseclib/Crypt/DES.php index 36611767..465f2512 100644 --- a/phpseclib/Crypt/DES.php +++ b/phpseclib/Crypt/DES.php @@ -138,10 +138,10 @@ define('CRYPT_DES_MODE_MCRYPT', CRYPT_MODE_MCRYPT); /** * Pure-PHP implementation of DES. * + * @package Crypt_DES * @author Jim Wigginton * @version 0.1.0 * @access public - * @package Crypt_DES */ class Crypt_DES extends Crypt_Base { diff --git a/phpseclib/Crypt/Hash.php b/phpseclib/Crypt/Hash.php index 0b1ca08a..06e47571 100644 --- a/phpseclib/Crypt/Hash.php +++ b/phpseclib/Crypt/Hash.php @@ -75,10 +75,10 @@ define('CRYPT_HASH_MODE_HASH', 3); /** * Pure-PHP implementations of keyed-hash message authentication codes (HMACs) and various cryptographic hashing functions. * + * @package Crypt_Hash * @author Jim Wigginton * @version 0.1.0 * @access public - * @package Crypt_Hash */ class Crypt_Hash { diff --git a/phpseclib/Crypt/RC2.php b/phpseclib/Crypt/RC2.php index ed3548f3..966a342d 100755 --- a/phpseclib/Crypt/RC2.php +++ b/phpseclib/Crypt/RC2.php @@ -116,9 +116,9 @@ define('CRYPT_RC2_MODE_MCRYPT', CRYPT_MODE_MCRYPT); /** * Pure-PHP implementation of RC2. * + * @package Crypt_RC2 * @version 0.1.1 * @access public - * @package Crypt_RC2 */ class Crypt_RC2 extends Crypt_Base { diff --git a/phpseclib/Crypt/RC4.php b/phpseclib/Crypt/RC4.php index deb6884f..7e5a6c59 100644 --- a/phpseclib/Crypt/RC4.php +++ b/phpseclib/Crypt/RC4.php @@ -94,10 +94,10 @@ define('CRYPT_RC4_DECRYPT', 1); /** * Pure-PHP implementation of RC4. * + * @package Crypt_RC4 * @author Jim Wigginton * @version 0.1.0 * @access public - * @package Crypt_RC4 */ class Crypt_RC4 extends Crypt_Base { diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index b54f95ab..4ce00456 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -239,10 +239,10 @@ define('CRYPT_RSA_PUBLIC_FORMAT_PKCS1', 7); /** * Pure-PHP PKCS#1 compliant implementation of RSA. * + * @package Crypt_RSA * @author Jim Wigginton * @version 0.1.0 * @access public - * @package Crypt_RSA */ class Crypt_RSA { diff --git a/phpseclib/Crypt/Rijndael.php b/phpseclib/Crypt/Rijndael.php index 54a8e48c..5a557929 100644 --- a/phpseclib/Crypt/Rijndael.php +++ b/phpseclib/Crypt/Rijndael.php @@ -135,10 +135,10 @@ define('CRYPT_RIJNDAEL_MODE_MCRYPT', CRYPT_MODE_MCRYPT); /** * Pure-PHP implementation of Rijndael. * + * @package Crypt_Rijndael * @author Jim Wigginton * @version 0.1.0 * @access public - * @package Crypt_Rijndael */ class Crypt_Rijndael extends Crypt_Base { diff --git a/phpseclib/Crypt/TripleDES.php b/phpseclib/Crypt/TripleDES.php index baac8aa4..ba2908fb 100644 --- a/phpseclib/Crypt/TripleDES.php +++ b/phpseclib/Crypt/TripleDES.php @@ -76,10 +76,10 @@ define('CRYPT_DES_MODE_CBC3', CRYPT_DES_MODE_CBC); /** * Pure-PHP implementation of Triple DES. * + * @package Crypt_TripleDES * @author Jim Wigginton * @version 0.1.0 * @access public - * @package Crypt_TripleDES */ class Crypt_TripleDES extends Crypt_DES { diff --git a/phpseclib/Crypt/Twofish.php b/phpseclib/Crypt/Twofish.php index 220ee948..7dec037b 100644 --- a/phpseclib/Crypt/Twofish.php +++ b/phpseclib/Crypt/Twofish.php @@ -119,11 +119,11 @@ define('CRYPT_TWOFISH_MODE_MCRYPT', CRYPT_MODE_MCRYPT); /** * Pure-PHP implementation of Twofish. * + * @package Crypt_Twofish * @author Jim Wigginton * @author Hans-Juergen Petrich * @version 1.0 * @access public - * @package Crypt_Twofish */ class Crypt_Twofish extends Crypt_Base { diff --git a/phpseclib/File/ANSI.php b/phpseclib/File/ANSI.php index cf87617f..df22de81 100644 --- a/phpseclib/File/ANSI.php +++ b/phpseclib/File/ANSI.php @@ -39,10 +39,10 @@ /** * Pure-PHP ANSI Decoder * + * @package File_ANSI * @author Jim Wigginton * @version 0.3.0 * @access public - * @package File_ANSI */ class File_ANSI { diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index c099ca36..2890f27c 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -110,10 +110,10 @@ define('FILE_ASN1_TYPE_ANY', -2); * * Bypass normal encoding rules in File_ASN1::encodeDER() * + * @package File_ASN1 * @author Jim Wigginton * @version 0.3.0 * @access public - * @package File_ASN1 */ class File_ASN1_Element { @@ -141,10 +141,10 @@ class File_ASN1_Element /** * Pure-PHP ASN.1 Parser * + * @package File_ASN1 * @author Jim Wigginton * @version 0.3.0 * @access public - * @package File_ASN1 */ class File_ASN1 { diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index ef19281b..21a3f0c4 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -123,10 +123,10 @@ define('FILE_X509_ATTR_REPLACE', -3); // Clear first, then add a value. /** * Pure-PHP X.509 Parser * + * @package File_X509 * @author Jim Wigginton * @version 0.3.1 * @access public - * @package File_X509 */ class File_X509 { diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index de25da2a..9cc8f6f5 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -173,10 +173,10 @@ define('MATH_BIGINTEGER_KARATSUBA_CUTOFF', 25); * Pure-PHP arbitrary precision integer arithmetic library. Supports base-2, base-10, base-16, and base-256 * numbers. * + * @package Math_BigInteger * @author Jim Wigginton * @version 1.0.0RC4 * @access public - * @package Math_BigInteger */ class Math_BigInteger { diff --git a/phpseclib/Net/SCP.php b/phpseclib/Net/SCP.php index c519fdd7..b53d34d9 100644 --- a/phpseclib/Net/SCP.php +++ b/phpseclib/Net/SCP.php @@ -81,10 +81,10 @@ define('NET_SCP_SSH2', 2); /** * Pure-PHP implementations of SCP. * + * @package Net_SCP * @author Jim Wigginton * @version 0.1.0 * @access public - * @package Net_SCP */ class Net_SCP { diff --git a/phpseclib/Net/SFTP.php b/phpseclib/Net/SFTP.php index 4baf3aa1..23d73b50 100644 --- a/phpseclib/Net/SFTP.php +++ b/phpseclib/Net/SFTP.php @@ -115,10 +115,10 @@ define('NET_SFTP_RESUME_START', 8); /** * Pure-PHP implementations of SFTP. * + * @package Net_SFTP * @author Jim Wigginton * @version 0.1.0 * @access public - * @package Net_SFTP */ class Net_SFTP extends Net_SSH2 { diff --git a/phpseclib/Net/SFTP/Stream.php b/phpseclib/Net/SFTP/Stream.php index 2f14d03c..56a36627 100644 --- a/phpseclib/Net/SFTP/Stream.php +++ b/phpseclib/Net/SFTP/Stream.php @@ -36,10 +36,10 @@ /** * SFTP Stream Wrapper * + * @package Net_SFTP_Stream * @author Jim Wigginton * @version 0.3.2 * @access public - * @package Net_SFTP_Stream */ class Net_SFTP_Stream { diff --git a/phpseclib/Net/SSH1.php b/phpseclib/Net/SSH1.php index 2513eefd..80fbbdc6 100644 --- a/phpseclib/Net/SSH1.php +++ b/phpseclib/Net/SSH1.php @@ -225,10 +225,10 @@ define('NET_SSH1_READ_REGEX', 2); /** * Pure-PHP implementation of SSHv1. * + * @package Net_SSH1 * @author Jim Wigginton * @version 0.1.0 * @access public - * @package Net_SSH1 */ class Net_SSH1 { diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 53c0743b..4f03ce61 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -143,10 +143,10 @@ define('NET_SSH2_LOG_MAX_SIZE', 1024 * 1024); /** * Pure-PHP implementation of SSHv2. * + * @package Net_SSH2 * @author Jim Wigginton * @version 0.1.0 * @access public - * @package Net_SSH2 */ class Net_SSH2 { diff --git a/tests/code_sniffer_ruleset.xml b/tests/code_sniffer_ruleset.xml index 032b8749..055318c8 100644 --- a/tests/code_sniffer_ruleset.xml +++ b/tests/code_sniffer_ruleset.xml @@ -14,7 +14,6 @@ 0 0 0 - 0 0 0 0 From 6ac922726d71381d696c4e97b21549542e9e331c Mon Sep 17 00:00:00 2001 From: terrafrost Date: Mon, 16 Dec 2013 11:27:12 -0600 Subject: [PATCH 37/39] SSH2: fix E_DEPRECATED on PHP5.5 --- phpseclib/Net/SSH2.php | 52 +++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 4f03ce61..6be16905 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -747,6 +747,30 @@ class Net_SSH2 */ var $is_timeout = false; + /** + * Log Boundary + * + * @see Net_SSH2::_format_log + * @access private + */ + var $log_boundary = ':'; + + /** + * Log Long Width + * + * @see Net_SSH2::_format_log + * @access private + */ + var $log_long_width = 65; + + /** + * Log Short Width + * + * @see Net_SSH2::_format_log + * @access private + */ + var $log_short_width = 16; + /** * Default Constructor. * @@ -3218,8 +3242,6 @@ class Net_SSH2 */ function _format_log($message_log, $message_number_log) { - static $boundary = ':', $long_width = 65, $short_width = 16; - $output = ''; for ($i = 0; $i < count($message_log); $i++) { $output.= $message_number_log[$i] . "\r\n"; @@ -3229,19 +3251,13 @@ class Net_SSH2 if (strlen($current_log)) { $output.= str_pad(dechex($j), 7, '0', STR_PAD_LEFT) . '0 '; } - $fragment = $this->_string_shift($current_log, $short_width); - $hex = substr( - preg_replace( - '#(.)#es', - '"' . $boundary . '" . str_pad(dechex(ord(substr("\\1", -1))), 2, "0", STR_PAD_LEFT)', - $fragment), - strlen($boundary) - ); + $fragment = $this->_string_shift($current_log, $this->log_short_width); + $hex = substr(preg_replace_callback('#.#s', array($this, '_format_log_helper'), $fragment), strlen($this->log_boundary)); // replace non ASCII printable characters with dots // http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters // also replace < with a . since < messes up the output on web browsers $raw = preg_replace('#[^\x20-\x7E]|<#', '.', $fragment); - $output.= str_pad($hex, $long_width - $short_width, ' ') . $raw . "\r\n"; + $output.= str_pad($hex, $this->log_long_width - $this->log_short_width, ' ') . $raw . "\r\n"; $j++; } while (strlen($current_log)); $output.= "\r\n"; @@ -3250,6 +3266,20 @@ class Net_SSH2 return $output; } + /** + * Helper function for _format_log + * + * For use with preg_replace_callback() + * + * @param Array $matches + * @access private + * @return String + */ + function _format_log_helper($matches) + { + return $this->log_boundary . str_pad(dechex(ord($matches[0])), 2, '0', STR_PAD_LEFT); + } + /** * Returns all errors * From f0b9f59bcc7cce1ac6d83a13379fa39b6d59c397 Mon Sep 17 00:00:00 2001 From: Marc Philip Scholten Date: Mon, 16 Dec 2013 19:45:37 +0100 Subject: [PATCH 38/39] Added test for Net_SSH2::_format_log() --- tests/Net/SSH2Test.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/Net/SSH2Test.php diff --git a/tests/Net/SSH2Test.php b/tests/Net/SSH2Test.php new file mode 100644 index 00000000..92af099f --- /dev/null +++ b/tests/Net/SSH2Test.php @@ -0,0 +1,41 @@ + + * @copyright MMXIII Marc Scholten + * @license http://www.opensource.org/licenses/mit-license.html MIT License + */ + +class Net_SSH2Test extends PhpseclibTestCase +{ + public function formatLogDataProvider() + { + return array( + array( + array('hello world'), + array('<--'), + "<--\r\n00000000 68:65:6c:6c:6f:20:77:6f:72:6c:64 hello world\r\n\r\n" + ), + array( + array('hello', 'world'), + array('<--', '<--'), + "<--\r\n00000000 68:65:6c:6c:6f hello\r\n\r\n" . + "<--\r\n00000000 77:6f:72:6c:64 world\r\n\r\n" + ), + ); + } + + /** + * @dataProvider formatLogDataProvider + */ + public function testFormatLog(array $message_log, array $message_number_log, $expected) + { + $ssh = $this->getMockBuilder('Net_SSH1') + ->disableOriginalConstructor() + ->setMethods(null) + ->getMock(); + + $result = $ssh->_format_log($message_log, $message_number_log); + + $this->assertEquals($expected, $result); + } +} From 46a1a0c1c2eda95322f5eaacd1da9a78817ef565 Mon Sep 17 00:00:00 2001 From: Marc Philip Scholten Date: Tue, 17 Dec 2013 20:09:26 +0100 Subject: [PATCH 39/39] Fixed typo and fixed bug with destructor being called in test on ssh object --- tests/Net/SSH2Test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Net/SSH2Test.php b/tests/Net/SSH2Test.php index 92af099f..954fb8b2 100644 --- a/tests/Net/SSH2Test.php +++ b/tests/Net/SSH2Test.php @@ -29,9 +29,9 @@ class Net_SSH2Test extends PhpseclibTestCase */ public function testFormatLog(array $message_log, array $message_number_log, $expected) { - $ssh = $this->getMockBuilder('Net_SSH1') + $ssh = $this->getMockBuilder('Net_SSH2') ->disableOriginalConstructor() - ->setMethods(null) + ->setMethods(array('__destruct')) ->getMock(); $result = $ssh->_format_log($message_log, $message_number_log);