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/Helper/CommandAssistant.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\Helper;
4
5
use Sensio\Bundle\GeneratorBundle\Command\Helper\QuestionHelper;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Symfony\Component\Console\Question\ChoiceQuestion;
9
use Symfony\Component\Console\Question\ConfirmationQuestion;
10
use Symfony\Component\Console\Question\Question;
11
use Symfony\Component\HttpKernel\Kernel;
12
13
class CommandAssistant
14
{
15
    /**
16
     * @var InputInterface
17
     */
18
    private $input;
19
20
    /**
21
     * @var OutputInterface
22
     */
23
    private $output;
24
25
    /**
26
     * @var QuestionHelper
27
     */
28
    private $questionHelper;
29
30
    /**
31
     * @var Kernel
32
     */
33
    private $kernel;
34
35
    /**
36
     * @param $input InputInterface
37
     */
38
    public function setInput(InputInterface $input)
39
    {
40
        $this->input = $input;
41
    }
42
43
    /**
44
     * @return OutputInterface
45
     */
46
    public function getOutput()
47
    {
48
        return $this->output;
49
    }
50
51
    /**
52
     * @param $output OutputInterface
53
     */
54 1
    public function setOutput(OutputInterface $output)
55
    {
56 1
        $this->output = $output;
57 1
    }
58
59
    /**
60
     * @param $questionHelper QuestionHelper
61
     */
62
    public function setQuestionHelper(QuestionHelper $questionHelper)
63
    {
64
        $this->questionHelper = $questionHelper;
65
    }
66
67
    /**
68
     * @return Kernel
69
     */
70
    public function getKernel()
71
    {
72
        return $this->kernel;
73
    }
74
75
    /**
76
     * @param $kernel Kernel
77
     */
78
    public function setKernel(Kernel $kernel)
79
    {
80
        $this->kernel = $kernel;
81
    }
82
83
    public function writeSection($text, $style = 'bg=blue;fg=white')
84
    {
85
        $this->getQuestionHelper()->writeSection($this->output, $text, $style);
86
    }
87
88
    /**
89
     * @return Questionhelper
0 ignored issues
show
Should the return type not be QuestionHelper?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
90
     */
91
    private function getQuestionHelper()
92
    {
93
        return $this->questionHelper;
94
    }
95
96 1
    public function writeLine($text, $type = OutputInterface::OUTPUT_NORMAL)
97
    {
98 1
        $this->output->writeln($text, $type);
99 1
    }
100
101
    public function write(
102
        $text,
103
        $newLine = false,
104
        $type = OutputInterface::OUTPUT_NORMAL
105
    ) {
106
        $this->output->write($text, $newLine, $type);
107
    }
108
109 View Code Duplication
    public function writeError($message, $exit = false)
110
    {
111
        $this->output->writeln(
112
            $this->getQuestionHelper()
113
                ->getHelperSet()
114
                ->get('formatter')
115
                ->formatBlock($message, 'error')
116
        );
117
        if ($exit) {
118
            exit;
119
        }
120
    }
121
122 View Code Duplication
    public function askAndValidate(
123
        $question,
124
        $validator,
125
        $defaultValue = null,
126
        array $autoComplete = null
127
    ) {
128
        $validationQuestion = new Question(
129
            $this->getQuestionHelper()->getQuestion($question, $defaultValue),
130
            $defaultValue
131
        );
132
        $validationQuestion->setAutocompleterValues($autoComplete);
133
        $validationQuestion->setValidator($validator);
134
135
        return $this->getQuestionHelper()->ask(
136
            $this->input,
137
            $this->output,
138
            $validationQuestion
139
        );
140
    }
141
142
    public function askConfirmation(
143
        $question,
144
        $defaultString,
145
        $separator = '?',
146
        $defaultValue = true
147
    ) {
148
        $confirmationQuestion = new ConfirmationQuestion(
149
            $this->getQuestionHelper()->getQuestion(
150
                $question,
151
                $defaultString,
152
                $separator
153
            ), $defaultValue
154
        );
155
156
        return $this->getQuestionHelper()->ask(
157
            $this->input,
158
            $this->output,
159
            $confirmationQuestion
160
        );
161
    }
162
163 View Code Duplication
    public function ask($question, $default = null, array $autoComplete = null)
164
    {
165
        $askQuestion = new Question(
166
            $this->questionHelper->getQuestion($question, $default), $default
167
        );
168
        $askQuestion->setAutocompleterValues($autoComplete);
169
170
        return $this->getQuestionHelper()->ask(
171
            $this->input,
172
            $this->output,
173
            $askQuestion
174
        );
175
    }
176
177
    public function askSelect(
178
        $question,
179
        $choices,
180
        $default = null,
181
        $multiSelect = false,
182
        $errorMessage = 'Value "%s" is invalid'
183
    ) {
184
        $bundleQuestion = new ChoiceQuestion(
185
            $this->getQuestionHelper()->getQuestion($question, $default),
186
            $choices
187
        );
188
        $bundleQuestion->setErrorMessage($errorMessage);
189
        $bundleQuestion->setMultiselect($multiSelect);
190
        if ($multiSelect) {
191
            $toReturn = array();
192
            foreach ($this->getQuestionHelper()->ask(
193
                $this->input,
194
                $this->output,
195
                $bundleQuestion
196
            ) as $each) {
197
                array_push(
198
                    $toReturn,
199
                    array_search($each, $bundleQuestion->getChoices())
200
                );
201
            }
202
203
            return $toReturn;
204
        } else {
205
            $value = $this->getQuestionHelper()->ask(
206
                $this->input,
207
                $this->output,
208
                $bundleQuestion
209
            );
210
211
            return array_search($value, $bundleQuestion->getChoices());
212
        }
213
    }
214
215
    public function setOption($name, $value)
216
    {
217
        $this->input->setOption($name, $value);
218
    }
219
220
    public function hasOption($name)
221
    {
222
        return $this->input->hasOption($name);
223
    }
224
225
    public function getOption($name)
226
    {
227
        return $this->input->getOption($name);
228
    }
229
230
    public function isInteractive()
231
    {
232
        return $this->input->isInteractive();
233
    }
234
235
    public function getOptionOrDefault($option, $default = null)
236
    {
237
        return $this->input->hasOption($option) ? $this->input->getOption(
238
            $option
239
        ) : $default;
240
    }
241
}
242