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.

view/api/charInfo.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
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
19
class api_charInfo implements apiEndpoint
20
{
21
	public function getDescription()
22
	{
23
		return array("type" => "description", "message" =>
24
				"Gives you a list of characters, with their corporation history, and some basic kill stats"
25
			);
26
	}
27
28
	public function getAcceptedParameters()
29
	{
30
		return array("type" => "parameters", "parameters" =>
31
			array(
32
				"characterID" => "The characterID of the character you need information on"
33
			)
34
		);
35
	}
36
	public function execute($parameters)
37
	{
38
		$data = array();
0 ignored issues
show
$data 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 $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
39
		if(isset($parameters["characterID"]))
40
			$characterID = (int) $parameters["characterID"][0];
41
42
		$exists = Db::queryField("SELECT characterID FROM zz_characters WHERE characterID = :characterID", "characterID", array(":characterID" => $characterID));
0 ignored issues
show
The variable $characterID does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
43
		if(!$exists)
44
			return array("type" => "error", "message" => "Character does not exist");
45
46
		$data = json_decode(Db::queryField("SELECT history FROM zz_characters WHERE characterID = :charID", "history", array(":charID" => $characterID)), true);
47
		$corporationID = $data["corporationID"];
48
		$allianceID = $data["allianceID"];
49
		$lastSeenSystemID = Db::queryField("SELECT solarSystemID FROM zz_participants WHERE characterID = :charID ORDER BY dttm DESC LIMIT 1", "solarSystemID", array(":charID" => $characterID));
50
		$corpActiveSystemID = Db::queryField("SELECT solarSystemID, count(killID) AS hits FROM zz_participants WHERE characterID = :charID AND corporationID = :corpID AND dttm >= date_sub(now(), interval 30 day) GROUP BY solarSystemID ORDER BY hits DESC LIMIT 10000", "solarSystemID", array(":charID" => $characterID, ":corpID" => $corporationID));
51
		$allianceActiveSystemID = Db::queryField("SELECT solarSystemID, count(killID) AS hits FROM zz_participants WHERE characterID = :charID AND allianceID = :alliID AND dttm >= date_sub(now(), interval 30 day) GROUP BY solarSystemID ORDER BY hits DESC LIMIT 10000", "solarSystemID", array(":charID" => $characterID, ":alliID" => $allianceID));
52
		$data["allianceTicker"] = Db::queryField("SELECT ticker FROM zz_alliances WHERE allianceID = :allianceID", "ticker", array(":allianceID" => $allianceID));
53
		$data["corporationTicker"] = Db::queryField("SELECT ticker FROM zz_corporations WHERE corporationID = :corporationID", "ticker", array(":corporationID" => $corporationID));
54
		$data["lastSeenSystem"] = Info::getSystemName($lastSeenSystemID);
55
		$data["lastSeenRegion"] = Info::getRegionName(Info::getRegionIDFromSystemID($lastSeenSystemID));
56
		$data["lastSeenDate"] = Db::queryField("SELECT dttm FROM zz_participants WHERE characterID = :charID ORDER BY dttm DESC LIMIT 1", "dttm", array(":charID" => $characterID));
57
		$data["lastSeenShip"] = Info::getShipName(Db::queryField("SELECT shipTypeID FROM zz_participants WHERE characterID = :charID AND shipTypeID != 0 ORDER BY dttm DESC LIMIT 1", "shipTypeID", array(":charID" => $characterID)));
58
		$data["corporationActiveArea"] = Info::getRegionName(Info::getRegionIDFromSystemID($corpActiveSystemID));
59
		$data["allianceActiveArea"] = isset($allianceID) ? Info::getRegionName(Info::getRegionIDFromSystemID($allianceActiveSystemID)) : "";
60
		$data["lifeTimeKills"] = Db::queryField("SELECT SUM(destroyed) AS kills FROM zz_stats WHERE typeID = :charID", "kills", array(":charID" => $characterID), 3600);
61
		$data["lifeTimeLosses"] = Db::queryField("SELECT SUM(lost) AS losses FROM zz_stats WHERE typeID = :charID", "losses", array(":charID" => $characterID), 3600);
62
		$data["top10FlownShips"] = Stats::getTopShips(array("characterID" => $characterID, "kills" => true, "month" => date("m"), "year" => date("y"), "limit" => 10), true);
63
		$data["top10ActiveSystems"] = Stats::getTopSystems(array("characterID" => $characterID, "kills" => true, "month" => date("m"), "year" => date("y"), "limit" => 10), true);
64
		$data["lastUpdatedOnBackend"] = Db::queryField("SELECT lastUpdated FROM zz_characters WHERE characterID = :charID", "lastUpdated", array(":charID" => $characterID));
65
		$data["soloKills"] = Db::queryField("SELECT count(*) as kills FROM zz_participants WHERE characterID = :charID AND isVictim = 0 AND number_involved = 1", "kills", array(":charID" => $characterID));
66
		$data["blobKills"] = Db::queryField("SELECT count(*) as kills FROM zz_participants WHERE characterID = :charID AND isVictim = 0 AND number_involved >= 50", "kills", array(":charID" => $characterID));
67
68
		if($data["soloKills"] > 0 && $data["blobKills"] > 0)
69
			$data["percentageSoloPVPer"] = $data["soloKills"] / $data["blobKills"] * 100;
70
71
		$penis = "(..)==";
72
		$cnt = log($data["lifeTimeKills"]) * 3;
73
		$i = 0;
74
		while($i < $cnt)
75
		{
76
			$penis .= "=";
77
			$i++;
78
		}
79
		$data["ePeenSize"] = $penis . "D";
80
81
		$facepalmLosses = Db::queryField("SELECT count(*) AS losses FROM zz_participants WHERE characterID = :charID AND shipPrice >= 200000000 AND isVictim = 1", "losses", array(":charID" => $characterID));
82
		$facepalms = "(>ლ)";
83
		$cnt = log($facepalmLosses);
84
		$i = 0;
85
		while($i < $cnt)
86
		{
87
			$facepalms .= "(>ლ)";
88
			$i++;
89
		}
90
91
		$data["facepalms"] = $facepalms;
92
		return $data;
93
94
		// Do the same with corporation and alliance apis?
95
		// Full character list for corporations / alliances ? :D could be usefull for spymasters and shit
96
	}
97
}
98