Issues (3885)

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.

doctrine/dbal/lib/Doctrine/DBAL/Tools/Dumper.php (6 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 Doctrine\DBAL\Tools;
4
5
use ArrayIterator;
6
use ArrayObject;
7
use DateTimeInterface;
8
use Doctrine\Common\Collections\Collection;
9
use Doctrine\Common\Persistence\Proxy;
10
use stdClass;
11
use function array_keys;
12
use function class_exists;
13
use function count;
14
use function end;
15
use function explode;
16
use function extension_loaded;
17
use function get_class;
18
use function html_entity_decode;
19
use function ini_get;
20
use function ini_set;
21
use function is_array;
22
use function is_object;
23
use function ob_get_clean;
24
use function ob_start;
25
use function strip_tags;
26
use function strrpos;
27
use function substr;
28
use function var_dump;
29
30
/**
31
 * Static class used to dump the variable to be used on output.
32
 * Simplified port of Util\Debug from doctrine/common.
33
 *
34
 * @internal
35
 */
36
final class Dumper
37
{
38
    /**
39
     * Private constructor (prevents instantiation).
40
     */
41
    private function __construct()
42
    {
43
    }
44
45
    /**
46
     * Returns a dump of the public, protected and private properties of $var.
47
     *
48
     * @link https://xdebug.org/
49
     *
50
     * @param mixed $var      The variable to dump.
51
     * @param int   $maxDepth The maximum nesting level for object properties.
52
     */
53
    public static function dump($var, int $maxDepth = 2) : string
54
    {
55
        $html = ini_get('html_errors');
56
57
        if ($html !== true) {
58
            ini_set('html_errors', true);
59
        }
60
61
        if (extension_loaded('xdebug')) {
62
            ini_set('xdebug.var_display_max_depth', $maxDepth);
63
        }
64
65
        $var = self::export($var, $maxDepth);
66
67
        ob_start();
68
        var_dump($var);
0 ignored issues
show
Security Debugging Code introduced by
\var_dump($var); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
69
70
        try {
71
            return strip_tags(html_entity_decode(ob_get_clean()));
72
        } finally {
73
            ini_set('html_errors', $html);
74
        }
75
    }
76
77
    /**
78
     * @param mixed $var
79
     *
80
     * @return mixed
0 ignored issues
show
Consider making the return type a bit more specific; maybe use integer|double|string|nu...n|resource|array|object.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
81
     */
82
    public static function export($var, int $maxDepth)
83
    {
84
        $return = null;
0 ignored issues
show
$return 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...
85
        $isObj  = is_object($var);
86
87
        if ($var instanceof Collection) {
0 ignored issues
show
The class Doctrine\Common\Collections\Collection does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
88
            $var = $var->toArray();
89
        }
90
91
        if ($maxDepth === 0) {
92
            return is_object($var) ? get_class($var)
93
                : (is_array($var) ? 'Array(' . count($var) . ')' : $var);
94
        }
95
96
        if (is_array($var)) {
97
            $return = [];
98
99
            foreach ($var as $k => $v) {
100
                $return[$k] = self::export($v, $maxDepth - 1);
101
            }
102
103
            return $return;
104
        }
105
106
        if (! $isObj) {
107
            return $var;
108
        }
109
110
        $return = new stdClass();
111
        if ($var instanceof DateTimeInterface) {
112
            $return->__CLASS__ = get_class($var);
113
            $return->date      = $var->format('c');
114
            $return->timezone  = $var->getTimezone()->getName();
115
116
            return $return;
117
        }
118
119
        $return->__CLASS__ = self::getClass($var);
120
121
        if ($var instanceof Proxy) {
0 ignored issues
show
The class Doctrine\Common\Persistence\Proxy does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
122
            $return->__IS_PROXY__          = true;
123
            $return->__PROXY_INITIALIZED__ = $var->__isInitialized();
124
        }
125
126
        if ($var instanceof ArrayObject || $var instanceof ArrayIterator) {
127
            $return->__STORAGE__ = self::export($var->getArrayCopy(), $maxDepth - 1);
128
        }
129
130
        return self::fillReturnWithClassAttributes($var, $return, $maxDepth);
131
    }
132
133
    /**
134
     * Fill the $return variable with class attributes
135
     * Based on obj2array function from {@see https://secure.php.net/manual/en/function.get-object-vars.php#47075}
136
     *
137
     * @param object $var
138
     *
139
     * @return mixed
0 ignored issues
show
Consider making the return type a bit more specific; maybe use stdClass.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
140
     */
141
    private static function fillReturnWithClassAttributes($var, stdClass $return, int $maxDepth)
142
    {
143
        $clone = (array) $var;
144
145
        foreach (array_keys($clone) as $key) {
146
            $aux  = explode("\0", $key);
147
            $name = end($aux);
148
            if ($aux[0] === '') {
149
                $name .= ':' . ($aux[1] === '*' ? 'protected' : $aux[1] . ':private');
150
            }
151
            $return->$name = self::export($clone[$key], $maxDepth - 1);
152
        }
153
154
        return $return;
155
    }
156
157
    /**
158
     * @param object $object
159
     */
160
    private static function getClass($object) : string
161
    {
162
        $class = get_class($object);
163
164
        if (! class_exists(Proxy::class)) {
165
            return $class;
166
        }
167
168
        $pos = strrpos($class, '\\' . Proxy::MARKER . '\\');
169
170
        if ($pos === false) {
171
            return $class;
172
        }
173
174
        return substr($class, $pos + Proxy::MARKER_LENGTH + 2);
175
    }
176
}
177