Skip to content

Commit abc1d24

Browse files
committed
Merge remote-tracking branch 'mainline/2.2-develop' into 2.2-develop-PR-port-20791
2 parents a353566 + db3bb6b commit abc1d24

File tree

959 files changed

+18800
-9470
lines changed

Some content is hidden

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

959 files changed

+18800
-9470
lines changed

.htaccess

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
############################################
3131
## default index file
32+
## Specifies option, to use methods arguments in backtrace or not
33+
SetEnv MAGE_DEBUG_SHOW_ARGS 1
3234

3335
DirectoryIndex index.php
3436

@@ -364,6 +366,15 @@
364366
Require all denied
365367
</IfVersion>
366368
</Files>
369+
<Files .user.ini>
370+
<IfVersion < 2.4>
371+
order allow,deny
372+
deny from all
373+
</IfVersion>
374+
<IfVersion >= 2.4>
375+
Require all denied
376+
</IfVersion>
377+
</Files>
367378

368379
# For 404s and 403s that aren't handled by the application, show plain 404 response
369380
ErrorDocument 404 /pub/errors/404.php

.htaccess.sample

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,15 @@
341341
Require all denied
342342
</IfVersion>
343343
</Files>
344+
<Files .user.ini>
345+
<IfVersion < 2.4>
346+
order allow,deny
347+
deny from all
348+
</IfVersion>
349+
<IfVersion >= 2.4>
350+
Require all denied
351+
</IfVersion>
352+
</Files>
344353

345354
# For 404s and 403s that aren't handled by the application, show plain 404 response
346355
ErrorDocument 404 /pub/errors/404.php

CHANGELOG.md

Lines changed: 473 additions & 0 deletions
Large diffs are not rendered by default.

app/bootstrap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* Environment initialization
99
*/
1010
error_reporting(E_ALL);
11+
stream_wrapper_unregister('phar');
1112
#ini_set('display_errors', 1);
1213

1314
/* PHP version validation */

app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
namespace Magento\AdminNotification\Block\Grid\Renderer;
1010

11+
/**
12+
* Renderer class for action in the admin notifications grid.
13+
*/
1114
class Actions extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
1215
{
1316
/**
@@ -37,19 +40,23 @@ public function __construct(
3740
*/
3841
public function render(\Magento\Framework\DataObject $row)
3942
{
40-
$readDetailsHtml = $row->getUrl() ? '<a class="action-details" target="_blank" href="' . $row->getUrl() . '">' .
43+
$readDetailsHtml = $row->getUrl() ? '<a class="action-details" target="_blank" href="' .
44+
$this->escapeUrl($row->getUrl())
45+
. '">' .
4146
__('Read Details') . '</a>' : '';
4247

43-
$markAsReadHtml = !$row->getIsRead() ? '<a class="action-mark" href="' . $this->getUrl(
44-
'*/*/markAsRead/',
45-
['_current' => true, 'id' => $row->getId()]
46-
) . '">' . __(
47-
'Mark as Read'
48-
) . '</a>' : '';
48+
$markAsReadHtml = !$row->getIsRead() ? '<a class="action-mark" href="' .
49+
$this->getUrl(
50+
'*/*/markAsRead/',
51+
['_current' => true, 'id' => $row->getId()]
52+
) . '">' . __(
53+
'Mark as Read'
54+
) . '</a>' : '';
4955

5056
$encodedUrl = $this->_urlHelper->getEncodedUrl();
5157
return sprintf(
52-
'%s%s<a class="action-delete" href="%s" onClick="deleteConfirm(\'%s\', this.href); return false;">%s</a>',
58+
'%s%s<a class="action-delete" href="%s" onclick="deleteConfirm(\'%s\', this.href, {data: {}});' .
59+
' return false;">%s</a>',
5360
$readDetailsHtml,
5461
$markAsReadHtml,
5562
$this->getUrl(

app/code/Magento/AdminNotification/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"lib-libxml": "*"
1212
},
1313
"type": "magento2-module",
14-
"version": "100.2.5",
14+
"version": "100.2.6",
1515
"license": [
1616
"OSL-3.0",
1717
"AFL-3.0"

app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/AdditionalCommentTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class AdditionalCommentTest extends \PHPUnit\Framework\TestCase
3636
protected function setUp()
3737
{
3838
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
39-
->setMethods(['getComment', 'getLabel'])
39+
->setMethods(['getComment', 'getLabel', 'getHtmlId', 'getName'])
4040
->disableOriginalConstructor()
4141
->getMock();
4242
$this->contextMock = $this->getMockBuilder(Context::class)

app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/CollectionTimeLabelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class CollectionTimeLabelTest extends \PHPUnit\Framework\TestCase
3737
protected function setUp()
3838
{
3939
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
40-
->setMethods(['getComment'])
40+
->setMethods(['getComment', 'getHtmlId', 'getName'])
4141
->disableOriginalConstructor()
4242
->getMock();
4343
$this->contextMock = $this->getMockBuilder(Context::class)

app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/SubscriptionStatusLabelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function setUp()
5151
->disableOriginalConstructor()
5252
->getMock();
5353
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
54-
->setMethods(['getComment'])
54+
->setMethods(['getComment', 'getHtmlId', 'getName'])
5555
->disableOriginalConstructor()
5656
->getMock();
5757
$this->formMock = $this->getMockBuilder(Form::class)

app/code/Magento/Analytics/Test/Unit/Block/Adminhtml/System/Config/VerticalTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class VerticalTest extends \PHPUnit\Framework\TestCase
3636
protected function setUp()
3737
{
3838
$this->abstractElementMock = $this->getMockBuilder(AbstractElement::class)
39-
->setMethods(['getComment', 'getLabel', 'getHint'])
39+
->setMethods(['getComment', 'getLabel', 'getHint', 'getHtmlId', 'getName'])
4040
->disableOriginalConstructor()
4141
->getMock();
4242
$this->contextMock = $this->getMockBuilder(Context::class)

app/code/Magento/Analytics/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"magento/framework": "101.0.*"
1111
},
1212
"type": "magento2-module",
13-
"version": "100.2.4",
13+
"version": "100.2.5",
1414
"license": [
1515
"OSL-3.0",
1616
"AFL-3.0"

app/code/Magento/Authorizenet/Model/Directpost.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,15 +543,16 @@ public function setResponseData(array $postData)
543543
public function validateResponse()
544544
{
545545
$response = $this->getResponse();
546-
//md5 check
547-
if (!$this->getConfigData('trans_md5')
548-
|| !$this->getConfigData('login')
549-
|| !$response->isValidHash($this->getConfigData('trans_md5'), $this->getConfigData('login'))
546+
$hashConfigKey = !empty($response->getData('x_SHA2_Hash')) ? 'signature_key' : 'trans_md5';
547+
548+
//hash check
549+
if (!$response->isValidHash($this->getConfigData($hashConfigKey), $this->getConfigData('login'))
550550
) {
551551
throw new \Magento\Framework\Exception\LocalizedException(
552552
__('The transaction was declined because the response hash validation failed.')
553553
);
554554
}
555+
555556
return true;
556557
}
557558

app/code/Magento/Authorizenet/Model/Directpost/Request.php

Lines changed: 103 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Authorizenet\Model\Directpost;
88

99
use Magento\Authorizenet\Model\Request as AuthorizenetRequest;
10+
use Magento\Framework\Intl\DateTimeFactory;
1011

1112
/**
1213
* Authorize.net request model for DirectPost model
@@ -18,9 +19,33 @@ class Request extends AuthorizenetRequest
1819
*/
1920
protected $_transKey = null;
2021

22+
/**
23+
* Hexadecimal signature key.
24+
*
25+
* @var string
26+
*/
27+
private $signatureKey = '';
28+
29+
/**
30+
* @var DateTimeFactory
31+
*/
32+
private $dateTimeFactory;
33+
34+
/**
35+
* @param DateTimeFactory $dateTimeFactory
36+
* @param array $data
37+
*/
38+
public function __construct(
39+
DateTimeFactory $dateTimeFactory,
40+
array $data = []
41+
) {
42+
$this->dateTimeFactory = $dateTimeFactory;
43+
parent::__construct($data);
44+
}
45+
2146
/**
2247
* Return merchant transaction key.
23-
* Needed to generate sign.
48+
* Needed to generate MD5 sign.
2449
*
2550
* @return string
2651
*/
@@ -31,7 +56,7 @@ protected function _getTransactionKey()
3156

3257
/**
3358
* Set merchant transaction key.
34-
* Needed to generate sign.
59+
* Needed to generate MD5 sign.
3560
*
3661
* @param string $transKey
3762
* @return $this
@@ -43,7 +68,7 @@ protected function _setTransactionKey($transKey)
4368
}
4469

4570
/**
46-
* Generates the fingerprint for request.
71+
* Generates the MD5 fingerprint for request.
4772
*
4873
* @param string $merchantApiLoginId
4974
* @param string $merchantTransactionKey
@@ -63,7 +88,7 @@ public function generateRequestSign(
6388
) {
6489
return hash_hmac(
6590
"md5",
66-
$merchantApiLoginId . "^" . $fpSequence . "^" . $fpTimestamp . "^" . $amount . "^" . $currencyCode,
91+
$merchantApiLoginId . '^' . $fpSequence . '^' . $fpTimestamp . '^' . $amount . '^' . $currencyCode,
6792
$merchantTransactionKey
6893
);
6994
}
@@ -85,6 +110,7 @@ public function setConstantData(\Magento\Authorizenet\Model\Directpost $paymentM
85110
->setXRelayUrl($paymentMethod->getRelayUrl());
86111

87112
$this->_setTransactionKey($paymentMethod->getConfigData('trans_key'));
113+
$this->setSignatureKey($paymentMethod->getConfigData('signature_key'));
88114
return $this;
89115
}
90116

@@ -168,17 +194,81 @@ public function setDataFromOrder(
168194
*/
169195
public function signRequestData()
170196
{
171-
$fpTimestamp = time();
172-
$hash = $this->generateRequestSign(
173-
$this->getXLogin(),
174-
$this->_getTransactionKey(),
175-
$this->getXAmount(),
176-
$this->getXCurrencyCode(),
177-
$this->getXFpSequence(),
178-
$fpTimestamp
179-
);
197+
$fpDate = $this->dateTimeFactory->create('now', new \DateTimeZone('UTC'));
198+
$fpTimestamp = $fpDate->getTimestamp();
199+
200+
if (!empty($this->getSignatureKey())) {
201+
$hash = $this->generateSha2RequestSign(
202+
$this->getXLogin(),
203+
$this->getSignatureKey(),
204+
$this->getXAmount(),
205+
$this->getXCurrencyCode(),
206+
$this->getXFpSequence(),
207+
$fpTimestamp
208+
);
209+
} else {
210+
$hash = $this->generateRequestSign(
211+
$this->getXLogin(),
212+
$this->_getTransactionKey(),
213+
$this->getXAmount(),
214+
$this->getXCurrencyCode(),
215+
$this->getXFpSequence(),
216+
$fpTimestamp
217+
);
218+
}
219+
180220
$this->setXFpTimestamp($fpTimestamp);
181221
$this->setXFpHash($hash);
222+
182223
return $this;
183224
}
225+
226+
/**
227+
* Generates the SHA2 fingerprint for request.
228+
*
229+
* @param string $merchantApiLoginId
230+
* @param string $merchantSignatureKey
231+
* @param string $amount
232+
* @param string $currencyCode
233+
* @param string $fpSequence An invoice number or random number.
234+
* @param string $fpTimestamp
235+
* @return string The fingerprint.
236+
*/
237+
private function generateSha2RequestSign(
238+
$merchantApiLoginId,
239+
$merchantSignatureKey,
240+
$amount,
241+
$currencyCode,
242+
$fpSequence,
243+
$fpTimestamp
244+
): string {
245+
$message = $merchantApiLoginId . '^' . $fpSequence . '^' . $fpTimestamp . '^' . $amount . '^' . $currencyCode;
246+
247+
return strtoupper(hash_hmac('sha512', $message, pack('H*', $merchantSignatureKey)));
248+
}
249+
250+
/**
251+
* Return merchant hexadecimal signature key.
252+
*
253+
* Needed to generate SHA2 sign.
254+
*
255+
* @return string
256+
*/
257+
private function getSignatureKey(): string
258+
{
259+
return $this->signatureKey;
260+
}
261+
262+
/**
263+
* Set merchant hexadecimal signature key.
264+
*
265+
* Needed to generate SHA2 sign.
266+
*
267+
* @param string $signatureKey
268+
* @return void
269+
*/
270+
private function setSignatureKey(string $signatureKey)
271+
{
272+
$this->signatureKey = $signatureKey;
273+
}
184274
}

0 commit comments

Comments
 (0)