Issues (62)

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/Traits/Controller.php (1 issue)

Labels
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 Microboard\Traits;
4
5
use Exception;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Http\RedirectResponse;
8
use Illuminate\Http\Request;
9
use Illuminate\View\View;
10
use Microboard\Factory;
11
use Microboard\Foundations\Traits\DependencyResolverTrait;
12
use Microboard\Foundations\Traits\QueryResolverTrait;
13
use Microboard\Foundations\Traits\ViewResolverTrait;
14
use Microboard\Foundations\Traits\WorkingWithWidgets;
15
use Throwable;
16
17
trait Controller
18
{
19
    use DependencyResolverTrait,
20
        QueryResolverTrait,
21
        WorkingWithWidgets,
22
        ViewResolverTrait;
23
24
    /**
25
     * @var string
26
     */
27
    protected string $baseName;
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
28
29
    /**
30
     * @var Factory
31
     */
32
    private Factory $microboard;
33
34
    /**
35
     * Controller constructor.
36
     * @param Factory $microboard
37
     */
38
    public function __construct(Factory $microboard)
39
    {
40
        $this->baseName = str_replace('Controller', '', class_basename($this));
41
        $this->model = $this->getModel() ? resolve($this->getModel()) : null;
42
        $this->microboard = $microboard;
43
    }
44
45
    /**
46
     * Display a listing of the resource.
47
     */
48
    public function index()
49
    {
50
        $this->authorize('viewAny', $this->model);
51
        $datatable = resolve($this->getDatatable(), [
52
            'attributes' => $this->attributes ?? []
53
        ]);
54
55
        return $datatable->render($this->getViewPathFor('index'), $this->getResourceVariables('index'));
56
    }
57
58
    /**
59
     * Show the form for creating a new resource.
60
     *
61
     * @return View
62
     */
63
    public function create()
64
    {
65
        $this->authorize('create', $this->model);
66
        return view($this->getViewPathFor('create'), $this->getResourceVariables('create'));
67
    }
68
69
    /**
70
     * Store a newly created resource in storage.
71
     *
72
     * @return RedirectResponse
73
     * @throws Throwable
74
     */
75
    public function store()
76
    {
77
        $request = resolve($this->getStoreFormRequest());
78
        $variables = $this->getResourceVariables('create');
79
        $this->authorize('create', $this->model);
80
81
        $model = $this->model->fill($this->getValidated($request));
82
        $this->model->saveOrFail();
83
        cache()->forget($variables['resourceName']);
84
85
        $this->microboard->success(
86
            trans($variables['translationsPrefix'] . '.messages.created'),
87
        );
88
89
        if ($response = $this->created($request, $model)) {
90
            return $response;
91
        }
92
93
        return redirect()->route("{$variables['routePrefix']}.show", $model);
94
    }
95
96
    /**
97
     * The model has been created.
98
     *
99
     * @param Request $request
100
     * @param Model $model
101
     * @return mixed
102
     */
103
    protected function created($request, $model)
104
    {
105
        //
106
    }
107
108
    /**
109
     * Display the specified resource.
110
     * @param Request $request
111
     * @return View
112
     */
113
    public function show(Request $request)
114
    {
115
        $model = $this->query($request);
116
        $this->authorize('view', $model);
117
118
        return view($this->getViewPathFor('show'), $this->getResourceVariables('show', $model));
119
    }
120
121
    /**
122
     * Show the form for editing the specified resource.
123
     *
124
     * @param Request $request
125
     * @return View
126
     */
127
    public function edit(Request $request)
128
    {
129
        $model = $this->query($request);
130
        $this->authorize('update', $model);
131
132
        return view($this->getViewPathFor('edit'), $this->getResourceVariables('update', $model));
133
    }
134
135
    /**
136
     * Update the specified resource in storage.
137
     *
138
     * @throws Exception
139
     */
140
    public function update()
141
    {
142
        $request = resolve($this->getUpdateFormRequest());
143
        $model = $this->query($request);
144
        $this->authorize('update', $model);
145
        $variables = $this->getResourceVariables('update');
146
147
        $model->update($this->getValidated($request));
148
        cache()->forget($variables['resourceName']);
149
150
        $this->microboard->success(
151
            trans($variables['translationsPrefix'] . '.messages.updated'),
152
        );
153
154
        if ($response = $this->updated($request, $model)) {
155
            return $response;
156
        }
157
158
        return redirect()->route("{$variables['routePrefix']}.show", $model);
159
    }
160
161
    /**
162
     * The model has been updated.
163
     *
164
     * @param Request $request
165
     * @param Model $model
166
     * @return mixed
167
     */
168
    protected function updated($request, $model)
169
    {
170
        //
171
    }
172
173
    /**
174
     * Remove the specified resource from storage.
175
     *
176
     * @param Request $request
177
     * @return RedirectResponse
178
     * @throws Exception
179
     */
180
    public function destroy(Request $request)
181
    {
182
        $variables = $this->getResourceVariables('delete');
183
        $model = $this->query($request);
184
        $this->authorize('update', $model);
185
186
        $model->delete();
187
        cache()->forget($variables['resourceName']);
188
189
        $this->microboard->warning(
190
            trans($variables['translationsPrefix'] . '.messages.deleted'),
191
        );
192
193
        if ($response = $this->deleted($request, $model)) {
194
            return $response;
195
        }
196
197
        return redirect()->route("{$variables['routePrefix']}.index");
198
    }
199
200
    /**
201
     * The model has been updated.
202
     *
203
     * @param Request $request
204
     * @param Model $model
205
     * @return mixed
206
     */
207
    protected function deleted($request, $model)
208
    {
209
        //
210
    }
211
}
212