Issues (98)

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.

app/Http/Controllers/InstallerController.php (15 issues)

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 App\Http\Controllers;
4
5
use Validator;
6
use Illuminate\Http\Request;
7
use Illuminate\Routing\Redirector;
8
use Illuminate\Support\Facades\Artisan;
9
use App\Http\Requests;
10
use App\Http\Helpers\Installer\DatabaseManager;
11
use App\Http\Helpers\Installer\EnvironmentManager;
12
use App\Http\Helpers\Installer\PermissionsChecker;
13
use App\Http\Helpers\Installer\RequirementsChecker;
14
use App\Http\Helpers\Installer\InstalledFileManager;
15
16
class InstallerController extends Controller
17
{
18
    /**
19
     * Create a new controller instance.
20
     *
21
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
22
     */
23
    public function __construct()
24
    {
25
        $this->middleware('canInstall');
26
    }
27
28
    /**
29
     * Display the installer welcome page.
30
     *
31
     * @return \Illuminate\View\View
32
     */
33
    public function stepWelcome()
34
    {
35
        return view('installer.welcome');
0 ignored issues
show
Bug Compatibility introduced by
The expression view('installer.welcome'); of type Illuminate\View\View|Ill...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 35 which is incompatible with the return type documented by App\Http\Controllers\Ins...Controller::stepWelcome of type Illuminate\View\View.
Loading history...
36
    }
37
38
    /**
39
     * XXXXXXXXXX
40
     *
41
     * @return \Illuminate\View\View
42
     */
43
    public function stepApplication()
44
    {
45
        return view('installer.application');
0 ignored issues
show
Bug Compatibility introduced by
The expression view('installer.application'); of type Illuminate\View\View|Ill...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 45 which is incompatible with the return type documented by App\Http\Controllers\Ins...roller::stepApplication of type Illuminate\View\View.
Loading history...
46
    }
47
48
    /**
49
     * XXXXXXXXXX
50
     *
51
     * @return \Illuminate\View\View
52
     */
53
    public function stepStoreApp(Request $request, Redirector $redirect)
54
    {
55
        session([
56
            'APP_URL'    => $request->url,
57
            'APP_LOCALE' => $request->locale,
58
            'APP_ENV'    => $request->env,
59
            'APP_KEY'    => env('APP_KEY')
60
        ]);
61
62
        return $redirect->route('KleisInstaller::stepDatabase');
63
    }
64
65
    /**
66
     * XXXXXXXXXX
67
     *
68
     * @return \Illuminate\View\View
69
     */
70
    public function stepDatabase()
71
    {
72
        return view('installer.database');
0 ignored issues
show
Bug Compatibility introduced by
The expression view('installer.database'); of type Illuminate\View\View|Ill...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 72 which is incompatible with the return type documented by App\Http\Controllers\Ins...ontroller::stepDatabase of type Illuminate\View\View.
Loading history...
73
    }
74
75
    /**
76
     * XXXXXXXXXX
77
     *
78
     * @return \Illuminate\View\View
79
     */
80
    public function stepStoreDb(Request $request, Redirector $redirect)
81
    {
82
        session([
83
            'DB_CONNECTION' => $request->dbtype,
84
            'DB_HOST'       => $request->dbhost,
85
            'DB_PORT'       => $request->dbport,
86
            'DB_DATABASE'   => $request->dbname,
87
            'DB_USERNAME'   => $request->dbuser,
88
            'DB_PASSWORD'   => $request->dbpassword
89
        ]);
90
91
        return $redirect->route('KleisInstaller::stepCustomization');
92
    }
93
94
    /**
95
     * XXXXXXXXXX
96
     *
97
     * @return \Illuminate\View\View
98
     */
99
    public function stepCustomization(Request $request)
100
    {
101
        $request->session()->forget('KLEIS_LOGO');
0 ignored issues
show
The method forget() does not seem to exist on object<Symfony\Component...ssion\SessionInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
102
        $request->session()->forget('KLEIS_ANNOUNCE');
0 ignored issues
show
The method forget() does not seem to exist on object<Symfony\Component...ssion\SessionInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
103
104
        return view('installer.customization');
0 ignored issues
show
Bug Compatibility introduced by
The expression view('installer.customization'); of type Illuminate\View\View|Ill...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 104 which is incompatible with the return type documented by App\Http\Controllers\Ins...ller::stepCustomization of type Illuminate\View\View.
Loading history...
105
    }
106
107
    /**
108
     * XXXXXXXXXX
109
     *
110
     * @return \Illuminate\View\View
111
     */
112
    public function stepStoreCusto(Request $request, Redirector $redirect)
113
    {
114
        $validator = Validator::make($request->all(), [
115
            'logo' => 'image|mimes:jpeg,png|dimensions:max_height:200',
116
        ]);
117
118
        if ($validator->fails()) {
119
            return $redirect->route('KleisInstaller::stepCustomization')
120
                            ->withErrors($validator)
121
                            ->withInput();
122
        }
123
124
        if ($request->hasFile('logo')) {
125
            if ($request->file('logo')->isValid()) {
126
                $ext = $request->logo->guessClientExtension();
127
                $filename = "logo.{$ext}";
128
                $request->logo->move('images', $filename);
129
                session(['KLEIS_LOGO' => $filename]);
130
            }
131
        }
132
133
        if(!empty($request->announce)) {
134
            $filename = 'announce.md';
135
            $mdfile = public_path("markdown/{$filename}");
136
            try {
137
                file_put_contents($mdfile, $request->announce);
138
            }  catch(Exception $e) {
0 ignored issues
show
The class App\Http\Controllers\Exception does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
139
                return $redirect->route('KleisInstaller::stepCustomization')
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $redirect->route(...ization')->withInput(); (Illuminate\Http\RedirectResponse) is incompatible with the return type documented by App\Http\Controllers\Ins...troller::stepStoreCusto of type Illuminate\View\View.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
140
                                ->withInput();
141
            }
142
            session(['KLEIS_ANNOUNCE' => $filename]);
143
        }
144
145
        return $redirect->route('KleisInstaller::stepEnvironment');
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $redirect->route(...ler::stepEnvironment'); (Illuminate\Http\RedirectResponse) is incompatible with the return type documented by App\Http\Controllers\Ins...troller::stepStoreCusto of type Illuminate\View\View.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
146
    }
147
148
149
    /**
150
     * XXXXXXXXXX
151
     *
152
     * @return \Illuminate\View\View
153
     */
154
    public function stepEnvironment(EnvironmentManager $environmentManager, Request $request)
155
    {
156
        $envConfig = $environmentManager->getEnvContent($request);
157
158
        return view('installer.environment', compact('envConfig'));
0 ignored issues
show
Bug Compatibility introduced by
The expression view('installer.environm... compact('envConfig')); of type Illuminate\View\View|Ill...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 158 which is incompatible with the return type documented by App\Http\Controllers\Ins...roller::stepEnvironment of type Illuminate\View\View.
Loading history...
159
    }
160
161
    /**
162
     * Processes the newly saved environment configuration and continue.
163
     *
164
     * @param Request $input
0 ignored issues
show
There is no parameter named $input. 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...
165
     * @param Redirector $redirect
166
     * @return \Illuminate\Http\RedirectResponse
167
     */
168
    public function stepSaveEnv(EnvironmentManager $environmentManager, Request $request, Redirector $redirect)
169
    {
170
        $status = $environmentManager->saveFile($request);
171
172
        if($status) {
173
            return $redirect->route('KleisInstaller::stepRequirements')
174
                            ->with(['message' => session('message')]);
175
        } else {
176
            return $redirect->route('KleisInstaller::stepEnvironment')
177
                            ->with(['message' => session('message')]);
178
        }
179
    }
180
181
    /**
182
     * Display the permissions check page.
183
     *
184
     * @return \Illuminate\View\View
185
     */
186
    public function stepPermissions(PermissionsChecker $checker)
187
    {
188
        $permissions = $checker->check(config('installer.permissions'));
189
190
        return view('installer.permissions', compact('permissions'));
0 ignored issues
show
Bug Compatibility introduced by
The expression view('installer.permissi...ompact('permissions')); of type Illuminate\View\View|Ill...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 190 which is incompatible with the return type documented by App\Http\Controllers\Ins...roller::stepPermissions of type Illuminate\View\View.
Loading history...
191
    }
192
193
    /**
194
     * Display the requirements page.
195
     *
196
     * @return \Illuminate\View\View
197
     */
198
    public function stepRequirements(RequirementsChecker $checker)
199
    {
200
        $requirements = $checker->check(config('installer.requirements'));
201
202
        return view('installer.requirements', compact('requirements'));
0 ignored issues
show
Bug Compatibility introduced by
The expression view('installer.requirem...mpact('requirements')); of type Illuminate\View\View|Ill...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 202 which is incompatible with the return type documented by App\Http\Controllers\Ins...oller::stepRequirements of type Illuminate\View\View.
Loading history...
203
    }
204
205
    /**
206
     * XXXXXXXXXX
207
     *
208
     * @return \Illuminate\View\View
209
     */
210
    public function stepMigrate(DatabaseManager $databaseManager)
211
    {
212
        $response = $databaseManager->migrateAndSeed();
213
214
        return redirect()->route('KleisInstaller::stepFinal')
215
                         ->with(['message' => $response]);
216
    }
217
218
    /**
219
     * Update installed file and display finished view.
220
     *
221
     * @param InstalledFileManager $fileManager
222
     * @return \Illuminate\View\View
223
     */
224
    public function stepFinish(InstalledFileManager $fileManager)
225
    {
226
        $fileManager->update();
227
228
        return view('installer.finished');
0 ignored issues
show
Bug Compatibility introduced by
The expression view('installer.finished'); of type Illuminate\View\View|Ill...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 228 which is incompatible with the return type documented by App\Http\Controllers\Ins...rController::stepFinish of type Illuminate\View\View.
Loading history...
229
    }
230
}
231