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/Paypal/Express.php (2 issues)

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\Paypal;
28
29
use Magento\Framework\Controller\ResultFactory;
30
use Magento\Quote\Model\Quote;
31
use Payone\Core\Model\PayoneConfig;
32
33
/**
34
 * Controller for PayPal Express initiation
35
 */
36
class Express extends \Magento\Framework\App\Action\Action
37
{
38
    /**
39
     * Checkout session
40
     *
41
     * @var \Magento\Checkout\Model\Session
42
     */
43
    protected $checkoutSession;
44
45
    /**
46
     * PAYONE request model
47
     *
48
     * @var \Payone\Core\Model\Api\Request\Genericpayment\PayPalExpress
49
     */
50
    protected $genericRequest;
51
52
    /**
53
     * PayPal payment model
54
     *
55
     * @var \Payone\Core\Model\Methods\Paypal
56
     */
57
    protected $paypalPayment;
58
59
    /**
60
     * Checkout helper
61
     *
62
     * @var \Magento\Checkout\Helper\Data
63
     */
64
    protected $checkoutHelper;
65
66
    /**
67
     * Customer session
68
     *
69
     * @var \Magento\Customer\Model\Session
70
     */
71
    protected $customerSession;
72
73
    /**
74
     * PAYONE payment helper
75
     *
76
     * @var \Payone\Core\Helper\Payment
77
     */
78
    protected $paymentHelper;
79
80
    /**
81
     * Constructor
82
     *
83
     * @param \Magento\Framework\App\Action\Context                       $context
84
     * @param \Magento\Checkout\Model\Session                             $checkoutSession
85
     * @param \Payone\Core\Model\Api\Request\Genericpayment\PayPalExpress $genericRequest
86
     * @param \Payone\Core\Model\Methods\Paypal                           $paypalPayment
87
     * @param \Magento\Checkout\Helper\Data                               $checkoutHelper
88
     * @param \Magento\Customer\Model\Session                             $customerSession
89
     * @param \Payone\Core\Helper\Payment                                 $paymentHelper
90
     */
91
    public function __construct(
92
        \Magento\Framework\App\Action\Context $context,
93
        \Magento\Checkout\Model\Session $checkoutSession,
94
        \Payone\Core\Model\Api\Request\Genericpayment\PayPalExpress $genericRequest,
95
        \Payone\Core\Model\Methods\Paypal $paypalPayment,
96
        \Magento\Checkout\Helper\Data $checkoutHelper,
97
        \Magento\Customer\Model\Session $customerSession,
98
        \Payone\Core\Helper\Payment $paymentHelper
99
    ) {
100
        parent::__construct($context);
101
        $this->checkoutSession = $checkoutSession;
102
        $this->genericRequest = $genericRequest;
103
        $this->paypalPayment = $paypalPayment;
104
        $this->checkoutHelper = $checkoutHelper;
105
        $this->customerSession = $customerSession;
106
        $this->paymentHelper = $paymentHelper;
107
    }
108
109
    /**
110
     * Determine if a logged in customer is required for an express checkout
111
     * For example needed for virtual products ( download-products etc. )
112
     *
113
     * @param  Quote $oQuote
114
     * @return bool
115
     */
116
    protected function loginNeededForExpressCheckout(Quote $oQuote)
117
    {
118
        $oCustomer = $this->customerSession->getCustomerDataObject();
119
        if (!$oCustomer->getId()) {
120
            $sCheckoutMethod = $oQuote->getCheckoutMethod();
121
            if ((!$sCheckoutMethod || $sCheckoutMethod != \Magento\Checkout\Model\Type\Onepage::METHOD_REGISTER)
122
                && !$this->checkoutHelper->isAllowedGuestCheckout($oQuote, $oQuote->getStoreId())
123
            ) {
124
                return true;
125
            }
126
        }
127
        return false;
128
    }
129
130
    /**
131
     * Redirect to payment-provider or to success page
132
     *
133
     * @return void
134
     */
135
    public function execute()
136
    {
137
        $oQuote = $this->checkoutSession->getQuote();
138
139
        if ($this->paymentHelper->isPayPalExpressActive() && $oQuote && $oQuote->hasItems()) {
140 View Code Duplication
            if ($this->loginNeededForExpressCheckout($oQuote)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
141
                $this->messageManager->addNoticeMessage(__('Please sign in to check out.'));
142
143
                $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
144
                return $resultRedirect->setPath('customer/account/login');
145
            }
146
147
            $this->paypalPayment->setIsPayPalExpress(true);
148
            $aResponse = $this->genericRequest->sendRequest($oQuote, $this->paypalPayment);
149
            if ($aResponse['status'] == 'ERROR') {
150
                $this->messageManager->addError(__($aResponse['customermessage']));
0 ignored issues
show
Deprecated Code introduced by
The method Magento\Framework\Messag...erInterface::addError() has been deprecated with message: 100.1.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
151
152
                $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
153
                return $resultRedirect->setPath('checkout/cart');
154
            } elseif ($aResponse['status'] == 'REDIRECT') {
155
                $oPayment = $oQuote->getPayment();
156
                $oPayment->setMethod(PayoneConfig::METHOD_PAYPAL);
157
                $oQuote->setPayment($oPayment);
158
                $oQuote->save();
159
160
                $this->checkoutSession->setPayoneWorkorderId($aResponse['workorderid']);
161
                $this->_redirect($aResponse['redirecturl']);
162
            }
163
            return;
164
        }
165
        $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
166
        return $resultRedirect->setPath('checkout/cart');
167
    }
168
}
169