Issues (80)

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.

Tests/Transport/Rpc/RpcClientOld.php (8 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 Cmobi\RabbitmqBundle\Tests\Transport\Rpc;
4
5
use Cmobi\RabbitmqBundle\Connection\CmobiAMQPChannel;
6
use Cmobi\RabbitmqBundle\Connection\CmobiAMQPConnection;
7
use Cmobi\RabbitmqBundle\Connection\ConnectionManager;
8
use Cmobi\RabbitmqBundle\Queue\CmobiAMQPMessage;
9
use Cmobi\RabbitmqBundle\Transport\Rpc\RpcClient;
10
use Cmobi\RabbitmqBundle\Tests\BaseTestCase;
11
12
class RpcClientTest extends BaseTestCase
13
{
14
    public function testGetQueueName()
15
    {
16
        $rpcClient = new RpcClient('test', $this->getConnectionManagerMock(), 'test');
17
18
        $this->assertEquals('test', $rpcClient->getQueueName());
19
    }
20
21
    public function testRefreshChannel()
22
    {
23
        $rpcClient = new RpcClient('test', $this->getConnectionManagerMock(), 'test');
24
25
        $this->assertInstanceOf(CmobiAMQPChannel::class, $rpcClient->refreshChannel());
0 ignored issues
show
The method refreshChannel() does not seem to exist on object<Cmobi\RabbitmqBun...ransport\Rpc\RpcClient>.

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...
26
    }
27
28
    public function testGetChannel()
29
    {
30
        $rpcClient = new RpcClient('test', $this->getConnectionManagerMock(), 'test');
31
32
        $this->assertInstanceOf(CmobiAMQPChannel::class, $rpcClient->refreshChannel());
0 ignored issues
show
The method refreshChannel() does not seem to exist on object<Cmobi\RabbitmqBun...ransport\Rpc\RpcClient>.

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...
33
    }
34
35
    public function testGetFromName()
36
    {
37
        $rpcClient = new RpcClient('test', $this->getConnectionManagerMock(), 'caller_test');
38
39
        $this->assertEquals('caller_test', $rpcClient->getFromName());
40
    }
41
42 View Code Duplication
    public function testGetResponse()
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...
43
    {
44
        $rpcClient = new RpcClient('test', $this->getConnectionManagerMock(), 'caller_test');
45
46
        $rpcClient->publish('test');
47
        /* @Todo prevent infinite while - improve it */
48
        $rpcClient->setResponse('testGetResponse() - OK');
49
50
        $rpcClient->onResponse(
51
            $this->getCmobiAMQPMessage('testGetResponse() - OK',
52
                $rpcClient->getCurrentCorrelationId())
53
        );
54
55
        $this->assertEquals('testGetResponse() - OK', $rpcClient->getResponse());
56
    }
57
58
    public function testGenerateCorrelationId()
59
    {
60
        $rpcClient = new RpcClient('test', $this->getConnectionManagerMock(), 'caller_test');
61
62
        $this->assertRegExp(sprintf('/%s/', $rpcClient->getCurrentCorrelationId()), $rpcClient->getQueueName());
63
    }
64
65 View Code Duplication
    public function testGetCurrentCorrelationId()
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...
66
    {
67
        $rpcClient = new RpcClient('test', $this->getConnectionManagerMock(), 'caller_test');
68
        /* @Todo prevent infinite while - improve it */
69
        $rpcClient->setResponse('testGetResponse() - OK');
70
71
        $rpcClient->publish('test');
72
        $rpcClient->onResponse(
73
            $this->getCmobiAMQPMessage('testGetResponse() - OK',
74
                $rpcClient->getCurrentCorrelationId())
75
        );
76
        $this->assertNotNull($rpcClient->getCurrentCorrelationId());
77
    }
78
79
    /**
80
     * @return ConnectionManager
81
     */
82 View Code Duplication
    protected function getConnectionManagerMock()
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...
83
    {
84
        $connectionManagerMock = $this->getMockBuilder(ConnectionManager::class)
85
            ->disableOriginalConstructor()
86
            ->getMock();
87
        $connectionManagerMock->method('getConnection')
88
            ->willReturn($this->getConnectionMock());
89
90
        return $connectionManagerMock;
91
    }
92
93
    /**
94
     * @return CmobiAMQPConnection
95
     */
96 View Code Duplication
    protected function getConnectionMock()
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...
97
    {
98
        $connectionMock = $this->getMockBuilder(CmobiAMQPConnection::class)
99
            ->disableOriginalConstructor()
100
            ->getMock();
101
        $connectionMock->method('isConnected')
102
            ->willReturn(true);
103
        $connectionMock->method('reconnect')
104
            ->willReturn(true);
105
        $connectionMock->method('channel')
106
            ->willReturn($this->getChannelMock());
107
108
        return $connectionMock;
109
    }
110
111
    /**
112
     * @return CmobiAMQPChannel
113
     */
114 View Code Duplication
    protected function getChannelMock()
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...
115
    {
116
        $channelMock = $this->getMockBuilder(CmobiAMQPChannel::class)
117
            ->disableOriginalConstructor()
118
            ->getMock();
119
        $channelMock
120
            ->expects($this->any())
121
            ->method('basic_publish')
122
            ->willReturn(true);
123
        $channelMock
124
            ->method('basicConsume')
125
            ->willReturn(true);
126
127
        return $channelMock;
128
    }
129
130
    /**
131
     * @param string $msg
132
     * @param null   $correlationId
133
     *
134
     * @return CmobiAMQPMessage
135
     */
136 View Code Duplication
    protected function getCmobiAMQPMessage($msg = '', $correlationId = 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...
137
    {
138
        $msgMock = $this->getMockBuilder(CmobiAMQPMessage::class)
139
            ->disableOriginalConstructor()
140
            ->getMock();
141
        $msgMock->method('get')
142
            ->willReturn('correlation_id')
143
            ->willReturn($correlationId);
144
        $msgMock->method('getBody')
145
            ->willReturn($msg);
146
147
        return $msgMock;
148
    }
149
}
150