Issues (80)

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.

api/index.php (13 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
4
require_once("vendor/autoload.php");
5
6
7
use App\Lib\DsManager\Helpers\MatchSimulator;
8
use App\Lib\DsManager\Models\Orm\League;
9
use App\Lib\DsManager\Models\Orm\LeagueRound;
10
use App\Lib\DsManager\Models\Orm\Match;
11
use App\Lib\DsManager\Models\Orm\MatchResult;
12
use \App\Lib\Helpers\Responder;
13
use \App\Lib\DsManager\Models\Orm\Player;
14
use \App\Lib\DsManager\Models\Orm\Team;
15
use \App\Lib\DsManager\Models\Orm\Coach;
16
17
$configuration = [
18
    'settings' => [
19
        'displayErrorDetails' => true,
20
    ],
21
];
22
$c = new \Slim\Container($configuration);
23
$api = new \Slim\App($c);
24
25
$api->get('/ping', function ($request, $response, $args) {
0 ignored issues
show
The parameter $args 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...
26
    $jsonResp = json_encode(
27
        [
28
            "status" => "service up",
29
            "message" => "in a bottle"
30
        ]
31
    );
32
    return Responder::getJsonResponse($jsonResp, $response);
33
});
34
35
$api->get('/statistics', function ($request, $response, $args) {
0 ignored issues
show
The parameter $args 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...
36
    return Responder::getJsonResponse(
37
        json_encode([
38
            'players' => Player::getBest(),
39
            'teams' => Team::getBest()
40
        ],JSON_NUMERIC_CHECK),
41
        $response
42
    );
43
});
44
45
$api->get('/coaches', function ($request, $response, $args) {
0 ignored issues
show
The parameter $args 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...
46
    return Responder::getJsonResponse(
47
        Coach::all(),
48
        $response
49
    );
50
});
51
52
$api->get('/teams', function ($request, $response, $args) {
0 ignored issues
show
The parameter $args 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...
53
    return Responder::getJsonResponse(
54
        Team::all(),
55
        $response
56
    );
57
});
58
59
$api->get('/teams/{id}', function ($request, $response, $args) {
60
    return Responder::getJsonResponse(
61
        Team::complete()
0 ignored issues
show
The method complete() does not exist on App\Lib\DsManager\Models\Orm\Team. Did you maybe mean scopeComplete()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
62
            ->where(
63
                [
64
                    'id' => $args['id']
65
                ]
66
            )->get(),
67
        $response
68
    );
69
});
70
71 View Code Duplication
$api->get('/teams/{id}/players', function ($request, $response, $args) {
72
    return Responder::getJsonResponse(
73
        Team::with(
0 ignored issues
show
The method where does only exist in Illuminate\Database\Eloquent\Builder, but not in Illuminate\Database\Eloquent\Model.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
74
            'roster'
75
        )->where(
76
            [
77
                'id' => $args['id']
78
            ]
79
        )->get(),
80
        $response
81
    );
82
});
83
84
$api->get('/teams/{id}/players/{playerId}', function ($request, $response, $args) {
85
    return Responder::getJsonResponse(
86
        Player::statistics()->where(
87
            [
88
                'id' => $args['playerId'],
89
                'team_id' => $args['id']
90
            ]
91
        )->get(),
92
        $response
93
    );
94
});
95
96 View Code Duplication
$api->get('/teams/{id}/coach', function ($request, $response, $args) {
97
    return Responder::getJsonResponse(
98
        Team::with(
0 ignored issues
show
The method where does only exist in Illuminate\Database\Eloquent\Builder, but not in Illuminate\Database\Eloquent\Model.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
99
            'coach'
100
        )->where(
101
            [
102
                'id' => $args['id']
103
            ]
104
        )->get(),
105
        $response
106
    );
107
});
108
109
$api->get('/leagues', function ($request, $response, $args) {
0 ignored issues
show
The parameter $args 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...
110
    return Responder::getJsonResponse(
111
        League::all(),
112
        $response
113
    );
114
});
115
116
$api->get('/leagues/{id}', function ($request, $response, $args) {
117
    return Responder::getJsonResponse(
118
        League::with('rounds')
0 ignored issues
show
The method where does only exist in Illuminate\Database\Eloquent\Builder, but not in Illuminate\Database\Eloquent\Model.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
119
            ->where(
120
                [
121
                    'id' => $args['id']
122
                ]
123
            )->first(),
124
        $response
125
    );
126
});
127
128
$api->get('/leagues/{id}/rounds/{roundId}', function ($request, $response, $args) {
129
    return Responder::getJsonResponse(
130
        LeagueRound::complete()
0 ignored issues
show
The method complete() does not exist on App\Lib\DsManager\Models\Orm\LeagueRound. Did you maybe mean scopeComplete()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
131
            ->where(
132
                [
133
                    'id' => $args['roundId'],
134
                ]
135
            )->first(),
136
        $response
137
    );
138
});
139
140
$api->put('/leagues/{id}/rounds/{roundId}/simulate', function ($request, $response, $args) {
141
    return Responder::getJsonResponse(
142
        MatchSimulator::simulateRound(
143
            $args['roundId']
144
        ),
145
        $response
146
    );
147
});
148
149
$api->get('/matches', function ($request, $response, $args) {
0 ignored issues
show
The parameter $args 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...
150
    return Responder::getJsonResponse(
151
        Match::teams()->get(),
152
        $response
153
    );
154
});
155
156
$api->post('/matches', function ($request, $response, $args) {
0 ignored issues
show
The parameter $args 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...
157
    $json = $request->getBody();
158
    $json = json_decode($json, true);
159
    return Responder::getJsonResponse(
160
        Match::create(
161
            $json
162
        ),
163
        $response
164
    );
165
});
166
167
$api->get('/matches/{id}', function ($request, $response, $args) {
168
    return Responder::getJsonResponse(
169
        Match::complete()
0 ignored issues
show
The method complete() does not exist on App\Lib\DsManager\Models\Orm\Match. Did you maybe mean scopeComplete()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
170
            ->where(
171
                [
172
                    'id' => $args['id']
173
                ]
174
            )->first(),
175
        $response
176
    );
177
});
178
179
$api->get('/matches/{id}/result', function ($request, $response, $args) {
180
    $result = MatchResult::complete()
181
        ->where(
182
            [
183
                'id' => $args['id']
184
            ]
185
        )->first();
186
187
    return Responder::getJsonResponse(
188
        $result,
189
        $response
190
    );
191
});
192
193
$api->put('/matches/{id}/simulate', function ($request, $response, $args) {
194
    return Responder::getJsonResponse(
195
        MatchSimulator::simulateCompleteResult(
196
            $args['id']
197
        ),
198
        $response
199
    );
200
});
201
$api->run();