Skip to content

Commit 60b953d

Browse files
Merge branch '2.4-develop' into add-logic-check-imports-less-for-enabled-modules
2 parents f8fd657 + 3056e9c commit 60b953d

File tree

487 files changed

+12769
-2410
lines changed

Some content is hidden

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

487 files changed

+12769
-2410
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ trim_trailing_whitespace = false
1414
[*.{yml,yaml,json}]
1515
indent_size = 2
1616

17-
[{composer, auth}.json]
17+
[{composer,auth}.json]
1818
indent_size = 4
1919

2020
[db_schema_whitelist.json]

app/code/Magento/AdminAnalytics/ViewModel/Metadata.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
namespace Magento\AdminAnalytics\ViewModel;
1010

1111
use Magento\Config\Model\Config\Backend\Admin\Custom;
12+
use Magento\Csp\Helper\CspNonceProvider;
1213
use Magento\Framework\App\Config\ScopeConfigInterface;
14+
use Magento\Framework\App\ObjectManager;
1315
use Magento\Framework\App\ProductMetadataInterface;
1416
use Magento\Backend\Model\Auth\Session;
1517
use Magento\Framework\App\State;
@@ -21,6 +23,11 @@
2123
*/
2224
class Metadata implements ArgumentInterface
2325
{
26+
/**
27+
* @var string
28+
*/
29+
private $nonce;
30+
2431
/**
2532
* @var State
2633
*/
@@ -41,22 +48,33 @@ class Metadata implements ArgumentInterface
4148
*/
4249
private $config;
4350

51+
/**
52+
* @var CspNonceProvider
53+
*/
54+
private $nonceProvider;
55+
4456
/**
4557
* @param ProductMetadataInterface $productMetadata
4658
* @param Session $authSession
4759
* @param State $appState
4860
* @param ScopeConfigInterface $config
61+
* @param CspNonceProvider|null $nonceProvider
4962
*/
5063
public function __construct(
5164
ProductMetadataInterface $productMetadata,
5265
Session $authSession,
5366
State $appState,
54-
ScopeConfigInterface $config
67+
ScopeConfigInterface $config,
68+
CspNonceProvider $nonceProvider = null
5569
) {
5670
$this->productMetadata = $productMetadata;
5771
$this->authSession = $authSession;
5872
$this->appState = $appState;
5973
$this->config = $config;
74+
75+
$this->nonceProvider = $nonceProvider ?: ObjectManager::getInstance()->get(CspNonceProvider::class);
76+
77+
$this->nonce = $this->nonceProvider->generateNonce();
6078
}
6179

6280
/**
@@ -156,4 +174,14 @@ public function getCurrentUserRoleName(): string
156174
{
157175
return $this->authSession->getUser()->getRole()->getRoleName();
158176
}
177+
178+
/**
179+
* Get a random nonce for each request.
180+
*
181+
* @return string
182+
*/
183+
public function getNonce(): string
184+
{
185+
return $this->nonce;
186+
}
159187
}

app/code/Magento/AdminAnalytics/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"magento/module-config": "*",
1212
"magento/module-store": "*",
1313
"magento/module-ui": "*",
14-
"magento/module-release-notification": "*"
14+
"magento/module-release-notification": "*",
15+
"magento/module-csp": "*"
1516
},
1617
"type": "magento2-module",
1718
"license": [

app/code/Magento/AdminAnalytics/view/adminhtml/templates/tracking.phtml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
/**
88
* @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
9+
* @var \Magento\Framework\Escaper $escaper
910
*/
1011
?>
1112

@@ -22,18 +23,25 @@
2223
<?php
2324
/** @var \Magento\AdminAnalytics\ViewModel\Metadata $metadata */
2425
$metadata = $block->getMetadata();
26+
$nonce = $escaper->escapeJs($metadata->getNonce());
2527
$scriptString = '
2628
var adminAnalyticsMetadata = {
27-
"secure_base_url": "' . $block->escapeJs($metadata->getSecureBaseUrlForScope()) . '",
28-
"version": "' . $block->escapeJs($metadata->getMagentoVersion()) . '",
29-
"product_edition": "' . $block->escapeJs($metadata->getProductEdition()) . '",
30-
"user": "' . $block->escapeJs($metadata->getCurrentUser()) . '",
31-
"mode": "' . $block->escapeJs($metadata->getMode()) . '",
32-
"store_name_default": "' . $block->escapeJs($metadata->getStoreNameForScope()) . '",
33-
"admin_user_created": "' . $block->escapeJs($metadata->getCurrentUserCreatedDate()) . '",
34-
"admin_user_logdate": "' . $block->escapeJs($metadata->getCurrentUserLogDate()) . '",
35-
"admin_user_role_name": "' . $block->escapeJs($metadata->getCurrentUserRoleName()) . '"
29+
"secure_base_url": "' . $escaper->escapeJs($metadata->getSecureBaseUrlForScope()) . '",
30+
"version": "' . $escaper->escapeJs($metadata->getMagentoVersion()) . '",
31+
"product_edition": "' . $escaper->escapeJs($metadata->getProductEdition()) . '",
32+
"user": "' . $escaper->escapeJs($metadata->getCurrentUser()) . '",
33+
"mode": "' . $escaper->escapeJs($metadata->getMode()) . '",
34+
"store_name_default": "' . $escaper->escapeJs($metadata->getStoreNameForScope()) . '",
35+
"admin_user_created": "' . $escaper->escapeJs($metadata->getCurrentUserCreatedDate()) . '",
36+
"admin_user_logdate": "' . $escaper->escapeJs($metadata->getCurrentUserLogDate()) . '",
37+
"admin_user_role_name": "' . $escaper->escapeJs($metadata->getCurrentUserRoleName()) . '"
3638
};
39+
40+
var digitalData = {
41+
"nonce": "' . $nonce . '"
42+
};
43+
44+
var cspNonce = "' . $nonce . '";
3745
';
3846
?>
3947
<?= /* @noEscape */ $secureRenderer->renderTag('script', [], $scriptString, false); ?>

app/code/Magento/AdvancedSearch/Model/DataProvider/AutocompleteSuggestions.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
<?php
2-
/************************************************************************
3-
*
2+
/**
43
* Copyright 2023 Adobe
54
* All Rights Reserved.
6-
*
7-
* NOTICE: All information contained herein is, and remains
8-
* the property of Adobe and its suppliers, if any. The intellectual
9-
* and technical concepts contained herein are proprietary to Adobe
10-
* and its suppliers and are protected by all applicable intellectual
11-
* property laws, including trade secret and copyright laws.
12-
* Dissemination of this information or reproduction of this material
13-
* is strictly forbidden unless prior written permission is obtained
14-
* from Adobe.
15-
* ***********************************************************************
165
*/
176
declare(strict_types=1);
187

app/code/Magento/AdvancedSearch/Test/Unit/Model/DataProvider/AutocompleteSuggestionsTest.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
<?php
2-
/************************************************************************
3-
*
2+
/**
43
* Copyright 2023 Adobe
54
* All Rights Reserved.
6-
*
7-
* NOTICE: All information contained herein is, and remains
8-
* the property of Adobe and its suppliers, if any. The intellectual
9-
* and technical concepts contained herein are proprietary to Adobe
10-
* and its suppliers and are protected by all applicable intellectual
11-
* property laws, including trade secret and copyright laws.
12-
* Dissemination of this information or reproduction of this material
13-
* is strictly forbidden unless prior written permission is obtained
14-
* from Adobe.
15-
* ***********************************************************************
165
*/
176
declare(strict_types=1);
187

app/code/Magento/Backend/Console/Command/MaintenanceStatusCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5353
{
5454
$output->writeln(
5555
'<info>Status: maintenance mode is ' .
56-
($this->maintenanceMode->isOn() ? 'active' : 'not active') . '</info>'
56+
($this->maintenanceMode->isOn() ? 'enabled' : 'disabled') . '</info>'
5757
);
5858
$addressInfo = $this->maintenanceMode->getAddressInfo();
5959
$addresses = implode(' ', $addressInfo);

app/code/Magento/Backend/Model/Validator/IpValidator.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
56
*/
7+
68
namespace Magento\Backend\Model\Validator;
79

10+
use Magento\Framework\App\Utility\IPAddress;
11+
812
/**
913
* Class to validate list of IPs for maintenance commands
1014
*/
@@ -25,12 +29,22 @@ class IpValidator
2529
*/
2630
private $invalidIps;
2731

32+
/**
33+
* @param IPAddress $ipAddress
34+
*/
35+
public function __construct(
36+
private readonly IPAddress $ipAddress,
37+
) {
38+
}
39+
2840
/**
2941
* Validates list of ips
3042
*
3143
* @param string[] $ips
3244
* @param bool $noneAllowed
45+
*
3346
* @return string[]
47+
*
3448
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
3549
*/
3650
public function validateIps(array $ips, $noneAllowed)
@@ -55,22 +69,26 @@ public function validateIps(array $ips, $noneAllowed)
5569
$messages[] = "Invalid IP $invalidIp";
5670
}
5771
}
72+
5873
return $messages;
5974
}
6075

6176
/**
6277
* Filter ips into 'none', valid and invalid ips
6378
*
6479
* @param string[] $ips
80+
*
6581
* @return void
6682
*/
6783
private function filterIps(array $ips)
6884
{
6985
foreach ($ips as $ip) {
70-
if (filter_var($ip, FILTER_VALIDATE_IP)) {
71-
$this->validIps[] = $ip;
72-
} elseif ($ip == 'none') {
86+
if ($ip === 'none') {
7387
$this->none[] = $ip;
88+
} elseif ($this->ipAddress->isValidAddress($ip)) {
89+
$this->validIps[] = $ip;
90+
} elseif ($this->ipAddress->isValidRange($ip)) {
91+
$this->validIps[] = $ip;
7492
} else {
7593
$this->invalidIps[] = $ip;
7694
}

app/code/Magento/Backend/Test/Unit/Console/Command/MaintenanceStatusCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,20 @@ public function executeDataProvider()
5353
return [
5454
[
5555
[true, ['127.0.0.1', '127.0.0.2']],
56-
'Status: maintenance mode is active' . PHP_EOL .
56+
'Status: maintenance mode is enabled' . PHP_EOL .
5757
'List of exempt IP-addresses: 127.0.0.1 127.0.0.2' . PHP_EOL
5858
],
5959
[
6060
[true, []],
61-
'Status: maintenance mode is active' . PHP_EOL . 'List of exempt IP-addresses: none' . PHP_EOL
61+
'Status: maintenance mode is enabled' . PHP_EOL . 'List of exempt IP-addresses: none' . PHP_EOL
6262
],
6363
[
6464
[false, []],
65-
'Status: maintenance mode is not active' . PHP_EOL . 'List of exempt IP-addresses: none' . PHP_EOL
65+
'Status: maintenance mode is disabled' . PHP_EOL . 'List of exempt IP-addresses: none' . PHP_EOL
6666
],
6767
[
6868
[false, ['127.0.0.1', '127.0.0.2']],
69-
'Status: maintenance mode is not active' . PHP_EOL .
69+
'Status: maintenance mode is disabled' . PHP_EOL .
7070
'List of exempt IP-addresses: 127.0.0.1 127.0.0.2' . PHP_EOL
7171
],
7272
];

app/code/Magento/Backend/Test/Unit/Model/Validator/IpValidatorTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\Backend\Test\Unit\Model\Validator;
99

1010
use Magento\Backend\Model\Validator\IpValidator;
11+
use Magento\Framework\App\Utility\IPAddress;
1112
use PHPUnit\Framework\TestCase;
1213

1314
/**
@@ -25,7 +26,9 @@ class IpValidatorTest extends TestCase
2526
*/
2627
protected function setUp(): void
2728
{
28-
$this->ipValidator = new IpValidator();
29+
$this->ipValidator = new IpValidator(
30+
new IPAddress()
31+
);
2932
}
3033

3134
/**
@@ -45,6 +48,7 @@ public function validateIpsNoneAllowedDataProvider(): array
4548
{
4649
return [
4750
[['127.0.0.1', '127.0.0.2'], []],
51+
[['127.0.0.0/24'], []],
4852
[['none'], []],
4953
[['none', '127.0.0.1'], ["Multiple values are not allowed when 'none' is used"]],
5054
[['127.0.0.1', 'none'], ["Multiple values are not allowed when 'none' is used"]],
@@ -72,6 +76,7 @@ public function validateIpsNoneNotAllowedDataProvider()
7276
{
7377
return [
7478
[['127.0.0.1', '127.0.0.2'], []],
79+
[['127.0.0.0/24'], []],
7580
[['none'], ["'none' is not allowed"]],
7681
[['none', '127.0.0.1'], ["'none' is not allowed"]],
7782
[['127.0.0.1', 'none'], ["'none' is not allowed"]],

0 commit comments

Comments
 (0)