Issues (73)

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.

Driver/AbstractAnnotationDriver.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
 * This file is part of the Cubiche package.
4
 *
5
 * Copyright (c) Cubiche
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Cubiche\Core\Metadata\Driver;
12
13
use Cubiche\Core\Metadata\Exception\MappingException;
14
use Cubiche\Tests\Generator\ClassUtils;
15
use Doctrine\Common\Annotations\Reader;
16
17
/**
18
 * AbstractAnnotationDriver class.
19
 *
20
 * @author Ivannis Suárez Jerez <[email protected]>
21
 */
22
abstract class AbstractAnnotationDriver implements DriverInterface
23
{
24
    /**
25
     * @var Reader
26
     */
27
    protected $reader;
28
29
    /**
30
     * The paths where to look for mapping files.
31
     *
32
     * @var array
33
     */
34
    protected $paths = [];
35
36
    /**
37
     * The paths excluded from path where to look for mapping files.
38
     *
39
     * @var array
40
     */
41
    protected $excludePaths = [];
42
43
    /**
44
     * The file extension of mapping documents.
45
     *
46
     * @var string
47
     */
48
    protected $fileExtension = '.php';
49
50
    /**
51
     * @var array|null
52
     */
53
    protected $classNames;
54
55
    /**
56
     * AbstractAnnotationDriver constructor.
57
     *
58
     * @param Reader $reader
59
     * @param array  $paths
60
     */
61
    public function __construct(Reader $reader, array $paths = array())
62
    {
63
        $this->reader = $reader;
64
        $this->addPaths($paths);
65
    }
66
67
    /**
68
     * @param array $paths
69
     */
70
    public function addPaths(array $paths)
71
    {
72
        $this->paths = array_unique(array_merge($this->paths, $paths));
73
    }
74
75
    /**
76
     * @param array $paths
77
     */
78
    public function addExcludePaths(array $paths)
79
    {
80
        $this->excludePaths = array_unique(array_merge($this->excludePaths, $paths));
81
    }
82
83
    /**
84
     * @return array
85
     */
86
    public function excludePaths()
87
    {
88
        return $this->excludePaths;
89
    }
90
91
    /**
92
     * @param string $fileExtension
93
     */
94
    public function setFileExtension($fileExtension)
95
    {
96
        $this->fileExtension = $fileExtension;
97
    }
98
99
    /**
100
     * {@inheritdoc}
101
     */
102
    public function getAllClassNames()
103
    {
104
        if ($this->classNames !== null) {
105
            return $this->classNames;
106
        }
107
108
        if (!$this->paths) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->paths of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
109
            throw MappingException::pathRequired();
110
        }
111
112
        $includedFiles = [];
113
        foreach ($this->paths as $path) {
114
            if (!is_dir($path)) {
115
                throw MappingException::invalidDirectory($path);
116
            }
117
118
            $iterator = new \RegexIterator(
119
                new \RecursiveIteratorIterator(
120
                    new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS),
121
                    \RecursiveIteratorIterator::LEAVES_ONLY
122
                ),
123
                '/^.+'.preg_quote($this->fileExtension).'$/i',
124
                \RecursiveRegexIterator::GET_MATCH
125
            );
126
127
            foreach ($iterator as $file) {
128
                $sourceFile = $file[0];
129
130
                if (!preg_match('(^phar:)i', $sourceFile)) {
131
                    $sourceFile = realpath($sourceFile);
132
                }
133
134
                foreach ($this->excludePaths as $excludePath) {
135
                    $exclude = str_replace('\\', '/', realpath($excludePath));
136
                    $current = str_replace('\\', '/', $sourceFile);
137
138
                    if (strpos($current, $exclude) !== false) {
139
                        continue 2;
140
                    }
141
                }
142
143
                require_once $sourceFile;
144
                $includedFiles[] = $sourceFile;
145
            }
146
        }
147
148
        $this->classNames = [];
149
        foreach ($includedFiles as $includedFile) {
150
            $this->classNames = array_merge($this->classNames, ClassUtils::getClassesInFile($includedFile));
151
        }
152
153
        return $this->classNames;
154
    }
155
}
156