Issues (107)

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.

Tests/Helper/RunnerManagerTest.php (4 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 Liip\MonitorBundle\Tests\Helper;
4
5
use Liip\MonitorBundle\Helper\RunnerManager;
6
7
class RunnerManagerTest extends \PHPUnit\Framework\TestCase
8
{
9
    /**
10
     * @var \PHPUnit_Framework_MockObject_MockObject
11
     */
12
    private $container;
13
14
    /**
15
     * @var RunnerManager
16
     */
17
    private $runnerManager;
18
19
    public function groupProvider()
20
    {
21
        return [
22
            [null],
23
            ['default'],
24
            ['test'],
25
        ];
26
    }
27
28
    /**
29
     * @dataProvider groupProvider
30
     *
31
     * @param string $group
32
     */
33
    public function testGetRunner($group)
34
    {
35
        $this->container
36
            ->expects($this->any())
37
            ->method('getParameter')
38
            ->with('liip_monitor.default_group')
39
            ->willReturn('default');
40
41
        $this->container
42
            ->expects($this->any())
43
            ->method('has')
44
            ->with('liip_monitor.runner_'.($group ?: 'default'))
45
            ->willReturn(true);
46
47
        $expectedResult = $this->getMockBuilder('Liip\MonitorBundle\Runner')->getMock();
48
49
        $this->container
50
            ->expects($this->any())
51
            ->method('get')
52
            ->with('liip_monitor.runner_'.($group ?: 'default'))
53
            ->willReturn($expectedResult);
54
55
        $result = $this->runnerManager->getRunner($group);
56
57
        $this->assertSame($expectedResult, $result);
58
    }
59
60
    public function testGetRunnerReturnsNull()
61
    {
62
        $this->container
63
            ->expects($this->any())
64
            ->method('has')
65
            ->with('liip_monitor.runner_testgroup')
66
            ->willReturn(false);
67
68
        $result = $this->runnerManager->getRunner('testgroup');
69
70
        $this->assertNull($result);
71
    }
72
73
    public function testGetRunners()
74
    {
75
        $this->container
76
            ->expects($this->any())
77
            ->method('getParameter')
78
            ->with('liip_monitor.runners')
79
            ->willReturn(['liip_monitor.runner_group_1', 'liip_monitor.runner_group_2']);
80
81
        $runnerMockBuilder = $this->getMockBuilder('Liip\MonitorBundle\Runner');
82
        $runner1 = $runnerMockBuilder->getMock();
83
        $runner2 = $runnerMockBuilder->getMock();
84
        $this->container
85
            ->expects($this->exactly(2))
86
            ->method('get')
87
            ->withConsecutive(
88
                ['liip_monitor.runner_group_1'],
89
                ['liip_monitor.runner_group_2']
90
            )
91
            ->willReturnOnConsecutiveCalls($runner1, $runner2);
92
93
        $result = $this->runnerManager->getRunners();
94
95
        $this->assertTrue(is_array($result));
96
        $this->assertCount(2, $result);
0 ignored issues
show
$result is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
97
        $this->assertArrayHasKey('group_1', $result);
98
        $this->assertArrayHasKey('group_2', $result);
99
        $this->assertSame($runner1, $result['group_1']);
100
        $this->assertSame($runner2, $result['group_2']);
101
    }
102
103
    public function testGetGroups()
104
    {
105
        $this->container
106
            ->expects($this->any())
107
            ->method('getParameter')
108
            ->with('liip_monitor.runners')
109
            ->willReturn(['liip_monitor.runner_group_1', 'liip_monitor.runner_group_2']);
110
111
        $result = $this->runnerManager->getGroups();
112
113
        $this->assertTrue(is_array($result));
114
        $this->assertCount(2, $result);
0 ignored issues
show
$result is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
115
        $this->assertContains('group_1', $result);
116
        $this->assertContains('group_2', $result);
117
    }
118
119
    public function testGetDefaultGroup()
120
    {
121
        $expectedResult = 'default';
122
123
        $this->container
124
            ->expects($this->any())
125
            ->method('getParameter')
126
            ->with('liip_monitor.default_group')
127
            ->willReturn($expectedResult);
128
129
        $result = $this->runnerManager->getDefaultGroup();
130
131
        $this->assertEquals($expectedResult, $result);
132
    }
133
134
    protected function setUp(): void
135
    {
136
        $this->container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMockBuilder('S...rInterface')->getMock() of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<PHPUnit_Framework_MockObject_MockObject> of property $container.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
137
138
        $this->runnerManager = new RunnerManager($this->container);
0 ignored issues
show
$this->container is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Symfony\Component...ion\ContainerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
139
    }
140
}
141