Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save barryvdh/8bf1ba88e4a7bfe3ad007de8dbf2600c to your computer and use it in GitHub Desktop.
Save barryvdh/8bf1ba88e4a7bfe3ad007de8dbf2600c to your computer and use it in GitHub Desktop.

Revisions

  1. barryvdh revised this gist Mar 29, 2019. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion readme.md
    Original file line number Diff line number Diff line change
    @@ -4,4 +4,6 @@

    3. Remove existing packages: `rm -rf vendor/magento/module-catalog vendor/magento/framework`

    4. Run `composer install` to re-install and apply patches.
    4. Run `composer install` to re-install and apply patches.

    See https://magento.com/security/patches/magento-2.3.1-2.2.8-and-2.1.17-security-update and https://www.ambionics.io/blog/magento-sqli for more information.
  2. barryvdh revised this gist Mar 29, 2019. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    1. Require composer-patches: `composer require cweagans/composer-patches`

    2. Add the `patches` section to your composer.json extra field.

    3. Remove existing packages: `rm -rf vendor/magento/module-catalog vendor/magento/framework`

    4. Run `composer install` to re-install and apply patches.
  3. barryvdh revised this gist Mar 29, 2019. No changes.
  4. barryvdh revised this gist Mar 29, 2019. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion composer.json
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,10 @@
    "extra": {
    "patches": {
    "magento/framework": {
    "PRODSECBUG-2198": "https://gist.github.com/barryvdh/8bf1ba88e4a7bfe3ad007de8dbf2600c/raw/6971b050732dd690348d1c10f51d41e72fb2f265/PRODSECBUG-2198-2.2-CE-2019-03-25-08-43-16-framework.patch"
    "PRODSECBUG-2198": "https://gist.github.com/barryvdh/8bf1ba88e4a7bfe3ad007de8dbf2600c/raw/e8d7e0072990cafbcba0e847b20fce62d8793938/PRODSECBUG-2198-2.2-CE-2019-03-25-08-43-16-framework.patch"
    },
    "magento/module-catalog": {
    "PRODSECBUG-2198": "https://gist.github.com/barryvdh/8bf1ba88e4a7bfe3ad007de8dbf2600c/raw/e8d7e0072990cafbcba0e847b20fce62d8793938/PRODSECBUG-2198-2.2-CE-2019-03-25-08-43-16-module-catalog.patch"
    }
    }
    }
  5. barryvdh revised this gist Mar 29, 2019. 2 changed files with 91 additions and 0 deletions.
    79 changes: 79 additions & 0 deletions PRODSECBUG-2198-2.2-CE-2019-03-25-08-43-16-module-catalog.patch
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,79 @@
    diff --git a/Model/Product/ProductFrontendAction/Synchronizer.php b/Model/Product/ProductFrontendAction/Synchronizer.php
    index 7a1926c..331c667 100644
    --- a/Model/Product/ProductFrontendAction/Synchronizer.php
    +++ b/Model/Product/ProductFrontendAction/Synchronizer.php
    @@ -138,7 +138,9 @@ class Synchronizer
    $productIds = [];

    foreach ($actions as $action) {
    - $productIds[] = $action['product_id'];
    + if (isset($action['product_id']) && is_int($action['product_id'])) {
    + $productIds[] = $action['product_id'];
    + }
    }

    return $productIds;
    @@ -159,33 +161,37 @@ class Synchronizer
    $customerId = $this->session->getCustomerId();
    $visitorId = $this->visitor->getId();
    $collection = $this->getActionsByType($typeId);
    - $collection->addFieldToFilter('product_id', $this->getProductIdsByActions($productsData));
    -
    - /**
    - * Note that collection is also filtered by visitor id and customer id
    - * This collection shouldnt be flushed when visitor has products and then login
    - * It can remove only products for visitor, or only products for customer
    - *
    - * ['product_id' => 'added_at']
    - * @var ProductFrontendActionInterface $item
    - */
    - foreach ($collection as $item) {
    - $this->entityManager->delete($item);
    - }
    -
    - foreach ($productsData as $productId => $productData) {
    - /** @var ProductFrontendActionInterface $action */
    - $action = $this->productFrontendActionFactory->create([
    - 'data' => [
    - 'visitor_id' => $customerId ? null : $visitorId,
    - 'customer_id' => $this->session->getCustomerId(),
    - 'added_at' => $productData['added_at'],
    - 'product_id' => $productId,
    - 'type_id' => $typeId
    - ]
    - ]);
    -
    - $this->entityManager->save($action);
    + $productIds = $this->getProductIdsByActions($productsData);
    +
    + if ($productIds) {
    + $collection->addFieldToFilter('product_id', $productIds);
    +
    + /**
    + * Note that collection is also filtered by visitor id and customer id
    + * This collection shouldn't be flushed when visitor has products and then login
    + * It can remove only products for visitor, or only products for customer
    + *
    + * ['product_id' => 'added_at']
    + * @var ProductFrontendActionInterface $item
    + */
    + foreach ($collection as $item) {
    + $this->entityManager->delete($item);
    + }
    +
    + foreach ($productsData as $productId => $productData) {
    + /** @var ProductFrontendActionInterface $action */
    + $action = $this->productFrontendActionFactory->create([
    + 'data' => [
    + 'visitor_id' => $customerId ? null : $visitorId,
    + 'customer_id' => $this->session->getCustomerId(),
    + 'added_at' => $productData['added_at'],
    + 'product_id' => $productId,
    + 'type_id' => $typeId
    + ]
    + ]);
    +
    + $this->entityManager->save($action);
    + }
    }
    }
    12 changes: 12 additions & 0 deletions composer.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    {
    "require": {
    "cweagans/composer-patches": "^1"
    },
    "extra": {
    "patches": {
    "magento/framework": {
    "PRODSECBUG-2198": "https://gist.github.com/barryvdh/8bf1ba88e4a7bfe3ad007de8dbf2600c/raw/6971b050732dd690348d1c10f51d41e72fb2f265/PRODSECBUG-2198-2.2-CE-2019-03-25-08-43-16-framework.patch"
    }
    }
    }
    }
  6. @peterjaap peterjaap revised this gist Mar 27, 2019. No changes.
  7. @peterjaap peterjaap revised this gist Mar 27, 2019. No changes.
  8. @peterjaap peterjaap created this gist Mar 27, 2019.
    16 changes: 16 additions & 0 deletions PRODSECBUG-2198-2.2-CE-2019-03-25-08-43-16-framework.patch
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    diff --git a/DB/Adapter/Pdo/Mysql.php b/DB/Adapter/Pdo/Mysql.php
    index 1449d6d..38085a3 100644
    --- a/DB/Adapter/Pdo/Mysql.php
    +++ b/DB/Adapter/Pdo/Mysql.php
    @@ -2904,7 +2904,7 @@ class Mysql extends \Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface
    if (isset($condition['to'])) {
    $query .= empty($query) ? '' : ' AND ';
    $to = $this->_prepareSqlDateCondition($condition, 'to');
    - $query = $this->_prepareQuotedSqlCondition($query . $conditionKeyMap['to'], $to, $fieldName);
    + $query = $query . $this->_prepareQuotedSqlCondition($conditionKeyMap['to'], $to, $fieldName);
    }
    } elseif (array_key_exists($key, $conditionKeyMap)) {
    $value = $condition[$key];
    --
    2.7.4