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/AMQP091/Queue.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
namespace ButterAMQP\AMQP091;
4
5
use ButterAMQP\AMQP091\Framing\Frame;
6
use ButterAMQP\AMQP091\Framing\Method\QueueBind;
7
use ButterAMQP\AMQP091\Framing\Method\QueueBindOk;
8
use ButterAMQP\AMQP091\Framing\Method\QueueDeclare;
9
use ButterAMQP\AMQP091\Framing\Method\QueueDeclareOk;
10
use ButterAMQP\AMQP091\Framing\Method\QueueDelete;
11
use ButterAMQP\AMQP091\Framing\Method\QueueDeleteOk;
12
use ButterAMQP\AMQP091\Framing\Method\QueuePurge;
13
use ButterAMQP\AMQP091\Framing\Method\QueuePurgeOk;
14
use ButterAMQP\AMQP091\Framing\Method\QueueUnbind;
15
use ButterAMQP\AMQP091\Framing\Method\QueueUnbindOk;
16
use ButterAMQP\QueueInterface;
17
18
class Queue implements QueueInterface
19
{
20
    /**
21
     * @var WireInterface
22
     */
23
    private $wire;
24
25
    /**
26
     * @var int
27
     */
28
    private $channel;
29
30
    /**
31
     * @var string
32
     */
33
    private $name;
34
35
    /**
36
     * @var int|null
37
     */
38
    private $messageCount;
39
40
    /**
41
     * @var int|null
42
     */
43
    private $consumerCount;
44
45
    /**
46
     * @param WireInterface $wire
47
     * @param int           $channel
48
     * @param string        $name
49
     */
50 25
    public function __construct(WireInterface $wire, $channel, $name)
51
    {
52 25
        $this->wire = $wire;
53 25
        $this->channel = $channel;
54 25
        $this->name = $name;
55 25
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60 15
    public function define($flags = 0, array $arguments = [])
61
    {
62 15
        $this->send(new QueueDeclare(
63 15
            $this->channel,
64 15
            0,
65 15
            $this->name,
66 15
            $flags & self::FLAG_PASSIVE,
67 15
            $flags & self::FLAG_DURABLE,
68 15
            $flags & self::FLAG_EXCLUSIVE,
69 15
            $flags & self::FLAG_AUTO_DELETE,
70 15
            $flags & self::FLAG_NO_WAIT,
71
            $arguments
72 15
        ));
73
74 15
        if ($flags & self::FLAG_NO_WAIT) {
75 1
            return $this;
76
        }
77
78
        /** @var QueueDeclareOk $frame */
79 14
        $frame = $this->wait(QueueDeclareOk::class);
80
81 14
        $this->name = $frame->getQueue();
82 14
        $this->messageCount = $frame->getMessageCount();
83 14
        $this->consumerCount = $frame->getConsumerCount();
84
85 14
        return $this;
86
    }
87
88
    /**
89
     * {@inheritdoc}
90
     */
91 3
    public function delete($flags = 0)
92
    {
93 3
        $this->send(new QueueDelete(
94 3
            $this->channel,
95 3
            0,
96 3
            $this->name,
97 3
            $flags & self::FLAG_IF_UNUSED,
98 3
            $flags & self::FLAG_IF_EMPTY,
99
            $flags & self::FLAG_NO_WAIT
100 3
        ));
101
102 3
        if ($flags & self::FLAG_NO_WAIT) {
103 1
            return $this;
104
        }
105
106
        /** @var QueueDeleteOk $frame */
107 2
        $frame = $this->wait(QueueDeleteOk::class);
108
109 2
        $this->messageCount = $frame->getMessageCount();
110
111 2
        return $this;
112
    }
113
114
    /**
115
     * {@inheritdoc}
116
     */
117 4 View Code Duplication
    public function bind($exchange, $routingKey = '', array $arguments = [], $flags = 0)
0 ignored issues
show
This method seems to be duplicated in 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...
118
    {
119 4
        $this->send(new QueueBind(
120 4
            $this->channel,
121 4
            0,
122 4
            $this->name,
123 4
            (string) $exchange,
124 4
            $routingKey,
125 4
            $flags & self::FLAG_NO_WAIT,
126
            $arguments
127 4
        ));
128
129 4
        if (!($flags & self::FLAG_NO_WAIT)) {
130 3
            $this->wait(QueueBindOk::class);
131 3
        }
132
133 4
        return $this;
134
    }
135
136
    /**
137
     * {@inheritdoc}
138
     */
139 1
    public function unbind($exchange, $routingKey = '', array $arguments = [])
140
    {
141 1
        $this->send(new QueueUnbind(
142 1
            $this->channel,
143 1
            0,
144 1
            $this->name,
145 1
            $exchange,
146 1
            $routingKey,
147
            $arguments
148 1
        ));
149
150 1
        $this->wait(QueueUnbindOk::class);
151
152 1
        return $this;
153
    }
154
155
    /**
156
     * {@inheritdoc}
157
     */
158 2
    public function purge($flags = 0)
159
    {
160 2
        $this->send(new QueuePurge(
161 2
            $this->channel,
162 2
            0,
163 2
            $this->name,
164 2
            (bool) ($flags & self::FLAG_NO_WAIT)
165 2
        ));
166
167 2
        if ($flags & self::FLAG_NO_WAIT) {
168 1
            return $this;
169
        }
170
171
        /** @var QueuePurgeOk $frame */
172 1
        $frame = $this->wait(QueuePurgeOk::class);
173
174 1
        $this->messageCount = $frame->getMessageCount();
175
176 1
        return $this;
177
    }
178
179
    /**
180
     * {@inheritdoc}
181
     */
182 4
    public function name()
183
    {
184 4
        return $this->name;
185
    }
186
187
    /**
188
     * {@inheritdoc}
189
     */
190 7
    public function messagesCount()
191
    {
192 7
        return $this->messageCount;
193
    }
194
195
    /**
196
     * {@inheritdoc}
197
     */
198 1
    public function consumerCount()
199
    {
200 1
        return $this->consumerCount;
201
    }
202
203
    /**
204
     * @return string
205
     */
206 14
    public function __toString()
207
    {
208 14
        return $this->name;
209
    }
210
211
    /**
212
     * @param Frame $frame
213
     *
214
     * @return $this
215
     */
216 22
    private function send(Frame $frame)
217
    {
218 22
        $this->wire->send($frame);
219
220 22
        return $this;
221
    }
222
223
    /**
224
     * @param string|array $type
225
     *
226
     * @return Frame
227
     */
228 18
    private function wait($type)
229
    {
230 18
        return $this->wire->wait($this->channel, $type);
231
    }
232
}
233