Issues (2)

Security Analysis    no request data  

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.

src/Console/InitCommand.php (1 issue)

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
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer\Console;
9
10
use Deployer\Initializer\Initializer;
11
use Deployer\Initializer\Template\CakeTemplate;
12
use Deployer\Initializer\Template\CodeIgniterTemplate;
13
use Deployer\Initializer\Template\CommonTemplate;
14
use Deployer\Initializer\Template\DrupalTemplate;
15
use Deployer\Initializer\Template\LaravelTemplate;
16
use Deployer\Initializer\Template\SymfonyTemplate;
17
use Deployer\Initializer\Template\Typo3Template;
18
use Deployer\Initializer\Template\Yii2AdvancedAppTemplate;
19
use Deployer\Initializer\Template\Yii2BasicAppTemplate;
20
use Deployer\Initializer\Template\YiiTemplate;
21
use Deployer\Initializer\Template\ZendTemplate;
22
use Symfony\Component\Console\Command\Command;
23
use Symfony\Component\Console\Input\InputInterface;
24
use Symfony\Component\Console\Input\InputOption;
25
use Symfony\Component\Console\Output\OutputInterface;
26
use Symfony\Component\Console\Style\SymfonyStyle;
27
use Symfony\Component\Process\Exception\RuntimeException;
28
use Symfony\Component\Process\Process;
29
30
/**
31
 * The command for initialize Deployer system in your project
32
 *
33
 * @author Vitaliy Zhuk <[email protected]>
34
 */
35
class InitCommand extends Command
36
{
37
    /**
38
     * @var Initializer
39
     */
40
    private $initializer;
41
42
    /**
43
     * @var array
44
     */
45
    private $availableTemplates;
46
47
    /**
48
     * Construct
49
     *
50
     * @param string $name
51
     */
52 17
    public function __construct($name = null)
53
    {
54 17
        $this->initializer = $this->createInitializer();
55 17
        $this->availableTemplates = $this->initializer->getTemplateNames();
56
57 17
        parent::__construct($name);
58 17
    }
59
60
    /**
61
     * {@inheritDoc}
62
     */
63 17
    protected function configure()
64
    {
65
        $this
66 17
            ->setName('init')
67 17
            ->setDescription('Initialize deployer in your project')
68 17
            ->addOption('template', 't', InputOption::VALUE_OPTIONAL, 'The template of you project. Available templates: ' . implode(', ', $this->availableTemplates))
69 17
            ->addOption('directory', null, InputOption::VALUE_OPTIONAL, 'The directory for create "deploy.php" file', getcwd())
70 17
            ->addOption('filename', null, InputOption::VALUE_OPTIONAL, 'The file name. Default "deploy.php"', 'deploy.php');
71 17
    }
72
73
    /**
74
     * {@inheritDoc}
75
     */
76
    protected function execute(InputInterface $input, OutputInterface $output)
77
    {
78
        $template = $input->getOption('template');
79
        $directory = $input->getOption('directory');
80
        $file = $input->getOption('filename');
81
        $params = [];
82
83
        if ($template === null) {
84
            $io = new SymfonyStyle($input, $output);
85
            $helper = $this->getHelper('question');
0 ignored issues
show
$helper is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
86
            $formatter = $this->getHelper('formatter');
87
88
            // Welcome message
89
            $output->writeln([
90
                '',
91
                $formatter->formatBlock('Welcome to the Deployer config generator', 'bg=blue;fg=white', true),
92
                '',
93
            ]);
94
95
            $io->text([
96
                'This utility will walk you through creating a deploy.php file.',
97
                'It only covers the most common items, and tries to guess sensible defaults.',
98
                '',
99
                'Press ^C at any time to quit.',
100
            ]);
101
102
            // Project type
103
            $template = $io->choice('Please select your project type', $this->availableTemplates, 'Common');
104
105
            // Repo
106
            $default = false;
107
            try {
108
                $default = (new Process('git remote get-url origin'))
109
                    ->mustRun()
110
                    ->getOutput();
111
                $default = trim($default);
112
            } catch (RuntimeException $e) {
113
                // pass
114
            }
115
            $params['repository'] = $io->ask('Repository', $default);
116
117
            // Privacy
118
            $io->text([
119
                'Contribute to the Deployer Development',
120
                '',
121
                'In order to help development and improve the features in Deployer,',
122
                'Deployer has a setting for usage data collection. This function',
123
                'collects anonymous usage data and sends it to Deployer. The data is',
124
                'used in Deployer development to get reliable statistics on which',
125
                'features are used (or not used). The information is not traceable',
126
                'to any individual or organization. Participation is voluntary,',
127
                'and you can change your mind at any time.',
128
                '',
129
                'Anonymous usage data contains Deployer version, php version, os type,',
130
                'name of the command being executed and whether it was successful or not,',
131
                'exception class name, count of hosts and anonymized project hash.',
132
                '',
133
                'If you would like to allow us to gather this information and help',
134
                'us develop a better tool, please add the code below.',
135
                '',
136
                "    <fg=white>set(<fg=cyan>'allow_anonymous_stats'</fg=cyan>, <fg=magenta;options=bold>true</fg=magenta;options=bold>);</fg=white>",
137
                '',
138
                'This function will not affect the performance of Deployer as',
139
                'the data is insignificant and transmitted in a separate process.',
140
            ]);
141
142
            $params['allow_anonymous_stats'] = $GLOBALS['allow_anonymous_stats'] = $io->confirm('Do you confirm?');
143
        }
144
145
        $filePath = $this->initializer->initialize($template, $directory, $file, $params);
146
147
        $output->writeln(sprintf(
148
            '<info>Successfully created:</info> <comment>%s</comment>',
149
            $filePath
150
        ));
151
    }
152
153
    /**
154
     * Create a initializer system
155
     *
156
     * @return Initializer
157
     */
158 17
    private function createInitializer()
159
    {
160 17
        $initializer = new Initializer();
161
162 17
        $initializer->addTemplate('Common', new CommonTemplate());
163 17
        $initializer->addTemplate('Laravel', new LaravelTemplate());
164 17
        $initializer->addTemplate('Symfony', new SymfonyTemplate());
165 17
        $initializer->addTemplate('Yii', new YiiTemplate());
166 17
        $initializer->addTemplate('Yii2 Basic App', new Yii2BasicAppTemplate());
167 17
        $initializer->addTemplate('Yii2 Advanced App', new Yii2AdvancedAppTemplate());
168 17
        $initializer->addTemplate('Zend Framework', new ZendTemplate());
169 17
        $initializer->addTemplate('CakePHP', new CakeTemplate());
170 17
        $initializer->addTemplate('CodeIgniter', new CodeIgniterTemplate());
171 17
        $initializer->addTemplate('Drupal', new DrupalTemplate());
172 17
        $initializer->addTemplate('TYPO3', new Typo3Template());
173
174 17
        return $initializer;
175
    }
176
}
177