From 55b142e9a93d05122b5932051e90a2eb6eaf4cb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A0=20=E6=81=A9=E6=A8=B9?= Date: Tue, 30 Jan 2024 14:24:47 +0900 Subject: [PATCH 01/11] fix php pkg install issues --- .../Admin/Store/OwnerStoreController.php | 46 +++++++++++++++---- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/src/Eccube/Controller/Admin/Store/OwnerStoreController.php b/src/Eccube/Controller/Admin/Store/OwnerStoreController.php index 9fe068412ab..ba924893ebd 100644 --- a/src/Eccube/Controller/Admin/Store/OwnerStoreController.php +++ b/src/Eccube/Controller/Admin/Store/OwnerStoreController.php @@ -32,6 +32,9 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Validator\Constraints as Assert; +use Symfony\Component\Validator\Validator\ValidatorInterface; + /** * @Route("/%eccube_admin_route%/store/plugin/api") @@ -48,6 +51,11 @@ class OwnerStoreController extends AbstractController */ protected $pluginService; + /** + * @var ValidatorInterface + */ + protected $validator; + /** * @var ComposerServiceInterface */ @@ -81,6 +89,7 @@ class OwnerStoreController extends AbstractController * @param PluginApiService $pluginApiService * @param BaseInfoRepository $baseInfoRepository * @param CacheUtil $cacheUtil + * @param ValidatorInterface $validatorInterface * * @throws \Doctrine\ORM\NoResultException * @throws \Doctrine\ORM\NonUniqueResultException @@ -92,7 +101,8 @@ public function __construct( SystemService $systemService, PluginApiService $pluginApiService, BaseInfoRepository $baseInfoRepository, - CacheUtil $cacheUtil + CacheUtil $cacheUtil, + ValidatorInterface $validatorInterface ) { $this->pluginRepository = $pluginRepository; $this->pluginService = $pluginService; @@ -100,6 +110,7 @@ public function __construct( $this->pluginApiService = $pluginApiService; $this->BaseInfo = $baseInfoRepository->get(); $this->cacheUtil = $cacheUtil; + $this->validator = $validatorInterface; // TODO: Check the flow of the composer service below $this->composerService = $composerService; @@ -263,13 +274,32 @@ public function apiInstall(Request $request) $pluginCode = $request->get('pluginCode'); - try { - $log = $this->composerService->execRequire('ec-cube/'.$pluginCode); + $errors = $this->validator->validate( + $pluginCode, + [ + new Assert\NotBlank(), + new Assert\Regex( + [ + 'pattern' => '/^[a-zA-Z0-9]+$/', + ] + ), + ] + ); + + if ($errors->count() != 0) { + $log = []; + foreach ($errors as $error) { + $log[] = $error->getMessage(); + } + } else { + try { + $log = $this->composerService->execRequire('ec-cube/'.$pluginCode); - return $this->json(['success' => true, 'log' => $log]); - } catch (\Exception $e) { - $log = $e->getMessage(); - log_error($e); + return $this->json(['success' => true, 'log' => $log]); + } catch (\Exception $e) { + $log = $e->getMessage(); + log_error($e); + } } return $this->json(['success' => false, 'log' => $log], 500); @@ -473,4 +503,4 @@ public function doUpdateConfirm(Plugin $Plugin) return $this->redirectToRoute('admin_store_authentication_setting'); } } -} +} \ No newline at end of file From 4ede3dbb5deb8c0a2e2bc49ac6096ecea90b5c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A0=20=E6=81=A9=E6=A8=B9?= Date: Tue, 30 Jan 2024 14:46:19 +0900 Subject: [PATCH 02/11] fix regex --- src/Eccube/Controller/Admin/Store/OwnerStoreController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Eccube/Controller/Admin/Store/OwnerStoreController.php b/src/Eccube/Controller/Admin/Store/OwnerStoreController.php index ba924893ebd..bdf63c1939d 100644 --- a/src/Eccube/Controller/Admin/Store/OwnerStoreController.php +++ b/src/Eccube/Controller/Admin/Store/OwnerStoreController.php @@ -280,7 +280,7 @@ public function apiInstall(Request $request) new Assert\NotBlank(), new Assert\Regex( [ - 'pattern' => '/^[a-zA-Z0-9]+$/', + 'pattern' => '/^[a-zA-Z0-9_]+$/', ] ), ] From 25e4105801bf87bb2631840c52db86d6274d7fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A0=20=E6=81=A9=E6=A8=B9?= Date: Thu, 22 Feb 2024 09:49:03 +0900 Subject: [PATCH 03/11] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AA=E8=A1=8C?= =?UTF-8?q?=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Controller/Admin/Store/OwnerStoreController.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Eccube/Controller/Admin/Store/OwnerStoreController.php b/src/Eccube/Controller/Admin/Store/OwnerStoreController.php index bdf63c1939d..9b76b0a022a 100644 --- a/src/Eccube/Controller/Admin/Store/OwnerStoreController.php +++ b/src/Eccube/Controller/Admin/Store/OwnerStoreController.php @@ -35,7 +35,6 @@ use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Validator\ValidatorInterface; - /** * @Route("/%eccube_admin_route%/store/plugin/api") */ @@ -54,7 +53,7 @@ class OwnerStoreController extends AbstractController /** * @var ValidatorInterface */ - protected $validator; + protected ValidatorInterface $validator; /** * @var ComposerServiceInterface From e0d57dcb735670567e8cec1dfba4c82f58f9d3f2 Mon Sep 17 00:00:00 2001 From: ji-eunsoo <132241702+ji-eunsoo@users.noreply.github.com> Date: Thu, 22 Feb 2024 09:53:27 +0900 Subject: [PATCH 04/11] =?UTF-8?q?=E5=B7=AE=E5=88=86=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Controller/Admin/Store/OwnerStoreController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Eccube/Controller/Admin/Store/OwnerStoreController.php b/src/Eccube/Controller/Admin/Store/OwnerStoreController.php index 9b76b0a022a..5395140deff 100644 --- a/src/Eccube/Controller/Admin/Store/OwnerStoreController.php +++ b/src/Eccube/Controller/Admin/Store/OwnerStoreController.php @@ -502,4 +502,4 @@ public function doUpdateConfirm(Plugin $Plugin) return $this->redirectToRoute('admin_store_authentication_setting'); } } -} \ No newline at end of file +} From aec96530db260ba9a200ef61723a42a2cec0eeda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A0=20=E6=81=A9=E6=A8=B9?= Date: Mon, 26 Feb 2024 17:08:05 +0900 Subject: [PATCH 05/11] add unittest --- .../Web/Admin/Store/PluginControllerTest.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php b/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php index 4bfdee3a80e..845c6e27007 100644 --- a/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php +++ b/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php @@ -49,4 +49,40 @@ public function testSubmit() $this->actual = $this->entityManager->getRepository(\Eccube\Entity\BaseInfo::class)->get()->getPhpPath(); $this->verify(); } + + /** + * * @dataProvider OwnerStoreInstallParam + */ + public function testInstall($param1, $param2, $message) + { + $form = [ + 'pluginCode' => $param1, + 'version' => $param2 + ]; + + $crawler = $this->client->request('POST', + $this->generateUrl('admin_store_plugin_api_install', $form), + [], + [], + [ + 'HTTP_X-Requested-With' => 'XMLHttpRequest', + 'CONTENT_TYPE' => 'application/json', + ] + ); + //ダウンロードできないことを確認 + $this->assertEquals(500, $this->client->getResponse()->getStatusCode()); + //ログを確認 + $this->assertContains($message, json_decode($this->client->getResponse()->getContent())->log); + } + + /** + * 異常系のテストケース + */ + public function OwnerStoreInstallParam() + { + return [ + ['api42+symfony/yaml:5.3', '4.2.3', '有効な値ではありません。'], + ['', '4.2.3','入力されていません。'], + ]; + } } From fbe7a8afe5f4b08fdcb4306ee3e58e713fc125aa Mon Sep 17 00:00:00 2001 From: ji-eunsoo <132241702+ji-eunsoo@users.noreply.github.com> Date: Tue, 27 Feb 2024 13:35:26 +0900 Subject: [PATCH 06/11] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Eccube/Tests/Web/Admin/Store/PluginControllerTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php b/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php index 845c6e27007..34c654e972f 100644 --- a/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php +++ b/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php @@ -53,11 +53,11 @@ public function testSubmit() /** * * @dataProvider OwnerStoreInstallParam */ - public function testInstall($param1, $param2, $message) + public function testFailureInstall($param1, $param2, $message) { $form = [ 'pluginCode' => $param1, - 'version' => $param2 + 'version' => $param2, ]; $crawler = $this->client->request('POST', @@ -69,9 +69,9 @@ public function testInstall($param1, $param2, $message) 'CONTENT_TYPE' => 'application/json', ] ); - //ダウンロードできないことを確認 + // ダウンロードできないことを確認 $this->assertEquals(500, $this->client->getResponse()->getStatusCode()); - //ログを確認 + // ログを確認 $this->assertContains($message, json_decode($this->client->getResponse()->getContent())->log); } From a87d8b57761fe858fe233669c4d75d90625ea92d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A0=20=E6=81=A9=E6=A8=B9?= Date: Wed, 28 Feb 2024 09:23:59 +0900 Subject: [PATCH 07/11] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php b/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php index 34c654e972f..e661b5e4196 100644 --- a/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php +++ b/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php @@ -51,7 +51,10 @@ public function testSubmit() } /** - * * @dataProvider OwnerStoreInstallParam + * 異常系を確認。正常系のインストールはE2Eテストの方で実施 + * + * @dataProvider OwnerStoreInstallParam + * */ public function testFailureInstall($param1, $param2, $message) { From 5315047dd2765428e751c149053209c23218dcf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A0=20=E6=81=A9=E6=A8=B9?= Date: Thu, 18 Apr 2024 11:04:28 +0900 Subject: [PATCH 08/11] =?UTF-8?q?=E3=82=A2=E3=83=83=E3=83=97=E3=83=87?= =?UTF-8?q?=E3=83=BC=E3=83=88=E3=81=AB=E5=85=A5=E5=8A=9B=E5=80=A4=E3=81=AE?= =?UTF-8?q?=E5=88=B6=E9=99=90=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Store/OwnerStoreController.php | 52 ++++++++++++++++--- .../Web/Admin/Store/PluginControllerTest.php | 46 +++++++++++++++- 2 files changed, 90 insertions(+), 8 deletions(-) diff --git a/src/Eccube/Controller/Admin/Store/OwnerStoreController.php b/src/Eccube/Controller/Admin/Store/OwnerStoreController.php index 5395140deff..6b786b16b3d 100644 --- a/src/Eccube/Controller/Admin/Store/OwnerStoreController.php +++ b/src/Eccube/Controller/Admin/Store/OwnerStoreController.php @@ -372,13 +372,53 @@ public function apiUpgrade(Request $request) $pluginCode = $request->get('pluginCode'); $version = $request->get('version'); - try { - $log = $this->composerService->execRequire('ec-cube/'.$pluginCode.':'.$version); + $log = []; + + $errors = $this->validator->validate( + $pluginCode, + [ + new Assert\NotBlank(), + new Assert\Regex( + [ + 'pattern' => '/^[a-zA-Z0-9_]+$/', + ] + ), + ] + ); - return $this->json(['success' => true, 'log' => $log]); - } catch (\Exception $e) { - $log = $e->getMessage(); - log_error($e); + if ($errors->count() != 0) { + foreach ($errors as $error) { + $log[] = $pluginCode.':'.$error->getMessage(); + } + } + + $errors = $this->validator->validate( + $version, + [ + new Assert\NotBlank(), + new Assert\Regex( + [ + 'pattern' => '/^[0-9.]+$/', + ] + ), + ] + ); + + if ($errors->count() != 0) { + foreach ($errors as $error) { + $log[] = $version.':'.$error->getMessage(); + } + } + + if (empty($log)) { + try { + $log = $this->composerService->execRequire('ec-cube/'.$pluginCode.':'.$version); + + return $this->json(['success' => true, 'log' => $log]); + } catch (\Exception $e) { + $log = $e->getMessage(); + log_error($e); + } } return $this->json(['success' => false, 'log' => $log], 500); diff --git a/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php b/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php index e661b5e4196..d762c2934b5 100644 --- a/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php +++ b/tests/Eccube/Tests/Web/Admin/Store/PluginControllerTest.php @@ -78,14 +78,56 @@ public function testFailureInstall($param1, $param2, $message) $this->assertContains($message, json_decode($this->client->getResponse()->getContent())->log); } + /** + * 異常系を確認。正常系のアップデートはE2Eテストの方で実施 + * + * @dataProvider OwnerStoreUpgradeParam + * + */ + public function testFailureUpgrade($param1, $param2, $message) + { + $form = [ + 'pluginCode' => $param1, + 'version' => $param2, + ]; + + $crawler = $this->client->request('POST', + $this->generateUrl('admin_store_plugin_api_upgrade', $form), + [], + [], + [ + 'HTTP_X-Requested-With' => 'XMLHttpRequest', + 'CONTENT_TYPE' => 'application/json', + ] + ); + // ダウンロードできないことを確認 + $this->assertEquals(500, $this->client->getResponse()->getStatusCode()); + + // ログを確認 + $this->assertStringContainsString($message, implode(',', json_decode($this->client->getResponse()->getContent())->log)); + } + /** * 異常系のテストケース */ public function OwnerStoreInstallParam() { return [ - ['api42+symfony/yaml:5.3', '4.2.3', '有効な値ではありません。'], - ['', '4.2.3','入力されていません。'], + ['api42+symfony/yaml:5.3', '4.3.0', '有効な値ではありません。'], + ['', '4.3.0','入力されていません。'], + ]; + } + + /** + * 異常系のテストケース + */ + public function OwnerStoreUpgradeParam() + { + return [ + ['api42+symfony/yaml:5.3', '4.3.0', '有効な値ではありません。'], + ['api42', '4.3.0 symfony/yaml:5.3', '有効な値ではありません。'], + ['api42', '','入力されていません。'], + ['', '4.3.0','入力されていません。'], ]; } } From bf419d9c119c8cf1de31f202a136e7277086b3f2 Mon Sep 17 00:00:00 2001 From: ji-eunsoo <132241702+ji-eunsoo@users.noreply.github.com> Date: Thu, 18 Apr 2024 12:57:08 +0900 Subject: [PATCH 09/11] =?UTF-8?q?=E3=83=80=E3=83=9F=E3=83=BC=E7=94=BB?= =?UTF-8?q?=E5=83=8F=E3=81=AE=E7=94=9F=E6=88=90=E6=99=82=E3=81=AB=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=81=8C=E8=90=BD=E3=81=A1=E3=82=8B=E3=81=9F?= =?UTF-8?q?=E3=82=81=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Eccube/Tests/Fixture/Generator.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/Eccube/Tests/Fixture/Generator.php b/tests/Eccube/Tests/Fixture/Generator.php index 7c2f4e1c15d..fa63caeca4e 100644 --- a/tests/Eccube/Tests/Fixture/Generator.php +++ b/tests/Eccube/Tests/Fixture/Generator.php @@ -55,6 +55,7 @@ use Eccube\Service\PurchaseFlow\PurchaseContext; use Eccube\Service\PurchaseFlow\PurchaseFlow; use Eccube\Util\StringUtil; +use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpFoundation\Session\SessionInterface; /** @@ -412,11 +413,11 @@ public function createProduct($product_name = null, $product_class_num = 3, $wit for ($i = 0; $i < 3; $i++) { $ProductImage = new ProductImage(); if ($with_image) { - $width = $faker->numberBetween(480, 640); - $height = $faker->numberBetween(480, 640); - $image = $faker->uuid.'.jpg'; - $src = file_get_contents('https://placekitten.com/'.$width.'/'.$height); - file_put_contents(__DIR__.'/../../../../html/upload/save_image/'.$image, $src); + $image = $faker->uuid.'.png'; + $src = __DIR__.'/../../../../html/upload/save_image/no_image_product.png'; + $dist = __DIR__.'/../../../../html/upload/save_image/'.$image; + $fs = new Filesystem(); + $fs->copy($src, $dist); } else { $image = $faker->word.'.jpg'; } From 6dcb07994e443faf23c32a100ad29efb3bd42f34 Mon Sep 17 00:00:00 2001 From: ji-eunsoo <132241702+ji-eunsoo@users.noreply.github.com> Date: Thu, 18 Apr 2024 15:14:13 +0900 Subject: [PATCH 10/11] =?UTF-8?q?=E5=A4=96=E9=83=A8=E3=81=AE=E4=B8=8D?= =?UTF-8?q?=E8=A6=81=E3=81=AA=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Controller/Admin/Store/OwnerStoreController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Eccube/Controller/Admin/Store/OwnerStoreController.php b/src/Eccube/Controller/Admin/Store/OwnerStoreController.php index 6b786b16b3d..882ae87cfb1 100644 --- a/src/Eccube/Controller/Admin/Store/OwnerStoreController.php +++ b/src/Eccube/Controller/Admin/Store/OwnerStoreController.php @@ -388,7 +388,7 @@ public function apiUpgrade(Request $request) if ($errors->count() != 0) { foreach ($errors as $error) { - $log[] = $pluginCode.':'.$error->getMessage(); + $log[] = $error->getMessage(); } } @@ -406,7 +406,7 @@ public function apiUpgrade(Request $request) if ($errors->count() != 0) { foreach ($errors as $error) { - $log[] = $version.':'.$error->getMessage(); + $log[] = $error->getMessage(); } } From e16dfa9d8eeda5c4aba656acf85aeb51fcec31d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A0=20=E6=81=A9=E6=A8=B9?= Date: Tue, 23 Jul 2024 13:31:11 +0900 Subject: [PATCH 11/11] =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 2 +- package.json | 2 +- src/Eccube/Common/Constant.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 80f89662e80..ff0ecdccf04 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "eccube", - "version": "4.2.3", + "version": "4.2.3-p1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 466d97ea39b..3fe10c7c147 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eccube", - "version": "4.2.3", + "version": "4.2.3-p1", "description": "EC-CUBE EC open platform.", "main": "index.js", "directories": { diff --git a/src/Eccube/Common/Constant.php b/src/Eccube/Common/Constant.php index 826eef987cc..177623cc479 100644 --- a/src/Eccube/Common/Constant.php +++ b/src/Eccube/Common/Constant.php @@ -18,7 +18,7 @@ class Constant /** * EC-CUBE VERSION. */ - public const VERSION = '4.2.3'; + public const VERSION = '4.2.3-p1'; /** * Enable value.