Issues (3098)

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/KochTest/Autoload/MapBuilderTest.php (7 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 KochTest\Autoload;
4
5
use Koch\Autoload\MapBuilder;
6
use org\bovigo\vfs\vfsStream;
7
use org\bovigo\vfs\vfsStreamDirectory;
8
use org\bovigo\vfs\vfsStreamWrapper;
9
10
class MapBuilderTest extends \PHPUnit_Framework_TestCase
11
{
12
    /**
13
     * @var MapBuilder
14
     */
15
    protected $object;
16
17
    protected function setUp()
18
    {
19
        $this->object = new MapBuilder();
20
21
        vfsStreamWrapper::register();
22
23
        $this->vfsFileURL = vfsStream::url('root/classmap.file');
0 ignored issues
show
The property vfsFileURL does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
24
        $this->file       = vfsStream::newFile('classmap.file', 0777);
0 ignored issues
show
The property file does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
25
26
        $this->vfsFileWithPHPClass = vfsStream::url('root/class.php');
0 ignored issues
show
The property vfsFileWithPHPClass does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
27
        $content                   = '<?php namespace SomeNamespace; class MyClass(){} ?>';
28
        $this->file2               = vfsStream::newFile('class.php', 0777)->setContent($content);
0 ignored issues
show
The property file2 does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
29
30
        $this->root = new vfsStreamDirectory('root');
0 ignored issues
show
The property root does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
31
        $this->root->addChild($this->file);
32
        $this->root->addChild($this->file2);
33
34
        vfsStreamWrapper::setRoot($this->root);
35
    }
36
37
    protected function tearDown()
38
    {
39
        unset($this->object);
40
    }
41
42
    /**
43
     * @covers Koch\Autoload\MapBuilder::build
44
     * @covers Koch\Autoload\MapBuilder::writeMapFile
45
     * @covers Koch\Autoload\MapBuilder::extractClassnames
46
     * @covers Koch\Functions\Functions::globRecursive
47
     * @covers Koch\Autoload\Loader::autoload
48
     * @covers Koch\Autoload\Loader::autoloadExclusions
49
     * @covers Koch\Autoload\Loader::autoloadInclusions
50
     * @covers Koch\Autoload\Loader::includeFileAndMap
51
     * @covers Koch\Autoload\Loader::autoloadByApcOrFileMap
52
     * @covers Koch\Autoload\Loader::autoloadIncludePath
53
     * @covers Koch\Autoload\Loader::writeAutoloadingMapFile
54
     * @covers Koch\Autoload\Loader::addMapping
55
     */
56
    public function testBuild()
57
    {
58
        // create classmap
59
       $this->object->build(
60
           [__DIR__ . '/../../../framework/Koch/Config/Adapter'],
61
           $this->vfsFileURL
62
       );
63
64
       // include classmap array
65
       $classmap = include $this->vfsFileURL;
66
67
        $this->assertTrue(is_array($classmap));
68
        $this->assertArrayHasKey('Koch\Config\Adapter\CSV', $classmap);
69
    }
70
71
    /**
72
     * @covers Koch\Autoload\MapBuilder::extractClassnames
73
     * @covers Koch\Autoload\Loader::autoload
74
     * @covers Koch\Autoload\Loader::autoloadExclusions
75
     * @covers Koch\Autoload\Loader::autoloadInclusions
76
     * @covers Koch\Autoload\Loader::includeFileAndMap
77
     * @covers Koch\Autoload\Loader::autoloadByApcOrFileMap
78
     * @covers Koch\Autoload\Loader::autoloadIncludePath
79
     * @covers Koch\Autoload\Loader::writeAutoloadingMapFile
80
     * @covers Koch\Autoload\Loader::addMapping
81
     */
82
    public function testExtractClassnames()
83
    {
84
        $classname = $this->object->extractClassnames($this->vfsFileWithPHPClass);
85
86
        $this->assertEquals($classname[0], 'SomeNamespace\MyClass');
87
    }
88
89
    /**
90
     * @covers Koch\Autoload\MapBuilder::extractClassnames
91
     * @covers Koch\Autoload\Loader::autoload
92
     * @covers Koch\Autoload\Loader::autoloadExclusions
93
     * @expectedException \InvalidArgumentException
94
     * @expectedExceptionMessage File from-not-existing-file.php does not exist.
95
     */
96
    public function testExtractClassnames_throwsException()
0 ignored issues
show
function testExtractClassnames_throwsException() does not seem to conform to the naming convention (^(?:[a-z]|__)[a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
97
    {
98
        $classname = $this->object->extractClassnames('from-not-existing-file.php');
0 ignored issues
show
$classname is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
99
    }
100
101
    /**
102
     * @covers Koch\Autoload\MapBuilder::writeMapFile
103
     */
104
    public function testWriteMapFile()
105
    {
106
        $classmap = ['classname' => 'filename'];
107
        $mapfile  = $this->vfsFileURL;
108
        $res      = $this->object->writeMapFile($classmap, $mapfile);
109
        $this->assertTrue($res);
110
    }
111
}
112