GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (423)

Security Analysis    not enabled

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.

system/libraries/Unit_test.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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 51 and the first side effect is on line 38.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * CodeIgniter
4
 *
5
 * An open source application development framework for PHP
6
 *
7
 * This content is released under the MIT License (MIT)
8
 *
9
 * Copyright (c) 2014 - 2015, British Columbia Institute of Technology
10
 *
11
 * Permission is hereby granted, free of charge, to any person obtaining a copy
12
 * of this software and associated documentation files (the "Software"), to deal
13
 * in the Software without restriction, including without limitation the rights
14
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
 * copies of the Software, and to permit persons to whom the Software is
16
 * furnished to do so, subject to the following conditions:
17
 *
18
 * The above copyright notice and this permission notice shall be included in
19
 * all copies or substantial portions of the Software.
20
 *
21
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
 * THE SOFTWARE.
28
 *
29
 * @package	CodeIgniter
30
 * @author	EllisLab Dev Team
31
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
32
 * @copyright	Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
33
 * @license	http://opensource.org/licenses/MIT	MIT License
34
 * @link	http://codeigniter.com
35
 * @since	Version 1.3.1
36
 * @filesource
37
 */
38
defined('BASEPATH') OR exit('No direct script access allowed');
39
40
/**
41
 * Unit Testing Class
42
 *
43
 * Simple testing class
44
 *
45
 * @package		CodeIgniter
46
 * @subpackage	Libraries
47
 * @category	UnitTesting
48
 * @author		EllisLab Dev Team
49
 * @link		http://codeigniter.com/user_guide/libraries/unit_testing.html
50
 */
51
class CI_Unit_test {
52
53
	/**
54
	 * Active flag
55
	 *
56
	 * @var	bool
57
	 */
58
	public $active = TRUE;
59
60
	/**
61
	 * Test results
62
	 *
63
	 * @var	array
64
	 */
65
	public $results = array();
66
67
	/**
68
	 * Strict comparison flag
69
	 *
70
	 * Whether to use === or == when comparing
71
	 *
72
	 * @var	bool
73
	 */
74
	public $strict = FALSE;
75
76
	/**
77
	 * Template
78
	 *
79
	 * @var	string
80
	 */
81
	protected $_template = NULL;
82
83
	/**
84
	 * Template rows
85
	 *
86
	 * @var	string
87
	 */
88
	protected $_template_rows = NULL;
89
90
	/**
91
	 * List of visible test items
92
	 *
93
	 * @var	array
94
	 */
95
	protected $_test_items_visible	= array(
96
		'test_name',
97
		'test_datatype',
98
		'res_datatype',
99
		'result',
100
		'file',
101
		'line',
102
		'notes'
103
	);
104
105
	// --------------------------------------------------------------------
106
107
	/**
108
	 * Constructor
109
	 *
110
	 * @return	void
111
	 */
112
	public function __construct()
113
	{
114
		log_message('info', 'Unit Testing Class Initialized');
115
	}
116
117
	// --------------------------------------------------------------------
118
119
	/**
120
	 * Run the tests
121
	 *
122
	 * Runs the supplied tests
123
	 *
124
	 * @param	array	$items
125
	 * @return	void
126
	 */
127
	public function set_test_items($items)
128
	{
129
		if ( ! empty($items) && is_array($items))
130
		{
131
			$this->_test_items_visible = $items;
132
		}
133
	}
134
135
	// --------------------------------------------------------------------
136
137
	/**
138
	 * Run the tests
139
	 *
140
	 * Runs the supplied tests
141
	 *
142
	 * @param	mixed	$test
143
	 * @param	mixed	$expected
144
	 * @param	string	$test_name
145
	 * @param	string	$notes
146
	 * @return	string
147
	 */
148
	public function run($test, $expected = TRUE, $test_name = 'undefined', $notes = '')
149
	{
150
		if ($this->active === FALSE)
151
		{
152
			return FALSE;
153
		}
154
155
		if (in_array($expected, array('is_object', 'is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null', 'is_resource'), TRUE))
156
		{
157
			$expected = str_replace('is_double', 'is_float', $expected);
158
			$result = $expected($test);
159
			$extype = str_replace(array('true', 'false'), 'bool', str_replace('is_', '', $expected));
160
		}
161
		else
162
		{
163
			$result = ($this->strict === TRUE) ? ($test === $expected) : ($test == $expected);
164
			$extype = gettype($expected);
165
		}
166
167
		$back = $this->_backtrace();
168
169
		$report = array (
170
			'test_name'     => $test_name,
171
			'test_datatype' => gettype($test),
172
			'res_datatype'  => $extype,
173
			'result'        => ($result === TRUE) ? 'passed' : 'failed',
174
			'file'          => $back['file'],
175
			'line'          => $back['line'],
176
			'notes'         => $notes
177
		);
178
179
		$this->results[] = $report;
180
181
		return $this->report($this->result(array($report)));
182
	}
183
184
	// --------------------------------------------------------------------
185
186
	/**
187
	 * Generate a report
188
	 *
189
	 * Displays a table with the test data
190
	 *
191
	 * @param	array	 $result
192
	 * @return	string
193
	 */
194
	public function report($result = array())
195
	{
196
		if (count($result) === 0)
197
		{
198
			$result = $this->result();
199
		}
200
201
		$CI =& get_instance();
202
		$CI->load->language('unit_test');
203
204
		$this->_parse_template();
205
206
		$r = '';
207
		foreach ($result as $res)
208
		{
209
			$table = '';
210
211
			foreach ($res as $key => $val)
212
			{
213
				if ($key === $CI->lang->line('ut_result'))
214
				{
215
					if ($val === $CI->lang->line('ut_passed'))
216
					{
217
						$val = '<span style="color: #0C0;">'.$val.'</span>';
218
					}
219
					elseif ($val === $CI->lang->line('ut_failed'))
220
					{
221
						$val = '<span style="color: #C00;">'.$val.'</span>';
222
					}
223
				}
224
225
				$table .= str_replace(array('{item}', '{result}'), array($key, $val), $this->_template_rows);
226
			}
227
228
			$r .= str_replace('{rows}', $table, $this->_template);
229
		}
230
231
		return $r;
232
	}
233
234
	// --------------------------------------------------------------------
235
236
	/**
237
	 * Use strict comparison
238
	 *
239
	 * Causes the evaluation to use === rather than ==
240
	 *
241
	 * @param	bool	$state
242
	 * @return	void
243
	 */
244
	public function use_strict($state = TRUE)
245
	{
246
		$this->strict = (bool) $state;
247
	}
248
249
	// --------------------------------------------------------------------
250
251
	/**
252
	 * Make Unit testing active
253
	 *
254
	 * Enables/disables unit testing
255
	 *
256
	 * @param	bool
257
	 * @return	void
258
	 */
259
	public function active($state = TRUE)
260
	{
261
		$this->active = (bool) $state;
262
	}
263
264
	// --------------------------------------------------------------------
265
266
	/**
267
	 * Result Array
268
	 *
269
	 * Returns the raw result data
270
	 *
271
	 * @param	array	$results
272
	 * @return	array
273
	 */
274
	public function result($results = array())
275
	{
276
		$CI =& get_instance();
277
		$CI->load->language('unit_test');
278
279
		if (count($results) === 0)
280
		{
281
			$results = $this->results;
282
		}
283
284
		$retval = array();
285
		foreach ($results as $result)
286
		{
287
			$temp = array();
288
			foreach ($result as $key => $val)
289
			{
290
				if ( ! in_array($key, $this->_test_items_visible))
291
				{
292
					continue;
293
				}
294
				elseif (in_array($key, array('test_name', 'test_datatype', 'test_res_datatype', 'result'), TRUE))
295
				{
296
					if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val), FALSE)))
297
					{
298
						$val = $line;
299
					}
300
				}
301
302
				$temp[$CI->lang->line('ut_'.$key, FALSE)] = $val;
303
			}
304
305
			$retval[] = $temp;
306
		}
307
308
		return $retval;
309
	}
310
311
	// --------------------------------------------------------------------
312
313
	/**
314
	 * Set the template
315
	 *
316
	 * This lets us set the template to be used to display results
317
	 *
318
	 * @param	string
319
	 * @return	void
320
	 */
321
	public function set_template($template)
322
	{
323
		$this->_template = $template;
324
	}
325
326
	// --------------------------------------------------------------------
327
328
	/**
329
	 * Generate a backtrace
330
	 *
331
	 * This lets us show file names and line numbers
332
	 *
333
	 * @return	array
334
	 */
335
	protected function _backtrace()
336
	{
337
		$back = debug_backtrace();
338
		return array(
339
			'file' => (isset($back[1]['file']) ? $back[1]['file'] : ''),
340
			'line' => (isset($back[1]['line']) ? $back[1]['line'] : '')
341
		);
342
	}
343
344
	// --------------------------------------------------------------------
345
346
	/**
347
	 * Get Default Template
348
	 *
349
	 * @return	string
350
	 */
351
	protected function _default_template()
352
	{
353
		$this->_template = "\n".'<table style="width:100%; font-size:small; margin:10px 0; border-collapse:collapse; border:1px solid #CCC;">{rows}'."\n</table>";
354
355
		$this->_template_rows = "\n\t<tr>\n\t\t".'<th style="text-align: left; border-bottom:1px solid #CCC;">{item}</th>'
356
					."\n\t\t".'<td style="border-bottom:1px solid #CCC;">{result}</td>'."\n\t</tr>";
357
	}
358
359
	// --------------------------------------------------------------------
360
361
	/**
362
	 * Parse Template
363
	 *
364
	 * Harvests the data within the template {pseudo-variables}
365
	 *
366
	 * @return	void
367
	 */
368
	protected function _parse_template()
369
	{
370
		if ($this->_template_rows !== NULL)
371
		{
372
			return;
373
		}
374
375
		if ($this->_template === NULL OR ! preg_match('/\{rows\}(.*?)\{\/rows\}/si', $this->_template, $match))
376
		{
377
			$this->_default_template();
378
			return;
379
		}
380
381
		$this->_template_rows = $match[1];
382
		$this->_template = str_replace($match[0], '{rows}', $this->_template);
383
	}
384
385
}
386
387
/**
388
 * Helper function to test boolean TRUE
389
 *
390
 * @param	mixed	$test
391
 * @return	bool
392
 */
393
function is_true($test)
394
{
395
	return ($test === TRUE);
396
}
397
398
/**
399
 * Helper function to test boolean FALSE
400
 *
401
 * @param	mixed	$test
402
 * @return	bool
403
 */
404
function is_false($test)
405
{
406
	return ($test === FALSE);
407
}
408