Issues (438)

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.

install/update.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
2
/* zKillboard
3
 * Copyright (C) 2012-2015 EVE-KILL Team and EVSCO.
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Affero General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU Affero General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU Affero General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18
if(php_sapi_name() != "cli")
19
    die("This is a cli script!");
20
21
$base = dirname(__FILE__);
22
23
if(php_sapi_name() != "cli")
24
die("This is a cli script!");
25
26
if(!extension_loaded('pcntl'))
27
die("This script needs the pcntl extension!");
28
29
// Update composer and any vendor products
30
out("\nUpdating composer...");
31
chdir("$base/..");
32
passthru("php composer.phar self-update");
33
out("\nUpdating vendor files...");
34
passthru("php composer.phar update --optimize-autoloader");
35
36
require_once( "config.php" );
37
chdir("$base");
38
39
// vendor autoload
40
require( "$base/../vendor/autoload.php" );
41
42
// zkb class autoloader
43
spl_autoload_register("zkbautoload");
44
45
function zkbautoload($class_name)
0 ignored issues
show
The function zkbautoload() has been defined more than once; this definition is ignored, only the first definition in init.php (L40-49) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
46
{
47
	global $base;
48
	$fileName = "$base/../classes/$class_name.php";
49
	if (file_exists($fileName))
50
	{
51
		require_once $fileName;
52
		return;
53
	}
54
}
55
56
Db::execute("SET SESSION wait_timeout = 120000000");
57
out("\n|g|Starting maintenance mode...|n|");
58
Db::execute("replace into zz_storage values ('maintenance', 'true')");
59
out("|b|Waiting 60 seconds for all executing scripts to stop...|n|");
60
sleep(60);
61
62
// Get a list of all tables
63
$tableResult = Db::query("show tables", array(), 0, false);
64
$tables = array();
65
foreach($tableResult as $row)
66
{
67
	$table = array_pop($row);
68
	$tables[$table] = true;
69
}
70
71
// Now install the db structure
72
try {
73
	$sqlFiles = scandir("$base/sql");
74
	foreach($sqlFiles as $file)
75
	{
76
		if (Util::endsWith($file, ".sql"))
77
		{
78
			$table = str_replace(".sql", "", $file);
79
			out("Updating table |g|$table|n| ... ", false, false);
80
			$sqlFile = "$base/sql/$file";
81
			loadFile($sqlFile, $table);
0 ignored issues
show
The call to loadFile() has too many arguments starting with $table.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
82
			out("|w|done|n|");
83
			$tables[$table] = false;
84
		}
85
	}
86
	foreach ($tables as $table=>$drop)
87
	{
88
		if ($drop && Util::startsWith($table, "zz_"))
89
		{
90
			out("|r|Dropping table: |g|$table|n|\n", false, false);
91
			Db::execute("drop table $table");
92
		}
93
	}
94
}
95
catch (Exception $ex)
96
{
97
	out("|r|Error!|n|");
98
	throw $ex;
99
}
100
101
$count = Db::execute("INSERT IGNORE INTO zz_users (username, moderator, admin, password) VALUES ('admin', 1, 1, '$2y$10\$maxuZ/qozcjIgr7ZSnrWJemywbThbPiJDYIuOk9eLxF0pGE5SkNNu')");
102
if ($count > 0)
103
	out("\n\n|r|*** NOTICE ***\nDefault admin user has been added with password 'admin'\nIt is strongly recommended you change this password!\n*** NOTICE ***\n");
104
105
out("|g|Unsetting maintenance mode|n|");
106
Db::execute("delete from zz_storage where locker = 'maintenance'");
107
out("All done, enjoy your update!");
108
109
function loadFile($file, $table)
0 ignored issues
show
The function loadFile() has been defined more than once; this definition is ignored, only the first definition in install/install.php (L241-258) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
110
{
111
	if (Util::endsWith($file, ".gz"))
112
		$handle = gzopen($file, "r");
113
	else
114
		$handle = fopen($file, "r");
115
116
	//Check to see if we are adding new tables
117
	if(Db::queryRow("SHOW TABLES LIKE'$table'", array(), 0, false)!= null)
118
	{
119
		if (Util::startsWith($table, "ccp_"))
120
			Db::execute("drop table $table");
121
		else
122
			Db::execute("alter table $table rename old_$table");
123
	}
124
125
126
	$query = "";
127
	while ($buffer = fgets($handle)) {
128
		$query .= $buffer;
129
		if (strpos($query, ";") !== false) {
130
			$query = str_replace(";", "", $query);
131
			Db::execute($query);
132
			$query = "";
133
		}
134
	}
135
	fclose($handle);
136
137
	if (Db::queryRow("SHOW TABLES LIKE 'old_$table'", array(), 0, false)!= null){ // Check again to see if the old_table is there
138
		if (!Util::startsWith($table, "ccp_")) {
139
			try {
140
				Db::execute("insert ignore into $table select * from old_$table");
141
				Db::execute("drop table old_$table");
142
			} catch (Exception $ex) {
143
				Db::execute("drop table $table");
144
				Db::execute("alter table old_$table rename $table");
145
				throw $ex;
146
			}
147
		}
148
	}
149
}
150
151
function out($message, $die = false, $newline = true)
0 ignored issues
show
The parameter $die is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The function out() has been defined more than once; this definition is ignored, only the first definition in install/install.php (L260-280) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
152
{
153
	$colors = array(
154
			"|w|" => "1;37", //White
155
			"|b|" => "0;34", //Blue
156
			"|g|" => "0;32", //Green
157
			"|r|" => "0;31", //Red
158
			"|n|" => "0" //Neutral
159
		       );
160
161
	$message = "$message|n|";
162
	foreach($colors as $color => $value)
163
		$message = str_replace($color, "\033[".$value."m", $message);
164
165
	if($newline)
166
		echo $message.PHP_EOL;
167
	else
168
		echo $message;
169
}
170