Issues (12)

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/Merchant/Notification.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 declare(strict_types=1);
2
3
namespace Personnage\Tinkoff\SDK\Merchant;
4
5
use function Personnage\Tinkoff\SDK\message_get_body;
6
use Personnage\Tinkoff\SDK\Exception\InvalidToken;
7
use Personnage\Tinkoff\SDK\PaymentCard;
8
use Psr\Http\Message\RequestInterface;
9
10
final class Notification
11
{
12
    use HasSignature;
13
14
    const AUTHORIZED = 'AUTHORIZED';
15
    const CONFIRMED = 'CONFIRMED';
16
    const PARTIAL_REFUNDED = 'PARTIAL_REFUNDED';
17
    const REFUNDED = 'REFUNDED';
18
    const REJECTED = 'REJECTED';
19
    const REVERSED = 'REVERSED';
20
21
    /**
22
     * @var array
23
     */
24
    private $values;
25
26
    /**
27
     * @var PaymentCard
28
     */
29
    private $paymentCard;
30
31
    /**
32
     * Create a new instance.
33
     *
34
     * @param array $values
35
     */
36
    public function __construct(array $values)
37
    {
38
        if (isset($values['DATA'])) {
39
            $values['DATA'] = urldecode($values['DATA']);
40
        }
41
42
        $this->values = $values;
43
    }
44
45
    /**
46
     * Create a new instance from request instance.
47
     *
48
     * @param  RequestInterface  $request
49
     * @return self
50
     */
51
    public static function fromRequest(RequestInterface $request): self
52
    {
53
        return new self(message_get_body($request));
54
    }
55
56
    /**
57
     * Throws an exception if token is invalid.
58
     *
59
     * @param  string  $secret
60
     * @throws InvalidToken
61
     */
62
    public function validate(string $secret)
63
    {
64
        if ($this->sign($this->values, $secret) !== $this->get('Token')) {
65
            throw new InvalidToken('Invalid token.');
66
        }
67
    }
68
69
    /**
70
     * Is request successful?
71
     *
72
     * @return bool
73
     */
74
    public function isSuccessful(): bool
75
    {
76
        return 'true' === $this->get('Success');
77
    }
78
79
    /**
80
     * Is request authorized?
81
     *
82
     * @return bool
83
     */
84
    public function isAuthorized(): bool
85
    {
86
        return self::AUTHORIZED === $this->get('Status');
87
    }
88
89
    /**
90
     * Is request confirmed?
91
     *
92
     * @return bool
93
     */
94
    public function isConfirmed(): bool
95
    {
96
        return self::CONFIRMED === $this->get('Status');
97
    }
98
99
    /**
100
     * Is request reversed?
101
     *
102
     * @return bool
103
     */
104
    public function isReversed(): bool
105
    {
106
        return self::REVERSED === $this->get('Status');
107
    }
108
109
    /**
110
     * Is request refunded?
111
     *
112
     * @return bool
113
     */
114
    public function isRefunded(): bool
115
    {
116
        return self::REFUNDED === $this->get('Status');
117
    }
118
119
    /**
120
     * Is request refunded?
121
     *
122
     * @return bool
123
     */
124
    public function isPartialRefunded(): bool
125
    {
126
        return self::PARTIAL_REFUNDED === $this->get('Status');
127
    }
128
129
    /**
130
     * Is request rejected?
131
     *
132
     * @return bool
133
     */
134
    public function isRejected(): bool
135
    {
136
        return self::REJECTED === $this->get('Status');
137
    }
138
139
    /**
140
     * Get a payment card instance if card id exists.
141
     *
142
     * @return PaymentCard|null
143
     */
144
    public function getPaymentCard()
145
    {
146
        if ($this->paymentCard || $this->get('CardId')) {
147
            $this->paymentCard = PaymentCard::make($this->get('CardId'), $this->get('Pan'), $this->get('ExpDate'));
0 ignored issues
show
Documentation Bug introduced by
It seems like \Personnage\Tinkoff\SDK\... $this->get('ExpDate')) of type object<self> is incompatible with the declared type object<Personnage\Tinkoff\SDK\PaymentCard> of property $paymentCard.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
148
        }
149
150
        return $this->paymentCard;
151
    }
152
153
    /**
154
     * Get same value by key.
155
     *
156
     * @param  string  $key
157
     * @return string|null
158
     */
159
    public function get(string $key)
160
    {
161
        return $this->values[$key] ?? null;
162
    }
163
164
    /**
165
     * Get all values as JSON.
166
     *
167
     * @param  int  $options
168
     * @return string
169
     */
170
    public function toJson($options = 0): string
171
    {
172
        return json_encode($this->toArray(), $options);
173
    }
174
175
    /**
176
     * Get all values as a plain array.
177
     *
178
     * @return array
179
     */
180
    public function toArray(): array
181
    {
182
        return $this->values;
183
    }
184
}
185