fjbender /
magento-2
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify |
||
| 5 | * it under the terms of the GNU Lesser General Public License as published by |
||
| 6 | * the Free Software Foundation, either version 3 of the License, or |
||
| 7 | * (at your option) any later version. |
||
| 8 | * |
||
| 9 | * PAYONE Magento 2 Connector is distributed in the hope that it will be useful, |
||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 12 | * GNU Lesser General Public License for more details. |
||
| 13 | * |
||
| 14 | * You should have received a copy of the GNU Lesser General Public License |
||
| 15 | * along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>. |
||
| 16 | * |
||
| 17 | * PHP version 5 |
||
| 18 | * |
||
| 19 | * @category Payone |
||
| 20 | * @package Payone_Magento2_Plugin |
||
| 21 | * @author FATCHIP GmbH <[email protected]> |
||
| 22 | * @copyright 2003 - 2016 Payone GmbH |
||
| 23 | * @license <http://www.gnu.org/licenses/> GNU Lesser General Public License |
||
| 24 | * @link http://www.payone.de |
||
| 25 | */ |
||
| 26 | |||
| 27 | namespace Payone\Core\Model\ResourceModel; |
||
| 28 | |||
| 29 | use Payone\Core\Helper\Toolkit; |
||
| 30 | use Magento\Framework\App\Action\Context; |
||
| 31 | use Magento\Sales\Model\Order; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * TransactionStatus resource model |
||
| 35 | */ |
||
| 36 | class TransactionStatus extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb |
||
| 37 | { |
||
| 38 | /** |
||
| 39 | * Context object |
||
| 40 | * |
||
| 41 | * @var \Magento\Framework\App\Action\Context |
||
| 42 | */ |
||
| 43 | protected $oContext = null; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Store manager object |
||
| 47 | * |
||
| 48 | * @var \Magento\Store\Model\StoreManagerInterface |
||
| 49 | */ |
||
| 50 | protected $storeManager; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Toolkit helper object |
||
| 54 | * |
||
| 55 | * @var Toolkit |
||
| 56 | */ |
||
| 57 | protected $toolkitHelper; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Constructor |
||
| 61 | * |
||
| 62 | * @param \Magento\Framework\Model\ResourceModel\Db\Context $context |
||
| 63 | * @param \Magento\Store\Model\StoreManagerInterface $storeManager |
||
| 64 | * @param \Payone\Core\Helper\Toolkit $toolkitHelper |
||
| 65 | * @param string $connectionName |
||
| 66 | */ |
||
| 67 | public function __construct( |
||
| 68 | \Magento\Framework\Model\ResourceModel\Db\Context $context, |
||
| 69 | \Magento\Store\Model\StoreManagerInterface $storeManager, |
||
| 70 | \Payone\Core\Helper\Toolkit $toolkitHelper, |
||
| 71 | $connectionName = null |
||
| 72 | ) { |
||
| 73 | parent::__construct($context, $connectionName); |
||
| 74 | $this->storeManager = $storeManager; |
||
| 75 | $this->toolkitHelper = $toolkitHelper; |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Initialize connection and table |
||
| 80 | * |
||
| 81 | * @return void |
||
| 82 | */ |
||
| 83 | protected function _construct() |
||
| 84 | { |
||
| 85 | $this->_init('payone_protocol_transactionstatus', 'id'); |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Get request-parameter value or a given default if not set |
||
| 90 | * |
||
| 91 | * @param string $sKey |
||
| 92 | * @param string $sDefault |
||
| 93 | * @return string |
||
| 94 | */ |
||
| 95 | public function getParam($sKey, $sDefault = '') |
||
| 96 | { |
||
| 97 | if ($this->oContext) { |
||
| 98 | $sParam = $this->oContext->getRequest()->getParam($sKey, $sDefault); |
||
| 99 | if (!$this->toolkitHelper->isUTF8($sParam)) { |
||
| 100 | $sParam = utf8_encode($sParam); |
||
| 101 | } |
||
| 102 | return $sParam; |
||
| 103 | } |
||
| 104 | return $sDefault; |
||
| 105 | } |
||
| 106 | |||
| 107 | /** |
||
| 108 | * Write TransactionStatus entry to database |
||
| 109 | * |
||
| 110 | * @param Context $oContext |
||
| 111 | * @param Order $oOrder |
||
| 112 | * @return $this |
||
| 113 | */ |
||
| 114 | public function addTransactionLogEntry(Context $oContext, Order $oOrder = null) |
||
| 115 | { |
||
| 116 | $this->oContext = $oContext; |
||
| 117 | $aRequest = $oContext->getRequest()->getPostValue(); |
||
|
0 ignored issues
–
show
|
|||
| 118 | $sRawStatus = serialize($aRequest); |
||
| 119 | if (!$this->toolkitHelper->isUTF8($sRawStatus)) { |
||
| 120 | $sRawStatus = utf8_encode($sRawStatus); // needed for serializing the array |
||
| 121 | } |
||
| 122 | $sOrderId = $oOrder !== null ? $oOrder->getIncrementId() : ''; |
||
| 123 | $this->getConnection()->insert( |
||
| 124 | $this->getMainTable(), |
||
| 125 | [ |
||
| 126 | 'order_id' => $sOrderId, |
||
| 127 | 'store_id' => $this->storeManager->getStore()->getId(), |
||
| 128 | 'reference' => $this->getParam('reference'), |
||
| 129 | 'txid' => $this->getParam('txid'), |
||
| 130 | 'txaction' => $this->getParam('txaction'), |
||
| 131 | 'sequencenumber' => $this->getParam('sequencenumber'), |
||
| 132 | 'clearingtype' => $this->getParam('clearingtype'), |
||
| 133 | 'txtime' => date('Y-m-d H:i:s', $this->getParam('txtime')), |
||
| 134 | 'price' => $this->getParam('price'), |
||
| 135 | 'balance' => $this->getParam('balance'), |
||
| 136 | 'receivable' => $this->getParam('receivable'), |
||
| 137 | 'currency' => $this->getParam('currency'), |
||
| 138 | 'aid' => $this->getParam('aid'), |
||
| 139 | 'portalid' => $this->getParam('portalid'), |
||
| 140 | 'key' => $this->getParam('key'), |
||
| 141 | 'mode' => $this->getParam('mode'), |
||
| 142 | 'userid' => $this->getParam('userid'), |
||
| 143 | 'customerid' => $this->getParam('customerid'), |
||
| 144 | 'company' => $this->getParam('company'), |
||
| 145 | 'firstname' => $this->getParam('firstname'), |
||
| 146 | 'lastname' => $this->getParam('lastname'), |
||
| 147 | 'street' => $this->getParam('street'), |
||
| 148 | 'zip' => $this->getParam('zip'), |
||
| 149 | 'city' => $this->getParam('city'), |
||
| 150 | 'email' => $this->getParam('email'), |
||
| 151 | 'country' => $this->getParam('country'), |
||
| 152 | 'shipping_company' => $this->getParam('shipping_company'), |
||
| 153 | 'shipping_firstname' => $this->getParam('shipping_firstname'), |
||
| 154 | 'shipping_lastname' => $this->getParam('shipping_lastname'), |
||
| 155 | 'shipping_street' => $this->getParam('shipping_street'), |
||
| 156 | 'shipping_zip' => $this->getParam('shipping_zip'), |
||
| 157 | 'shipping_city' => $this->getParam('shipping_city'), |
||
| 158 | 'shipping_country' => $this->getParam('shipping_country'), |
||
| 159 | 'param' => $this->getParam('param'), |
||
| 160 | 'accessname' => $this->getParam('accessname'), |
||
| 161 | 'accesscode' => $this->getParam('accesscode'), |
||
| 162 | 'bankcountry' => $this->getParam('bankcountry'), |
||
| 163 | 'bankaccount' => $this->getParam('bankaccount'), |
||
| 164 | 'bankcode' => $this->getParam('bankcode'), |
||
| 165 | 'bankaccountholder' => $this->getParam('bankaccountholder'), |
||
| 166 | 'cardexpiredate' => $this->getParam('cardexpiredate'), |
||
| 167 | 'cardtype' => $this->getParam('cardtype'), |
||
| 168 | 'cardpan' => $this->getParam('cardpan'), |
||
| 169 | 'clearing_bankaccountholder' => $this->getParam('clearing_bankaccountholder'), |
||
| 170 | 'clearing_bankaccount' => $this->getParam('clearing_bankaccount'), |
||
| 171 | 'clearing_bankcode' => $this->getParam('clearing_bankcode'), |
||
| 172 | 'clearing_bankname' => $this->getParam('clearing_bankname'), |
||
| 173 | 'clearing_bankbic' => $this->getParam('clearing_bankbic'), |
||
| 174 | 'clearing_bankiban' => $this->getParam('clearing_bankiban'), |
||
| 175 | 'clearing_legalnote' => $this->getParam('clearing_legalnote'), |
||
| 176 | 'clearing_duedate' => $this->getParam('clearing_duedate'), |
||
| 177 | 'clearing_reference' => $this->getParam('clearing_reference'), |
||
| 178 | 'clearing_instructionnote' => $this->getParam('clearing_instructionnote'), |
||
| 179 | 'raw_status' => $sRawStatus, |
||
| 180 | ] |
||
| 181 | ); |
||
| 182 | return $this; |
||
| 183 | } |
||
| 184 | |||
| 185 | /** |
||
| 186 | * Get TransactionStatus id be txid |
||
| 187 | * |
||
| 188 | * @param string $sTxid |
||
| 189 | * @return string |
||
| 190 | */ |
||
| 191 | public function getAppointedIdByTxid($sTxid) |
||
| 192 | { |
||
| 193 | $oConn = $this->getConnection(); |
||
| 194 | |||
| 195 | $oSelect = $oConn->select()->from($this->getMainTable()) |
||
| 196 | ->where('txid = :txid') |
||
| 197 | ->where('txaction = :txaction'); |
||
| 198 | |||
| 199 | return $oConn->fetchOne($oSelect, ['txid' => $sTxid, 'txaction' => 'appointed']); |
||
| 200 | } |
||
| 201 | } |
||
| 202 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: