Issues (33)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/Processor/AbstractMessageProcessor.php (3 issues)

1
<?php
2
namespace NeedleProject\LaravelRabbitMq\Processor;
3
4
use PhpAmqpLib\Message\AMQPMessage;
5
use Psr\Log\LoggerAwareInterface;
6
use Psr\Log\LoggerAwareTrait;
7
8
/**
9
 * Class AbstractMessageProcessor
10
 *
11
 * @package NeedleProject\LaravelRabbitMq\Processor
12
 * @author  Adrian tilita <[email protected]>
13
 */
14
abstract class AbstractMessageProcessor implements MessageProcessorInterface, LoggerAwareInterface
15
{
16
    use LoggerAwareTrait;
17
18
    /**
19
     * @const string Key used on message to identify if we ack/nack via the child
20
     */
21
    const HANDLED_PROPERTY = 'handled_property';
22
23
    /**
24
     * @var int
25
     */
26
    private $messageCount = 0;
27
28
    /**
29
     * {@inheritdoc}
30
     * @param AMQPMessage $message
31
     */
32
    public function consume(AMQPMessage $message)
33
    {
34
        $this->messageCount++;
35
        try {
36
            $response = $this->processMessage($message);
37
            // Already ack/nack from inside the processor using
38
            // the protected methods ::ack / ::nack
39
            if (property_exists($message, self::HANDLED_PROPERTY)) {
40
                $this->logger->debug("Already handled!");
0 ignored issues
show
The method debug() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
                $this->logger->/** @scrutinizer ignore-call */ 
41
                               debug("Already handled!");

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
41
                return;
42
            }
43
            if ($response === true) {
44
                $this->ack($message);
45
            } else {
46
                $this->nack($message);
47
            }
48
        } catch (\Throwable $e) {
49
            $this->logger->error(
50
                sprintf(
51
                    "Could not process message, got %s from %s in %d for message: %s",
52
                    get_class($e) . '-' . $e->getMessage(),
53
                    (string)$e->getFile(),
54
                    (int)$e->getLine(),
55
                    (string)$message->getBody()
56
                )
57
            );
58
            $this->nack($message);
59
        }
60
    }
61
62
    /**
63
     * @param AMQPMessage $message
64
     */
65
    protected function ack(AMQPMessage $message)
66
    {
67
        try {
68
            $this->logger->debug(sprintf("Processed with success message %s", $message->getBody()));
69
            $message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']);
0 ignored issues
show
Deprecated Code introduced by
The property PhpAmqpLib\Message\AMQPMessage::$delivery_info has been deprecated: Will be removed in version 4.0, use one of getters to get delivery info. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

69
            /** @scrutinizer ignore-deprecated */ $message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']);

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
70
            $message->{self::HANDLED_PROPERTY} = true;
71
        } catch (\Throwable $e) {
72
            $this->logger->error(
73
                sprintf(
74
                    "Could not process message, got %s from %s in %d for message: %s",
75
                    get_class($e) . '-' . $e->getMessage(),
76
                    (string)$e->getFile(),
77
                    (int)$e->getLine(),
78
                    (string)$message->getBody()
79
                )
80
            );
81
        }
82
    }
83
84
    /**
85
     * @param AMQPMessage $message
86
     * @param bool $redeliver
87
     */
88
    protected function nack(AMQPMessage $message, bool $redeliver = true)
89
    {
90
        try {
91
            $this->logger->debug(sprintf("Did not processed with success message %s", $message->getBody()));
92
            $message->delivery_info['channel']->basic_nack($message->delivery_info['delivery_tag'], false, $redeliver);
0 ignored issues
show
Deprecated Code introduced by
The property PhpAmqpLib\Message\AMQPMessage::$delivery_info has been deprecated: Will be removed in version 4.0, use one of getters to get delivery info. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

92
            $message->delivery_info['channel']->basic_nack(/** @scrutinizer ignore-deprecated */ $message->delivery_info['delivery_tag'], false, $redeliver);

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
93
            $message->{self::HANDLED_PROPERTY} = true;
94
        } catch (\Throwable $e) {
95
            $this->logger->debug(sprintf("Did not processed with success message %s", $message->getBody()));
96
        }
97
    }
98
99
    /**
100
     * @return int
101
     */
102
    public function getProcessedMessages(): int
103
    {
104
        return $this->messageCount;
105
    }
106
107
    /**
108
     * @param AMQPMessage $message
109
     * @return bool
110
     */
111
    abstract public function processMessage(AMQPMessage $message): bool;
112
}
113