Skip to content

Commit 1089058

Browse files
authored
Security changes from upstream 2.4.7-p1 (#98)
* Security changes from upstream 2.4.7-p1
1 parent 550a092 commit 1089058

File tree

36 files changed

+273
-545
lines changed

36 files changed

+273
-545
lines changed

.github/workflows/coding-standard-baseline.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
name: Coding Standard With Baseline
22
on:
33
pull_request:
4-
branches:
5-
- 2.4-develop
4+
branches: ["**"]
65
permissions:
76
contents: read
87
jobs:

.github/workflows/nx-integration-tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: Integration Tests (Using Nx)
22
run-name: ${{ github.actor }} is running Integration Tests
33
on:
44
pull_request:
5-
branches:
6-
- 2.4-develop
5+
branches: ["**"]
76

87
permissions:
98
contents: write

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: Unit Tests
22
run-name: ${{ github.actor }} is running Unit Tests
33
on:
44
pull_request:
5-
branches:
6-
- 2.4-develop
5+
branches: ["**"]
76

87
permissions:
98
contents: write

app/code/Magento/Catalog/Test/Mftf/Test/AdminApplyTierPriceToProductTest/StoreFrontDeleteProductImagesAssignedDifferentRolesTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<!-- Go to the product page on StoreFront and see the Base image -->
7878
<amOnPage url="{{StorefrontProductPage.url($simpleProductOne.custom_attributes[url_key]$)}}" stepKey="goToProductPage"/>
7979
<waitForPageLoad stepKey="waitForPageLoad"/>
80-
<seeElement selector="{{StorefrontProductMediaSection.imageFile('/adobe-base')}}" stepKey="seeBaseImageOnProductPage"/>
80+
<waitForElementVisible selector="{{StorefrontProductMediaSection.imageFile('/adobe-base')}}" stepKey="seeBaseImageOnProductPage"/>
8181
<!-- Go to the category page and see the Small image -->
8282
<amOnPage url="{{StorefrontCategoryPage.url($testCategory.custom_attributes[url_key]$)}}" stepKey="goToCategoryPage"/>
8383
<waitForPageLoad stepKey="waitForPageLoadingToFinish"/>

app/code/Magento/Customer/Model/Plugin/UpdateCustomer.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,19 @@ public function beforeSave(
5252
CustomerInterface $customer,
5353
?string $passwordHash = null
5454
): array {
55-
$customerSessionId = $this->userContext->getUserType() === $this->userContext::USER_TYPE_CUSTOMER ?
56-
(int)$this->userContext->getUserId() : 0;
55+
$userType = $this->userContext->getUserType();
56+
$customerSessionId = (int)$this->userContext->getUserId();
5757
$customerId = (int)$this->request->getParam('customerId');
5858
$bodyParams = $this->request->getBodyParams();
59-
if (!isset($bodyParams['customer']['Id']) && $customerId) {
60-
if ($customerId === $customerSessionId || $customerSessionId === 0) {
61-
$customer = $this->getUpdatedCustomer($customerRepository->getById($customerId), $customer);
62-
}
59+
60+
if ($userType === UserContextInterface::USER_TYPE_CUSTOMER &&
61+
!isset($bodyParams['customer']['Id']) &&
62+
$customerId &&
63+
$customerId === $customerSessionId
64+
) {
65+
$customer = $this->getUpdatedCustomer($customerRepository->getById($customerId), $customer);
66+
} elseif ($userType === UserContextInterface::USER_TYPE_ADMIN && $customerId) {
67+
$customer = $this->getUpdatedCustomer($customerRepository->getById($customerId), $customer);
6368
}
6469

6570
return [$customer, $passwordHash];

app/code/Magento/Customer/Plugin/Webapi/Controller/Rest/ValidateCustomerData.php

Lines changed: 0 additions & 56 deletions
This file was deleted.

app/code/Magento/Customer/Test/Unit/Plugin/Webapi/Controller/Rest/ValidateCustomerDataTest.php

Lines changed: 0 additions & 123 deletions
This file was deleted.

app/code/Magento/Customer/etc/webapi_rest/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
</argument>
3232
</arguments>
3333
</type>
34-
<type name="Magento\Webapi\Controller\Rest\ParamsOverrider">
35-
<plugin name="validateCustomerData" type="Magento\Customer\Plugin\Webapi\Controller\Rest\ValidateCustomerData" sortOrder="1" disabled="false" />
36-
</type>
3734
<preference for="Magento\Customer\Api\AccountManagementInterface"
3835
type="Magento\Customer\Model\AccountManagementApi" />
3936
</config>

app/code/Magento/Quote/Model/BillingAddressManagement.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ public function assign($cartId, AddressInterface $address, $useForShipping = fal
7777
{
7878
/** @var \Magento\Quote\Model\Quote $quote */
7979
$quote = $this->quoteRepository->getActive($cartId);
80-
81-
// validate the address
82-
$this->addressValidator->validateWithExistingAddress($quote, $address);
83-
8480
$address->setCustomerId($quote->getCustomerId());
8581
$quote->removeAddress($quote->getBillingAddress()->getId());
8682
$quote->setBillingAddress($address);

app/code/Magento/Quote/Model/QuoteAddressValidator.php

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -121,27 +121,6 @@ public function validate(AddressInterface $addressData): bool
121121
return true;
122122
}
123123

124-
/**
125-
* Validate Quest Address for guest user
126-
*
127-
* @param AddressInterface $address
128-
* @param CartInterface $cart
129-
* @return void
130-
* @throws NoSuchEntityException
131-
*/
132-
private function doValidateForGuestQuoteAddress(AddressInterface $address, CartInterface $cart): void
133-
{
134-
//validate guest cart address
135-
if ($address->getId() !== null) {
136-
$old = $cart->getAddressById($address->getId());
137-
if ($old === false) {
138-
throw new NoSuchEntityException(
139-
__('Invalid quote address id %1', $address->getId())
140-
);
141-
}
142-
}
143-
}
144-
145124
/**
146125
* Validate address to be used for cart.
147126
*
@@ -153,9 +132,6 @@ private function doValidateForGuestQuoteAddress(AddressInterface $address, CartI
153132
*/
154133
public function validateForCart(CartInterface $cart, AddressInterface $address): void
155134
{
156-
if ($cart->getCustomerIsGuest()) {
157-
$this->doValidateForGuestQuoteAddress($address, $cart);
158-
}
159135
$this->doValidate($address, $cart->getCustomerIsGuest() ? null : (int) $cart->getCustomer()->getId());
160136
}
161137

@@ -171,8 +147,8 @@ public function validateWithExistingAddress(CartInterface $cart, AddressInterfac
171147
{
172148
// check if address belongs to quote.
173149
if ($address->getId() !== null) {
174-
$old = $cart->getAddressesCollection()->getItemById($address->getId());
175-
if ($old === null) {
150+
$old = $cart->getAddressById($address->getId());
151+
if (empty($old)) {
176152
throw new NoSuchEntityException(
177153
__('Invalid quote address id %1', $address->getId())
178154
);

0 commit comments

Comments
 (0)