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/UserController.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\Common\Exception\NoEntityFoundException;
25
use Parthenon\User\Exception\PasswordResetInvalidException;
26
use Parthenon\User\Formatter\UserFormatterInterface;
27
use Parthenon\User\RequestProcessor\ChangePassword;
28
use Parthenon\User\RequestProcessor\ConfirmEmail;
29
use Parthenon\User\RequestProcessor\InviteUser;
30
use Parthenon\User\RequestProcessor\PasswordReset;
31
use Parthenon\User\RequestProcessor\PasswordResetConfirm;
32
use Parthenon\User\RequestProcessor\Settings;
33
use Parthenon\User\RequestProcessor\UserSignup;
34
use Psr\Log\LoggerInterface;
35
use Symfony\Bridge\Twig\Attribute\Template;
36
use Symfony\Bundle\SecurityBundle\Security;
37
use Symfony\Component\HttpFoundation\JsonResponse;
38
use Symfony\Component\HttpFoundation\RedirectResponse;
39
use Symfony\Component\HttpFoundation\Request;
40
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
41
use Symfony\Component\Routing\Annotation\Route;
42
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
43
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
44
45
final class UserController
46
{
47
    #[Route('/user/signup/{code}', name: 'parthenon_user_signup_invited')]
48
    #[Route('/user/signup', name: 'parthenon_user_signup')]
49
    #[Template('user/signup.html.twig')]
50
    public function signup(Request $request, UserSignup $processor, LoggerInterface $logger)
51
    {
52
        $logger->info('User sign up page called');
53
54
        return $processor->process($request);
55
    }
56
57
    #[Route('/user/signedup', name: 'parthenon_user_signed_up')]
58
    #[Template('user/signedup.html.twig')]
59
    public function signedup(Request $request, LoggerInterface $logger)
0 ignored issues
show
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

59
    public function signedup(/** @scrutinizer ignore-unused */ Request $request, LoggerInterface $logger)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
60
    {
61
        $logger->info('User signed up page called');
62
63
        return [];
64
    }
65
66
    #[Route('/user/reset', name: 'parthenon_user_reset')]
67
    #[Template('user/reset.html.twig')]
68
    public function reset(Request $request, PasswordReset $processor, LoggerInterface $logger)
69
    {
70
        $logger->info('User reset password page called');
71
72
        return $processor->process($request);
73
    }
74
75
    #[Route('/user/password', name: 'parthenon_user_change_password')]
76
    #[Template('user/change_password.html.twig')]
77
    public function changePassword(Request $request, ChangePassword $processor, LoggerInterface $logger)
78
    {
79
        $logger->info('User change password page called');
80
81
        return $processor->process($request);
82
    }
83
84
    #[Route('/user/invite', name: 'parthenon_user_invite')]
85
    #[Template('user/invite.html.twig')]
86
    public function inviteUser(Request $request, InviteUser $processor, LoggerInterface $logger)
87
    {
88
        $logger->info('User invite page called');
89
90
        return $processor->process($request);
91
    }
92
93
    #[Route('/user/reset/{code}', name: 'parthenon_user_reset_confirm')]
94
    #[Template('user/reset_confirm.html.twig')]
95
    public function resetConfirm(Request $request, PasswordResetConfirm $processor, LoggerInterface $logger)
96
    {
97
        $logger->info('User confirm reset password page called');
98
99
        try {
100
            return $processor->process($request);
101
        } catch (NoEntityFoundException|PasswordResetInvalidException $e) {
102
            $logger->warning('An error occured during a user reset');
103
            throw new NotFoundHttpException();
104
        }
105
    }
106
107
    #[Route('/user/settings', name: 'parthenon_user_settings')]
108
    #[Template('user/settings.html.twig')]
109
    public function profile(Request $request, Settings $processor, LoggerInterface $logger)
110
    {
111
        $logger->info('User settings page called');
112
113
        return $processor->process($request);
114
    }
115
116
    #[Route('/user/confirm/{confirmationCode}', name: 'parthenon_user_confirm')]
117
    public function confirmEmail(Request $request, ConfirmEmail $processor, LoggerInterface $logger)
118
    {
119
        $logger->info('User confirm email page called');
120
121
        return $processor->process($request);
122
    }
123
124
    #[Route('/login', name: 'parthenon_user_login')]
125
    #[Template('user/login.html.twig')]
126
    public function login(LoggerInterface $logger, AuthenticationUtils $authenticationUtils, Security $security, UrlGeneratorInterface $urlGenerator)
127
    {
128
        $logger->info('User login page called');
129
        $user = $security->getUser();
130
        if ($user) {
131
            return new RedirectResponse($urlGenerator->generate('parthenon_main_index'));
132
        }
133
134
        // get the login error if there is one
135
        $error = $authenticationUtils->getLastAuthenticationError();
136
        // last username entered by the user
137
        $lastUsername = $authenticationUtils->getLastUsername();
138
139
        return [
140
            'last_username' => $lastUsername,
141
            'error' => $error,
142
        ];
143
    }
144
145
    #[Route('/authenticate', name: 'parthenon_user_authenticate')]
146
    public function authenticate(LoggerInterface $logger, AuthenticationUtils $authenticationUtils, Security $security, UserFormatterInterface $userFormatter): JsonResponse
147
    {
148
        $logger->info('User login page called');
149
        $user = $security->getUser();
150
        if ($user) {
151
            return new JsonResponse($userFormatter->format($user));
152
        }
153
        // get the login error if there is one
154
        $error = $authenticationUtils->getLastAuthenticationError();
155
        // last username entered by the user
156
        $lastUsername = $authenticationUtils->getLastUsername();
157
158
        return new JsonResponse([
159
            'last_username' => $lastUsername,
160
            'error' => $error,
161
        ]);
162
    }
163
164
    #[Route('/logout', name: 'parthenon_user_logout', methods: ['GET'])]
165
    public function logout()
166
    {
167
        // controller can be blank: it will never be executed!
168
        throw new \Exception('Don\'t forget to activate logout in security.yaml');
169
    }
170
}
171