Issues (24)

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.

classes/Migration/Driver/Mysql/Table.php (5 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 defined('SYSPATH') OR die('No direct script access.');
2
3
class Migration_Driver_Mysql_Table extends Migration_Driver_Table
4
{
5
6
	public function params(array $columns = NULL, array $options = NULL)
7
	{
8
		$columns = (array) $columns;
9
		$this->options = Arr::get( (array) $options, 'options');
0 ignored issues
show
Documentation Bug introduced by
It seems like \Arr::get((array) $options, 'options') of type * is incompatible with the declared type array of property $options.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
10
11
		if (Arr::get((array) $options, 'id', TRUE))
12
		{
13
			$columns = array_merge(array('id' => 'primary_key'), $columns);
14 1
		}
15
16 1
		foreach ($columns as $column_name => $params)
17 1
		{
18
			$this->columns[$column_name] = $this->driver->column($column_name)->params($params);
19 1
		}
20 1
21 1
		return $this;
22 1
	}
23
24 1
	public function load()
25
	{
26 1
		$this->columns = array();
27 1
		$this->options = array();
28
		$this->keys = array();
0 ignored issues
show
The property keys does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
29 1
30
		$result = $this->driver->pdo->query("SHOW TABLE STATUS LIKE '{$this->name}'");
0 ignored issues
show
The property pdo does not seem to exist in Migration_Driver.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
31
32 1
		if ($result->rowCount() !== 1)
33
		{
34 1
			throw new Migration_Exception(":table does not exist", array(':table' => $this->name));
35 1
		}
36 1
37
		$table->options[] = 'ENGINE='.$result->fetchObject()->Engine;
0 ignored issues
show
The variable $table does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
38 1
39
		$fields_reuslt = $this->driver->pdo->query("SHOW COLUMNS FROM `{$this->name}`");
40 1
41 1
		while($result = $fields_reuslt->fetchObject())
42 1
		{
43
			$this->columns[$result->Field] = $this->driver->column($result->Field)->load($result);
44
		}
45
		return $this;
46
	}
47
48
	public function sql()
49
	{
50
		$primary_keys = array();
51
		$columns = array();
52
53
		foreach ($this->columns as $column)
54
		{
55
			$columns[] = $column->sql();
56 1
			if ($column->param('primary'))
57
			{
58 1
				$primary_keys[] = "`".$column->name()."`";
59 1
			}
60
		}
61 1
62
		if ($primary_keys)
0 ignored issues
show
Bug Best Practice introduced by
The expression $primary_keys 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...
63 1
		{
64 1
			$columns[] = 'PRIMARY KEY ('.join(', ', $primary_keys).')';
65 1
		}
66 1
67 1
		return join(' ', array_filter(array(
68 1
			"CREATE TABLE `{$this->name}`",
69
			'('. join(', ', $columns).')',
70
			$this->options
71 1
		)));
72 1
	}
73
}
74