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/Migration.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
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 52 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 3.0.0
36
 * @filesource
37
 */
38
defined('BASEPATH') OR exit('No direct script access allowed');
39
40
/**
41
 * Migration Class
42
 *
43
 * All migrations should implement this, forces up() and down() and gives
44
 * access to the CI super-global.
45
 *
46
 * @package		CodeIgniter
47
 * @subpackage	Libraries
48
 * @category	Libraries
49
 * @author		Reactor Engineers
50
 * @link
51
 */
52
class CI_Migration {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type CI_Migration has been defined more than once; this definition is ignored, only the first definition in application/libraries/Migration.php (L52-578) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
53
54
	/**
55
	 * Whether the library is enabled
56
	 *
57
	 * @var bool
58
	 */
59
	protected $_migration_enabled = FALSE;
60
61
	/**
62
	 * Migration numbering type
63
	 *
64
	 * @var	bool
65
	 */
66
	protected $_migration_type = 'sequential';
67
68
	/**
69
	 * Path to migration classes
70
	 *
71
	 * @var string
72
	 */
73
	protected $_migration_path = NULL;
74
75
	/**
76
	 * Current migration version
77
	 *
78
	 * @var mixed
79
	 */
80
	protected $_migration_version = 0;
81
82
	/**
83
	 * Database table with migration info
84
	 *
85
	 * @var string
86
	 */
87
	protected $_migration_table = 'migrations';
88
89
	/**
90
	 * Whether to automatically run migrations
91
	 *
92
	 * @var	bool
93
	 */
94
	protected $_migration_auto_latest = FALSE;
95
96
	/**
97
	 * Migration basename regex
98
	 *
99
	 * @var bool
100
	 */
101
	protected $_migration_regex = NULL;
102
103
	/**
104
	 * Error message
105
	 *
106
	 * @var string
107
	 */
108
	protected $_error_string = '';
109
110
	/**
111
	 * Initialize Migration Class
112
	 *
113
	 * @param	array	$config
114
	 * @return	void
115
	 */
116
	public function __construct($config = array())
117
	{
118
		// Only run this constructor on main library load
119 View Code Duplication
		if ( ! in_array(get_class($this), array('CI_Migration', config_item('subclass_prefix').'Migration'), TRUE))
120
		{
121
			return;
122
		}
123
124
		foreach ($config as $key => $val)
125
		{
126
			$this->{'_'.$key} = $val;
127
		}
128
129
		log_message('info', 'Migrations Class Initialized');
130
131
		// Are they trying to use migrations while it is disabled?
132
		if ($this->_migration_enabled !== TRUE)
133
		{
134
			show_error('Migrations has been loaded but is disabled or set up incorrectly.');
135
		}
136
137
		// If not set, set it
138
		$this->_migration_path !== '' OR $this->_migration_path = APPPATH.'migrations/';
139
140
		// Add trailing slash if not set
141
		$this->_migration_path = rtrim($this->_migration_path, '/').'/';
142
143
		// Load migration language
144
		$this->lang->load('migration');
145
146
		// They'll probably be using dbforge
147
		$this->load->dbforge();
148
149
		// Make sure the migration table name was set.
150
		if (empty($this->_migration_table))
151
		{
152
			show_error('Migrations configuration file (migration.php) must have "migration_table" set.');
153
		}
154
155
		// Migration basename regex
156
		$this->_migration_regex = ($this->_migration_type === 'timestamp')
157
			? '/^\d{14}_(\w+)$/'
158
			: '/^\d{3}_(\w+)$/';
159
160
		// Make sure a valid migration numbering type was set.
161 View Code Duplication
		if ( ! in_array($this->_migration_type, array('sequential', 'timestamp')))
162
		{
163
			show_error('An invalid migration numbering type was specified: '.$this->_migration_type);
164
		}
165
166
		// If the migrations table is missing, make it
167
		if ( ! $this->db->table_exists($this->_migration_table))
168
		{
169
			$this->dbforge->add_field(array(
170
				'version' => array('type' => 'BIGINT', 'constraint' => 20),
171
			));
172
173
			$this->dbforge->create_table($this->_migration_table, TRUE);
174
175
			$this->db->insert($this->_migration_table, array('version' => 0));
176
		}
177
178
		// Do we auto migrate to the latest migration?
179
		if ($this->_migration_auto_latest === TRUE && ! $this->latest())
180
		{
181
			show_error($this->error_string());
182
		}
183
	}
184
185
	// --------------------------------------------------------------------
186
187
	/**
188
	 * Migrate to a schema version
189
	 *
190
	 * Calls each migration step required to get to the schema version of
191
	 * choice
192
	 *
193
	 * @param	string	$target_version	Target schema version
194
	 * @return	mixed	TRUE if no migrations are found, current version string on success, FALSE on failure
195
	 */
196
	public function version($target_version)
197
	{
198
		// Note: We use strings, so that timestamp versions work on 32-bit systems
199
		$current_version = $this->_get_version();
200
201 View Code Duplication
		if ($this->_migration_type === 'sequential')
202
		{
203
			$target_version = sprintf('%03d', $target_version);
204
		}
205
		else
206
		{
207
			$target_version = (string) $target_version;
208
		}
209
210
		$migrations = $this->find_migrations();
211
212 View Code Duplication
		if ($target_version > 0 && ! isset($migrations[$target_version]))
213
		{
214
			$this->_error_string = sprintf($this->lang->line('migration_not_found'), $target_version);
215
			return FALSE;
216
		}
217
218
		if ($target_version > $current_version)
219
		{
220
			// Moving Up
221
			$method = 'up';
222
		}
223
		else
224
		{
225
			// Moving Down, apply in reverse order
226
			$method = 'down';
227
			krsort($migrations);
228
		}
229
230
		if (empty($migrations))
231
		{
232
			return TRUE;
233
		}
234
235
		$previous = FALSE;
236
237
		// Validate all available migrations, and run the ones within our target range
238 View Code Duplication
		foreach ($migrations as $number => $file)
239
		{
240
			// Check for sequence gaps
241
			if ($this->_migration_type === 'sequential' && $previous !== FALSE && abs($number - $previous) > 1)
242
			{
243
				$this->_error_string = sprintf($this->lang->line('migration_sequence_gap'), $number);
244
				return FALSE;
245
			}
246
247
			include_once($file);
248
			$class = 'Migration_'.ucfirst(strtolower($this->_get_migration_name(basename($file, '.php'))));
249
250
			// Validate the migration file structure
251
			if ( ! class_exists($class, FALSE))
252
			{
253
				$this->_error_string = sprintf($this->lang->line('migration_class_doesnt_exist'), $class);
254
				return FALSE;
255
			}
256
257
			$previous = $number;
258
259
			// Run migrations that are inside the target range
260
			if (
261
				($method === 'up'   && $number > $current_version && $number <= $target_version) OR
262
				($method === 'down' && $number <= $current_version && $number > $target_version)
263
			)
264
			{
265
				$instance = new $class();
266
				if ( ! is_callable(array($instance, $method)))
267
				{
268
					$this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class);
269
					return FALSE;
270
				}
271
272
				log_message('debug', 'Migrating '.$method.' from version '.$current_version.' to version '.$number);
273
				call_user_func(array($instance, $method));
274
				$current_version = $number;
275
				$this->_update_version($current_version);
276
			}
277
		}
278
279
		// This is necessary when moving down, since the the last migration applied
280
		// will be the down() method for the next migration up from the target
281
		if ($current_version <> $target_version)
282
		{
283
			$current_version = $target_version;
284
			$this->_update_version($current_version);
285
		}
286
287
		log_message('debug', 'Finished migrating to '.$current_version);
288
289
		return $current_version;
290
	}
291
292
	// --------------------------------------------------------------------
293
294
	/**
295
	 * Sets the schema to the latest migration
296
	 *
297
	 * @return	mixed	Current version string on success, FALSE on failure
298
	 */
299
	public function latest()
300
	{
301
		$migrations = $this->find_migrations();
302
303
		if (empty($migrations))
304
		{
305
			$this->_error_string = $this->lang->line('migration_none_found');
306
			return FALSE;
307
		}
308
309
		$last_migration = basename(end($migrations));
310
311
		// Calculate the last migration step from existing migration
312
		// filenames and proceed to the standard version migration
313
		return $this->version($this->_get_migration_number($last_migration));
314
	}
315
316
	// --------------------------------------------------------------------
317
318
	/**
319
	 * Sets the schema to the migration version set in config
320
	 *
321
	 * @return	mixed	TRUE if no migrations are found, current version string on success, FALSE on failure
322
	 */
323
	public function current()
324
	{
325
		return $this->version($this->_migration_version);
326
	}
327
328
	// --------------------------------------------------------------------
329
330
	/**
331
	 * Error string
332
	 *
333
	 * @return	string	Error message returned as a string
334
	 */
335
	public function error_string()
336
	{
337
		return $this->_error_string;
338
	}
339
340
	// --------------------------------------------------------------------
341
342
	/**
343
	 * Retrieves list of available migration scripts
344
	 *
345
	 * @return	array	list of migration file paths sorted by version
346
	 */
347
	public function find_migrations()
348
	{
349
		$migrations = array();
350
351
		// Load all *_*.php files in the migrations path
352 View Code Duplication
		foreach (glob($this->_migration_path.'*_*.php') as $file)
353
		{
354
			$name = basename($file, '.php');
355
356
			// Filter out non-migration files
357
			if (preg_match($this->_migration_regex, $name))
358
			{
359
				$number = $this->_get_migration_number($name);
360
361
				// There cannot be duplicate migration numbers
362
				if (isset($migrations[$number]))
363
				{
364
					$this->_error_string = sprintf($this->lang->line('migration_multiple_version'), $number);
365
					show_error($this->_error_string);
366
				}
367
368
				$migrations[$number] = $file;
369
			}
370
		}
371
372
		ksort($migrations);
373
		return $migrations;
374
	}
375
376
	// --------------------------------------------------------------------
377
378
	/**
379
	 * Extracts the migration number from a filename
380
	 *
381
	 * @param	string	$migration
382
	 * @return	string	Numeric portion of a migration filename
383
	 */
384
	protected function _get_migration_number($migration)
385
	{
386
		return sscanf($migration, '%[0-9]+', $number)
387
			? $number : '0';
388
	}
389
390
	// --------------------------------------------------------------------
391
392
	/**
393
	 * Extracts the migration class name from a filename
394
	 *
395
	 * @param	string	$migration
396
	 * @return	string	text portion of a migration filename
397
	 */
398
	protected function _get_migration_name($migration)
399
	{
400
		$parts = explode('_', $migration);
401
		array_shift($parts);
402
		return implode('_', $parts);
403
	}
404
405
	// --------------------------------------------------------------------
406
407
	/**
408
	 * Retrieves current schema version
409
	 *
410
	 * @return	string	Current migration version
411
	 */
412
	protected function _get_version()
413
	{
414
		$row = $this->db->select('version')->get($this->_migration_table)->row();
415
		return $row ? $row->version : '0';
416
	}
417
418
	// --------------------------------------------------------------------
419
420
	/**
421
	 * Stores the current schema version
422
	 *
423
	 * @param	string	$migration	Migration reached
424
	 * @return	void
425
	 */
426
	protected function _update_version($migration)
427
	{
428
		$this->db->update($this->_migration_table, array(
429
			'version' => $migration
430
		));
431
	}
432
433
	// --------------------------------------------------------------------
434
435
	/**
436
	 * Enable the use of CI super-global
437
	 *
438
	 * @param	string	$var
439
	 * @return	mixed
440
	 */
441
	public function __get($var)
442
	{
443
		return get_instance()->$var;
444
	}
445
446
}
447