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/NodeTraverser.php (4 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 PhpParser;
4
5
class NodeTraverser implements NodeTraverserInterface
6
{
7
    /**
8
     * @var NodeVisitor[] Visitors
9
     */
10
    protected $visitors;
11
12
    /**
13
     * @var bool
14
     */
15
    private $cloneNodes;
16
17
    /**
18
     * Constructs a node traverser.
19
     *
20
     * @param bool $cloneNodes Should the traverser clone the nodes when traversing the AST
21
     */
22
    public function __construct($cloneNodes = false) {
23
        $this->visitors = array();
24
        $this->cloneNodes = $cloneNodes;
25
    }
26
27
    /**
28
     * Adds a visitor.
29
     *
30
     * @param NodeVisitor $visitor Visitor to add
31
     */
32
    public function addVisitor(NodeVisitor $visitor) {
33
        $this->visitors[] = $visitor;
34
    }
35
36
    /**
37
     * Removes an added visitor.
38
     *
39
     * @param NodeVisitor $visitor
40
     */
41
    public function removeVisitor(NodeVisitor $visitor) {
42
        foreach ($this->visitors as $index => $storedVisitor) {
43
            if ($storedVisitor === $visitor) {
44
                unset($this->visitors[$index]);
45
                break;
46
            }
47
        }
48
    }
49
50
    /**
51
     * Traverses an array of nodes using the registered visitors.
52
     *
53
     * @param Node[] $nodes Array of nodes
54
     *
55
     * @return Node[] Traversed array of nodes
56
     */
57
    public function traverse(array $nodes) {
58 View Code Duplication
        foreach ($this->visitors as $visitor) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
            if (null !== $return = $visitor->beforeTraverse($nodes)) {
60
                $nodes = $return;
61
            }
62
        }
63
64
        $nodes = $this->traverseArray($nodes);
65
66 View Code Duplication
        foreach ($this->visitors as $visitor) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
67
            if (null !== $return = $visitor->afterTraverse($nodes)) {
68
                $nodes = $return;
69
            }
70
        }
71
72
        return $nodes;
73
    }
74
75
    protected function traverseNode(Node $node) {
76
        if ($this->cloneNodes) {
77
            $node = clone $node;
78
        }
79
80
        foreach ($node->getSubNodeNames() as $name) {
81
            $subNode =& $node->$name;
82
83
            if (is_array($subNode)) {
84
                $subNode = $this->traverseArray($subNode);
85
            } elseif ($subNode instanceof Node) {
86
                $traverseChildren = true;
87 View Code Duplication
                foreach ($this->visitors as $visitor) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
88
                    $return = $visitor->enterNode($subNode);
89
                    if (self::DONT_TRAVERSE_CHILDREN === $return) {
90
                        $traverseChildren = false;
91
                    } else if (null !== $return) {
92
                        $subNode = $return;
93
                    }
94
                }
95
96
                if ($traverseChildren) {
97
                    $subNode = $this->traverseNode($subNode);
98
                }
99
100
                foreach ($this->visitors as $visitor) {
101
                    if (null !== $return = $visitor->leaveNode($subNode)) {
102
                        $subNode = $return;
103
                    }
104
                }
105
            }
106
        }
107
108
        return $node;
109
    }
110
111
    protected function traverseArray(array $nodes) {
112
        $doNodes = array();
113
114
        foreach ($nodes as $i => &$node) {
115
            if (is_array($node)) {
116
                $node = $this->traverseArray($node);
117
            } elseif ($node instanceof Node) {
118
                $traverseChildren = true;
119 View Code Duplication
                foreach ($this->visitors as $visitor) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
120
                    $return = $visitor->enterNode($node);
121
                    if (self::DONT_TRAVERSE_CHILDREN === $return) {
122
                        $traverseChildren = false;
123
                    } else if (null !== $return) {
124
                        $node = $return;
125
                    }
126
                }
127
128
                if ($traverseChildren) {
129
                    $node = $this->traverseNode($node);
130
                }
131
132
                foreach ($this->visitors as $visitor) {
133
                    $return = $visitor->leaveNode($node);
134
135
                    if (self::REMOVE_NODE === $return) {
136
                        $doNodes[] = array($i, array());
137
                        break;
138
                    } elseif (is_array($return)) {
139
                        $doNodes[] = array($i, $return);
140
                        break;
141
                    } elseif (null !== $return) {
142
                        $node = $return;
143
                    }
144
                }
145
            }
146
        }
147
148
        if (!empty($doNodes)) {
149
            while (list($i, $replace) = array_pop($doNodes)) {
150
                array_splice($nodes, $i, 1, $replace);
151
            }
152
        }
153
154
        return $nodes;
155
    }
156
}
157