Issues (42)

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/baokim/VerifiedData.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
 * @link https://github.com/yiiviet/yii2-payment
4
 * @copyright Copyright (c) 2017 Yii Viet
5
 * @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
6
 */
7
8
namespace yiiviet\payment\baokim;
9
10
use yii\base\InvalidConfigException;
11
use yii\helpers\ArrayHelper;
12
13
use yiiviet\payment\VerifiedData as BaseVerifiedData;
14
15
/**
16
 * Lớp VerifiedData cung cấp dữ liệu đã được xác minh từ các truy vấn IPN, success url.
17
 *
18
 * @method PaymentClient getClient() đối tượng client đã dùng để thực thi request.
19
 *
20
 * @property PaymentClient $client đối tượng client đã dùng để thực thi request.
21
 * @property mixed $order_id mã đơn hàng tại hệ thống.
22
 * @property int $created_on thời gian tạo đơn hàng (timestamp).
23
 * @property int $payment_type hình thức khách giao dịch (1 Trực tiếp, 2 Tạm giữ).
24
 * @property int $transaction_status trạng thái giao dịch.
25
 * @property int $total_amount tổng số tiền khách trả.
26
 * @property int $net_amount tổng số tiền thực nhận.
27
 * @property int $fee_amount số tiền phí Bảo Kim thu.
28
 * @property int $merchant_id mã website tích hợp.
29
 * @property int $transaction_id mã giao dịch tại Bảo Kim.
30
 * @property string $payer_name tên người mua, chỉ tồn tại khi phương thức thanh toán thông qua bảo kim không phải `pro`.
31
 * @property string $payer_email email người mua, chỉ tồn tại khi phương thức thanh toán thông qua bảo kim không phải `pro`.
32
 * @property string $payer_phone_no số điện thoại người mua, chỉ tồn tại khi phương thức thanh toán thông qua bảo kim không phải `pro`.
33
 * @property string $shipping_address địa chỉ giao hàng, chỉ tồn tại khi phương thức thanh toán thông qua bảo kim không phải `pro`.
34
 * @property string $customer_name tên người mua, chỉ tồn tại khi phương thức thanh toán `pro`.
35
 * @property string $customer_email email người mua, chỉ tồn tại khi phương thức thanh toán `pro`.
36
 * @property string $customer_phone số điện thoại người mua, chỉ tồn tại khi phương thức thanh toán `pro`.
37
 * @property string $customer_address địa chỉ giao hàng, chỉ tồn tại khi phương thức thanh toán `pro`.
38
 * @property string $merchant_address địa chỉ merchant, chỉ tồn tại khi phương thức thanh toán `pro`.
39
 * @property string $merchant_email email merchant, chỉ tồn tại khi phương thức thanh toán `pro`.
40
 * @property string $merchant_location khu vực merchant, chỉ tồn tại khi phương thức thanh toán `pro`.
41
 * @property string $merchant_name tên người bán (merchant), chỉ tồn tại khi phương thức thanh toán `pro`.
42
 * @property string $merchant_phone số điên thoại người bán, chỉ tồn tại khi phương thức thanh toán `pro`.
43
 * @property string $customer_location khu vực khách hàng, chỉ tồn tại khi phương thức thanh toán `pro`.
44
 *
45
 * @author Vuong Minh <[email protected]>
46
 * @since 1.0
47
 */
48
class VerifiedData extends BaseVerifiedData
49
{
50
51
    /**
52
     * @inheritdoc
53
     */
54 1
    public function rules()
55
    {
56
        return [
57 1
            [['checksum'], 'required', 'on' => PaymentGateway::VRC_PURCHASE_SUCCESS],
58
            [['checksum'], 'verifyChecksum', 'message' => '{attribute} not match', 'on' => PaymentGateway::VRC_PURCHASE_SUCCESS]
59
        ];
60
    }
61
62
    /**
63
     * Phương thức kiểm tra tính hợp lệ của mã `checksum` gửi từ Bảo Kim.
64
     *
65
     * @param string $attribute Chứa giá trị thuộc tính cần kiểm tra.
66
     * @param string $params Mảng thông tin khi thiết lập rule.
67
     * @param \yii\validators\InlineValidator $validator Đối tượng [[\yii\validators\InlineValidator]] đang thực thi kiểm tra dữ liệu.
68
     * @throws \yii\base\NotSupportedException|InvalidConfigException
69
     */
70 1
    public function verifyChecksum($attribute, $params, \yii\validators\InlineValidator $validator)
0 ignored issues
show
The parameter $params is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
71
    {
72
        /** @var PaymentClient $client */
73 1
        $client = $this->getClient();
74 1
        $data = $this->get(false);
75 1
        $expectSignature = ArrayHelper::remove($data, $attribute, false);
76 1
        ksort($data);
77 1
        $dataSign = implode('', $data);
78
79 1 View Code Duplication
        if (!$expectSignature || !$client->validateSignature($dataSign, $expectSignature, PaymentClient::SIGNATURE_HMAC)) {
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...
80 1
            $validator->addError($this, $attribute, $validator->message);
81
        }
82 1
    }
83
84
}
85