Issues (19)

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.

src/Message/QueryTransactionRequest.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
 * @link https://github.com/phpviet/omnipay-vnpay
4
 *
5
 * @copyright (c) PHP Viet
6
 * @license [MIT](https://opensource.org/licenses/MIT)
7
 */
8
9
namespace Omnipay\VNPay\Message;
10
11
/**
12
 * @author Vuong Minh <[email protected]>
13
 * @since 1.0.0
14
 */
15
class QueryTransactionRequest extends AbstractSignatureRequest
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    protected $productionEndpoint = 'https://merchant.vnpay.vn/merchant_webapi/merchant.html';
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected $testEndpoint = 'https://sandbox.vnpayment.vn/merchant_webapi/merchant.html';
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function initialize(array $parameters = [])
31
    {
32
        parent::initialize($parameters);
33
34
        $this->setParameter('vnp_Command', 'querydr');
35
36
        return $this;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     * @throws \Omnipay\Common\Exception\InvalidResponseException
42
     */
43
    public function sendData($data): SignatureResponse
44
    {
45
        $query = http_build_query($data, null, '&', PHP_QUERY_RFC3986);
46
        $requestUrl = $this->getEndpoint().'?'.$query;
47
        $response = $this->httpClient->request('GET', $requestUrl);
48
        $responseRawData = $response->getBody()->getContents();
49
        parse_str($responseRawData, $responseData);
50
51
        return $this->response = new SignatureResponse($this, $responseData);
52
    }
53
54
    /**
55
     * Trả về mã giao dịch của VNPay.
56
     * Đây là phương thức ánh xạ của [[getTransactionReference()]].
57
     *
58
     * @return null|string
59
     * @see getTransactionReference
60
     */
61
    public function getVnpTransactionNo(): ?string
62
    {
63
        return $this->getParameter('vnp_TransactionNo');
64
    }
65
66
    /**
67
     * Thiết lập mã giao dịch của VNPay.
68
     * Đây là phương thức ánh xạ của [[setTransactionReference()]].
69
     *
70
     * @param  null|string  $no
71
     * @return $this
72
     * @see setTransactionReference
73
     */
74
    public function setVnpTransactionNo(?string $no)
75
    {
76
        return $this->setParameter('vnp_TransactionNo', $no);
77
    }
78
79
    /**
80
     * {@inheritdoc}
81
     */
82
    public function getTransactionReference(): ?string
83
    {
84
        return $this->getParameter('vnp_TransactionNo');
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90
    public function setTransactionReference($value)
91
    {
92
        return $this->setParameter('vnp_TransactionNo', $value);
93
    }
94
95
    /**
96
     * Trả về thời gian phát sinh giao dịch tại VNPay.
97
     *
98
     * @return null|string
99
     */
100
    public function getVnpTransDate(): ?string
101
    {
102
        return $this->getParameter('vnp_TransDate');
103
    }
104
105
    /**
106
     * Thiết lập thời gian phát sinh giao dịch tại VNPay.
107
     *
108
     * @param  null|string  $date
109
     * @return $this
110
     */
111
    public function setVnpTransDate(?string $date)
112
    {
113
        return $this->setParameter('vnp_TransDate', $date);
114
    }
115
116
    /**
117
     * {@inheritdoc}
118
     */
119
    protected function getSignatureParameters(): array
120
    {
121
        $parameters = [
122
            'vnp_Version', 'vnp_Command', 'vnp_TmnCode', 'vnp_TxnRef', 'vnp_OrderInfo', 'vnp_TransDate',
123
            'vnp_CreateDate', 'vnp_IpAddr',
124
        ];
125
126
        if ($this->getVnpTransactionNo()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->getVnpTransactionNo() of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
127
            $parameters[] = 'vnp_TransactionNo';
128
        }
129
130
        return $parameters;
131
    }
132
}
133