Issues (563)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/Admin/Controllers/BabelController.php (10 issues)

1
<?php
2
3
namespace App\Admin\Controllers;
4
5
use App\Http\Controllers\Controller;
6
use App\Models\Babel\ExtensionModel;
7
use Encore\Admin\Layout\Column;
8
use Encore\Admin\Layout\Content;
9
use Encore\Admin\Layout\Row;
10
use Illuminate\Support\Facades\Redirect;
11
use Illuminate\Support\Str;
12
13
class BabelController extends Controller
14
{
15
    /**
16
     * Show the MarketSpace Page.
17
     *
18
     * @return Response
0 ignored issues
show
The type App\Admin\Controllers\Response was not found. Did you mean Response? If so, make sure to prefix the type with \.
Loading history...
19
     */
20
    public function index(Content $content)
0 ignored issues
show
The parameter $content is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

20
    public function index(/** @scrutinizer ignore-unused */ Content $content)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
21
    {
22
        return redirect()->route('admin.babel.installed');
0 ignored issues
show
Bug Best Practice introduced by
The expression return redirect()->route('admin.babel.installed') returns the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type App\Admin\Controllers\Response.
Loading history...
23
    }
24
25
    /**
26
     * Show the Installed Page.
27
     *
28
     * @return Response
29
     */
30
    public function installed(Content $content)
31
    {
32
        return $content
0 ignored issues
show
Bug Best Practice introduced by
The expression return $content->header(...ion(...) { /* ... */ }) returns the type Encore\Admin\Layout\Content which is incompatible with the documented return type App\Admin\Controllers\Response.
Loading history...
33
            ->header('Installed Babel Extension')
34
            ->description('Manage your installed Babel Extension')
35
            ->row(function(Row $row) {
36
                $row->column(12, function(Column $column) {
37
                    $column->append(Self::installedView());
38
                });
39
            });
40
    }
41
42
    /**
43
     * Show the MarketSpace Page.
44
     *
45
     * @return Response
46
     */
47
    public function marketspace(Content $content)
48
    {
49
        return $content
0 ignored issues
show
Bug Best Practice introduced by
The expression return $content->header(...ion(...) { /* ... */ }) returns the type Encore\Admin\Layout\Content which is incompatible with the documented return type App\Admin\Controllers\Response.
Loading history...
50
            ->header('Babel Marketspace')
51
            ->description('Find extensions from marketspace')
52
            ->row(function(Row $row) {
53
                $row->column(12, function(Column $column) {
54
                    $column->append(Self::marketspaceView());
55
                });
56
            });
57
    }
58
59
    /**
60
     * Show the MarketSpace Detail Page.
61
     *
62
     * @return Response
63
     */
64
    public function detail($code, Content $content)
65
    {
66
        return $content
0 ignored issues
show
Bug Best Practice introduced by
The expression return $content->header(...ion(...) { /* ... */ }) returns the type Encore\Admin\Layout\Content which is incompatible with the documented return type App\Admin\Controllers\Response.
Loading history...
67
            ->header("Extension: $code")
68
            ->description('Details about this extension')
69
            ->row(function(Row $row) use ($code) {
70
                $row->column(12, function(Column $column) use ($code) {
71
                    $column->append(Self::marketspaceDetailView($code));
72
                });
73
            });
74
    }
75
76
    /**
77
     * Show the Extension Update Page.
78
     *
79
     * @return Response
80
     */
81
    public function update($extension, Content $content)
82
    {
83
        return $this->execute('update', $extension, $content);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->execute('u..., $extension, $content) returns the type Encore\Admin\Layout\Content which is incompatible with the documented return type App\Admin\Controllers\Response.
Loading history...
84
    }
85
86
    /**
87
     * Show the Extension Install Page.
88
     *
89
     * @return Response
90
     */
91
    public function install($extension, Content $content)
92
    {
93
        return $this->execute('install', $extension, $content);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->execute('i..., $extension, $content) returns the type Encore\Admin\Layout\Content which is incompatible with the documented return type App\Admin\Controllers\Response.
Loading history...
94
    }
95
96
    public function execute($command, $extension, Content $content)
97
    {
98
        return $content
99
            ->header(Str::title($command)." $extension")
100
            ->row(function(Row $row) use ($extension) {
101
                $row->column(12, function(Column $column) use ($extension) {
102
                    $column->append(Self::executingView($extension));
103
                });
104
            });
105
    }
106
107
    public function updateExtension($extension, Content $content)
108
    {
109
        $this->operateExtension('update', $extension, $content);
110
    }
111
112
    public function installExtension($extension, Content $content)
113
    {
114
        $this->operateExtension('install', $extension, $content);
115
    }
116
117
    public function operateExtension($command, $extension, Content $content)
0 ignored issues
show
The parameter $content is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

117
    public function operateExtension($command, $extension, /** @scrutinizer ignore-unused */ Content $content)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
118
    {
119
        self::executeArtisan("babel:$command $extension --no-interaction");
120
    }
121
122
    private static function installedView()
123
    {
124
        $installedExtensionList=ExtensionModel::localList();
125
126
        return view('admin::babel.installed', [
127
            'installedExtensionList'=>$installedExtensionList
128
        ]);
129
    }
130
131
    private static function marketspaceView()
132
    {
133
        $extensionList=ExtensionModel::list();
134
135
        if (empty($extensionList)) {
136
            return view('admin::babel.empty');
137
        }
138
139
        return view('admin::babel.marketspace', [
140
            'extensionList'=>$extensionList
141
        ]);
142
    }
143
144
    private static function marketspaceDetailView($code)
145
    {
146
        $details=ExtensionModel::remoteDetail($code);
147
148
        if (empty($details)) {
149
            return view('admin::babel.empty');
150
        }
151
152
        return view('admin::babel.detail', [
153
            'details'=>$details
154
        ]);
155
    }
156
157
    private static function executingView($extension)
158
    {
159
        $details=ExtensionModel::remoteDetail($extension);
160
161
        if (empty($details)) {
162
            return view('admin::babel.empty');
163
        }
164
165
        return view('admin::babel.execute', [
166
            'extension'=>$extension
167
        ]);
168
    }
169
170
    private static function executeArtisan($command)
171
    {
172
        $fp=popen('php "'.base_path('artisan').'" '.$command, "r");
173
        while ($b=fgets($fp, 2048)) {
174
            echo str_pad(json_encode([
175
                "ret"=>200,
176
                "desc"=>"Succeed",
177
                "data"=>[
178
                    "message"=>$b
179
                ]
180
            ])."\n", 4096);
181
            @ob_flush();
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for ob_flush(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled  annotation

181
            /** @scrutinizer ignore-unhandled */ @ob_flush();

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
182
            flush();
183
        }
184
185
        pclose($fp);
186
    }
187
}
188