Issues (5)

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/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
/**
3
 * @package    Fuel\Routing
4
 * @version    2.0
5
 * @author     Fuel Development Team
6
 * @license    MIT License
7
 * @copyright  2010 - 2015 Fuel Development Team
8
 * @link       http://fuelphp.com
9
 */
10
11
namespace Fuel\Routing;
12
13
use Closure;
14
use LogicException;
15
16
class Router extends Container
17
{
18
	const MATCH_ANY = '.+';
19
	const MATCH_NUM = '[[:digit:]]+';
20
	const MATCH_ALNUM = '[[:alnum:]]+';
21
	const MATCH_ALPHA = '[[:alpha:]]+';
22
	const MATCH_SEGMENT = '[^/]*';
23
24
	protected $filters = array();
25
26
	protected $autoFilter = null;
27
28
	public function setAutoFilter($filter)
29
	{
30
		$this->autoFilter = $filter;
31
32
		return $this;
33
	}
34
35
	public function filter($filter, Closure $callback)
36
	{
37
		$this->filters[$filter] = $callback;
38
39
		return $this;
40
	}
41
42
	public function applyFilters(Match $match, array $filters)
43
	{
44
		foreach ($filters as $filter => $parameters)
45
		{
46
			array_unshift($parameters, $match);
47
			$filter = $this->resolveFilter($filter);
48
			$result = call_user_func_array($filter, $parameters);
49
50
			if ($result === null or $result === true)
51
			{
52
				continue;
53
			}
54
55
			if ($result === false)
56
			{
57
				return false;
58
			}
59
60
			$match->response = $result;
61
62
			break;
63
		}
64
65
		return $match;
66
	}
67
68
	public function applyAutoFilter(Match $match)
69
	{
70
		return call_user_func($this->autoFilter, $match);
71
	}
72
73
	public function resolveFilter($name)
74
	{
75
		if (isset($this->filters[$name]))
76
		{
77
			return $this->filters[$name];
78
		}
79
80
		$method = 'filter'.ucfirst($name);
81
82
		if (method_exists($this, $method))
83
		{
84
			return array($this, $method);
85
		}
86
87
		throw new LogicException('Could not find filter: '.$name);
88
	}
89
90
	public function filterDomain(Match $match, $domain)
91
	{
92
		return $_SERVER['SERVER_NAME'] === $domain;
93
	}
94
95
	public function filterNamespace(Match $match, $namespace)
96
	{
97
		$match->setNamespace($namespace);
98
	}
99
100
	public function filterController(Match $match, $controller)
101
	{
102
		$match->setController($controller);
103
	}
104
105
	public function filterAction(Match $match, $action)
106
	{
107
		$match->setAction($action);
108
	}
109
110
	public function filterTo(Match $match, $to)
111
	{
112
		list($controller, $action) = explode('@', $to);
113
114
		$match->setController($controller);
115
		$match->setAction($action);
116
	}
117
118
	public function translate($uri, $method)
119
	{
120
		$uri = trim($uri, '/');
121
122
		foreach ($this->routes as $route)
123
		{
124
			if ($match = $this->match($route, $uri, $method))
125
			{
126
				return $match;
127
			}
128
		}
129
130
		return new Match(null, $method, $uri, $uri);
131
	}
132
133
	public function match(Route $route, $uri, $method = '*')
134
	{
135
		if ($match = $route->match($uri, $method))
136
		{
137
			if ($route->filters)
0 ignored issues
show
Bug Best Practice introduced by
The expression $route->filters of type array 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...
138
			{
139
				return $this->applyFilters($match, $route->filters);
140
			}
141
			elseif ($this->autoFilter)
142
			{
143
				return $this->applyAutoFilter($match);
144
			}
145
			return $match;
146
		}
147
	}
148
}
149