Issues (2473)

Branch: master

Security Analysis    no vulnerabilities found

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.

engine/classes/Elgg/Router.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
namespace Elgg;
3
4
/**
5
 * Delegates requests to controllers based on the registered configuration.
6
 *
7
 * Plugin devs should use these wrapper functions:
8
 *  * elgg_register_page_handler
9
 *  * elgg_unregister_page_handler
10
 *
11
 * @package    Elgg.Core
12
 * @subpackage Router
13
 * @since      1.9.0
14
 * @access private
15
 */
16
class Router {
17
	private $handlers = array();
18
	private $hooks;
19
20
	/**
21
	 * Constructor
22
	 *
23
	 * @param \Elgg\PluginHooksService $hooks For customized routing.
24
	 */
25 7
	public function __construct(\Elgg\PluginHooksService $hooks) {
26 7
		$this->hooks = $hooks;
27 7
	}
28
29
	/**
30
	 * Routes the request to a registered page handler
31
	 *
32
	 * This function triggers a plugin hook `'route', $identifier` so that plugins can
33
	 * modify the routing or handle a request.
34
	 *
35
	 * @param \Elgg\Http\Request $request The request to handle.
36
	 * @return boolean Whether the request was routed successfully.
37
	 * @access private
38
	 */
39 5
	public function route(\Elgg\Http\Request $request) {
40 5
		$segments = $request->getUrlSegments();
41 5
		if ($segments) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $segments of type string[] 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...
42 4
			$identifier = array_shift($segments);
43 4
		} else {
44 1
			$identifier = '';
45
46
			// this plugin hook is deprecated. Use elgg_register_page_handler()
47
			// to register for the '' (empty string) handler.
48
			// allow plugins to override the front page (return true to indicate
49
			// that the front page has been served)
50 1
			$result = _elgg_services()->hooks->trigger('index', 'system', null, false);
51 1
			if ($result === true) {
52
				elgg_deprecated_notice("The 'index', 'system' plugin has been deprecated. See elgg_front_page_handler()", 1.9);
53
				exit;
54
			}
55
		}
56
57
		// return false to stop processing the request (because you handled it)
58
		// return a new $result array if you want to route the request differently
59
		$result = array(
60 5
			'identifier' => $identifier,
61 5
			'handler' => $identifier, // backward compatibility
62 5
			'segments' => $segments,
63 5
		);
64 5
		$result = $this->hooks->trigger('route', $identifier, $result, $result);
65 5
		if ($result === false) {
66 1
			return true;
67
		}
68
69 4
		if ($identifier != $result['identifier']) {
70 1
			$identifier = $result['identifier'];
71 4
		} else if ($identifier != $result['handler']) {
72 1
			$identifier = $result['handler'];
73 1
		}
74
75 4
		$segments = $result['segments'];
76
77 4
		$handled = false;
78 4
		if (isset($this->handlers[$identifier]) && is_callable($this->handlers[$identifier])) {
79 3
			$function = $this->handlers[$identifier];
80 3
			$handled = call_user_func($function, $segments, $identifier);
81 3
		}
82
83 4
		return $handled || headers_sent();
84
	}
85
86
	/**
87
	 * Register a function that gets called when the first part of a URL is
88
	 * equal to the identifier.
89
	 *
90
	 * @param string $identifier The page type to handle
91
	 * @param string $function   Your function name
92
	 *
93
	 * @return bool Depending on success
94
	 */
95 6
	public function registerPageHandler($identifier, $function) {
96 6
		if (is_callable($function, true)) {
97 5
			$this->handlers[$identifier] = $function;
98 5
			return true;
99
		}
100
101 1
		return false;
102
	}
103
104
	/**
105
	 * Unregister a page handler for an identifier
106
	 *
107
	 * @param string $identifier The page type identifier
108
	 *
109
	 * @return void
110
	 */
111 1
	public function unregisterPageHandler($identifier) {
112 1
		unset($this->handlers[$identifier]);
113 1
	}
114
115
	/**
116
	 * Get page handlers as array of identifier => callback
117
	 * 
118
	 * @return array
119
	 */
120 1
	public function getPageHandlers() {
121 1
		return $this->handlers;
122
	}
123
}
124
125