Issues (51)

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.

src/TopologicalSort.php (2 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 ParamProcessor;
4
5
/**
6
 * Sorts a series of dependency pairs in linear order.
7
 *
8
 * Based on http://blog.metafoundry.com/2007/09/topological-sort-in-php.html
9
 *
10
 * @deprecated since 1.7
11
 * @codingStandardsIgnoreFile
12
 */
13
class TopologicalSort {
14
15
	private $mNodes = [];
16
	private $mNodeNames = [];
17
18
	/**
19
	 * Dependency pairs are a list of arrays in the form
20
	 * $name => $val where $key must come before $val in load order.
21
	 */
22 49
	public function __construct( array $dependencies = [], $parse = true ) {
23 49
		$this->mNodeNames = array_keys( $dependencies );
24
25 49
		if ( $parse ) {
26 49
			$dependencies = $this->parseDependencyList( $dependencies );
27
		}
28
29
		// turn pairs into double-linked node tree
30 49
		foreach ( $dependencies as $dpair ) {
31
			$module = key( $dpair );
32
			$dependency = current( $dpair );
33
			if ( !isset( $this->mNodes[$module] ) ) $this->mNodes[$module] = new TSNode( $module );
0 ignored issues
show
Deprecated Code introduced by
The class ParamProcessor\TSNode has been deprecated with message: since 1.7

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
34
			if ( !isset( $this->mNodes[$dependency] ) ) $this->mNodes[$dependency] = new TSNode( $dependency );
0 ignored issues
show
Deprecated Code introduced by
The class ParamProcessor\TSNode has been deprecated with message: since 1.7

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
35
			if ( !in_array( $dependency, $this->mNodes[$module]->children ) ) $this->mNodes[$module]->children[] = $dependency;
36
			if ( !in_array( $module, $this->mNodes[$dependency]->parents ) ) $this->mNodes[$dependency]->parents[] = $module;
37
		}
38 49
	}
39
40
	/**
41
	 * Perform Topological Sort.
42
	 *
43
	 * @return array Sorted array
44
	 */
45 49
	public function doSort() {
46 49
		$nodes = $this->mNodes;
47
48
		// get nodes without parents
49 49
		$root_nodes = array_values( $this->getRootNodes( $nodes ) );
50
51
		// begin algorithm
52 49
		$sorted = [];
53 49
		while ( count( $nodes ) > 0 ) {
54
			// check for circular reference
55
			if ( $root_nodes === [] ) {
56
				return [];
57
			}
58
59
60
			// remove this node from root_nodes
61
			// and add it to the output
62
			$n = array_pop( $root_nodes );
63
			$sorted[] = $n->name;
64
65
			// for each of its  children
66
			// queue the new node finally remove the original
67
			for ( $i = count( $n->children ) - 1; $i >= 0; $i -- ) {
68
				$childnode = $n->children[$i];
69
				// remove the link from this node to its
70
				// children ($nodes[$n->name]->children[$i]) AND
71
				// remove the link from each child to this
72
				// parent ($nodes[$childnode]->parents[?]) THEN
73
				// remove this child from this node
74
				unset( $nodes[$n->name]->children[$i] );
75
				$parent_position = array_search ( $n->name, $nodes[$childnode]->parents );
76
				unset( $nodes[$childnode]->parents[$parent_position] );
77
				// check if this child has other parents
78
				// if not, add it to the root nodes list
79
				if ( !count( $nodes[$childnode]->parents ) ) {
80
					array_push( $root_nodes, $nodes [$childnode] );
81
				}
82
			}
83
84
			// nodes.Remove(n);
85
			unset( $nodes[$n->name] );
86
		}
87
88 49
		$looseNodes = [];
89
90
		// Return the result with the loose nodes (items with no dependencies) appended.
91 49
		foreach( $this->mNodeNames as $name ) {
92 49
			if ( !in_array( $name, $sorted ) ) {
93 49
				$looseNodes[] = $name;
94
			}
95
		}
96
97 49
		return array_merge( $sorted, $looseNodes );
98
	}
99
100
	/**
101
	 * Returns a list of node objects that do not have parents
102
	 *
103
	 * @param array $nodes array of node objects
104
	 *
105
	 * @return array of node objects
106
	 */
107 49
	private function getRootNodes( array $nodes ) {
108 49
		$output =  [];
109
110 49
		foreach ( $nodes as $name => $node ) {
111
			if ( !count ( $node->parents ) ) {
112
				$output[$name] = $node;
113
			}
114
		}
115
116 49
		return $output;
117
	}
118
119
	/**
120
	 * Parses an array of dependencies into an array of dependency pairs
121
	 *
122
	 * The array of dependencies would be in the form:
123
	 * $dependency_list = array(
124
	 *  "name" => array("dependency1","dependency2","dependency3"),
125
	 *  "name2" => array("dependencyA","dependencyB","dependencyC"),
126
	 *  ...etc
127
	 * );
128
	 *
129
	 * @param array $dlist Array of dependency pairs for use as parameter in doSort method
130
	 *
131
	 * @return array
132
	 */
133 49
	private function parseDependencyList( array $dlist = [] ) {
134 49
		$output = [];
135
136 49
		foreach ( $dlist as $name => $dependencies ) {
137 49
			foreach ( $dependencies as $d ) {
138
				$output[] = [ $d => $name ];
139
			}
140
		}
141
142 49
		return $output;
143
	}
144
}
145
146
/**
147
 * @deprecated since 1.7
148
 */
149
class TSNode {
150
	public $name;
151
	public $children = [];
152
	public $parents = [];
153
154
	public function __construct( $name = '' ) {
155
		if ( !is_string( $name ) ) {
156
			throw new \InvalidArgumentException( 'Name needs to be a string' );
157
		}
158
		$this->name = $name;
159
	}
160
}