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.

tests/unit/Command/BaseConsumerCommandTest.php (3 issues)

1
<?php
2
namespace NeedleProject\LaravelRabbitMq\Command;
3
4
use PHPUnit\Framework\TestCase;
5
use NeedleProject\LaravelRabbitMq\ConsumerInterface;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Console\Style\SymfonyStyle;
9
10
class BaseConsumerCommandTest extends TestCase
11
{
12
    public function testHandleCollaboration()
13
    {
14
        $consumerMock = $this->createMock(ConsumerInterface::class);
15
        $inputInterfaceMock = $this->createMock(InputInterface::class);
16
        $outputInterfaceMock = $this->createMock(OutputInterface::class);
17
18
        $consumerCommand = new class($consumerMock, $inputInterfaceMock, $outputInterfaceMock) extends BaseConsumerCommand {
19
20
            private $consumerMock = null;
21
22
            public function __construct($consumerMock, $inputInterfaceMock, $outputInterfaceMock)
23
            {
24
                $this->input = $inputInterfaceMock;
25
                $this->output = $outputInterfaceMock;
26
                $this->consumerMock = $consumerMock;
27
            }
28
29
            protected function getConsumer(string $consumerAliasName): ConsumerInterface
30
            {
31
                return $this->consumerMock;
32
            }
33
        };
34
35
        // actual collaboration scenarios
36
        $inputInterfaceMock->expects($this->exactly(3))
37
            ->method('getOption')
38
            ->with($this->logicalOr(
39
                $this->equalTo('time'),
40
                $this->equalTo('messages'),
41
                $this->equalTo('memory')
42
            ))
43
            ->will($this->returnCallback(function () {
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\TestCase::returnCallback() has been deprecated: Use <code>$double->willReturnCallback()</code> instead of <code>$double->will($this->returnCallback())</code> ( Ignorable by Annotation )

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

43
            ->will(/** @scrutinizer ignore-deprecated */ $this->returnCallback(function () {

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

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

Loading history...
44
                switch (func_get_arg(0)) {
45
                    case 'messages':
46
                        return 10;
47
                        break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
48
                    case 'time':
49
                        return 20;
50
                        break;
51
                    case 'memory':
52
                        return 128;
53
                        break;
54
                    case 'consumer':
55
                        return 'fooBar';
56
                        break;
57
                }
58
            }));
59
        $inputInterfaceMock->expects($this->once())
60
            ->method('getArgument')
61
            ->willReturn('fooBar');
62
63
        $consumerMock->expects($this->once())
64
            ->method('startConsuming')
65
            ->with(10, 20, 128)
66
            ->willReturn(null);
67
68
        $consumerCommand->handle();
69
    }
70
71
    public function testFailConsumeCollaboration()
72
    {
73
        $consumerMock = $this->createMock(ConsumerInterface::class);
74
        $inputInterfaceMock = $this->createMock(InputInterface::class);
75
        $outputInterfaceMock = $this->createMock(SymfonyStyle::class);
76
77
        $consumerCommand = new class($consumerMock, $inputInterfaceMock, $outputInterfaceMock) extends BaseConsumerCommand {
78
79
            private $consumerMock = null;
80
81
            public function __construct($consumerMock, $inputInterfaceMock, $outputInterfaceMock)
82
            {
83
                $this->input = $inputInterfaceMock;
84
                $this->consumerMock = $consumerMock;
85
                $this->output = $outputInterfaceMock;
86
            }
87
88
            protected function getConsumer(string $consumerAliasName): ConsumerInterface
89
            {
90
                return $this->consumerMock;
91
            }
92
        };
93
94
        // actual collaboration scenarios
95
        $inputInterfaceMock->expects($this->exactly(3))
96
            ->method('getOption')
97
            ->will($this->returnValue(2));
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\TestCase::returnValue() has been deprecated: Use <code>$double->willReturn()</code> instead of <code>$double->will($this->returnValue())</code> ( Ignorable by Annotation )

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

97
            ->will(/** @scrutinizer ignore-deprecated */ $this->returnValue(2));

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

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

Loading history...
98
        $inputInterfaceMock->expects($this->once())
99
            ->method('getArgument')
100
            ->willReturn('fooBar');
101
102
        $consumerMock->expects($this->once())
103
            ->method('startConsuming')
104
            ->will($this->throwException(new \Exception('foo')));
105
106
        $outputInterfaceMock->expects($this->once())
107
            ->method('error')
108
            ->with('foo')
109
            ->willReturn(null);
110
111
        $consumerCommand->handle();
112
    }
113
}
114