Issues (20)

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/ModuleLoaderTest.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
/*
4
 * The MIT License
5
 *
6
 * Copyright 2016 Alejandro Peña Florentín ([email protected]).
7
 *
8
 * Permission is hereby granted, free of charge, to any person obtaining a copy
9
 * of this software and associated documentation files (the "Software"), to deal
10
 * in the Software without restriction, including without limitation the rights
11
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
 * copies of the Software, and to permit persons to whom the Software is
13
 * furnished to do so, subject to the following conditions:
14
 *
15
 * The above copyright notice and this permission notice shall be included in
16
 * all copies or substantial portions of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
 * THE SOFTWARE.
25
 */
26
27
namespace Tight\Tests;
28
29
/**
30
 * Description of ModuleLoaderTest
31
 *
32
 * @author Alejandro Peña Florentín ([email protected])
33
 */
34
class ModuleLoaderTest extends \PHPUnit_Framework_TestCase
35
{
36
37
    private $loader;
38
    private $testModule;
39
40
    public function setUp() {
41
42
        $this->loader = new \Tight\Modules\ModuleLoader(new \Tight\Tight);
43
        $this->testModule = new TestLoaderModule("TestModule");
44
    }
45
46
    public function tearDown() {
47
        
48
    }
49
50
    /**
51
     * @test
52
     */
53
    public function testModuleLoaderGetModules() {
54
        $expected = [];
55
        $this->assertEquals($expected, $this->loader->getModules());
56
        $this->assertNull($this->loader->getModule("undefinedModule"));
57
    }
58
59
    /**
60
     * @test
61
     * @depends testModuleLoaderGetModules
62
     */
63 View Code Duplication
    public function testModuleLoaderAdd() {
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...
64
        $key = $this->testModule->getModuleName();
65
        $expected = [$key => $this->testModule];
66
        $this->loader->add($this->testModule);
67
        $this->assertEquals($expected, $this->loader->getModules());
68
    }
69
70
    /**
71
     * @test
72
     * @depends testModuleLoaderAdd
73
     * @expectedException \Tight\Exception\ModuleException
74
     */
75
    public function testModuleLoaderAddWithException() {
76
        $this->loader->add($this->testModule);
77
        $this->setExpectedException("\Tight\Exception\ModuleException");
78
        $this->loader->add($this->testModule);
79
    }
80
81
    /**
82
     * @test
83
     * @depends testModuleLoaderAdd
84
     */
85 View Code Duplication
    public function testModuleLoaderGetModule() {
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...
86
        $this->loader->add($this->testModule);
87
        $modName = $this->testModule->getModuleName();
88
        $expected = $this->testModule;
89
        $this->assertEquals($expected, $this->loader->getModule($modName));
90
    }
91
92
    /**
93
     * @test
94
     * @depends testModuleLoaderAdd
95
     */
96
    public function testModuleLoaderRemove() {
97
        $this->loader->add($this->testModule);
98
        $this->assertTrue($this->loader->remove($this->testModule->getModuleName()));
99
        $this->assertFalse($this->loader->remove($this->testModule->getModuleName()));
100
    }
101
    /**
102
     * @test
103
     * @depends testModuleLoaderAdd
104
     */
105
    public function testModuleLoaderGetModulesInfo(){
106
        $expected[0] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$expected was never initialized. Although not strictly required by PHP, it is generally a good practice to add $expected = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
107
            "name" => "TestModule",
108
            "version"=> "v1.0"
109
        ];
110
        $this->assertEquals([],$this->loader->getModulesInfo());
111
        $this->loader->add($this->testModule);
112
        $this->assertEquals($expected,$this->loader->getModulesInfo());
113
    }
114
}
115
116
class TestLoaderModule extends \Tight\Modules\AbstractModule
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
117
{
118
119
    public function onConfigChange() {
120
        
121
    }
122
123
    public function onLoad() {
124
        
125
    }
126
127
    public function onRemove() {
128
        
129
    }
130
131
}
132