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/losses.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
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_losses implements apiEndpoint
20
{
21
	public function getDescription()
22
	{
23
		return array("type" => "description", "message" =>
24
				"Shows losses for various entities, using various parameters. You must as minimum pass one of the requiredParameters."
25
			);
26
	}
27
28
	public function getAcceptedParameters()
29
	{
30
		return array("type" => "parameters",
31
			"parameters" => array(
32
				"characterID" => "list losses for a certain characterID.",
33
				"corporationID" => "list losses for a certain corporationID.",
34
				"allianceID" => "list losses for a certain allianceID.",
35
				"factionID" => "list losses for a certain factionID.",
36
				"shipTypeID" => "list losses where a certain shipTypeID is involved.",
37
				"solarSystemID" => "list losses that happened in a certain solarSystemID.",
38
				"regionID" => "list losses that happened in a certain regionID.",
39
				"w-space" => "Only list losses that has happened in wormhole space-",
40
				"page" => "Pagination.",
41
				"orderDirection" => "ASC: Oldest to newest, DESC: newest to oldest (DESC is faster than ASC, by a factor 100).",
42
				"pastSeconds" => "only show losses that has happened in the past number of seconds.",
43
				"startTime" => "Show losses from a certain startTime. (Requires endTime).",
44
				"endTime" => "Show losses to a certain endTime. (Requires startTime).",
45
				"limit" => "Limit the amount of losses shown. Minimum 1, maximum 1000.",
46
				"beforeKillID" => "Show killmails from before this killID.",
47
				"afterKillID" => "Show killmails after this killID.",
48
				"iskValue" => "Only show killmails with a total iskValue above this.",
49
				"no-attackers" => "Remove attackers from the killmail.",
50
				"no-items" => "Remove items from the killmail.",
51
				"finalblow-only" => "Only show killmails where the entity caused a finalBlow (Doesn't work with solarSystemID and regionID)."
52
			),
53
			"requiredParameters" => array(
54
				"characterID",
55
				"corporationID",
56
				"allianceID",
57
				"factionID",
58
				"shipTypeID",
59
				"solarSystemID",
60
				"regionID",
61
				"w-space"
62
			)
63
		);
64
	}
65
	public function execute($parameters)
66
	{
67
		// Generate an accepted parameters array.
68
		$acceptedParameters = self::getAcceptedParameters();
69
		foreach($acceptedParameters["parameters"] as $key => $value)
70
			$acceptedParameters[] = $key;
71
72
		// Remove unwanted parameters
73
		foreach($parameters as $key => $value)
74
			if(!in_array($key, $acceptedParameters))
75
				unset($parameters[$key]);
76
77
		// It's the losses endpoint, so it has to be true..
78
		$parameters["losses"] = true;
79
80
		// If there aren't enough parameters being passed, throw an error.
81
		if(count($parameters) < 2)
82
			return array(
83
				"type" => "error",
84
				"message" => "Invalid request. Atleast two parameters are required."
85
			);
86
87
		// API is true
88
		$paramters["api"] = true;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$paramters was never initialized. Although not strictly required by PHP, it is generally a good practice to add $paramters = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
89
90
		// At least one of these parameters is required
91
		$requiredM = array("characterID", "corporationID", "allianceID", "factionID", "shipTypeID", "solarSystemID", "regionID", "w-space");
92
		$hasRequired = false;
93
		foreach($requiredM as $required)
94
			$hasRequired |= array_key_exists($required, $parameters);
95
96
		if (!isset($parameters["killID"]) && !$hasRequired)
97
			return array(
98
				"type" => "error",
99
				"message" => "Error, must pass atleast one required parameters."
100
			);
101
102
		$requestURI = $_SERVER["REQUEST_URI"];
103
		$key = md5("lossesApi:$requestURI");
104
105
		$data = Cache::get($key);
106
		if(empty($data))
107
		{
108
			$data = Feed::getKills($parameters);
109
			Cache::set($key, $data, 3600);
110
		}
111
112
		$return = array();
113
		foreach($data as $kill)
114
			$return[] = json_decode($kill, true);
115
116
		return $return;
117
	}
118
}
119