Issues (194)

Security Analysis    no vulnerabilities found

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.

LeaderboardOutfitEndpointController.php (3 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
3
// @todo Go over this ENTIRE file again as there's been major refactors since and it's likely broken!
4
5
namespace Ps2alerts\Api\Controller\Endpoint\Leaderboards;
6
7
use Ps2alerts\Api\Repository\Metrics\OutfitTotalRepository;
8
use Ps2alerts\Api\Transformer\Leaderboards\OutfitLeaderboardTransformer;
9
use Psr\Http\Message\ResponseInterface;
10
11
class LeaderboardOutfitEndpointController extends AbstractLeaderboardEndpointController
12
{
13
    protected $repository;
14
15
    /**
16
     * Construct
17
     *
18
     * @param League\Fractal\Manager $fractal
0 ignored issues
show
There is no parameter named $fractal. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
19
     */
20
    public function __construct(
21
        OutfitTotalRepository  $repository
22
    ) {
23
        $this->repository = $repository;
24
    }
25
26
    /**
27
     * Get Outfit Leaderboard
28
     *
29
     * @return ResponseInterface
30
     */
31
    public function outfits()
0 ignored issues
show
outfits uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
32
    {
33
        $valid = $this->validateRequestVars();
34
35
        // If validation didn't pass, chuck 'em out
36
        if ($valid !== true) {
37
            return $this->respondWithError($valid->getMessage(), self::CODE_WRONG_ARGS);
38
        }
39
40
        $server = $_GET['server'];
41
        $limit  = $_GET['limit'];
42
        $offset = $_GET['offset'];
43
44
        // Translate field into table specific columns
45
46
        if (isset($_GET['field'])) {
47
            $field = $this->getField($_GET['field']);
48
        }
49
50
        if (! isset($field)) {
51
            return $this->respondWithError('Field wasn\'t provided and is required.', self::CODE_WRONG_ARGS);
52
        }
53
54
        // Perform Query
55
        $query = $this->repository->newQuery();
56
        $query->cols(['*']);
57
        $query->orderBy(["{$field} desc"]);
58
        $query->where('outfitID > 0');
59
60
        if (isset($server)) {
61
            $query->where('outfitServer = ?', $server);
62
        }
63
64
        if (isset($limit)) {
65
            $query->limit($limit);
66
        } else {
67
            $query->limit(10); // Set default limit
68
        }
69
70
        if (isset($offset)) {
71
            $query->offset($offset);
72
        }
73
74
        return $this->respond(
75
            'collection',
76
            $this->repository->fireStatementAndReturn($query),
77
            new OutfitLeaderboardTransformer
78
        );
79
    }
80
81
    /**
82
     * Gets the appropiate field for the table and handles some table naming oddities
83
     * @param  string $input Field to look at
84
     * @return string
85
     */
86 View Code Duplication
    public function getField($input) {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
87
        $field = null;
88
        switch ($input) {
89
            case 'kills':
90
                $field = 'outfitKills';
91
                break;
92
            case 'deaths':
93
                $field = 'outfitDeaths';
94
                break;
95
            case 'teamkills':
96
                $field = 'outfitTKs';
97
                break;
98
            case 'suicides':
99
                $field = 'outfitSuicides';
100
                break;
101
            case 'captures':
102
                $field = 'outfitCaptures';
103
                break;
104
        }
105
106
        return $field;
107
    }
108
}
109