From 658c9817c2b9ddbfcf1635fc67cd8011d82954e6 Mon Sep 17 00:00:00 2001 From: Steve Robbins Date: Tue, 8 Mar 2016 14:19:21 -0800 Subject: [PATCH] Adding supee-7405, version check by controller for 2.* --- src/MageScan/Check/Patch/MageReport.php | 1 + src/MageScan/Check/Version.php | 1 + .../Check/Version/VersionController.php | 55 +++++++++++++++++++ src/bootstrap.php | 2 +- 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/MageScan/Check/Version/VersionController.php diff --git a/src/MageScan/Check/Patch/MageReport.php b/src/MageScan/Check/Patch/MageReport.php index a9f230a..79548e5 100644 --- a/src/MageScan/Check/Patch/MageReport.php +++ b/src/MageScan/Check/Patch/MageReport.php @@ -53,6 +53,7 @@ class MageReport extends AbstractCheck 'scan/result/supee6285', 'scan/result/supee6482', 'scan/result/supee6788', + 'scan/result/supee7405', ]; /** diff --git a/src/MageScan/Check/Version.php b/src/MageScan/Check/Version.php index 9bb175a..da8add1 100644 --- a/src/MageScan/Check/Version.php +++ b/src/MageScan/Check/Version.php @@ -38,6 +38,7 @@ class Version extends AbstractCheck protected $versionCheck = [ 'FileHash', 'DocComment', + 'VersionController', ]; /** diff --git a/src/MageScan/Check/Version/VersionController.php b/src/MageScan/Check/Version/VersionController.php new file mode 100644 index 0000000..a600229 --- /dev/null +++ b/src/MageScan/Check/Version/VersionController.php @@ -0,0 +1,55 @@ + + * @copyright 2015 Steve Robbins + * @license http://creativecommons.org/licenses/by/4.0/ CC BY 4.0 + * @link https://github.com/steverobbins/magescan + */ + +namespace MageScan\Check\Version; + +use MageScan\Check\AbstractCheck; +use MageScan\Check\Version; +use Mvi\Check; + +/** + * Magento 2 has a controller that tells you the version + * + * @category MageScan + * @package MageScan + * @author Steve Robbins + * @copyright 2015 Steve Robbins + * @license http://creativecommons.org/licenses/by/4.0/ CC BY 4.0 + * @link https://github.com/steverobbins/magescan + */ +class VersionController extends AbstractCheck +{ + /** + * Check for version controller + * + * @return array|boolean + */ + public function getInfo() + { + $response = $this->getRequest()->get('magento_version'); + if ($response->getStatusCode() == 200) { + preg_match("/Magento\/([0-9]\.[0-9\.]+) \(([a-zA-Z]+)\)/", $response->getBody(), $matches); + if (isset($matches[1]) && isset($matches[2])) { + $edition = $matches[2]; + $version = $matches[1]; + // An early versions of EE 2.0 would say it's 1.0 + if ($edition == 'Enterprise' && $version == '1.0') { + $version = '2.0'; + } + return [$edition, $version]; + } + } + return false; + } +} diff --git a/src/bootstrap.php b/src/bootstrap.php index 591e06e..11a6c76 100644 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -25,7 +25,7 @@ use MageScan\Command\SelfUpdateCommand; use Symfony\Component\Console\Application; -$app = new Application('Mage Scan', '1.12.1'); +$app = new Application('Mage Scan', '1.12.2'); $app->add(new AllCommand); $app->add(new VersionCommand);