Issues (11)

Security Analysis    no request data  

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.

src/Request/AbstractRequest.php (4 issues)

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
 * This file is part of the Nexylan packages.
5
 *
6
 * (c) Nexylan SAS <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Nexy\PayboxDirect\Request;
13
14
use Greg0ire\Enum\Bridge\Symfony\Validator\Constraint\Enum;
15
use Symfony\Component\Validator\Constraints as Assert;
16
17
/**
18
 * @author Sullivan Senechal <[email protected]>
19
 */
20
abstract class AbstractRequest implements RequestInterface
21
{
22
    /**
23
     * @var int
24
     *
25
     * @Enum(class="Nexy\PayboxDirect\Enum\Activity", showKeys=true)
26
     */
27
    private $activity = null;
28
29
    /**
30
     * @var \DateTime
31
     *
32
     * @Assert\Type("\DateTime")
33
     */
34
    private $date = null;
35
36
    /**
37
     * @var bool
38
     *
39
     * @Assert\Type("bool")
40
     */
41
    private $showCountry = false;
42
43
    /**
44
     * @var bool
45
     *
46
     * @Assert\Type("bool")
47
     */
48
    private $showSha1 = false;
49
50
    /**
51
     * @var bool
52
     *
53
     * @Assert\Type("bool")
54
     */
55
    private $showCardType = false;
56
57
    /**
58
     * @var string|null
59
     *
60
     * @Assert\Type("string")
61
     * @Assert\Length(min=1, max=250)
62
     */
63
    private $subscriberRef = null;
64
65
    /**
66
     * @param null|string $subscriberRef
67
     */
68
    public function __construct($subscriberRef = null)
69
    {
70
        $this->subscriberRef = $subscriberRef;
71
    }
72
73
    /**
74
     * @param int $activity
75
     *
76
     * @return $this
77
     */
78
    final public function setActivity($activity)
79
    {
80
        $this->activity = $activity;
81
82
        return $this;
83
    }
84
85
    /**
86
     * @param \DateTime|null $date
87
     *
88
     * @return $this
89
     */
90
    final public function setDate(\DateTime $date = null)
91
    {
92
        $this->date = $date;
93
94
        return $this;
95
    }
96
97
    /**
98
     * @param bool $showCountry
99
     *
100
     * @return $this
101
     */
102
    final public function setShowCountry($showCountry)
103
    {
104
        $this->showCountry = $showCountry;
105
106
        return $this;
107
    }
108
109
    /**
110
     * @param bool $showSha1
111
     *
112
     * @return $this
113
     */
114
    final public function setShowSha1($showSha1)
115
    {
116
        $this->showSha1 = $showSha1;
117
118
        return $this;
119
    }
120
121
    /**
122
     * @param bool $showCardType
123
     *
124
     * @return $this
125
     */
126
    final public function setShowCardType($showCardType)
127
    {
128
        $this->showCardType = $showCardType;
129
130
        return $this;
131
    }
132
133
    /**
134
     * @return bool
135
     */
136
    final protected function hasSubscriberRef()
137
    {
138
        return !empty($this->subscriberRef);
139
    }
140
141
    /**
142
     * @return null|string
143
     */
144
    final protected function getSubscriberRef()
145
    {
146
        return $this->subscriberRef;
147
    }
148
149
    /**
150
     * {@inheritdoc}
151
     */
152
    public function getParameters()
153
    {
154
        $parameters = [
155
            'DATEQ' => $this->date instanceof \DateTime ? $this->date->format('dmYHis') : null,
156
        ];
157
158
        if ($this->activity) {
159
            $parameters['ACTIVITE'] = $this->activity;
160
        }
161
        if ($this->showCountry) {
162
            $parameters['PAYS'] = '';
163
        }
164
        if ($this->showSha1) {
165
            $parameters['SHA-1'] = '';
166
        }
167
        if ($this->showCardType) {
168
            $parameters['TYPECARTE'] = '';
169
        }
170
171
        if (method_exists($this, 'getTransactionNumber')) {
172
            $parameters['NUMTRANS'] = $this->getTransactionNumber();
0 ignored issues
show
It seems like you code against a specific sub-type and not the parent class Nexy\PayboxDirect\Request\AbstractRequest as the method getTransactionNumber() does only exist in the following sub-classes of Nexy\PayboxDirect\Request\AbstractRequest: Nexy\PayboxDirect\Reques...encedTransactionRequest, Nexy\PayboxDirect\Reques...beredTransactionRequest, Nexy\PayboxDirect\Request\CancelRequest, Nexy\PayboxDirect\Request\DebitRequest, Nexy\PayboxDirect\Request\InquiryRequest, Nexy\PayboxDirect\Request\RefundRequest, Nexy\PayboxDirect\Reques...ancelTransactionRequest, Nexy\PayboxDirect\Request\UpdateAmountRequest. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

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 sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
173
        }
174
        if (method_exists($this, 'getCallNumber')) {
175
            $parameters['NUMAPPEL'] = $this->getCallNumber();
0 ignored issues
show
It seems like you code against a specific sub-type and not the parent class Nexy\PayboxDirect\Request\AbstractRequest as the method getCallNumber() does only exist in the following sub-classes of Nexy\PayboxDirect\Request\AbstractRequest: Nexy\PayboxDirect\Reques...encedTransactionRequest, Nexy\PayboxDirect\Reques...beredTransactionRequest, Nexy\PayboxDirect\Request\CancelRequest, Nexy\PayboxDirect\Request\DebitRequest, Nexy\PayboxDirect\Request\InquiryRequest, Nexy\PayboxDirect\Request\RefundRequest, Nexy\PayboxDirect\Reques...ancelTransactionRequest, Nexy\PayboxDirect\Request\UpdateAmountRequest. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

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 sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
176
        }
177
        if (method_exists($this, 'hasAuthorization') && $this->hasAuthorization()) {
0 ignored issues
show
It seems like you code against a specific sub-type and not the parent class Nexy\PayboxDirect\Request\AbstractRequest as the method hasAuthorization() does only exist in the following sub-classes of Nexy\PayboxDirect\Request\AbstractRequest: Nexy\PayboxDirect\Reques...horizeAndCaptureRequest, Nexy\PayboxDirect\Request\AuthorizeRequest, Nexy\PayboxDirect\Reques...bscriberRegisterRequest, Nexy\PayboxDirect\Request\SubscriberUpdateRequest, Nexy\PayboxDirect\Request\UpdateAmountRequest. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

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 sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
178
            $parameters['AUTORISATION'] = $this->getAuthorization();
0 ignored issues
show
It seems like you code against a specific sub-type and not the parent class Nexy\PayboxDirect\Request\AbstractRequest as the method getAuthorization() does only exist in the following sub-classes of Nexy\PayboxDirect\Request\AbstractRequest: Nexy\PayboxDirect\Reques...horizeAndCaptureRequest, Nexy\PayboxDirect\Request\AuthorizeRequest, Nexy\PayboxDirect\Reques...bscriberRegisterRequest, Nexy\PayboxDirect\Request\SubscriberUpdateRequest, Nexy\PayboxDirect\Request\UpdateAmountRequest. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

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 sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
179
        }
180
181
        // Direct Plus requests special case.
182
        if ($this->hasSubscriberRef()) {
183
            $parameters['REFABONNE'] = $this->getSubscriberRef();
184
        }
185
186
        return $parameters;
187
    }
188
}
189