Issues (3099)

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.

GeneratorBundle/Command/InstallCommand.php (1 issue)

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
namespace Kunstmaan\GeneratorBundle\Command;
4
5
use Kunstmaan\GeneratorBundle\Helper\CommandAssistant;
6
use Sensio\Bundle\GeneratorBundle\Command\GeneratorCommand;
7
use Symfony\Component\Console\Input\ArrayInput;
8
use Symfony\Component\Console\Input\InputOption;
9
use Symfony\Component\Console\Question\Question;
10
use Symfony\Component\Console\Style\SymfonyStyle;
11
use Symfony\Component\Console\Input\InputInterface;
12
use Symfony\Component\Console\Input\InputDefinition;
13
use Symfony\Component\Console\Output\OutputInterface;
14
use Sensio\Bundle\GeneratorBundle\Command\Validators;
15
use Symfony\Component\HttpKernel\Kernel;
16
use Sensio\Bundle\GeneratorBundle\Command\Helper\QuestionHelper;
17
use Symfony\Component\Process\Process;
18
19
/**
20
 * Kunstmaan installer
21
 */
22
final class InstallCommand extends GeneratorCommand
23
{
24
    /**
25
     * @var int
26
     */
27
    private $commandSteps = 0;
28
29
    /** @var CommandAssistant */
30
    private $assistant;
31
32
    /** @var string */
33
    private $projectDir;
34
35
    /** @var bool */
36
    private $shouldStop = false;
37
38
    /**
39
     * @param string $rootDir
0 ignored issues
show
There is no parameter named $rootDir. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
40
     */
41
    public function __construct(string $projectDir)
42
    {
43
        $this->projectDir = $projectDir;
44
45
        parent::__construct();
46
    }
47
48
    protected function configure()
49
    {
50
        $this
51
            ->setName('kuma:install')
52
            ->setDescription('KunstmaanCMS installer.')
53
            ->setDefinition(
54
                new InputDefinition(
55
                    [
56
                        new InputOption('db-installed', '', InputOption::VALUE_NONE, 'Acknowledge that you have setup your database"'),
57
                        new InputOption('demosite', '', InputOption::VALUE_REQUIRED, 'Do you want to create a "demosite"'),
58
                        new InputOption('create-tests', '', InputOption::VALUE_REQUIRED, 'Do you want to create tests for you pages/pageparts'),
59
                        new InputOption('namespace', '', InputOption::VALUE_OPTIONAL, 'The namespace of the bundle to create (only for SF3)'),
60
                        new InputOption('dir', '', InputOption::VALUE_OPTIONAL, 'The directory where to create the bundle (only for SF3)'),
61
                        new InputOption('bundle-name', '', InputOption::VALUE_OPTIONAL, 'The optional bundle name (only for SF3)'),
62
                    ]
63
                )
64
            );
65
    }
66
67 View Code Duplication
    private function initAssistant($input, $output)
68
    {
69
        if (is_null($this->assistant)) {
70
            $this->assistant = new CommandAssistant();
71
            $this->assistant->setQuestionHelper($this->getQuestionHelper());
72
            $this->assistant->setKernel($this->getApplication()->getKernel());
73
        }
74
        $this->assistant->setOutput($output);
75
        $this->assistant->setInput($input);
76
    }
77
78
    protected function interact(InputInterface $input, OutputInterface $output)
79
    {
80
        $this->initAssistant($input, $output);
81
82
        $questionHelper = new QuestionHelper();
83
84
        $outputStyle = new SymfonyStyle($input, $output);
85
        $outputStyle->writeln('<info>Installing KunstmaanCms...</info>');
86
        $outputStyle->writeln($this->getKunstmaanLogo());
87
88
        if (Kernel::VERSION_ID >= 40000 && true !== $input->getOption('db-installed')) {
89
            $this->shouldStop = !$this->assistant->askConfirmation('We need access to your database. Are the database credentials setup properly? (y/n)', 'y');
90
            if ($this->shouldStop) {
91
                return;
92
            }
93
        }
94
95
        // Only ask namespace for Symfony 3
96
        if (Kernel::VERSION_ID < 40000 && null === $input->getOption('namespace')) {
97
            $question = new Question(
98
                $questionHelper->getQuestion('Bundle namespace', $input->getOption('namespace')),
99
                $input->getOption('namespace')
100
            );
101
            $question->setValidator([Validators::class, 'validateBundleNamespace']);
102
            $namespace = $questionHelper->ask($input, $output, $question);
103
            $input->setOption('namespace', $namespace);
104
            $input->setOption('bundle-name', strtr($namespace, ['\\Bundle\\' => '', '\\' => '']));
105
106
            $dir = $input->getOption('dir') ?: $this->projectDir . '/src';
107
            $input->setOption('dir', $dir);
108
        }
109
110 View Code Duplication
        if (null === $input->getOption('demosite')) {
111
            $demoSiteOption = $this->assistant->askConfirmation('Do you want to create a "demosite"? (y/n)', 'n');
112
            $input->setOption('demosite', $demoSiteOption === true ? 'Yes' : 'No');
113
        }
114
115 View Code Duplication
        if (null === $input->getOption('create-tests')) {
116
            $createTests = $this->assistant->askConfirmation('Do you want to create tests for you pages/pageparts? (y/n)', 'n', '?', false);
117
            $input->setOption('create-tests', $createTests === true ? 'Yes' : 'No');
118
        }
119
120
        $output->writeln('<info>Installation start</info>');
121
    }
122
123
    protected function execute(InputInterface $input, OutputInterface $output)
124
    {
125
        if ($this->shouldStop) {
126
            return;
127
        }
128
129
        $this->initAssistant($input, $output);
130
131
        $defaultSiteOptions = [];
132
        $defaultSiteOptions['--browsersync'] = 'https://myproject.dev';
133
        if ($input->getOption('demosite') === 'Yes') {
134
            $defaultSiteOptions['--articleoverviewpageparent'] = 'HomePage';
135
            $defaultSiteOptions['--demosite'] = true;
136
        }
137
138
        if (Kernel::VERSION_ID < 40000) {
139
            $defaultSiteOptions = ['--namespace' => $input->getOption('namespace')];
140
141
            $this->executeCommand($output, 'kuma:generate:bundle', [
142
                '--namespace' => $input->getOption('namespace'),
143
                '--dir' => $input->getOption('dir'),
144
                '--bundle-name' => $input->getOption('bundle-name'),
145
            ]);
146
        }
147
148
        if (Kernel::VERSION_ID >= 40000) {
149
            $this->executeCommand($output, 'kuma:generate:config');
150
        }
151
152
        $this
153
            ->executeCommand($output, 'kuma:generate:default-site', $defaultSiteOptions)
154
            ->executeCommand($output, 'doctrine:database:create')
155
            ->executeCommand($output, 'doctrine:schema:drop', ['--force' => true])
156
            ->executeCommand($output, 'doctrine:schema:create')
157
            ->executeCommand($output, 'doctrine:fixtures:load', ['-n' => true], true)
158
            ->executeCommand($output, 'assets:install')
159
        ;
160
161
        if ($input->getOption('create-tests') === 'Yes') {
162
            $adminTestOptions = [];
163
            if (Kernel::VERSION_ID < 40000) {
164
                $adminTestOptions = ['--namespace' => $input->getOption('namespace')];
165
            }
166
167
            $this->executeCommand($output, 'kuma:generate:admin-tests', $adminTestOptions);
168
        }
169
170
        $this->assistant->writeSection('Installation done. Enjoy your KunstmaanCMS', 'bg=green;fg=black');
171
        $this->assistant->writeSection('PRO TIP: If you like to use the default frontend setup, run the buildUI.sh script or run the commands separate to compile the frontend assets. ', 'bg=blue;fg=white');
172
173
        return 0;
174
    }
175
176
    protected function executeCommand(OutputInterface $output, $command, array $options = [], $separateProcess = false)
177
    {
178
        $options = array_merge(['--no-debug' => true], $options);
179
180
        ++$this->commandSteps;
181
182
        try {
183
            if ($separateProcess) {
184
                $process = new Process(array_merge(['bin/console', $command], array_keys($options)));
185
                $process->setTty(true);
186
                $process->run();
187
188
                if (!$process->isSuccessful()) {
189
                    throw new \RuntimeException($process->getErrorOutput());
190
                }
191
            } else {
192
                $updateInput = new ArrayInput($options);
193
                $updateInput->setInteractive(true);
194
                $this->getApplication()->find($command)->run($updateInput, $output);
195
            }
196
            $output->writeln(sprintf('<info>Step %d: "%s" - [OK]</info>', $this->commandSteps, $command));
197
        } catch (\Throwable $e) {
198
            $output->writeln(sprintf('<error>Step %d: "%s" - [FAILED] Message: %s</error>', $this->commandSteps, $command, $e->getMessage()));
199
        }
200
201
        return $this;
202
    }
203
204
    protected function getKunstmaanLogo()
205
    {
206
        return '
207
         /$$   /$$                                 /$$                                                  /$$$$$$                         
208
        | $$  /$$/                                | $$                                                 /$$__  $$                        
209
        | $$ /$$/  /$$   /$$ /$$$$$$$   /$$$$$$$ /$$$$$$   /$$$$$$/$$$$   /$$$$$$   /$$$$$$  /$$$$$$$ | $$  \__/ /$$$$$$/$$$$   /$$$$$$$
210
        | $$$$$/  | $$  | $$| $$__  $$ /$$_____/|_  $$_/  | $$_  $$_  $$ |____  $$ |____  $$| $$__  $$| $$      | $$_  $$_  $$ /$$_____/
211
        | $$  $$  | $$  | $$| $$  \ $$|  $$$$$$   | $$    | $$ \ $$ \ $$  /$$$$$$$  /$$$$$$$| $$  \ $$| $$      | $$ \ $$ \ $$|  $$$$$$ 
212
        | $$\  $$ | $$  | $$| $$  | $$ \____  $$  | $$ /$$| $$ | $$ | $$ /$$__  $$ /$$__  $$| $$  | $$| $$    $$| $$ | $$ | $$ \____  $$
213
        | $$ \  $$|  $$$$$$/| $$  | $$ /$$$$$$$/  |  $$$$/| $$ | $$ | $$|  $$$$$$$|  $$$$$$$| $$  | $$|  $$$$$$/| $$ | $$ | $$ /$$$$$$$/
214
        |__/  \__/ \______/ |__/  |__/|_______/    \___/  |__/ |__/ |__/ \_______/ \_______/|__/  |__/ \______/ |__/ |__/ |__/|_______/ 
215
        ';
216
    }
217
218
    protected function createGenerator()
219
    {
220
        // we don't need generator here
221
    }
222
}
223