Issues (110)

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.

lib/PhpParser/BuilderAbstract.php (1 issue)

Labels
Severity

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 PhpParser;
4
5
use PhpParser\Node\Name;
6
use PhpParser\Node\Expr;
7
use PhpParser\Node\Stmt;
8
use PhpParser\Node\Scalar;
9
use PhpParser\Comment;
10
11
abstract class BuilderAbstract implements Builder {
12
    /**
13
     * Normalizes a node: Converts builder objects to nodes.
14
     *
15
     * @param Node|Builder $node The node to normalize
16
     *
17
     * @return Node The normalized node
18
     */
19
    protected function normalizeNode($node) {
20
        if ($node instanceof Builder) {
21
            return $node->getNode();
22
        } elseif ($node instanceof Node) {
23
            return $node;
24
        }
25
26
        throw new \LogicException('Expected node or builder object');
27
    }
28
29
    /**
30
     * Normalizes a name: Converts plain string names to PhpParser\Node\Name.
31
     *
32
     * @param Name|string $name The name to normalize
33
     *
34
     * @return Name The normalized name
35
     */
36
    protected function normalizeName($name) {
37
        if ($name instanceof Name) {
38
            return $name;
39
        } elseif (is_string($name)) {
40
            if (!$name) {
41
                throw new \LogicException('Name cannot be empty');
42
            }
43
44
            if ($name[0] == '\\') {
45
                return new Name\FullyQualified(substr($name, 1));
46
            } elseif (0 === strpos($name, 'namespace\\')) {
47
                return new Name\Relative(substr($name, strlen('namespace\\')));
48
            } else {
49
                return new Name($name);
50
            }
51
        }
52
53
        throw new \LogicException('Name must be a string or an instance of PhpParser\Node\Name');
54
    }
55
56
    /**
57
     * Normalizes a value: Converts nulls, booleans, integers,
58
     * floats, strings and arrays into their respective nodes
59
     *
60
     * @param mixed $value The value to normalize
61
     *
62
     * @return Expr The normalized value
63
     */
64
    protected function normalizeValue($value) {
65
        if ($value instanceof Node) {
66
            return $value;
67
        } elseif (is_null($value)) {
68
            return new Expr\ConstFetch(
69
                new Name('null')
70
            );
71
        } elseif (is_bool($value)) {
72
            return new Expr\ConstFetch(
73
                new Name($value ? 'true' : 'false')
74
            );
75
        } elseif (is_int($value)) {
76
            return new Scalar\LNumber($value);
77
        } elseif (is_float($value)) {
78
            return new Scalar\DNumber($value);
79
        } elseif (is_string($value)) {
80
            return new Scalar\String_($value);
81
        } elseif (is_array($value)) {
82
            $items = array();
83
            $lastKey = -1;
84
            foreach ($value as $itemKey => $itemValue) {
85
                // for consecutive, numeric keys don't generate keys
86
                if (null !== $lastKey && ++$lastKey === $itemKey) {
87
                    $items[] = new Expr\ArrayItem(
88
                        $this->normalizeValue($itemValue)
89
                    );
90
                } else {
91
                    $lastKey = null;
92
                    $items[] = new Expr\ArrayItem(
93
                        $this->normalizeValue($itemValue),
94
                        $this->normalizeValue($itemKey)
95
                    );
96
                }
97
            }
98
99
            return new Expr\Array_($items);
100
        } else {
101
            throw new \LogicException('Invalid value');
102
        }
103
    }
104
105
    /**
106
     * Normalizes a doc comment: Converts plain strings to PhpParser\Comment\Doc.
107
     *
108
     * @param Comment\Doc|string $docComment The doc comment to normalize
109
     *
110
     * @return Comment\Doc The normalized doc comment
111
     */
112
    protected function normalizeDocComment($docComment) {
113
        if ($docComment instanceof Comment\Doc) {
114
            return $docComment;
115
        } else if (is_string($docComment)) {
116
            return new Comment\Doc($docComment);
117
        } else {
118
            throw new \LogicException('Doc comment must be a string or an instance of PhpParser\Comment\Doc');
119
        }
120
    }
121
122
    /**
123
     * Sets a modifier in the $this->type property.
124
     *
125
     * @param int $modifier Modifier to set
126
     */
127
    protected function setModifier($modifier) {
128
        Stmt\Class_::verifyModifier($this->type, $modifier);
0 ignored issues
show
The property type 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...
129
        $this->type |= $modifier;
130
    }
131
}
132