Issues (547)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

Controller/Onepage/Debit.php (1 issue)

Upgrade to new PHP Analysis Engine

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\Controller\Onepage;
28
29
use Magento\Framework\View\Result\Page;
30
use Payone\Core\Model\Methods\PayoneMethod;
31
use Magento\Quote\Model\Quote;
32
use Magento\Framework\Exception\LocalizedException;
33
34
/**
35
 * Controller for mandate management with debit payment
36
 */
37
class Debit extends \Magento\Framework\App\Action\Action
38
{
39
    /**
40
     * Checkout session
41
     *
42
     * @var \Magento\Checkout\Model\Session
43
     */
44
    protected $checkoutSession;
45
46
    /**
47
     * PAYONE debit request class
48
     *
49
     * @var \Payone\Core\Model\Api\Request\Managemandate
50
     */
51
    protected $managemandateRequest;
52
53
    /**
54
     * Page result factory
55
     *
56
     * @var \Magento\Framework\View\Result\PageFactory
57
     */
58
    protected $pageFactory;
59
60
    /**
61
     * Cart management interface
62
     *
63
     * @var \Magento\Quote\Api\CartManagementInterface
64
     */
65
    protected $cartManagement;
66
67
    /**
68
     * Onepage checkout model
69
     *
70
     * @var \Magento\Checkout\Model\Type\Onepage
71
     */
72
    protected $typeOnepage;
73
74
    /**
75
     * Constructor
76
     *
77
     * @param \Magento\Framework\App\Action\Context        $context
78
     * @param \Magento\Checkout\Model\Session              $checkoutSession
79
     * @param \Payone\Core\Model\Api\Request\Managemandate $managemandateRequest
80
     * @param \Magento\Framework\View\Result\PageFactory   $pageFactory
81
     * @param \Magento\Quote\Api\CartManagementInterface   $cartManagement
82
     * @param \Magento\Checkout\Model\Type\Onepage         $typeOnepage
83
     */
84
    public function __construct(
85
        \Magento\Framework\App\Action\Context $context,
86
        \Magento\Checkout\Model\Session $checkoutSession,
87
        \Payone\Core\Model\Api\Request\Managemandate $managemandateRequest,
88
        \Magento\Framework\View\Result\PageFactory $pageFactory,
89
        \Magento\Quote\Api\CartManagementInterface $cartManagement,
90
        \Magento\Checkout\Model\Type\Onepage $typeOnepage
91
    ) {
92
        parent::__construct($context);
93
        $this->checkoutSession = $checkoutSession;
94
        $this->managemandateRequest = $managemandateRequest;
95
        $this->pageFactory = $pageFactory;
96
        $this->cartManagement = $cartManagement;
97
        $this->typeOnepage = $typeOnepage;
98
    }
99
100
    /**
101
     * Execute managemandate request and handle response
102
     *
103
     * @param  PayoneMethod $oPayment
104
     * @param  Quote        $oQuote
105
     * @return array
106
     * @throws LocalizedException
107
     */
108
    protected function handleManagemandateRequest(PayoneMethod $oPayment, Quote $oQuote)
109
    {
110
        $aResponse = $this->managemandateRequest->sendRequest($oPayment, $oQuote);
111
        if ($aResponse['status'] == 'ERROR') {// request was not successfull
112
            throw new LocalizedException(__($aResponse['errorcode'].' - '.$aResponse['customermessage']));
113
        } elseif (is_array($aResponse) && array_key_exists('mandate_status', $aResponse) !== false) {
114
            // write mandate to session
115
            $this->checkoutSession->setPayoneMandate($aResponse);
116
        }
117
        return $aResponse;
118
    }
119
120
    /**
121
     *
122
     * @param  PayoneMethod $oPayment
123
     * @param  Quote $oQuote
124
     * @return void|Page
125
     */
126
    protected function handleMandate(PayoneMethod $oPayment, Quote $oQuote)
127
    {
128
        if ($oPayment->getCustomConfigParam('sepa_mandate_enabled')) {
129
            $aMandate = $this->checkoutSession->getPayoneMandate();
130
            if (!$aMandate) {// Is initial call, so get the mandate
131
                $aResponse = $this->handleManagemandateRequest($oPayment, $oQuote);
132
                if ($aResponse && array_key_exists('mandate_status', $aResponse) !== false && $aResponse['mandate_status'] == 'pending') {
0 ignored issues
show
Bug Best Practice introduced by
The expression $aResponse of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
133
                    $oPageObject = $this->pageFactory->create();
134
                    return $oPageObject;
135
                }
136
            } elseif ($this->getRequest()->getParam('mandate_granted') == 1 &&
137
                     $this->getRequest()->getParam('mandate_id') != $aMandate['mandate_identification']
138
            ) {// Is return from the mandate-page with granted mandate but mandate id mismatch
139
                $this->_redirect($this->_url->getUrl('checkout'));
140
                return;
141
            } // else - mandate is granted so proceed to success page
142
        }
143
        // trigger order creation
144
        $this->cartManagement->placeOrder($oQuote->getId());
145
        $this->_redirect($this->_url->getUrl('checkout/onepage/success'));
146
    }
147
148
    /**
149
     * Handle debit checkout
150
     * Display mandate if activated
151
     * Just create the order if mandate is deactivated
152
     * Redirect to basket if quote or payment is missing
153
     *
154
     * @return void|Page
155
     */
156
    public function execute()
157
    {
158
        $oQuote = $this->checkoutSession->getQuote();
159
        $oQuote->setCheckoutMethod($this->typeOnepage->getCheckoutMethod());
160
161
        $oPayment = $oQuote->getPayment()->getMethodInstance();
162
        if (!$oQuote || !$oPayment) {// something is wrong, redirect to checkout start
163
            $this->_redirect($this->_url->getUrl('checkout'));
164
            return;
165
        }
166
167
        try {
168
            return $this->handleMandate($oPayment, $oQuote);
169
        } catch (\Exception $ex) {
170
            $this->checkoutSession->setPayoneDebitError($ex->getMessage());
171
            $oPageObject = $this->pageFactory->create();
172
            return $oPageObject;
173
        }
174
    }
175
}
176