Issues (5)

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/base/Connection.php (2 issues)

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
namespace devtransition\rabbitmq\base;
4
5
use PhpAmqpLib\Channel\AMQPChannel;
6
use PhpAmqpLib\Connection\AMQPStreamConnection;
7
use PhpAmqpLib\Connection\AMQPSSLConnection;
8
use yii\base\Component;
9
10
11
/**
12
 * Connection represents an advanced instance of PhpAmqpLibs AMQPStreamConnection.
13
 *
14
 * Connection works together with Channels .... explain..
15
 *
16
 * @property string $host RabbitMQ server hostname or IP address. Defaults to `localhost`.
17
 * @property integer $port TCP-Port where RabbitMQ is listening. Defaults to `5672`.
18
 * @property string $username RabbitMQ server username on connect. Defaults to `guest`.
19
 * @property string $password RabbitMQ server password on connect. Defaults to `guest`.
20
 * @property string $vhost RabbitMQ server virtual host to use. Defaults to `/`.
21
 * @property \PhpAmqpLib\Connection\AMQPStreamConnection $connection The PhpAmqpLib connection instance. This property is read-only.
22
 *
23
 * @author Nicolas Wild <[email protected]>
24
 */
25
class Connection extends Component implements ConnectionInterface
26
{
27
    /**
28
     * @var AMQPStreamConnection
29
     */
30
    public $connection;
31
    /**
32
     * @var string
33
     */
34
    public $host = 'localhost';
35
    /**
36
     * @var integer
37
     */
38
    public $port = 5672;
39
    /**
40
     * @var string
41
     */
42
    public $username = 'guest';
43
    /**
44
     * @var string
45
     */
46
    public $password = '';
47
    /**
48
     * @var string
49
     */
50
    public $vhost = '/';
51
    /**
52
     * @var array
53
     */
54
    public $options = [];
55
    /**
56
     * @var AMQPChannel[]
57
     */
58
    protected $channels = [];
59
60
    /**
61
     * @var AMQPStreamConnection
62
     */
63
    protected $amqpConnection;
64
    /**
65
     * @inheritdoc
66
     */
67
    public function init()
68
    {
69
        parent::init();
70
        $this->_parseOptions();
0 ignored issues
show
The call to the method devtransition\rabbitmq\b...ection::_parseOptions() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
71
        $this->open();
72
    }
73
74
    public function open()
75
    {
76
        /* TODO: Implement options appy and TLS */
77
78
        $this->amqpConnection = new AMQPStreamConnection(
79
            $this->host,
80
            $this->port,
81
            $this->username,
82
            $this->password,
83
            $this->vhost,
84
            $insist = false,
85
            $login_method = 'AMQPLAIN',
86
            $login_response = null,
87
            $locale = 'en_US',
88
            $connection_timeout = 3,
89
            $read_write_timeout = 3,
90
            $context = null,
91
            $keepalive = false,
92
            $heartbeat = 0
93
        );
94
    }
95
96
    public function close()
97
    {
98
        $this->amqpConnection->close();
99
    }
100
101
    public function reconnect()
102
    {
103
        $this->amqpConnection-> reconnect();
104
    }
105
106
    public function isConnected()
107
    {
108
        $this->amqpConnection->isConnected();
0 ignored issues
show
The call to the method PhpAmqpLib\Connection\AM...nnection::isConnected() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
109
    }
110
111
    /**
112
     * Returns low-level AMQP connection instance
113
     *
114
     * @return AMQPStreamConnection|AMQPSSLConnection
115
     */
116
    public function getAmqpInstance()
117
    {
118
        return $this->amqpConnection;
119
    }
120
121
122
    private function _parseOptions()
123
    {
124
        /* TODO: Implement */
125
    }
126
}
127