Issues (101)

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.

Console/Component/User/DeleteUserCommand.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
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Explicit Architecture POC,
7
 * which is created on top of the Symfony Demo application.
8
 *
9
 * (c) Herberto Graça <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace Acme\App\Presentation\Console\Component\User;
16
17
use Acme\App\Core\Component\User\Application\Service\UserService;
18
use Acme\App\Core\Component\User\Application\Validation\UserValidationService;
19
use Doctrine\ORM\EntityManagerInterface;
20
use Symfony\Component\Console\Command\Command;
21
use Symfony\Component\Console\Input\InputArgument;
22
use Symfony\Component\Console\Input\InputInterface;
23
use Symfony\Component\Console\Output\OutputInterface;
24
use Symfony\Component\Console\Style\SymfonyStyle;
25
26
/**
27
 * A console command that deletes users from the database.
28
 *
29
 * To use this command, open a terminal window, enter into your project
30
 * directory and execute the following:
31
 *
32
 *     $ php bin/console app:delete-user
33
 *
34
 * Check out the code of the src/App/Command/AddUserCommand.php file for
35
 * the full explanation about Symfony commands.
36
 *
37
 * See https://symfony.com/doc/current/cookbook/console/console_command.html
38
 * For more advanced uses, commands can be defined as services too. See
39
 * https://symfony.com/doc/current/console/commands_as_services.html
40
 *
41
 * @author Oleg Voronkovich <[email protected]>
42
 */
43
class DeleteUserCommand extends Command
44
{
45
    /**
46
     * @var string
47
     */
48
    protected static $defaultName = 'app:delete-user';
49
50
    /** @var SymfonyStyle */
51
    private $io;
52
53
    /**
54
     * @var EntityManagerInterface
55
     */
56
    private $entityManager;
57
58
    /**
59
     * @var UserValidationService
60
     */
61
    private $validator;
62
63
    /**
64
     * @var UserService
65
     */
66
    private $userService;
67
68
    public function __construct(EntityManagerInterface $em, UserValidationService $validator, UserService $userService)
69
    {
70
        parent::__construct();
71
72
        $this->entityManager = $em;
73
        $this->validator = $validator;
74
        $this->userService = $userService;
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80
    protected function configure(): void
81
    {
82
        $this
83
            ->setDescription('Deletes users from the database')
84
            ->addArgument('username', InputArgument::REQUIRED, 'The username of an existing user')
85
            ->setHelp(<<<'HELP'
86
                The <info>%command.name%</info> command deletes users from the database:
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected EOF
Loading history...
87
88
                  <info>php %command.full_name%</info> <comment>username</comment>
89
90
                If you omit the argument, the command will ask you to
91
                provide the missing value:
92
93
                  <info>php %command.full_name%</info>
94
                HELP
95
            );
96
    }
97
98
    protected function initialize(InputInterface $input, OutputInterface $output): void
99
    {
100
        // SymfonyStyle is an optional feature that Symfony provides so you can
101
        // apply a consistent look to the commands of your application.
102
        // See https://symfony.com/doc/current/console/style.html
103
        $this->io = new SymfonyStyle($input, $output);
104
    }
105
106
    protected function interact(InputInterface $input, OutputInterface $output): void
107
    {
108
        if ($input->getArgument('username') !== null) {
109
            return;
110
        }
111
112
        $this->io->title('Delete User Command Interactive Wizard');
113
        $this->io->text([
114
            'If you prefer to not use this interactive wizard, provide the',
115
            'arguments required by this command as follows:',
116
            '',
117
            ' $ php bin/console app:delete-user username',
118
            '',
119
            'Now we\'ll ask you for the value of all the missing command arguments.',
120
            '',
121
        ]);
122
123
        $username = $this->io->ask('Username', null, [$this->validator, 'validateUsername']);
124
        $input->setArgument('username', $username);
125
    }
126
127
    protected function execute(InputInterface $input, OutputInterface $output): void
128
    {
129
        $username = $input->getArgument('username');
130
131
        $this->userService->deleteUser($username);
132
133
        $this->entityManager->flush();
134
135
        $this->io->success(sprintf('User "%s" was successfully deleted.', $username));
136
    }
137
}
138