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/RefundRequest.php (8 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
 * OKPAY driver for Omnipay PHP payment library.
4
 *
5
 * @link      https://github.com/hiqdev/omnipay-okpay
6
 * @package   omnipay-okpay
7
 * @license   MIT
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace Omnipay\OKPAY\Message;
12
13
use Omnipay\Common\Exception\InvalidRequestException;
14
15
class RefundRequest extends AbstractRequest
16
{
17
    protected $endpoint = 'https://api.okpay.com/OkPayAPI?wsdl';
18
19 1
    public function getSecret()
20
    {
21 1
        return $this->getParameter('secret');
22
    }
23
24 2
    public function setSecret($value)
25
    {
26 2
        return $this->setParameter('secret', $value);
27
    }
28
29
    public function getPayeeAccount()
30
    {
31
        return $this->getParameter('payeeAccount');
32
    }
33
34
    public function setPayeeAccount($value)
35
    {
36
        return $this->setParameter('payeeAccount', $value);
37
    }
38
39
    public function getData()
40
    {
41
        $this->validate('purse', 'payeeAccount', 'amount', 'secret', 'description');
42
43
        $data['secret'] = $this->getSecret();
0 ignored issues
show
Coding Style Comprehensibility introduced by
$data was never initialized. Although not strictly required by PHP, it is generally a good practice to add $data = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
44
        $data['walletId'] = $this->getPurse();
45
        $data['receiver'] = $this->getPayeeAccount();
46
        $data['amount'] = $this->getAmount();
47
        $data['currency'] = $this->getCurrency();
48
        $data['description'] = $this->getDescription();
49
50
        return $data;
51
    }
52
53
    public function sendData($data)
54
    {
55
        $response = $this->soapCall($data);
56
57
        return $this->response = new RefundResponse($this, $response);
58
    }
59
60
    private function soapCall($data)
61
    {
62
        $datePart = gmdate('Ymd');
63
        $timePart = gmdate('H');
64
        $authString = "{$data['secret']}:{$datePart}:{$timePart}";
65
66
        $sha256 = bin2hex(hash('sha256', $authString, true));
67
        $secToken = strtoupper($sha256);
68
69
        try {
70
            $client = new \SoapClient(
71
                $this->endpoint, [
72
                    'soap_version' => SOAP_1_1,
73
                    'stream_context' => stream_context_create(
74
                        [
75
                            'ssl' => [
76
                                'verify_peer' => false,
77
                                'verify_peer_name' => false,
78
                            ],
79
                        ]
80
                    ),
81
                ]
82
            );
83
84
            $this->WalletID = $data['walletId'];
0 ignored issues
show
The property WalletID does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
85
            $this->SecurityToken = $secToken;
0 ignored issues
show
The property SecurityToken does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
86
            $this->Currency = $data['currency'];
0 ignored issues
show
The property Currency does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
87
            $this->Receiver = $data['receiver'];
0 ignored issues
show
The property Receiver does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
88
            $this->Amount = $data['amount'];
0 ignored issues
show
The property Amount does not seem to exist. Did you mean negativeAmountAllowed?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
89
            $this->Comment = $data['description'];
0 ignored issues
show
The property Comment does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
90
            $this->IsReceiverPaysFees = false;
0 ignored issues
show
The property IsReceiverPaysFees does not seem to exist. Did you mean Receiver?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
91
92
            $webService = $client->Send_Money($this);
93
            $wsResult = $webService->Send_MoneyResult;
94
95
            return $wsResult;
96
        } catch (\Exception $e) {
97
            throw new InvalidRequestException($e->getMessage());
98
        }
99
    }
100
}
101