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.

Model/Api/Request/AddressRequest.php (1 issue)

Labels
Severity

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\Model\Api\Request;
28
29
use Payone\Core\Helper\Country as CountryHelper;
30
use Payone\Core\Model\PayoneConfig;
31
use Payone\Core\Model\Methods\PayoneMethod;
32
use Magento\Quote\Model\Quote\Address as QuoteAddress;
33
use Magento\Sales\Model\Order\Address as OrderAddress;
34
35
/**
36
 * Base class for all PAYONE requests that need the address methods
37
 */
38
abstract class AddressRequest extends Base
39
{
40
    /**
41
     * PAYONE customer helper
42
     *
43
     * @var \Payone\Core\Helper\Customer
44
     */
45
    protected $customerHelper;
46
47
    /**
48
     * Constructor
49
     *
50
     * @param \Payone\Core\Helper\Shop                $shopHelper
51
     * @param \Payone\Core\Helper\Environment         $environmentHelper
52
     * @param \Payone\Core\Helper\Api                 $apiHelper
53
     * @param \Payone\Core\Model\ResourceModel\ApiLog $apiLog
54
     * @param \Payone\Core\Helper\Customer            $customerHelper
55
     */
56
    public function __construct(
57
        \Payone\Core\Helper\Shop $shopHelper,
58
        \Payone\Core\Helper\Environment $environmentHelper,
59
        \Payone\Core\Helper\Api $apiHelper,
60
        \Payone\Core\Model\ResourceModel\ApiLog $apiLog,
61
        \Payone\Core\Helper\Customer $customerHelper
62
    ) {
63
        parent::__construct($shopHelper, $environmentHelper, $apiHelper, $apiLog);
64
        $this->customerHelper = $customerHelper;
65
    }
66
67
    /**
68
     * Add address-parameters to the request
69
     *
70
     * @param  QuoteAddress|OrderAddress $oAddress
71
     * @param  bool                      $blIsShipping
72
     * @return void
73
     */
74
    protected function addAddress($oAddress, $blIsShipping = false)
75
    {
76
        $sPre = '';
77
        if ($blIsShipping === true) {
78
            $sPre = 'shipping_'; // add shipping prefix for shipping addresses
79
        }
80
        $this->addParameter($sPre.'firstname', $oAddress->getFirstname());
81
        $this->addParameter($sPre.'lastname', $oAddress->getLastname());
82
        if ($oAddress->getCompany()) {// company name existing?
83
            $this->addParameter($sPre.'company', $oAddress->getCompany());
84
        }
85
86
        $aStreet = $oAddress->getStreet();
87
        $sStreet = is_array($aStreet) ? implode(' ', $aStreet) : $aStreet; // street may be an array
88
        $this->addParameter($sPre.'street', trim($sStreet));
89
        $this->addParameter($sPre.'zip', $oAddress->getPostcode());
90
        $this->addParameter($sPre.'city', $oAddress->getCity());
91
        $this->addParameter($sPre.'country', $oAddress->getCountryId());
92
93
        if (CountryHelper::isStateNeeded($oAddress->getCountryId()) && $oAddress->getRegionCode()) {
94
            $this->addParameter($sPre.'state', $this->customerHelper->getRegionCode($oAddress));
95
        }
96
    }
97
98
    /**
99
     * Add user-data to the request
100
     *
101
     * @param  QuoteAddress|OrderAddress $oBilling
102
     * @param  PayoneMethod              $oPayment
103
     * @param  string                    $iGender
104
     * @param  string                    $sEmail
105
     * @param  string                    $sDob
106
     * @param  bool                      $blIsUpdateUser
107
     * @return void
108
     */
109
    protected function addUserDataParameters($oBilling, PayoneMethod $oPayment, $iGender, $sEmail, $sDob, $blIsUpdateUser = false)
110
    {
111
        $this->addAddress($oBilling);
112
113
        if ($iGender || $blIsUpdateUser) {
114
            $this->addParameter('salutation', $this->customerHelper->getSalutationParameter($iGender), $blIsUpdateUser);
115
            $this->addParameter('gender', $this->customerHelper->getGenderParameter($iGender), $blIsUpdateUser);
116
        }
117
118
        $this->addParameter('email', $sEmail);
119
        if ($blIsUpdateUser || $oBilling->getTelephone()) {
120
            $this->addParameter('telephonenumber', $oBilling->getTelephone(), $blIsUpdateUser);
121
        }
122
123
        if ((
124
                in_array($oPayment->getCode(), [PayoneConfig::METHOD_KLARNA]) &&
125
                in_array($oBilling->getCountryId(), ['DE', 'NL', 'AT'])
126
            ) || ($blIsUpdateUser || ($sDob != '0000-00-00 00:00:00' && $sDob != ''))
127
        ) {
128
            $this->addParameter('birthday', str_replace('-', '', date('Ymd', strtotime($sDob)), $blIsUpdateUser));
129
        }
130
131
        $this->addParameter('language', $this->shopHelper->getLocale());
132
        if ($blIsUpdateUser || $oBilling->getVatId() != '') {
133
            $this->addParameter('vatid', $oBilling->getVatId(), $blIsUpdateUser);
0 ignored issues
show
It seems like $blIsUpdateUser can also be of type integer or null; however, Payone\Core\Model\Api\Request\Base::addParameter() does only seem to accept boolean, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
134
        }
135
    }
136
}
137