Issues (4)

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.

test/ApplicationTest.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
 * This file is part of LuisMulinari\Consoleful
4
 *
5
 * @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
6
 */
7
8
namespace LuisMulinari\Consoleful;
9
10
use Lcobucci\DependencyInjection\ContainerBuilder;
11
use Lcobucci\DependencyInjection\ContainerConfig;
12
use Lcobucci\DependencyInjection\Builders\DelegatingBuilder;
13
use LuisMulinari\Consoleful\fixtures\CommandTest;
14
use LuisMulinari\Consoleful\fixtures\ContainerAwareCommandTest;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
use Symfony\Component\DependencyInjection\ContainerInterface;
18
19
/**
20
 * Class ApplicationTest
21
 *
22
 * @author Luis Henrique Mulinari <[email protected]>
23
 */
24
class ApplicationTest extends \PHPUnit_Framework_TestCase
25
{
26
    /**
27
     * @var ContainerBuilder
28
     */
29
    protected $builder;
30
31
    /**
32
     * @var ContainerConfig
33
     */
34
    protected $config;
35
36
    protected function setUp()
37
    {
38
        $this->config = $this->getMock(ContainerConfig::class, [], [], '', false);
39
        $this->builder = $this->getMockForAbstractClass(
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMockForAbstrac... array('getContainer')) of type object<PHPUnit_Framework_MockObject_MockObject> is incompatible with the declared type object<Lcobucci\Dependen...ction\ContainerBuilder> of property $builder.

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...
40
            ContainerBuilder::class,
41
            [],
42
            '',
43
            true,
44
            true,
45
            true,
46
            ['getContainer']
47
        );
48
    }
49
50
    /**
51
     * @test
52
     *
53
     * @covers LuisMulinari\Consoleful\Application::__construct
54
     * @covers Symfony\Component\Console\Application::__construct
55
     */
56
    public function constructShouldConfigureTheAttributes()
57
    {
58
        $application = new Application('name', 'version', $this->config, $this->builder);
59
60
        $this->assertAttributeEquals('name', 'name', $application);
61
        $this->assertAttributeEquals('version', 'version', $application);
62
        $this->assertAttributeSame($this->config, 'containerConfig', $application);
63
        $this->assertAttributeSame($this->builder, 'builder', $application);
64
    }
65
66
    /**
67
     * @test
68
     *
69
     * @covers LuisMulinari\Consoleful\Application::__construct
70
     * @covers Symfony\Component\Console\Application::__construct
71
     */
72
    public function constructShouldCreateBuilderWhenNotInformed()
73
    {
74
        $application = new Application('name', 'version', $this->config);
75
76
        $this->assertAttributeInstanceOf(DelegatingBuilder::class, 'builder', $application);
77
    }
78
79
    /**
80
     * @test
81
     *
82
     * @covers LuisMulinari\Consoleful\Application::__construct
83
     * @covers LuisMulinari\Consoleful\Application::doRun
84
     * @covers LuisMulinari\Consoleful\Application::injectContainer
85
     * @covers Symfony\Component\Console\Application::__construct
86
     * @covers Symfony\Component\Console\Application::doRun
87
     * @covers Lcobucci\DependencyInjection\ContainerInjector::setContainer
88
     * @covers Lcobucci\DependencyInjection\ContainerInjector::getContainer
89
     */
90
    public function doRunShouldNotBuildTheContainerWhenNoConfigurationWasUsed()
91
    {
92
        $input = $this->getMock(InputInterface::class);
93
        $output = $this->getMock(OutputInterface::class);
94
95
        $this->builder->expects($this->never())
0 ignored issues
show
The method expects() does not seem to exist on object<Lcobucci\Dependen...ction\ContainerBuilder>.

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...
96
                      ->method('getContainer');
97
98
        $application = new Application('name', 'version', null, $this->builder);
99
        $application->doRun($input, $output);
100
101
        $this->assertAttributeEquals(null, 'container', $application);
102
    }
103
104
    /**
105
     * @test
106
     *
107
     * @covers LuisMulinari\Consoleful\Application::__construct
108
     * @covers LuisMulinari\Consoleful\Application::doRun
109
     * @covers LuisMulinari\Consoleful\Application::injectContainer
110
     * @covers Symfony\Component\Console\Application::__construct
111
     * @covers Symfony\Component\Console\Application::doRun
112
     * @covers Lcobucci\DependencyInjection\ContainerInjector::setContainer
113
     * @covers Lcobucci\DependencyInjection\ContainerInjector::getContainer
114
     */
115
    public function doRunShouldBuildTheContainerIfItWasnConfiguredYet()
116
    {
117
        $input = $this->getMock(InputInterface::class);
118
        $output = $this->getMock(OutputInterface::class);
119
        $container = $this->getMock(ContainerInterface::class);
120
121
        $this->builder->expects($this->once())
0 ignored issues
show
The method expects() does not seem to exist on object<Lcobucci\Dependen...ction\ContainerBuilder>.

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...
122
                      ->method('getContainer')
123
                      ->with($this->config)
124
                      ->willReturn($container);
125
126
        $application = new Application('name', 'version', $this->config, $this->builder);
127
        $application->doRun($input, $output);
128
129
        $this->assertAttributeSame($container, 'container', $application);
130
    }
131
132
    /**
133
     * @test
134
     *
135
     * @covers LuisMulinari\Consoleful\Application::__construct
136
     * @covers LuisMulinari\Consoleful\Application::doRun
137
     * @covers LuisMulinari\Consoleful\Application::injectContainer
138
     * @covers Symfony\Component\Console\Application::__construct
139
     * @covers Symfony\Component\Console\Application::add
140
     * @covers Symfony\Component\Console\Application::doRun
141
     * @covers Lcobucci\DependencyInjection\ContainerInjector::setContainer
142
     * @covers Lcobucci\DependencyInjection\ContainerInjector::getContainer
143
     */
144
    public function doRunShouldInjectTheContainerOnContainerAwareCommands()
145
    {
146
        $input = $this->getMock(InputInterface::class);
147
        $output = $this->getMock(OutputInterface::class);
148
        $container = $this->getMock(ContainerInterface::class);
149
150
        $this->builder->expects($this->never())
0 ignored issues
show
The method expects() does not seem to exist on object<Lcobucci\Dependen...ction\ContainerBuilder>.

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...
151
                      ->method('getContainer');
152
153
        $command = new CommandTest();
154
        $command2 = new ContainerAwareCommandTest();
155
156
        $application = new Application('name', 'version', $this->config, $this->builder);
157
        $application->add($command);
158
        $application->add($command2);
159
        $application->setContainer($container);
160
        $application->doRun($input, $output);
161
162
        $this->assertAttributeSame($container, 'container', $command2);
163
    }
164
}
165