Issues (222)

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.

src/User/Controller/TeamController.php (1 issue)

Severity
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (C) 2020-2025 Iain Cambridge
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by
10
 * the Free Software Foundation, either version 2.1 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20
 */
21
22
namespace Parthenon\User\Controller;
23
24
use Parthenon\User\Entity\MemberInterface;
25
use Parthenon\User\Entity\TeamInviteCode;
26
use Parthenon\User\Entity\User;
27
use Parthenon\User\Entity\UserInterface;
28
use Parthenon\User\Repository\TeamInviteCodeRepositoryInterface;
29
use Parthenon\User\Repository\UserRepositoryInterface;
30
use Parthenon\User\RequestProcessor\TeamInvite;
31
use Parthenon\User\Team\CurrentTeamProvider;
32
use Psr\Log\LoggerInterface;
33
use Symfony\Bridge\Twig\Attribute\Template;
34
use Symfony\Bundle\SecurityBundle\Security;
35
use Symfony\Component\HttpFoundation\JsonResponse;
36
use Symfony\Component\HttpFoundation\Request;
37
use Symfony\Component\Routing\Attribute\Route;
38
39
class TeamController
40
{
41
    #[Route('/user/team', name: 'parthenon_team_view', methods: ['GET'])]
42
    public function viewTeam(
43
        LoggerInterface $logger,
44
        Security $security,
45
        CurrentTeamProvider $teamProvider,
46
        TeamInviteCodeRepositoryInterface $inviteCodeRepository,
47
    ) {
48
        $logger->info('A user viewed their team');
49
        /** @var User $user */
50
        $user = $security->getUser();
0 ignored issues
show
The assignment to $user is dead and can be removed.
Loading history...
51
        $team = $teamProvider->getCurrentTeam();
52
53
        $sentInvites = [];
54
        foreach ($inviteCodeRepository->findAllUnusedInvitesForTeam($team) as $inviteCode) {
55
            $sentInvites[] = [
56
                'id' => (string) $inviteCode->getId(),
57
                'email' => $inviteCode->getEmail(),
58
                'created_at' => $inviteCode->getCreatedAt()->format(\DATE_ATOM),
59
            ];
60
        }
61
62
        $members = [];
63
        foreach ($team->getMembers() as $member) {
64
            $members[] = [
65
                'id' => (string) $member->getId(),
66
                'email' => $member->getEmail(),
67
                'name' => $member->getName(),
68
                'created_at' => $member->getCreatedAt()->format(\DATE_ATOM),
69
                'is_deleted' => $member->isDeleted(),
70
            ];
71
        }
72
73
        $body = [
74
            'sent_invites' => $sentInvites,
75
            'members' => $members,
76
        ];
77
78
        return new JsonResponse($body);
79
    }
80
81
    #[Route('/user/team/invite', name: 'parthenon_user_team_invite')]
82
    #[Template('user/team_invite.html.twig')]
83
    public function inviteUser(Request $request, TeamInvite $processor, LoggerInterface $logger)
84
    {
85
        $logger->info('A user has visited the invite page');
86
87
        return $processor->process($request);
88
    }
89
90
    #[Route('/user/team/invite/{id}/cancel', name: 'parthenon_team_invite_cancel', methods: ['POST'])]
91
    public function cancelInvite(Request $request, LoggerInterface $logger, TeamInviteCodeRepositoryInterface $inviteCodeRepository)
92
    {
93
        $logger->info('A user has cancelled an invite', ['invite_code_id' => $request->get('id')]);
94
95
        try {
96
            /** @var TeamInviteCode $inviteCode */
97
            $inviteCode = $inviteCodeRepository->findById($request->get('id'));
98
99
            $inviteCode->setUsed(true);
100
            $inviteCode->setUsedAt(new \DateTime('now'));
101
            $inviteCode->setCancelled(true);
102
103
            $inviteCodeRepository->save($inviteCode);
104
        } catch (\Throwable $e) {
105
            $logger->error('An error occurred while sending an invite', ['error_message' => $e->getMessage()]);
106
107
            return new JsonResponse(['success' => false]);
108
        }
109
110
        return new JsonResponse(['success' => true]);
111
    }
112
113
    #[Route('/user/team/member/{id}/disable', name: 'parthenon_team_invite_disable', methods: ['POST'])]
114
    public function disableMember(Request $request, LoggerInterface $logger, Security $security, CurrentTeamProvider $teamProvider, UserRepositoryInterface $userRepository)
115
    {
116
        $id = $request->get('id');
117
        $logger->info('A user has disable a member', ['id' => $id]);
118
        /** @var User $user */
119
        $user = $security->getUser();
120
        $team = $teamProvider->getCurrentTeam();
121
122
        try {
123
            if ($user->getId()->toString() == $id) {
124
                $logger->warning('A user has tried disable themselves', ['id' => $id]);
125
126
                return new JsonResponse(['success' => false]);
127
            }
128
129
            /** @var UserInterface $deletedUser */
130
            $deletedUser = $userRepository->findById($id);
131
132
            if (!$deletedUser instanceof MemberInterface) {
133
                throw new \Exception('Not a member');
134
            }
135
            if ($deletedUser->getTeam()->getId()->toString() != $team->getId()->toString()) {
136
                $logger->warning('A user has tried disable a user from a different team', ['id' => $id]);
137
138
                return new JsonResponse(['success' => false]);
139
            }
140
141
            $deletedUser->markAsDeleted();  /* @phpstan-ignore-line */
142
            $userRepository->save($deletedUser);
143
        } catch (\Throwable $e) {
144
            $logger->error('An error occured while trying to disable a user', ['error_message' => $e->getMessage()]);
145
146
            return new JsonResponse(['success' => false]);
147
        }
148
149
        return new JsonResponse(['success' => true]);
150
    }
151
}
152