Issues (387)

Branch: develop

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.

Descriptor/Builder/Reflector/FileAssemblerTest.php (1 issue)

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
 * phpDocumentor
4
 *
5
 * PHP Version 5.3
6
 *
7
 * @author    Mike van Riel <[email protected]>
8
 * @author    Sven Hagemann <[email protected]>
9
 * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
10
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
11
 * @link      http://phpdoc.org
12
 */
13
14
namespace phpDocumentor\Descriptor\Builder\Reflector;
15
16
use Mockery as m;
17
use phpDocumentor\Descriptor\Collection;
18
use phpDocumentor\Descriptor\PackageDescriptor;
19
20
use phpDocumentor\Reflection\DocBlock;
21
use phpDocumentor\Reflection\Php\File;
22
23
/**
24
 * Test class for \phpDocumentor\Descriptor\Builder
25
 *
26
 * @covers \phpDocumentor\Descriptor\Builder\Reflector\FileAssembler
27
 */
28
class FileAssemblerTest extends \Mockery\Adapter\Phpunit\MockeryTestCase
29
{
30
    /** @var FileAssembler $fixture */
31
    protected $fixture;
32
33
    /** @var PackageDescriptor */
34
    private $defaultPackage;
35
36
    /**
37
     * Creates a new fixture to test with.
38
     */
39
    protected function setUp()
40
    {
41
        $this->fixture = new FileAssembler();
42
        $this->fixture->setBuilder($this->getProjectDescriptorBuilderMock());
43
        $this->defaultPackage = new PackageDescriptor();
44
        $this->defaultPackage->setName('\\PhpDocumentor');
45
    }
46
47
    /**
48
     * Creates a Descriptor from a provided class.
49
     */
50
    public function testCreateFileDescriptorFromReflector()
51
    {
52
        $filename = 'file.php';
53
        $content = '<?php ... ?>';
54
        $hash = md5($content);
55
56
        $abstractDescriptor = m::mock('phpDocumentor\Descriptor\DescriptorAbstract');
57
        $abstractDescriptor->shouldReceive('getLineNumber')->andReturn(1337);
0 ignored issues
show
The method andReturn does only exist in Mockery\ExpectationInterface, but not in Mockery\HigherOrderMessage.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
58
59
        $docBlockDescription = new DocBlock\Description(
60
            <<<DOCBLOCK
61
            /**
62
             * This is a example description
63
             */
64
DOCBLOCK
65
        );
66
67
        $docBlockMock = new DocBlock('This is a example description', $docBlockDescription);
68
69
        $fileReflectorMock = new File($hash, $filename, $content, $docBlockMock);
70
//        $fileReflectorMock->shouldReceive('getConstants')->once()->andReturn(
71
//            new Collection(array($abstractDescriptor))
72
//        );
73
//
74
//        $fileReflectorMock->shouldReceive('getFunctions')->once()->andReturn(
75
//            new Collection(array($abstractDescriptor))
76
//        );
77
//
78
//        $fileReflectorMock->shouldReceive('getClasses')->once()->andReturn(
79
//            new Collection(array($abstractDescriptor))
80
//        );
81
//
82
//        $fileReflectorMock->shouldReceive('getInterfaces')->once()->andReturn(
83
//            new Collection(array($abstractDescriptor))
84
//        );
85
//
86
//        $fileReflectorMock->shouldReceive('getTraits')->once()->andReturn(
87
//            new Collection(array($abstractDescriptor))
88
//        );
89
//
90
//        $fileReflectorMock->shouldReceive('getMarkers')->once()->andReturn(
91
//            array('type', 'message', 1337)
92
//        );
93
//
94
//        $fileReflectorMock->shouldReceive('getIncludes')->andReturn(new Collection);
95
//        $fileReflectorMock->shouldReceive('getNamespaceAliases')->andReturn(new Collection);
96
97
        $descriptor = $this->fixture->create($fileReflectorMock);
98
99
        $this->assertSame($filename, $descriptor->getName());
100
        $this->assertSame($hash, $descriptor->getHash());
101
        $this->assertSame($content, $descriptor->getSource());
102
        //TODO: check this when we are testing default package behavoir
103
        //$this->assertSame($this->defaultPackage, $descriptor->getPackage());
104
    }
105
106
    /**
107
     * Create a descriptor builder mock
108
     *
109
     * @return m\MockInterface
110
     */
111
    protected function getProjectDescriptorBuilderMock()
112
    {
113
        $projectDescriptorBuilderMock = m::mock('phpDocumentor\Descriptor\ProjectDescriptorBuilder');
114
        $projectDescriptorBuilderMock->shouldReceive('getDefaultPackage')
115
            ->andReturn($this->defaultPackage);
116
117
        $projectDescriptorBuilderMock->shouldReceive(
118
            'getProjectDescriptor->getSettings->shouldIncludeSource'
119
        )->andReturn(true);
120
        $projectDescriptorBuilderMock->shouldReceive('buildDescriptor')->andReturnUsing(function ($param) {
121
            $mock = m::mock('phpDocumentor\Descriptor\DescriptorAbstract');
122
            $mock->shouldReceive('setLocation')->atLeast()->once();
123
            $mock->shouldReceive('getTags')->atLeast()->once()->andReturn(new Collection());
124
            $mock->shouldReceive('getFullyQualifiedStructuralElementName')
125
                ->once()
126
                ->andReturn('Frank_is_een_eindbaas');
127
128
            return $mock;
129
        });
130
131
        return $projectDescriptorBuilderMock;
132
    }
133
}
134