Skip to content

Commit 64b398c

Browse files
AC-2571: Implemented Input Validation
* Add Input Validation
1 parent f605b71 commit 64b398c

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

app/code/Magento/CatalogRule/Controller/Adminhtml/Promo/Catalog/NewConditionHtml.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@
66
*/
77
namespace Magento\CatalogRule\Controller\Adminhtml\Promo\Catalog;
88

9+
use Magento\CatalogRule\Controller\Adminhtml\Promo\Catalog as CatalogAction;
910
use Magento\Framework\App\Action\HttpGetActionInterface;
1011
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
1112
use Magento\Rule\Model\Condition\AbstractCondition;
12-
use Magento\CatalogRule\Controller\Adminhtml\Promo\Catalog as CatalogAction;
13+
use Magento\Rule\Model\Condition\ConditionInterface;
1314

1415
class NewConditionHtml extends CatalogAction implements HttpPostActionInterface, HttpGetActionInterface
1516
{
1617
/**
18+
* New condition html action
19+
*
1720
* @return void
1821
*/
1922
public function execute()
@@ -23,6 +26,18 @@ public function execute()
2326
$typeArr = explode('|', str_replace('-', '/', $this->getRequest()->getParam('type')));
2427
$type = $typeArr[0];
2528

29+
/**
30+
* @SuppressWarnings(PHPCPD-START)
31+
*/
32+
if (class_exists($type) && !in_array(ConditionInterface::class, class_implements($type))) {
33+
$html = '';
34+
$this->getResponse()->setBody($html);
35+
return;
36+
}
37+
/**
38+
* @SuppressWarnings(PHPCPD-END)
39+
*/
40+
2641
$model = $this->_objectManager->create($type)
2742
->setId($id)
2843
->setType($type)

app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewConditionHtml.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Framework\App\Action\HttpPostActionInterface;
99
use Magento\Rule\Model\Condition\AbstractCondition;
10+
use Magento\Rule\Model\Condition\ConditionInterface;
1011
use Magento\SalesRule\Controller\Adminhtml\Promo\Quote;
1112

1213
/**
@@ -26,6 +27,18 @@ public function execute()
2627
$typeArr = explode('|', str_replace('-', '/', $this->getRequest()->getParam('type')));
2728
$type = $typeArr[0];
2829

30+
/**
31+
* @SuppressWarnings(PHPCPD-START)
32+
*/
33+
if (class_exists($type) && !in_array(ConditionInterface::class, class_implements($type))) {
34+
$html = '';
35+
$this->getResponse()->setBody($html);
36+
return;
37+
}
38+
/**
39+
* @SuppressWarnings(PHPCPD-END)
40+
*/
41+
2942
$model = $this->_objectManager->create(
3043
$type
3144
)->setId(

0 commit comments

Comments
 (0)