{"action":"created","comment":{"url":"https://api.github.com/repos/magento-engcom/php-7.2-support/pulls/comments/193246840","pull_request_review_id":126182698,"id":193246840,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5MzI0Njg0MA==","diff_hunk":"@@ -0,0 +1,95 @@\n+<?php\n+/**\n+ * Copyright © Magento, Inc. All rights reserved.\n+ * See COPYING.txt for license details.\n+ */\n+\n+declare(strict_types=1);\n+\n+namespace Magento\\Sales\\Console\\Command;\n+\n+use Symfony\\Component\\Console\\Input\\InputInterface;\n+use Symfony\\Component\\Console\\Output\\OutputInterface;\n+use Symfony\\Component\\Console\\Command\\Command;\n+use Magento\\Framework\\Console\\Cli;\n+use Magento\\Framework\\Encryption\\Encryptor;\n+\n+/**\n+ * Command for updated encrypted credit card data to the latest cipher\n+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)\n+ */\n+class PaymentUpdateEncryptCommand extends Command\n+{\n+    /** Command name */\n+    const NAME = 'encryption:update:payment';\n+    const LEGACY_PATTERN = '^[[:digit:]]+:[^%s]:.*$';\n+\n+    /**\n+     * @var \\Magento\\Framework\\Encryption\\Encryptor\n+     */\n+    private $encryptor;\n+\n+    /**\n+     * @var \\Magento\\Sales\\Model\\ResourceModel\\Order\\Payment\n+     */\n+    private $paymentResource;\n+\n+    /**\n+     * @param \\Magento\\Framework\\Encryption\\Encryptor $encryptor\n+     * @param \\Magento\\Sales\\Model\\ResourceModel\\Order\\Payment $paymentResource\n+     */\n+    public function __construct(\n+        \\Magento\\Framework\\Encryption\\Encryptor $encryptor,\n+        \\Magento\\Sales\\Model\\ResourceModel\\Order\\Payment $paymentResource\n+    ) {\n+        $this->encryptor = $encryptor;\n+        $this->paymentResource = $paymentResource;\n+        parent::__construct();\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    protected function configure()\n+    {\n+        $this->setName(self::NAME)\n+            ->setDescription(\n+                'Re-encrypts encrypted credit card data with latest encryption cipher.'\n+            );\n+        parent::configure();\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    protected function execute(InputInterface $input, OutputInterface $output)\n+    {\n+        $connection = $this->paymentResource->getConnection();\n+        $table = $this->paymentResource->getTable('sales_order_payment');\n+        $select = $connection->select()->from($table, ['entity_id', 'cc_number_enc'])\n+            ->where(\n+                'cc_number_enc REGEXP ?',\n+                sprintf(self::LEGACY_PATTERN, Encryptor::CIPHER_LATEST)\n+            )->limit(1000);\n+\n+        while ($attributeValues = $connection->fetchPairs($select)) {\n+            $connection->beginTransaction();","path":"app/code/Magento/Sales/Console/Command/PaymentUpdateEncryptCommand.php","position":76,"original_position":76,"commit_id":"6d9495128d767ce79e944d726e9f9943c7941cbc","original_commit_id":"6d9495128d767ce79e944d726e9f9943c7941cbc","user":{"login":"buskamuza","id":1749703,"node_id":"MDQ6VXNlcjE3NDk3MDM=","avatar_url":"https://avatars3.githubusercontent.com/u/1749703?v=4","gravatar_id":"","url":"https://api.github.com/users/buskamuza","html_url":"https://github.com/buskamuza","followers_url":"https://api.github.com/users/buskamuza/followers","following_url":"https://api.github.com/users/buskamuza/following{/other_user}","gists_url":"https://api.github.com/users/buskamuza/gists{/gist_id}","starred_url":"https://api.github.com/users/buskamuza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/buskamuza/subscriptions","organizations_url":"https://api.github.com/users/buskamuza/orgs","repos_url":"https://api.github.com/users/buskamuza/repos","events_url":"https://api.github.com/users/buskamuza/events{/privacy}","received_events_url":"https://api.github.com/users/buskamuza/received_events","type":"User","site_admin":false},"body":"As the command can be run by somebody on a live store, transactions may cause performance issues/locks.\r\nI propose to remove the transaction, and add another condition to the update, so that we guaranteed do not replace data that a user could enter if it happens between we fetch the data and update it. Something like this:\r\nreplace `['entity_id = ?' => (int)$valueId]` with `['entity_id = ?' => (int)$valueId, 'and cc_number_enc = ?' => $value]`","created_at":"2018-06-05T22:54:49Z","updated_at":"2018-06-05T22:54:49Z","html_url":"https://github.com/magento-engcom/php-7.2-support/pull/135#discussion_r193246840","pull_request_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/pulls/135","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/magento-engcom/php-7.2-support/pulls/comments/193246840"},"html":{"href":"https://github.com/magento-engcom/php-7.2-support/pull/135#discussion_r193246840"},"pull_request":{"href":"https://api.github.com/repos/magento-engcom/php-7.2-support/pulls/135"}}},"pull_request":{"url":"https://api.github.com/repos/magento-engcom/php-7.2-support/pulls/135","id":186245056,"node_id":"MDExOlB1bGxSZXF1ZXN0MTg2MjQ1MDU2","html_url":"https://github.com/magento-engcom/php-7.2-support/pull/135","diff_url":"https://github.com/magento-engcom/php-7.2-support/pull/135.diff","patch_url":"https://github.com/magento-engcom/php-7.2-support/pull/135.patch","issue_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/issues/135","number":135,"state":"open","locked":false,"title":"Sodium Encryption","user":{"login":"pmclain","id":12674247,"node_id":"MDQ6VXNlcjEyNjc0MjQ3","avatar_url":"https://avatars1.githubusercontent.com/u/12674247?v=4","gravatar_id":"","url":"https://api.github.com/users/pmclain","html_url":"https://github.com/pmclain","followers_url":"https://api.github.com/users/pmclain/followers","following_url":"https://api.github.com/users/pmclain/following{/other_user}","gists_url":"https://api.github.com/users/pmclain/gists{/gist_id}","starred_url":"https://api.github.com/users/pmclain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmclain/subscriptions","organizations_url":"https://api.github.com/users/pmclain/orgs","repos_url":"https://api.github.com/users/pmclain/repos","events_url":"https://api.github.com/users/pmclain/events{/privacy}","received_events_url":"https://api.github.com/users/pmclain/received_events","type":"User","site_admin":false},"body":"### Description\r\nMoves all new encryption to the sodium library. Supports decryption using legacy mcrypt ciphers. This PR ensures new values are (en-de)crypted with sodium and legacy values can be decrypted using mcrypt. \r\n\r\nA data patch updating configuration values with a `backend_model` of `\\Magento\\Config\\Model\\Config\\Backend\\Encrypted::class` and the contents of `sales_order_payment.cc_number_enc`. This mirrors the re-encryption behavior when change the key in `Magento\\EncryptionKey\\Model\\ResourceModel\\Key\\Change`\r\n\r\n### Fixed Issues (if relevant)\r\n1. magento-engcom/php-7.2-support#124 \r\n2. magento-engcom/php-7.2-support#128 - `\\Magento\\Framework\\Encryption\\Crypt` is deprecated and replaced with `\\Magento\\Framework\\Encryption\\Adapter\\Mcrypt`. An exception is thrown when `Mcrypt::encrypt` is called.\r\n3. magento-engcom/php-7.2-support#129\r\n\r\n### Manual testing scenarios\r\n1. Install any Magento version using mcrypt\r\n2. Configure Braintree Payment Gateway in admin panel\r\n3. Checkout using Braintree Payment\r\n4. Expect success\r\n5. Upgrade installation to libsodium\r\n6. Checkout using Braintree Payment\r\n7. Expect success - the existing mcrypt gateway credentials are decrypted to allow checkout. Values are **not** re-encrypted with sodium.\r\n8. Update Braintree encrypted values in admin panel to trigger sodium encryption\r\n9. Checkout using Braintree Payment\r\n10. Expect success\r\n\r\n### Contribution checklist\r\n - [ ] Pull request has a meaningful description of its purpose\r\n - [ ] All commits are accompanied by meaningful commit messages\r\n - [ ] All new or changed code is covered with unit/integration tests (if applicable)\r\n - [ ] All automated tests passed successfully (all builds on Travis CI are green)\r\n","created_at":"2018-05-07T02:58:24Z","updated_at":"2018-06-05T22:54:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"93bdaa59bc37b7fddbaa5b3071ea187252085694","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/pulls/135/commits","review_comments_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/pulls/135/comments","review_comment_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/pulls/comments{/number}","comments_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/issues/135/comments","statuses_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/statuses/6d9495128d767ce79e944d726e9f9943c7941cbc","head":{"label":"pmclain:2.3.1/libsodium","ref":"2.3.1/libsodium","sha":"6d9495128d767ce79e944d726e9f9943c7941cbc","user":{"login":"pmclain","id":12674247,"node_id":"MDQ6VXNlcjEyNjc0MjQ3","avatar_url":"https://avatars1.githubusercontent.com/u/12674247?v=4","gravatar_id":"","url":"https://api.github.com/users/pmclain","html_url":"https://github.com/pmclain","followers_url":"https://api.github.com/users/pmclain/followers","following_url":"https://api.github.com/users/pmclain/following{/other_user}","gists_url":"https://api.github.com/users/pmclain/gists{/gist_id}","starred_url":"https://api.github.com/users/pmclain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmclain/subscriptions","organizations_url":"https://api.github.com/users/pmclain/orgs","repos_url":"https://api.github.com/users/pmclain/repos","events_url":"https://api.github.com/users/pmclain/events{/privacy}","received_events_url":"https://api.github.com/users/pmclain/received_events","type":"User","site_admin":false},"repo":{"id":118012218,"node_id":"MDEwOlJlcG9zaXRvcnkxMTgwMTIyMTg=","name":"php-7.2-support","full_name":"pmclain/php-7.2-support","owner":{"login":"pmclain","id":12674247,"node_id":"MDQ6VXNlcjEyNjc0MjQ3","avatar_url":"https://avatars1.githubusercontent.com/u/12674247?v=4","gravatar_id":"","url":"https://api.github.com/users/pmclain","html_url":"https://github.com/pmclain","followers_url":"https://api.github.com/users/pmclain/followers","following_url":"https://api.github.com/users/pmclain/following{/other_user}","gists_url":"https://api.github.com/users/pmclain/gists{/gist_id}","starred_url":"https://api.github.com/users/pmclain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmclain/subscriptions","organizations_url":"https://api.github.com/users/pmclain/orgs","repos_url":"https://api.github.com/users/pmclain/repos","events_url":"https://api.github.com/users/pmclain/events{/privacy}","received_events_url":"https://api.github.com/users/pmclain/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pmclain/php-7.2-support","description":"Repository for implementing support of php-7.2 support in Magento","fork":true,"url":"https://api.github.com/repos/pmclain/php-7.2-support","forks_url":"https://api.github.com/repos/pmclain/php-7.2-support/forks","keys_url":"https://api.github.com/repos/pmclain/php-7.2-support/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pmclain/php-7.2-support/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pmclain/php-7.2-support/teams","hooks_url":"https://api.github.com/repos/pmclain/php-7.2-support/hooks","issue_events_url":"https://api.github.com/repos/pmclain/php-7.2-support/issues/events{/number}","events_url":"https://api.github.com/repos/pmclain/php-7.2-support/events","assignees_url":"https://api.github.com/repos/pmclain/php-7.2-support/assignees{/user}","branches_url":"https://api.github.com/repos/pmclain/php-7.2-support/branches{/branch}","tags_url":"https://api.github.com/repos/pmclain/php-7.2-support/tags","blobs_url":"https://api.github.com/repos/pmclain/php-7.2-support/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pmclain/php-7.2-support/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pmclain/php-7.2-support/git/refs{/sha}","trees_url":"https://api.github.com/repos/pmclain/php-7.2-support/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pmclain/php-7.2-support/statuses/{sha}","languages_url":"https://api.github.com/repos/pmclain/php-7.2-support/languages","stargazers_url":"https://api.github.com/repos/pmclain/php-7.2-support/stargazers","contributors_url":"https://api.github.com/repos/pmclain/php-7.2-support/contributors","subscribers_url":"https://api.github.com/repos/pmclain/php-7.2-support/subscribers","subscription_url":"https://api.github.com/repos/pmclain/php-7.2-support/subscription","commits_url":"https://api.github.com/repos/pmclain/php-7.2-support/commits{/sha}","git_commits_url":"https://api.github.com/repos/pmclain/php-7.2-support/git/commits{/sha}","comments_url":"https://api.github.com/repos/pmclain/php-7.2-support/comments{/number}","issue_comment_url":"https://api.github.com/repos/pmclain/php-7.2-support/issues/comments{/number}","contents_url":"https://api.github.com/repos/pmclain/php-7.2-support/contents/{+path}","compare_url":"https://api.github.com/repos/pmclain/php-7.2-support/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pmclain/php-7.2-support/merges","archive_url":"https://api.github.com/repos/pmclain/php-7.2-support/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pmclain/php-7.2-support/downloads","issues_url":"https://api.github.com/repos/pmclain/php-7.2-support/issues{/number}","pulls_url":"https://api.github.com/repos/pmclain/php-7.2-support/pulls{/number}","milestones_url":"https://api.github.com/repos/pmclain/php-7.2-support/milestones{/number}","notifications_url":"https://api.github.com/repos/pmclain/php-7.2-support/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pmclain/php-7.2-support/labels{/name}","releases_url":"https://api.github.com/repos/pmclain/php-7.2-support/releases{/id}","deployments_url":"https://api.github.com/repos/pmclain/php-7.2-support/deployments","created_at":"2018-01-18T17:02:33Z","updated_at":"2018-01-18T17:03:34Z","pushed_at":"2018-06-04T17:20:23Z","git_url":"git://github.com/pmclain/php-7.2-support.git","ssh_url":"git@github.com:pmclain/php-7.2-support.git","clone_url":"https://github.com/pmclain/php-7.2-support.git","svn_url":"https://github.com/pmclain/php-7.2-support","homepage":null,"size":354302,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"2.3-develop"}},"base":{"label":"magento-engcom:2.3.1-develop","ref":"2.3.1-develop","sha":"9f76f7cce2773c6367bda42a0d54dd50efbcee52","user":{"login":"magento-engcom","id":25439648,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1NDM5NjQ4","avatar_url":"https://avatars0.githubusercontent.com/u/25439648?v=4","gravatar_id":"","url":"https://api.github.com/users/magento-engcom","html_url":"https://github.com/magento-engcom","followers_url":"https://api.github.com/users/magento-engcom/followers","following_url":"https://api.github.com/users/magento-engcom/following{/other_user}","gists_url":"https://api.github.com/users/magento-engcom/gists{/gist_id}","starred_url":"https://api.github.com/users/magento-engcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magento-engcom/subscriptions","organizations_url":"https://api.github.com/users/magento-engcom/orgs","repos_url":"https://api.github.com/users/magento-engcom/repos","events_url":"https://api.github.com/users/magento-engcom/events{/privacy}","received_events_url":"https://api.github.com/users/magento-engcom/received_events","type":"Organization","site_admin":false},"repo":{"id":115111902,"node_id":"MDEwOlJlcG9zaXRvcnkxMTUxMTE5MDI=","name":"php-7.2-support","full_name":"magento-engcom/php-7.2-support","owner":{"login":"magento-engcom","id":25439648,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1NDM5NjQ4","avatar_url":"https://avatars0.githubusercontent.com/u/25439648?v=4","gravatar_id":"","url":"https://api.github.com/users/magento-engcom","html_url":"https://github.com/magento-engcom","followers_url":"https://api.github.com/users/magento-engcom/followers","following_url":"https://api.github.com/users/magento-engcom/following{/other_user}","gists_url":"https://api.github.com/users/magento-engcom/gists{/gist_id}","starred_url":"https://api.github.com/users/magento-engcom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/magento-engcom/subscriptions","organizations_url":"https://api.github.com/users/magento-engcom/orgs","repos_url":"https://api.github.com/users/magento-engcom/repos","events_url":"https://api.github.com/users/magento-engcom/events{/privacy}","received_events_url":"https://api.github.com/users/magento-engcom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/magento-engcom/php-7.2-support","description":"Repository for implementing support of php-7.2 support in Magento","fork":false,"url":"https://api.github.com/repos/magento-engcom/php-7.2-support","forks_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/forks","keys_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/keys{/key_id}","collaborators_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/teams","hooks_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/hooks","issue_events_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/issues/events{/number}","events_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/events","assignees_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/assignees{/user}","branches_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/branches{/branch}","tags_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/tags","blobs_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/git/refs{/sha}","trees_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/git/trees{/sha}","statuses_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/statuses/{sha}","languages_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/languages","stargazers_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/stargazers","contributors_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/contributors","subscribers_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/subscribers","subscription_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/subscription","commits_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/commits{/sha}","git_commits_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/git/commits{/sha}","comments_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/comments{/number}","issue_comment_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/issues/comments{/number}","contents_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/contents/{+path}","compare_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/compare/{base}...{head}","merges_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/merges","archive_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/downloads","issues_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/issues{/number}","pulls_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/pulls{/number}","milestones_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/milestones{/number}","notifications_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/labels{/name}","releases_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/releases{/id}","deployments_url":"https://api.github.com/repos/magento-engcom/php-7.2-support/deployments","created_at":"2017-12-22T12:06:17Z","updated_at":"2018-06-04T06:44:34Z","pushed_at":"2018-06-05T22:02:38Z","git_url":"git://github.com/magento-engcom/php-7.2-support.git","ssh_url":"git@github.com:magento-engcom/php-7.2-support.git","clone_url":"https://github.com/magento-engcom/php-7.2-support.git","svn_url":"https://github.com/magento-engcom/php-7.2-support","homepage":null,"size":384911,"stargazers_count":20,"watchers_count":20,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"archived":false,"open_issues_count":27,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":23,"open_issues":27,"watchers":20,"default_branch":"2.3.1-develop"}},"_links":{"self":{"href":"https://api.github.com/repos/magento-engcom/php-7.2-support/pulls/135"},"html":{"href":"https://github.com/magento-engcom/php-7.2-support/pull/135"},"issue":{"href":"https://api.github.com/repos/magento-engcom/php-7.2-support/issues/135"},"comments":{"href":"https://api.github.com/repos/magento-engcom/php-7.2-support/issues/135/comments"},"review_comments":{"href":"https://api.github.com/repos/magento-engcom/php-7.2-support/pulls/135/comments"},"review_comment":{"href":"https://api.github.com/repos/magento-engcom/php-7.2-support/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/magento-engcom/php-7.2-support/pulls/135/commits"},"statuses":{"href":"https://api.github.com/repos/magento-engcom/php-7.2-support/statuses/6d9495128d767ce79e944d726e9f9943c7941cbc"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"buskamuza"}}