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/Channel.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
namespace devtransition\rabbitmq\base;
4
5
use PhpAmqpLib\Channel\AMQPChannel;
6
use PhpAmqpLib\Message\AMQPMessage;
7
use yii\base\Component;
8
use yii\helpers\ArrayHelper;
9
10
11
class Channel extends Component
12
{
13
    const EXCHANGE_TYPE_TOPIC = 'topic';
14
    const EXCHANGE_TYPE_DIRECT = 'direct';
15
    const EXCHANGE_TYPE_HEADERS = 'headers';
16
    const EXCHANGE_TYPE_FANOUT = 'fanout';
17
18
    /**
19
     * @var Connection
20
     */
21
    protected $connection;
22
23
    /**
24
     * @var AMQPChannel
25
     */
26
    protected $amqpChannel;
27
28
    /**
29
     * @inheritdoc
30
     */
31
    public function __construct(ConnectionInterface $connection, $config = [])
32
    {
33
        $this->connection = $connection;
0 ignored issues
show
Documentation Bug introduced by
$connection is of type object<devtransition\rab...se\ConnectionInterface>, but the property $connection was declared to be of type object<devtransition\rabbitmq\base\Connection>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
34
        $this->amqpChannel = $this->connection->getAmqpInstance()->channel();
35
        parent::__construct($config);
36
    }
37
38
    public function __destruct()
39
    {
40
        $this->amqpChannel->close();
41
    }
42
43
    /**
44
     * Server should continue sending data to us. Default on new channels.
45
     */
46
    public function enableFlow()
47
    {
48
        $this->amqpChannel->flow(true);
49
    }
50
51
    /**
52
     * Server should stop sending data to us.
53
     */
54
    public function disableFlow()
55
    {
56
        $this->amqpChannel->flow(true);
57
    }
58
59
    public function send()
60
    {
61
        $msg = new AMQPMessage('test');
62
        $this->amqpChannel->basic_publish($msg, '', 'test');
63
    }
64
65
    public function getMessageOne($queue, $no_ack = false)
66
    {
67
        $msg = $this->amqpChannel->basic_get($queue, $no_ack = false);
68
        if ($msg instanceof AMQPMessage) {
69
            $res = new AMQPMessage();
70
            return $res;
71
        }
72
73
        throw new InvalidValueException("response was not a valid amqp message object");
74
    }
75
76
    public function getMessageConsume($queue, Callable $callback, Array $options = [])
77
    {
78
        return $this->amqpChannel->basic_consume(
79
            $queue = '',
80
            $consumer_tag = ArrayHelper::getValue($options, 'consumer_tag', ''),
81
            $no_local = ArrayHelper::getValue($options, 'no_local', false),
82
            $no_ack = ArrayHelper::getValue($options, 'no_ack', false),
83
            $exclusive = ArrayHelper::getValue($options, 'exclusive', false),
84
            $nowait = ArrayHelper::getValue($options, 'nowait', false),
85
            $callback,
86
            $ticket = null,
87
            $arguments = array()
88
        );
89
90
        /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
91
        while (count($this->channel->callbacks)) {
92
            $this->channel->wait();
93
        }
94
        */
95
96
    }
97
98
    public function declareExchange($name, $type, $passive = false, $durable = false, $auto_delete = true, $internal = false)
99
    {
100
        return $this->amqpChannel->exchange_declare($name, $type, $passive, $durable, $auto_delete, $internal);
101
    }
102
103
    public function deleteExchange($name, $if_unused = false, $if_empty = false, $nowait = false)
104
    {
105
        return $this->amqpChannel->exchange_delete($name, $if_unused, $if_empty, $nowait);
106
    }
107
108
    public function declareQueue($name, $passive = false, $durable = false, $auto_delete = true, $internal = false)
109
    {
110
        return $this->amqpChannel->queue_declare($name, $passive, $durable, $auto_delete, $internal);
111
    }
112
113
    public function deleteQueue($name, $if_unused = false, $if_empty = false, $nowait = false)
114
    {
115
        return $this->amqpChannel->queue_delete($name, $if_unused, $if_empty, $nowait);
116
    }
117
118
    public function purgeQueue($name, $nowait = false)
119
    {
120
        return $this->amqpChannel->queue_purge($name, $nowait);
121
    }
122
123
    public function bindQueueExchange($queue, $exchange, $routing_key)
124
    {
125
        return $this->amqpChannel->queue_bind($queue, $exchange, $routing_key);
126
    }
127
}
128