This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * YiiDebugToolbarRouter class file. |
||
4 | * |
||
5 | * @author Sergey Malyshev <[email protected]> |
||
6 | */ |
||
7 | |||
8 | /** |
||
9 | * YiiDebugToolbarRouter represents an ... |
||
10 | * |
||
11 | * Description of YiiDebugToolbarRouter |
||
12 | * |
||
13 | * @author Sergey Malyshev <[email protected]> |
||
14 | * @version $Id$ |
||
15 | * @package YiiDebugToolbar |
||
16 | * @since 1.1.7 |
||
17 | */ |
||
18 | class YiiDebugToolbarRoute extends CLogRoute |
||
19 | { |
||
20 | |||
21 | private $_panels = array( |
||
22 | 'YiiDebugToolbarPanelServer', |
||
23 | 'YiiDebugToolbarPanelRequest', |
||
24 | 'YiiDebugToolbarPanelSettings', |
||
25 | 'YiiDebugToolbarPanelViewsRendering', |
||
26 | 'YiiDebugToolbarPanelSql', |
||
27 | 'YiiDebugToolbarPanelLogging', |
||
28 | ); |
||
29 | |||
30 | /** |
||
31 | * The filters are given in an array, each filter being: |
||
32 | * - a normal IP (192.168.0.10 or '::1') |
||
33 | * - an incomplete IP (192.168.0.* or 192.168.0.) |
||
34 | * - a CIDR mask (192.168.0.0/24) |
||
35 | * - "*" for everything. |
||
36 | */ |
||
37 | public $ipFilters=array('127.0.0.1','::1'); |
||
38 | |||
39 | /** |
||
40 | * If true, then after reloading the page will open the current panel. |
||
41 | * @var bool |
||
42 | */ |
||
43 | public $openLastPanel = true; |
||
44 | |||
45 | private $_toolbarWidget, |
||
46 | $_startTime, |
||
47 | $_endTime; |
||
48 | |||
49 | |||
50 | private $_proxyMap = array( |
||
51 | 'viewRenderer' => 'YiiDebugViewRenderer' |
||
52 | ); |
||
53 | |||
54 | public function setPanels(array $pannels) |
||
55 | { |
||
56 | $selfPanels = array_fill_keys($this->_panels, array()); |
||
57 | $this->_panels = array_merge($selfPanels, $pannels); |
||
58 | } |
||
59 | |||
60 | public function getPanels() |
||
61 | { |
||
62 | return $this->_panels; |
||
63 | } |
||
64 | |||
65 | public function getStartTime() |
||
66 | { |
||
67 | return $this->_startTime; |
||
68 | } |
||
69 | |||
70 | public function getEndTime() |
||
71 | { |
||
72 | return $this->_endTime; |
||
73 | } |
||
74 | |||
75 | public function getLoadTime() |
||
76 | { |
||
77 | return ($this->endTime-$this->startTime); |
||
78 | } |
||
79 | |||
80 | protected function getToolbarWidget() |
||
81 | { |
||
82 | if (null === $this->_toolbarWidget) |
||
83 | { |
||
84 | $this->_toolbarWidget = Yii::createComponent(array( |
||
85 | 'class'=>'YiiDebugToolbar', |
||
86 | 'panels'=> $this->panels |
||
87 | ), $this); |
||
88 | } |
||
89 | return $this->_toolbarWidget; |
||
90 | } |
||
91 | |||
92 | public function init() |
||
93 | { |
||
94 | $this->_startTime=microtime(true); |
||
95 | |||
96 | parent::init(); |
||
97 | |||
98 | $c = ($this->allowIp(Yii::app()->request->userHostAddress) && !Yii::app()->getRequest()->getIsAjaxRequest() && (Yii::app() instanceof CWebApplication)); |
||
0 ignored issues
–
show
$c is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
99 | $h = $this->allowIp(Yii::app()->request->userHostAddress); |
||
0 ignored issues
–
show
$h is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
100 | $a = !Yii::app()->getRequest()->getIsAjaxRequest(); |
||
0 ignored issues
–
show
$a is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
101 | $i = (Yii::app() instanceof CWebApplication); |
||
0 ignored issues
–
show
The class
CWebApplication does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() $i is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
102 | |||
103 | $this->enabled && $this->enabled = ($this->allowIp(Yii::app()->request->userHostAddress) |
||
104 | && !Yii::app()->getRequest()->getIsAjaxRequest() && (Yii::app() instanceof CWebApplication)); |
||
0 ignored issues
–
show
The class
CWebApplication does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
105 | |||
106 | if ($this->enabled) |
||
107 | { |
||
108 | Yii::app()->attachEventHandler('onBeginRequest', array($this, 'onBeginRequest')); |
||
109 | Yii::app()->attachEventHandler('onEndRequest', array($this, 'onEndRequest')); |
||
110 | Yii::setPathOfAlias('yii-debug-toolbar', dirname(__FILE__)); |
||
111 | Yii::app()->setImport(array( |
||
112 | 'yii-debug-toolbar.*', |
||
113 | 'yii-debug-toolbar.components.*' |
||
114 | )); |
||
115 | $this->categories = ''; |
||
116 | $this->levels=''; |
||
117 | } |
||
118 | } |
||
119 | |||
120 | protected function onBeginRequest(CEvent $event) |
||
121 | { |
||
122 | $this->initComponents(); |
||
123 | |||
124 | $this->getToolbarWidget() |
||
125 | ->init(); |
||
126 | } |
||
127 | |||
128 | protected function initComponents() |
||
129 | { |
||
130 | foreach ($this->_proxyMap as $name=>$class) |
||
131 | { |
||
132 | $instance = Yii::app()->getComponent($name); |
||
133 | if (null !== ($instance)) |
||
134 | { |
||
135 | Yii::app()->setComponent($name, null); |
||
136 | } |
||
137 | $this->_proxyMap[$name] = array( |
||
138 | 'class'=>$class, |
||
139 | 'instance' => $instance |
||
140 | ); |
||
141 | } |
||
142 | Yii::app()->setComponents($this->_proxyMap, false); |
||
143 | } |
||
144 | |||
145 | |||
146 | /** |
||
147 | * Processes the current request. |
||
148 | * It first resolves the request into controller and action, |
||
149 | * and then creates the controller to perform the action. |
||
150 | */ |
||
151 | private function processRequest() |
||
0 ignored issues
–
show
|
|||
152 | { |
||
153 | if(is_array(Yii::app()->catchAllRequest) && isset(Yii::app()->catchAllRequest[0])) |
||
154 | { |
||
155 | $route=Yii::app()->catchAllRequest[0]; |
||
156 | foreach(array_splice(Yii::app()->catchAllRequest,1) as $name=>$value) |
||
157 | $_GET[$name]=$value; |
||
158 | } |
||
159 | else |
||
160 | $route=Yii::app()->getUrlManager()->parseUrl(Yii::app()->getRequest()); |
||
161 | Yii::app()->runController($route); |
||
162 | } |
||
163 | |||
164 | protected function onEndRequest(CEvent $event) |
||
165 | { |
||
166 | |||
167 | } |
||
168 | |||
169 | public function collectLogs($logger, $processLogs=false) |
||
170 | { |
||
171 | parent::collectLogs($logger, $processLogs); |
||
172 | } |
||
173 | |||
174 | protected function processLogs($logs) |
||
175 | { |
||
176 | $this->_endTime = microtime(true); |
||
177 | $this->enabled && $this->getToolbarWidget()->run(); |
||
178 | } |
||
179 | |||
180 | /** |
||
181 | * Checks to see if the user IP is allowed by {@link ipFilters}. |
||
182 | * @param string $ip the user IP |
||
183 | * @return boolean whether the user IP is allowed by {@link ipFilters}. |
||
184 | */ |
||
185 | protected function allowIp($ip) |
||
186 | { |
||
187 | foreach ($this->ipFilters as $filter) |
||
188 | { |
||
189 | $filter = trim($filter); |
||
190 | // normal or incomplete IPv4 |
||
191 | if (preg_match('/^[\d\.]*\*?$/', $filter)) { |
||
192 | $filter = rtrim($filter, '*'); |
||
193 | if (strncmp($ip, $filter, strlen($filter)) === 0) |
||
194 | { |
||
195 | return true; |
||
196 | } |
||
197 | } |
||
198 | // CIDR |
||
199 | else if (preg_match('/^([\d\.]+)\/(\d+)$/', $filter, $match)) |
||
200 | { |
||
201 | if (self::matchIpMask($ip, $match[1], $match[2])) |
||
202 | { |
||
203 | return true; |
||
204 | } |
||
205 | } |
||
206 | // IPv6 |
||
207 | else if ($ip === $filter) |
||
208 | { |
||
209 | return true; |
||
210 | } |
||
211 | } |
||
212 | return false; |
||
213 | } |
||
214 | |||
215 | /** |
||
216 | * Check if an IP matches a CIDR mask. |
||
217 | * |
||
218 | * @param integer|string $ip IP to check. |
||
219 | * @param integer|string $matchIp Radical of the mask (e.g. 192.168.0.0). |
||
0 ignored issues
–
show
There is no parameter named
$matchIp . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not. ![]() |
|||
220 | * @param integer $maskBits Size of the mask (e.g. 24). |
||
221 | */ |
||
222 | protected static function matchIpMask($ip, $maskIp, $maskBits) |
||
223 | { |
||
224 | $mask =~ (pow(2, 32-$maskBits)-1); |
||
225 | if (false === is_int($ip)) |
||
226 | { |
||
227 | $ip = ip2long($ip); |
||
228 | } |
||
229 | if (false === is_int($maskIp)) |
||
230 | { |
||
231 | $maskIp = ip2long($maskIp); |
||
232 | } |
||
233 | if (($ip & $mask) === ($maskIp & $mask)) |
||
234 | { |
||
235 | return true; |
||
236 | } else { |
||
237 | return false; |
||
238 | } |
||
239 | } |
||
240 | } |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.