Issues (1507)

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.

PHPDaemon/Clients/AMQP/Message.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 PHPDaemon\Clients\AMQP;
4
5
use PHPDaemon\Clients\AMQP\Driver\Exception\AMQPMessageException;
6
use PHPDaemon\Clients\AMQP\Driver\Protocol\ExchangeInterface;
7
use PHPDaemon\Clients\AMQP\Driver\Protocol\QueueInterface;
8
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\Basic\BasicAckFrame;
9
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\Basic\BasicNackFrame;
10
use PHPDaemon\Clients\AMQP\Driver\Protocol\v091\Protocol\Basic\BasicRejectFrame;
11
12
/**
13
 * Class Message
14
 * @author Aleksey I. Kuleshov YOU GLOBAL LIMITED
15
 * @package PHPDaemon\Clients\AMQP
16
 */
17
class Message
18
{
19
20
    /**
21
     * @var int
22
     */
23
    protected $contentLength;
24
25
    /**
26
     * @var string
27
     */
28
    protected $contentType;
29
30
    /**
31
     * @var string
32
     */
33
    protected $contentEncoding;
34
35
    /**
36
     * @var int
37
     */
38
    protected $tag;
39
40
    /**
41
     * @var bool
42
     */
43
    protected $isDelivered = false;
44
45
    /**
46
     * @var ExchangeInterface
47
     */
48
    protected $exchange;
49
50
    /**
51
     * @var string
52
     */
53
    protected $routingKey;
54
55
    /**
56
     * @var QueueInterface
57
     */
58
    protected $queue;
59
60
    /**
61
     * @var Channel
62
     */
63
    protected $channel;
64
65
    /**
66
     * @var array
67
     */
68
    protected $headers = [];
69
70
    /**
71
     * @var string
72
     */
73
    protected $messageId;
74
75
    /**
76
     * @var int
77
     */
78
    protected $deliveryMode;
79
80
    /**
81
     * @var int
82
     */
83
    protected $priority;
84
85
    /**
86
     * @var string
87
     */
88
    protected $correlationId;
89
90
    /**
91
     * @var string
92
     */
93
    protected $replyTo;
94
95
    /**
96
     * @var string
97
     */
98
    protected $expiration;
99
100
    /**
101
     * @var int
102
     */
103
    protected $timestamp;
104
105
    /**
106
     * @var string
107
     */
108
    protected $type;
109
110
    /**
111
     * @var string
112
     */
113
    protected $userId;
114
115
    /**
116
     * @var string
117
     */
118
    protected $appId;
119
120
    /**
121
     * @var string
122
     */
123
    protected $clusterId;
124
125
    /**
126
     * @var string
127
     */
128
    protected $content;
129
130
    /**
131
     * Acknowledge the message.
132
     *
133
     * @throws \InvalidArgumentException
134
     * @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
135
     * @throws \PHPDaemon\Clients\AMQP\Driver\Exception\AMQPMessageException
136
     */
137
    public function ack()
138
    {
139
        $this->checkChannel();
140
141
        $outputFrame = BasicAckFrame::create($this->tag);
142
        $outputFrame->frameChannelId = $this->channel->getId();
143
144
        $this->channel->getConnection()->command($outputFrame);
145
    }
146
147
    /**
148
     * Not Acknowledge the message.
149
     *
150
     * @param null $multiple
151
     * @param null $requeue
152
     * @throws \InvalidArgumentException
153
     * @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
154
     */
155 View Code Duplication
    public function nack($multiple = null, $requeue = null)
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...
156
    {
157
        $this->checkChannel();
158
159
        $outputFrame = BasicNackFrame::create($this->tag, $multiple, $requeue);
160
        $outputFrame->frameChannelId = $this->channel->getId();
161
        $this->channel->getConnection()->command($outputFrame);
162
    }
163
164
    /**
165
     * Reject the message and requeue it.
166
     *
167
     * @see ConsumerOptionsInterface::$noAck to consume messages without requiring
168
     *      excplicit acknowledgement by the consumer.
169
     *
170
     * @param bool $requeue
171
     * @throws \InvalidArgumentException
172
     * @throws \PHPDaemon\Clients\AMQP\Driver\Protocol\Exception\AMQPProtocolException
173
     * @throws \PHPDaemon\Clients\AMQP\Driver\Exception\AMQPMessageException
174
     */
175 View Code Duplication
    public function reject($requeue = true)
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...
176
    {
177
        $this->checkChannel();
178
179
        $outputFrame = BasicRejectFrame::create($this->tag, $requeue);
180
        $outputFrame->frameChannelId = $this->channel->getId();
181
        if (null !== $requeue) {
182
            $outputFrame->requeue = $requeue;
183
        }
184
        $this->channel->getConnection()->command($outputFrame);
185
    }
186
187
    /**
188
     * Get the length of the message content, in bytes.
189
     * @return int
190
     */
191
    public function getContentLength()
192
    {
193
        return $this->contentLength;
194
    }
195
196
    /**
197
     * Set the length of the message content, in bytes.
198
     * @param int $contentLength
199
     * @return Message
200
     */
201
    public function setContentLength($contentLength)
202
    {
203
        $this->contentLength = $contentLength;
204
        return $this;
205
    }
206
207
    /**
208
     * @return string
209
     */
210
    public function getContentType()
211
    {
212
        return $this->contentType;
213
    }
214
215
    /**
216
     * @param string $contentType
217
     * @return $this
218
     */
219
    public function setContentType($contentType)
220
    {
221
        $this->contentType = $contentType;
222
        return $this;
223
    }
224
225
    /**
226
     * @return string
227
     */
228
    public function getContentEncoding()
229
    {
230
        return $this->contentEncoding;
231
    }
232
233
    /**
234
     * @param string $contentEncoding
235
     * @return $this
236
     */
237
    public function setContentEncoding($contentEncoding)
238
    {
239
        $this->contentEncoding = $contentEncoding;
240
        return $this;
241
    }
242
243
    /**
244
     * Get the delivery tag.
245
     * @return int
246
     */
247
    public function getTag()
248
    {
249
        return $this->tag;
250
    }
251
252
    /**
253
     * Set the delivery tag.
254
     * @param int $tag
255
     * @return Message
256
     */
257
    public function setTag($tag)
258
    {
259
        $this->tag = $tag;
260
        return $this;
261
    }
262
263
    /**
264
     * Check if the message has previously been delivered to a consumer but was
265
     * implicitly or explicitly rejected.
266
     * @return bool
267
     */
268
    public function isRedelivered()
269
    {
270
        return $this->isDelivered;
271
    }
272
273
    /**
274
     * Get the name of the exchange that the message was published to.
275
     * @return ExchangeInterface
276
     */
277
    public function getExchange()
278
    {
279
        return $this->exchange;
280
    }
281
282
    /**
283
     * Set the name of the exchange that the message was published to.
284
     * @param ExchangeInterface $exchange
285
     * @return Message
286
     */
287
    public function setExchange($exchange)
288
    {
289
        $this->exchange = $exchange;
290
        return $this;
291
    }
292
293
    /**
294
     * Get the routing key used when the message was published.
295
     * @return  string
296
     */
297
    public function getRoutingKey()
298
    {
299
        return $this->routingKey;
300
    }
301
302
    /**
303
     * Set the routing key used when the message was published.
304
     * @param $routingKey
305
     * @return Message
306
     */
307
    public function setRoutingKey($routingKey)
308
    {
309
        $this->routingKey = $routingKey;
310
        return $this;
311
    }
312
313
    /**
314
     * @return QueueInterface
315
     */
316
    public function getQueue()
317
    {
318
        return $this->queue;
319
    }
320
321
    /**
322
     * @param QueueInterface $queue
323
     * @return $this
324
     */
325
    public function setQueue($queue)
326
    {
327
        $this->queue = $queue;
328
        return $this;
329
    }
330
331
    /**
332
     * @return Channel
333
     */
334
    public function getChannel()
335
    {
336
        return $this->channel;
337
    }
338
339
    /**
340
     * @param Channel $channel
341
     * @return $this
342
     */
343
    public function setChannel($channel)
344
    {
345
        $this->channel = $channel;
346
        return $this;
347
    }
348
349
    /**
350
     * @return string
351
     */
352
    public function getContent()
353
    {
354
        return $this->content;
355
    }
356
357
    /**
358
     * @param string $content
359
     * @return $this
360
     */
361
    public function setContent($content)
362
    {
363
        $this->content = $content;
364
        return $this;
365
    }
366
367
    /**
368
     * Проеряет, что канал еще жив
369
     *
370
     * @throws AMQPMessageException
371
     */
372
    private function checkChannel()
373
    {
374
        if (!$this->channel->isConnected()) {
375
            throw new AMQPMessageException('Channel is closed');
376
        }
377
378
        if (null === $this->channel->getId()) {
379
            throw new AMQPMessageException('AMQPChannel id not found');
380
        }
381
382
        return true;
383
    }
384
385
    /**
386
     * @return string
387
     */
388
    public function getCorrelationId()
389
    {
390
        return $this->correlationId;
391
    }
392
393
    /**
394
     * @param string $correlationId
395
     * @return $this
396
     */
397
    public function setCorrelationId($correlationId)
398
    {
399
        $this->correlationId = $correlationId;
400
        return $this;
401
    }
402
403
    /**
404
     * @return string
405
     */
406
    public function getReplyTo()
407
    {
408
        return $this->replyTo;
409
    }
410
411
    /**
412
     * @param string $replyTo
413
     * @return $this
414
     */
415
    public function setReplyTo($replyTo)
416
    {
417
        $this->replyTo = $replyTo;
418
        return $this;
419
    }
420
421
    /**
422
     * @return bool
423
     */
424
    public function isDelivered()
425
    {
426
        return $this->isDelivered;
427
    }
428
429
    /**
430
     * @param bool $isDelivered
431
     * @return $this
432
     */
433
    public function setIsDelivered($isDelivered)
434
    {
435
        $this->isDelivered = $isDelivered;
436
        return $this;
437
    }
438
439
    /**
440
     * @return array
441
     */
442
    public function getHeaders()
443
    {
444
        return $this->headers;
445
    }
446
447
    /**
448
     * @param array $headers
449
     * @return $this
450
     */
451
    public function setHeaders($headers)
452
    {
453
        $this->headers = $headers;
454
        return $this;
455
    }
456
457
    /**
458
     * @return string
459
     */
460
    public function getMessageId()
461
    {
462
        return $this->messageId;
463
    }
464
465
    /**
466
     * @param string $messageId
467
     * @return $this
468
     */
469
    public function setMessageId($messageId)
470
    {
471
        $this->messageId = $messageId;
472
        return $this;
473
    }
474
475
    /**
476
     * @return int
477
     */
478
    public function getDeliveryMode()
479
    {
480
        return $this->deliveryMode;
481
    }
482
483
    /**
484
     * @param int $deliveryMode
485
     * @return $this
486
     */
487
    public function setDeliveryMode($deliveryMode)
488
    {
489
        $this->deliveryMode = $deliveryMode;
490
        return $this;
491
    }
492
493
    /**
494
     * @return int
495
     */
496
    public function getPriority()
497
    {
498
        return $this->priority;
499
    }
500
501
    /**
502
     * @param int $priority
503
     * @return $this
504
     */
505
    public function setPriority($priority)
506
    {
507
        $this->priority = $priority;
508
        return $this;
509
    }
510
511
    /**
512
     * @return string
513
     */
514
    public function getExpiration()
515
    {
516
        return $this->expiration;
517
    }
518
519
    /**
520
     * @param string $expiration
521
     * @return $this
522
     */
523
    public function setExpiration($expiration)
524
    {
525
        $this->expiration = $expiration;
526
        return $this;
527
    }
528
529
    /**
530
     * @return int
531
     */
532
    public function getTimestamp()
533
    {
534
        return $this->timestamp;
535
    }
536
537
    /**
538
     * @param int $timestamp
539
     * @return $this
540
     */
541
    public function setTimestamp($timestamp)
542
    {
543
        $this->timestamp = $timestamp;
544
        return $this;
545
    }
546
547
    /**
548
     * @return string
549
     */
550
    public function getType()
551
    {
552
        return $this->type;
553
    }
554
555
    /**
556
     * @param string $type
557
     * @return $this
558
     */
559
    public function setType($type)
560
    {
561
        $this->type = $type;
562
        return $this;
563
    }
564
565
    /**
566
     * @return string
567
     */
568
    public function getUserId()
569
    {
570
        return $this->userId;
571
    }
572
573
    /**
574
     * @param string $userId
575
     * @return $this
576
     */
577
    public function setUserId($userId)
578
    {
579
        $this->userId = $userId;
580
        return $this;
581
    }
582
583
    /**
584
     * @return string
585
     */
586
    public function getAppId()
587
    {
588
        return $this->appId;
589
    }
590
591
    /**
592
     * @param string $appId
593
     * @return $this
594
     */
595
    public function setAppId($appId)
596
    {
597
        $this->appId = $appId;
598
        return $this;
599
    }
600
601
    /**
602
     * @return string
603
     */
604
    public function getClusterId()
605
    {
606
        return $this->clusterId;
607
    }
608
609
    /**
610
     * @param string $clusterId
611
     * @return $this
612
     */
613
    public function setClusterId($clusterId)
614
    {
615
        $this->clusterId = $clusterId;
616
        return $this;
617
    }
618
}
619