Issues (152)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/Controllers/PickController.php (2 issues)

1
<?php
2
3
namespace PhpDraft\Controllers;
4
5
use Silex\Application;
6
use Symfony\Component\HttpFoundation\Request;
7
use PhpDraft\Domain\Models\PhpDraftResponse;
8
use PhpDraft\Domain\Models\PickSearchModel;
9
10
class PickController {
11
  public function GetAll(Application $app, Request $request) {
12
    $draftId = (int)$request->get('draft_id');
13
    $draft = $app['phpdraft.DraftRepository']->Load($draftId);
14
15
    $response = $app['phpdraft.PickService']->GetAll($draft);
16
17
    return $app->json($response, $response->responseType());
18
  }
19
20
  public function GetUpdated(Application $app, Request $request) {
21
    $draftId = (int)$request->get('draft_id');
22
    $pickCounter = (int)$request->get('pick_counter');
23
24
    $response = $app['phpdraft.PickService']->LoadUpdatedData($draftId, $pickCounter);
25
26
    return $app->json($response, $response->responseType());
27
  }
28
29
  public function GetLast(Application $app, Request $request) {
30
    $draftId = (int)$request->get('draft_id');
31
    $amount = (int)$request->get('amount');
32
33
    if ($amount == 0) {
34
      $amount = 10;
35
    }
36
37
    return $app->json($app['phpdraft.PickRepository']->LoadLastPicks($draftId, $amount));
38
  }
39
40
  public function GetNext(Application $app, Request $request) {
41
    $draftId = (int)$request->get('draft_id');
42
    $amount = (int)$request->get('amount');
43
44
    if ($amount == 0) {
45
      $amount = 10;
46
    }
47
48
    $draft = $app['phpdraft.DraftRepository']->Load($draftId);
49
50
    return $app->json($app['phpdraft.PickRepository']->LoadNextPicks($draftId, $draft->draft_current_pick, $amount));
51
  }
52
53
  public function GetAllManagerPicks(Application $app, Request $request) {
54
    $draftId = (int)$request->get('draft_id');
55
    $managerId = (int)$request->get('manager_id');
56
57
    $draft = $app['phpdraft.DraftRepository']->Load($draftId);
58
59
    return $app->json($app['phpdraft.PickRepository']->LoadManagerPicks($managerId, $draft, false));
60
  }
61
62
  public function GetSelectedManagerPicks(Application $app, Request $request) {
63
    $draftId = (int)$request->get('draft_id');
0 ignored issues
show
The assignment to $draftId is dead and can be removed.
Loading history...
64
    $managerId = (int)$request->get('manager_id');
65
66
    return $app->json($app['phpdraft.PickRepository']->LoadManagerPicks($managerId));
67
  }
68
69
  public function GetAllRoundPicks(Application $app, Request $request) {
70
    $draftId = (int)$request->get('draft_id');
71
    $draft = $app['phpdraft.DraftRepository']->Load($draftId);
72
    $draftRound = (int)$request->get('draft_round');
73
    $sortAscending = (bool)$request->get('sort_ascending');
74
75
    return $app->json($app['phpdraft.PickRepository']->LoadRoundPicks($draft, $draftRound, $sortAscending, false));
76
  }
77
78
  public function GetSelectedRoundPicks(Application $app, Request $request) {
79
    $draftId = (int)$request->get('draft_id');
80
    $draft = $app['phpdraft.DraftRepository']->Load($draftId);
81
    $draftRound = (int)$request->get('draft_round');
82
    $sortAscending = (bool)$request->get('sort_ascending');
83
84
    return $app->json($app['phpdraft.PickRepository']->LoadRoundPicks($draft, $draftRound, $sortAscending));
85
  }
86
87
  public function SearchPicks(Application $app, Request $request) {
88
    $draftId = (int)$request->get('draft_id');
89
    $keywords = $request->get('keywords');
90
    $team = $request->get('team');
91
    $position = $request->get('position');
92
    $sort = $request->get('sort');
93
94
    $team = isset($team) ? $team : null;
95
    $position = isset($position) ? $position : null;
96
    $sort = isset($sort) ? $sort : 'DESC';
97
98
    $pickSearchModel = new PickSearchModel($draftId, $keywords, $team, $position, $sort);
99
100
    $pickSearchModel = $app['phpdraft.PickSearchRepository']->SearchStrict($pickSearchModel);
101
    $pickSearchModel = $app['phpdraft.PickSearchRepository']->SearchLoose($pickSearchModel);
102
103
    #If there's a space and no matches so far, create another searches where we manually split them firstname/lastname by sace automatically
104
    $splitNameAutomatically = count($pickSearchModel->player_results) == 0 && strpos($keywords, " ") != false;
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing strpos($keywords, ' ') of type integer to the boolean false. If you are specifically checking for non-zero, consider using something more explicit like > 0 or !== 0 instead.
Loading history...
105
106
    if ($splitNameAutomatically) {
107
      $pickSearchModel = new PickSearchModel($draftId, $keywords, $team, $position, $sort);
108
      $names = explode(" ", $keywords, 2);
109
      $pickSearchModel = $app['phpdraft.PickSearchRepository']->SearchSplit($pickSearchModel, $names[0], $names[1]);
110
    }
111
112
    return $app->json($pickSearchModel);
113
  }
114
115
  public function UpdateDepthChart(Application $app, Request $request) {
116
    $draft_id = (int)$request->get('draft_id');
117
    $pick_id = (int)$request->get('pick_id');
118
    $draft = $app['phpdraft.DraftRepository']->Load($draft_id);
119
120
    try {
121
      $pick = $app['phpdraft.PickRepository']->Load($pick_id);
122
123
      $pick->depth_chart_position_id = (int)$request->get('position_id');
124
    } catch (\Exception $e) {
125
      $response = new PhpDraftResponse(false, array());
126
      $response->errors[] = "Unable to edit pick #$pick_id";
127
128
      return $app->json($response, $response->responseType());
129
    }
130
131
    $validity = $app['phpdraft.PickValidator']->IsPickValidForDepthChartUpdate($draft, $pick);
132
133
    if (!$validity->success) {
134
      return $app->json($validity, $validity->responseType());
135
    }
136
137
    $response = $app['phpdraft.PickService']->UpdatePickDepthChart($draft, $pick);
138
139
    return $app->json($response, $response->responseType());
140
  }
141
}
142