Issues (9)

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.

src/Commands/Setup.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 namespace Lanin\Laravel\SetupWizard\Commands;
2
3
use Illuminate\Console\Command;
4
use Lanin\Laravel\SetupWizard\Commands\Steps\AbstractStep;
5
6
class Setup extends Command
7
{
8
    const VERSION = '0.1.4';
9
10
    /**
11
     * The name and signature of the console command.
12
     *
13
     * @var string
14
     */
15
    protected $signature = 'app:setup
16
                            {step? : Step to run}
17
                            {--P|pretend : Pretend to execute}';
18
19
    /**
20
     * The console command description.
21
     *
22
     * @var string
23
     */
24
    protected $description = 'Setup the project.';
25
26
    /**
27
     * Installation steps.
28
     *
29
     * @var array
30
     */
31
    public $steps = [];
32
33
    /**
34
     * @inheritDoc
35
     */
36 22
    public function __construct()
37
    {
38 22
        parent::__construct();
39
40 22
        $this->steps = config('setup.steps');
0 ignored issues
show
Documentation Bug introduced by
It seems like config('setup.steps') of type * is incompatible with the declared type array of property $steps.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
41 22
    }
42
43
    /**
44
     * @inheritDoc
45
     */
46 2
    public function getHelp()
47
    {
48 2
        $help = $this->description . ' Available steps:' . PHP_EOL;
49
50 2
        foreach ($this->steps as $alias => $class)
51
        {
52 2
            $help .= '  - <comment>' . $alias . '</comment>' . PHP_EOL;
53 2
        }
54
55 2
        return $help;
56
    }
57
58
    /**
59
     * Execute the console command.
60
     *
61
     * @return mixed
62
     */
63 4
    public function handle()
64
    {
65 4
        $this->info(sprintf('%s (v%s)', config('setup.title'), self::VERSION));
66
67 4
        $pretend = (bool) $this->option('pretend');
68 4
        $steps   = (array) $this->argument('step');
69 4
        $return  = $this->runSteps($steps, $pretend);
70
71 4
        $this->info('Setup finished.');
72
73 4
        return $return;
74
    }
75
76
    /**
77
     * Run all steps one by one.
78
     *
79
     * @param  array $steps
80
     * @param  bool $pretend
81
     * @return bool
82
     */
83 10
    protected function runSteps($steps = [], $pretend = false)
84
    {
85 10
        $return = true;
86 10
        $steps  = empty($steps) ? array_keys($this->steps) : $steps;
87
88 10
        foreach ($steps as $step)
89
        {
90 8
            if ($this->runStep($step, $pretend) === false)
91 8
            {
92 2
                $return = false;
93 2
            }
94 10
        }
95
96 10
        return $return;
97
    }
98
99
    /**
100
     * Run installation step
101
     *
102
     * @param  string $step
103
     * @param  bool $pretend
104
     * @return bool
105
     */
106 4
    protected function runStep($step, $pretend = false)
107
    {
108
        try
109
        {
110 4
            $step = $this->createStep($step);
111
112 2
            if ($this->confirm($step->prompt(), true))
113 2
            {
114 2
                return $step->run($pretend);
115
            }
116
        }
117 2
        catch (\Exception $e)
118
        {
119 2
            $this->error($e->getMessage());
120
        }
121
122 2
        return false;
123
    }
124
125
    /**
126
     * Instantiate step class.
127
     *
128
     * @param string $step
129
     * @return AbstractStep
130
     * @throws \Exception
131
     */
132 10
    protected function createStep($step)
133
    {
134 10
        if ( ! $this->stepExist($step))
135 10
        {
136 4
            throw new \Exception("Step <comment>{$step}</comment> doesn't exist.");
137
        }
138
139 6
        $class = $this->steps[$step];
140 6
        $step  = new $class($this);
141
142 6
        if ( ! ($step instanceof AbstractStep))
143 6
        {
144 2
            throw new \Exception("Step class <comment>{$class}</comment> should be an instance of AbstractStep.");
145
        }
146
147 4
        return $step;
148
    }
149
150
    /**
151
     * Check if step exists.
152
     *
153
     * @param  string $step
154
     * @return bool
155
     */
156 12
    protected function stepExist($step)
157
    {
158 12
        return isset($this->steps[$step]) && class_exists($this->steps[$step]);
159
    }
160
161
}
162