Issues (273)

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.

controllers/PlayerController.php (1 issue)

Labels
Severity

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
use BZIon\Form\Creator\PlayerAdminNotesFormCreator as FormCreator;
4
use Carbon\Carbon;
5
use Symfony\Component\Form\Form;
6
use Symfony\Component\HttpFoundation\Request;
7
8
class PlayerController extends JSONController
9
{
10
    private $creator;
11
12
    public function showAction(Player $player, Player $me, Request $request)
13
    {
14
        $formView = null;
15
16
        if ($me->hasPermission(Permission::VIEW_VISITOR_LOG) && !$this->isDemoMode()) {
17
            $this->creator = new FormCreator($player);
18
            $form = $this->creator->create()->handleRequest($request);
19
20
            if ($form->isValid()) {
21
                $form = $this->handleAdminNotesForm($form, $player, $me);
22
            }
23
24
            $formView = $form->createView();
25
        }
26
27
        $periods = [];
28
        $season = Season::getCurrentSeasonRange();
29
        $periodLength = round($season->getEndOfRange()->diffInDays($season->getStartOfRange()) / 30);
30
        $seasonStart = $season->getStartOfRange();
31
32
        for ($i = 0; $i < $periodLength; $i++) {
33
            $periods[] = $seasonStart->firstOfMonth()->copy();
34
            $periods[] = $seasonStart->day(15)->copy();
35
            $periods[] = $seasonStart->lastOfMonth()->copy();
36
37
            $seasonStart->addMonth();
38
        }
39
40
        $currentPeriod = new ArrayIterator($periods);
41
        $playerEloSeason = $player->getEloSeasonHistory();
42
        $seasonSummary = [];
43
44
        foreach ($playerEloSeason as $elo) {
45
            if ($elo['month'] > $currentPeriod->current()->month || $elo['day'] > $currentPeriod->current()->day) {
46
                $currentPeriod->next();
47
            }
48
49
            $seasonSummary[$currentPeriod->current()->format('M d')] = $elo['elo'];
50
        }
51
52
        $bans = Ban::getQueryBuilder()
53
            ->where('player')->is($player->getId())
54
            ->getModels($fast = true)
55
        ;
56
57
        return array(
58
            'bans' => $bans,
59
            'player'         => $player,
60
            'seasonSummary'  => $seasonSummary,
61
            'adminNotesForm' => $formView,
62
        );
63
    }
64
65
    public function editAction(Player $player, Player $me)
66
    {
67
        if (!$me->canEdit($player)) {
68
            throw new ForbiddenException("You are not allowed to edit other players");
69
        }
70
71
        $params = array(
72
            'me'   => $player,
73
            'self' => false,
74
        );
75
76
        return $this->forward('edit', $params, 'Profile');
77
    }
78
79
    public function listAction(Request $request, Player $me, Team $team = null)
80
    {
81
        $query = Player::getQueryBuilder();
82
83
        // Load all countries into the cache so they are ready for later
84
        Country::getQueryBuilder()->addToCache();
85
86
        if ($team) {
87
            $query->where('team')->is($team);
88
        } else {
89
            // Add all teams to the cache
90
            $this->getQueryBuilder('Team')
91
                ->where('members')->greaterThan(0)
92
                ->addToCache();
93
        }
94
95
        if ($request->query->has('exceptMe')) {
96
            $query->except($me);
97
        }
98
99
        $groupBy = $request->query->get('groupBy');
100
        $sortBy = $request->query->get('sortBy');
101
        $sortOrder = $request->query->get('sortOrder');
102
103
        $query
104
            ->active()
105
            ->withMatchActivity()
106
            ->sortBy('name')
107
        ;
108
109
        if (!$request->query->get('showAll')) {
110
            $query->having('activity')->greaterThan(0);
111
        }
112
113
        if ($sortBy || $sortOrder) {
114
            $sortBy = $sortBy ? $sortBy : 'callsign';
115
            $sortOrder = $sortOrder ? $sortOrder : 'ASC';
116
117
            if ($sortBy === 'activity') {
118
                $query->sortBy($sortBy);
119
            }
120
121
            if ($sortOrder == 'DESC') {
122
                $query->reverse();
123
            }
124
        }
125
126
        $players = $query->getModels($fast = true);
127
128
        if ($groupBy) {
129
            $grouped = [];
130
131
            /** @var Player $player */
132
            foreach ($players as $player) {
133
                $key = '';
134
135
                if ($groupBy == 'country') {
136
                    $key = $player->getCountry()->getName();
137
                } elseif ($groupBy == 'team') {
138
                    $key = $player->getTeam()->getEscapedName();
139
140
                    if ($key == '<em>None</em>') {
141
                        $key = ' ';
142
                    }
143
                } elseif ($groupBy == 'activity') {
144
                    $key = ($player->getMatchActivity() > 0.0) ? 'Active' : 'Inactive';
145
                }
146
147
                $grouped[$key][] = $player;
148
            }
149
150
            ksort($grouped);
151
            $players = $grouped;
152
        }
153
154
        return array(
155
            'grouped' => ($groupBy !== null),
156
            'players' => $players,
157
        );
158
    }
159
160
    /**
161
     * Handle the admin notes form
162
     * @param  Form   $form   The form
163
     * @param  Player $player The player in question
164
     * @param  Player $me     The currently logged in player
165
     * @return Form   The updated form
166
     */
167
    private function handleAdminNotesForm($form, $player, $me)
168
    {
169
        $notes = $form->get('notes')->getData();
170
        if ($form->get('save_and_sign')->isClicked()) {
0 ignored issues
show
The method isClicked() does not seem to exist on object<Symfony\Component\Form\Form>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
171
            $notes .= ' — ' . $me->getUsername() . ' on ' . TimeDate::now()->toRFC2822String();
172
        }
173
174
        $player->setAdminNotes($notes);
175
        $this->getFlashBag()->add('success', "The admin notes for {$player->getUsername()} have been updated");
176
177
        // Reset the form so that the user sees the updated admin notes
178
        return $this->creator->create();
179
    }
180
}
181