Issues (7)

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/Commands/InstallCommand.php (2 issues)

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
namespace agoalofalife\Commands;
4
5
use agoalofalife\CapsuleSettings;
6
use agoalofalife\database\migrations\CitiesMigration;
7
use agoalofalife\database\migrations\CountryMigration;
8
use agoalofalife\database\migrations\RegionsMigration;
9
use agoalofalife\database\seeds\CitiesTableSeeder;
10
use agoalofalife\database\seeds\CountryTableSeeder;
11
use agoalofalife\database\seeds\RegionsTableSeeder;
12
use agoalofalife\ManagerMigrations;
13
use agoalofalife\ManagerSeeder;
14
use agoalofalife\Support\Local;
15
use Illuminate\Database\Capsule\Manager;
16
use Symfony\Component\Console\Command\Command;
17
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
18
use Symfony\Component\Console\Helper\Table;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Output\OutputInterface;
21
use Symfony\Component\Console\Question\ChoiceQuestion;
22
use Symfony\Component\Console\Question\ConfirmationQuestion;
23
use Symfony\Component\Console\Question\Question;
24
use Symfony\Component\Console\Style\SymfonyStyle;
25
26
27
class InstallCommand extends Command
28
{
29
    protected $settings;
30
31 1
    protected function configure() : void
32
    {
33 1
        $this->setName('install')->setHelp('Sets up tables with the regions, cities and so on..');
34 1
    }
35
36
    protected function execute(InputInterface $input, OutputInterface $output)
37
    {
38
39
        $style = new OutputFormatterStyle('black', 'yellow', array('bold', 'blink'));
40
        $output->getFormatter()->setStyle('fire', $style);
41
42
        $output->writeln([
0 ignored issues
show
array('<fire>Hi let\'s s...=====================') is of type array<integer,string,{"0":"string","1":"string"}>, but the function expects a string|object<Symfony\Co...onsole\Output\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
43
            '<fire>Hi let\'s start to do the migration!</fire>',
44
            '======================================'
45
        ]);
46
47
        $helper = $this->getHelper('question');
48
        $question = new ChoiceQuestion(
49
            'Please choose your database type :',
50
            array('mysql', 'postgres'),
51
            0
52
        );
53
        $question->setErrorMessage('Database %s is invalid.');
54
        // get type database
55
        $this->settings['databaseType'] = $helper->ask($input, $output, $question);
56
57
        $output->writeln('');
58
        $output->writeln( " You have just selected: <info>{$this->settings['databaseType']}</info>");
59
60
        $helper   = $this->getHelper('question');
61
        $question = new Question("Enter <info>host</info> for database , please : ", 'localhost');
62
63
        // get host
64
        $this->settings['host']     = $helper->ask($input, $output, $question);
65
        $output->writeln( " You have just selected: <info>{$this->settings['host']} </info>");
66
67
        $output->writeln('');
68
        $helper   = $this->getHelper('question');
69
        $question = new Question("Enter <info>database name</info>,  please : ");
70
71
        // get name database
72
        $this->settings['databaseName']     = $helper->ask($input, $output, $question);
73
        $output->writeln( " You have just selected: <info>{$this->settings['databaseName']} </info>");
74
75
        $output->writeln('');
76
        $helper   = $this->getHelper('question');
77
        $question = new Question("Enter <info>database username</info>,  please : ");
78
79
        //get username in database
80
        $this->settings['databaseUsername']     = $helper->ask($input, $output, $question);
81
        $output->writeln( " You have just selected: <info>{$this->settings['databaseUsername']} </info>");
82
83
        $output->writeln('');
84
        $helper   = $this->getHelper('question');
85
        $question = new Question("Enter <info>database password</info>,  please : ");
86
        $question->setHidden(true);
87
        $question->setHiddenFallback(false);
88
89
        // get password
90
        $this->settings['databasePassword']    = $helper->ask($input, $output, $question);
91
92
93
         $table = new Table($output);
94
         $table->setHeaders(array('name', 'value'))
95
                ->setRows(array(
96
                    array('Type database', $this->settings['databaseType']),
97
                    array('Host database', $this->settings['host']),
98
                    array('Name database', $this->settings['databaseName']),
99
                    array('Username database', $this->settings['databaseUsername'])
100
                ));
101
102
        $table->render();
103
104
        $helper   = $this->getHelper('question');
105
        $question = new ConfirmationQuestion("<question>Are you sure?? y/n</question>", false);
106
107
        if (!$helper->ask($input, $output, $question)) {
108
            return;
109
        }
110
        // connection database
111
        $capsule = new CapsuleSettings(new Manager());
112
        $capsule->settings( $this->settings );
113
        $capsule->checkConnection();
114
115
116
        $output->writeln(['','', '<info>Then go ahead!</info>']);
0 ignored issues
show
array('', '', '<info>Then go ahead!</info>') is of type array<integer,string,{"0..."string","2":"string"}>, but the function expects a string|object<Symfony\Co...onsole\Output\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
117
118
        $helper = $this->getHelper('question');
119
        $question = new ChoiceQuestion(
120
            'Please select your native language :',
121
            array(0 => 'ru', 'en', 'ua', 'be', 'es', 'fi', 'de', 'it'),
122
            0
123
        );
124
        $question->setErrorMessage('Local %s is invalid.');
125
126
        // get native language
127
        $this->settings['localization'] = $helper->ask($input, $output, $question);
128
        (new Local())->setLocal($this->settings['localization']);
129
130
        $helper   = $this->getHelper('question');
131
        $question = new Question("Enter <info> the country you wish to migrate</info>,  please : ");
132
        $output->writeln('<comment>the list of countries you can see here 3166-1 alpha-2</comment>');
133
        $output->writeln('<comment>you can specify multiple countries separated by commas</comment>');
134
        $output->writeln('<comment>example EN, RU</comment>');
135
136
        //  the list of countries that need to migrate
137
        $this->settings['country']     = $helper->ask($input, $output, $question);
138
        $output->writeln( " You have just selected: <info>{$this->settings['country']} </info>");
139
        config(['geography.country' =>  $this->settings['country'] ]);
140
141
        $io = new SymfonyStyle($input, $output);
142
        $io->progressStart(3);
143
144
        // migrate table
145
        (new ManagerMigrations([
146
                new CountryMigration,
147
                new RegionsMigration,
148
                new CitiesMigration
149
            ]))->builder();
150
        $io->progressAdvance(2);
151
152
        // seed data
153
        (new ManagerSeeder(array(
154
            new CountryTableSeeder,
155
            new RegionsTableSeeder,
156
            new CitiesTableSeeder
157
        )))->run();
158
159
        $io->progressFinish();
160
        $output->writeln('<info>Successfully created all!</info>');
161
    }
162
}