Skip to content

Commit 88bfa91

Browse files
author
Korshenko, Oleksii(okorshenko)
committed
Merge pull request #601 from magento-sparta/2.0.6_backlog
2.0.6 Security release [Support]
2 parents 721ee66 + 772164d commit 88bfa91

File tree

63 files changed

+1880
-727
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1880
-727
lines changed

app/code/Magento/Authorizenet/Controller/Directpost/Payment/Redirect.php

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,12 @@
88

99
use Magento\Framework\App\ObjectManager;
1010
use Magento\Payment\Block\Transparent\Iframe;
11-
use Magento\Framework\Escaper;
1211

1312
/**
1413
* Class Redirect
1514
*/
1615
class Redirect extends \Magento\Authorizenet\Controller\Directpost\Payment
1716
{
18-
/**
19-
* @var Escaper
20-
*/
21-
private $escaper;
22-
2317
/**
2418
* Retrieve params and put javascript into iframe
2519
*
@@ -29,7 +23,7 @@ public function execute()
2923
{
3024
$helper = $this->dataFactory->create('frontend');
3125

32-
$redirectParams = $this->filterData($this->getRequest()->getParams());
26+
$redirectParams = $this->getRequest()->getParams();
3327
$params = [];
3428
if (!empty($redirectParams['success'])
3529
&& isset($redirectParams['x_invoice_num'])
@@ -38,9 +32,11 @@ public function execute()
3832
$this->_getDirectPostSession()->unsetData('quote_id');
3933
$params['redirect_parent'] = $helper->getSuccessOrderUrl([]);
4034
}
35+
4136
if (!empty($redirectParams['error_msg'])) {
4237
$cancelOrder = empty($redirectParams['x_invoice_num']);
4338
$this->_returnCustomerQuote($cancelOrder, $redirectParams['error_msg']);
39+
$params['error_msg'] = $redirectParams['error_msg'];
4440
}
4541

4642
if (isset($redirectParams['controller_action_name'])
@@ -50,34 +46,8 @@ public function execute()
5046
unset($params['redirect_parent']);
5147
}
5248

53-
$this->_coreRegistry->register(Iframe::REGISTRY_KEY, array_merge($params, $redirectParams));
49+
$this->_coreRegistry->register(Iframe::REGISTRY_KEY, $params);
5450
$this->_view->addPageLayoutHandles();
5551
$this->_view->loadLayout(false)->renderLayout();
5652
}
57-
58-
/**
59-
* Escape xss in request data
60-
* @param array $data
61-
* @return array
62-
*/
63-
private function filterData(array $data)
64-
{
65-
$self = $this;
66-
array_walk($data, function (&$item) use ($self) {
67-
$item = $self->getEscaper()->escapeXssInUrl($item);
68-
});
69-
return $data;
70-
}
71-
72-
/**
73-
* Get Escaper instance
74-
* @return Escaper
75-
*/
76-
private function getEscaper()
77-
{
78-
if (!$this->escaper) {
79-
$this->escaper = ObjectManager::getInstance()->get(Escaper::class);
80-
}
81-
return $this->escaper;
82-
}
8353
}

app/code/Magento/Authorizenet/Test/Unit/Controller/Directpost/Payment/RedirectTest.php

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Magento\Authorizenet\Controller\Directpost\Payment\Redirect;
99
use Magento\Framework\App\RequestInterface;
1010
use Magento\Framework\App\ViewInterface;
11-
use Magento\Framework\Escaper;
1211
use Magento\Framework\Registry;
1312
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1413
use Magento\Payment\Block\Transparent\Iframe;
@@ -34,11 +33,6 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
3433
*/
3534
private $coreRegistry;
3635

37-
/**
38-
* @var Escaper|MockObject
39-
*/
40-
private $escaper;
41-
4236
/**
4337
* @var Redirect
4438
*/
@@ -57,21 +51,11 @@ protected function setUp()
5751
->setMethods(['register'])
5852
->getMock();
5953

60-
$this->escaper = static::getMockBuilder(Escaper::class)
61-
->disableOriginalConstructor()
62-
->setMethods(['escapeXssInUrl'])
63-
->getMock();
64-
6554
$this->controller = $objectManager->getObject(Redirect::class, [
6655
'request' => $this->request,
6756
'view' => $this->view,
6857
'coreRegistry' => $this->coreRegistry
6958
]);
70-
71-
$refClass = new \ReflectionClass(Redirect::class);
72-
$refProperty = $refClass->getProperty('escaper');
73-
$refProperty->setAccessible(true);
74-
$refProperty->setValue($this->controller, $this->escaper);
7559
}
7660

7761
/**
@@ -87,14 +71,9 @@ public function testExecute()
8771
->method('getParams')
8872
->willReturn($params);
8973

90-
$this->escaper->expects(static::once())
91-
->method('escapeXssInUrl')
92-
->with($url)
93-
->willReturn($url);
94-
9574
$this->coreRegistry->expects(static::once())
9675
->method('register')
97-
->with(Iframe::REGISTRY_KEY, $params);
76+
->with(Iframe::REGISTRY_KEY, []);
9877

9978
$this->view->expects(static::once())
10079
->method('addPageLayoutHandles');

app/code/Magento/Backend/App/BackendAppList.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function getCurrentApp()
4444
if ($appName && isset($this->backendApps[$appName])) {
4545
return $this->backendApps[$appName];
4646
}
47+
return null;
4748
}
4849

4950
/**

app/code/Magento/Braintree/Model/PaymentMethod.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use \Braintree_Exception;
1111
use \Braintree_Transaction;
1212
use \Braintree_Result_Successful;
13+
use Magento\Framework\DataObject;
1314
use Magento\Framework\Exception\LocalizedException;
1415
use Magento\Sales\Model\Order\Payment\Transaction;
1516
use Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\CollectionFactory as TransactionCollectionFactory;
@@ -254,15 +255,29 @@ public function __construct(
254255
*/
255256
public function assignData(\Magento\Framework\DataObject $data)
256257
{
257-
parent::assignData($data);
258+
$additionalData = $data->getAdditionalData();
259+
260+
if (!is_array($data->getAdditionalData())) {
261+
return $this;
262+
}
263+
$additionalData = new DataObject($additionalData);
264+
258265
$infoInstance = $this->getInfoInstance();
259266
if ($this->getConfigData('fraudprotection') > 0) {
260-
$infoInstance->setAdditionalInformation('device_data', $data->getData('device_data'));
267+
$infoInstance->setAdditionalInformation('device_data', $additionalData->getData('device_data'));
261268
}
262-
$infoInstance->setAdditionalInformation('cc_last4', $data->getData('cc_last4'));
263-
$infoInstance->setAdditionalInformation('cc_token', $data->getCcToken());
264-
$infoInstance->setAdditionalInformation('payment_method_nonce', $data->getPaymentMethodNonce());
265-
$infoInstance->setAdditionalInformation('store_in_vault', $data->getStoreInVault());
269+
270+
$infoInstance->setAdditionalInformation('cc_last4', $additionalData->getData('cc_last4'));
271+
$infoInstance->setAdditionalInformation('cc_token', $additionalData->getData('cc_token'));
272+
$infoInstance->setAdditionalInformation(
273+
'payment_method_nonce',
274+
$additionalData->getData('payment_method_nonce')
275+
);
276+
277+
$infoInstance->setCcLast4($additionalData->getData('cc_last4'));
278+
$infoInstance->setCcType($additionalData->getData('cc_type'));
279+
$infoInstance->setCcExpMonth($additionalData->getData('cc_exp_month'));
280+
$infoInstance->setCcExpYear($additionalData->getData('cc_exp_year'));
266281
return $this;
267282
}
268283

app/code/Magento/Braintree/Model/PaymentMethod/PayPal.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use \Braintree_Exception;
1111
use \Braintree_Transaction;
1212
use \Braintree_Result_Successful;
13+
use Magento\Framework\DataObject;
1314
use Magento\Framework\Exception\LocalizedException;
1415
use Magento\Braintree\Model\PaymentMethod;
1516
use Magento\Payment\Model\InfoInterface;
@@ -152,8 +153,18 @@ public function getConfigData($field, $storeId = null)
152153
*/
153154
public function assignData(\Magento\Framework\DataObject $data)
154155
{
156+
$additionalData = $data->getAdditionalData();
157+
158+
if (!is_array($data->getAdditionalData())) {
159+
return $this;
160+
}
161+
$additionalData = new DataObject($additionalData);
162+
155163
$infoInstance = $this->getInfoInstance();
156-
$infoInstance->setAdditionalInformation('payment_method_nonce', $data->getPaymentMethodNonce());
164+
$infoInstance->setAdditionalInformation(
165+
'payment_method_nonce',
166+
$additionalData->getData('payment_method_nonce')
167+
);
157168
return $this;
158169
}
159170

app/code/Magento/Braintree/Test/Unit/Model/PaymentMethod/PayPalTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,12 @@ public function testAssignData()
230230
$paymentMethodNonce = 'nonce';
231231
$storeInVault = true;
232232
$data = [
233-
'cc_last4' => $ccLast4,
234-
'cc_token' => $ccToken,
235-
'payment_method_nonce' => $paymentMethodNonce,
236-
'store_in_vault' => $storeInVault,
233+
'additional_data' => [
234+
'cc_last4' => $ccLast4,
235+
'cc_token' => $ccToken,
236+
'payment_method_nonce' => $paymentMethodNonce,
237+
'store_in_vault' => $storeInVault
238+
]
237239
];
238240
$data = new \Magento\Framework\DataObject($data);
239241
$this->model->setInfoInstance($this->infoInstanceMock);

0 commit comments

Comments
 (0)