Issues (140)

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.

resources/views/controller.blade.php (2 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 echo "<?php";
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected '"'
Loading history...
Security Best Practice introduced by
It is not recommend to use PHP's short opening tag <?, better use <?php, or <?= in case of outputting.

Short opening tags are disabled in PHP’s default configuration. In such a case, all content of this file is output verbatim to the browser without being parsed, or executed.

As a precaution to avoid these problems better use the long opening tag <?php.

Loading history...
2
@endphp
3
4
namespace {{ $controllerNamespace }};
5
@if($export)
6
    use App\Exports\{{$exportBaseName}};
7
    use Maatwebsite\Excel\Excel
8
@endif
9
use App\Http\Controllers\Controller;
10
use App\Http\Requests\{{ $modelWithNamespaceFromDefault }}\Index{{ $modelBaseName }};
11
use App\Http\Requests\{{ $modelWithNamespaceFromDefault }}\Store{{ $modelBaseName }};
12
use App\Http\Requests\{{ $modelWithNamespaceFromDefault }}\Update{{ $modelBaseName }};
13
use App\Http\Requests\{{ $modelWithNamespaceFromDefault }}\Destroy{{ $modelBaseName }};
14
use {{$modelFullName}};
15
use {{$repoFullName}};
16
use Illuminate\Http\Request;
17
use Illuminate\Support\Str;
18
use Inertia\Inertia;
19
use Yajra\DataTables\Html\Column;
20
21
class {{ $controllerBaseName }}  extends Controller
22
{
23
    private {{$repoBaseName}} $repo;
24
    public function __construct({{$repoBaseName}} $repo)
25
    {
26
        $this->repo = $repo;
27
    }
28
29
    /**
30
    * Display a listing of the resource.
31
    *
32
    * @param Request $request
33
    * @return  \Inertia\Response
34
    * @throws \Illuminate\Auth\Access\AuthorizationException
35
    */
36
    public function index(Request $request): \Inertia\Response
37
    {
38
        $this->authorize('viewAny', {{$modelBaseName}}::class);
39
        return Inertia::render('{{$modelPlural}}/Index',[
40
            "can" => [
41
                "viewAny" => \Auth::user()->can('viewAny', {{$modelBaseName}}::class),
42
                "create" => \Auth::user()->can('create', {{$modelBaseName}}::class),
43
            ],
44
            "columns" => $this->repo::dtColumns(),
45
        ]);
46
    }
47
48
    /**
49
    * Show the form for creating a new resource.
50
    *
51
    * @return \Inertia\Response
52
    */
53
    public function create()
54
    {
55
        $this->authorize('create', {{$modelBaseName}}::class);
56
        return Inertia::render("{{$modelPlural}}/Create",[
57
            "can" => [
58
            "viewAny" => \Auth::user()->can('viewAny', {{$modelBaseName}}::class),
59
            "create" => \Auth::user()->can('create', {{$modelBaseName}}::class),
60
            ]
61
        ]);
62
    }
63
64
    /**
65
    * Store a newly created resource in storage.
66
    *
67
    * {{"@"}}param Store{{$modelBaseName}} $request
68
    * {{"@"}}return \Illuminate\Http\RedirectResponse
69
    */
70
    public function store(Store{{$modelBaseName}} $request)
71
    {
72
        try {
73
            $data = $request->sanitizedObject();
74
            ${{$modelVariableName}} = $this->repo::store($data);
75
            return back()->with(['success' => "The {{$modelTitle}} was created succesfully."]);
76
        } catch (\Throwable $exception) {
77
            \Log::error($exception);
78
            return back()->with([
79
                'error' => $exception->getMessage(),
80
            ]);
81
        }
82
    }
83
84
    /**
85
    * Display the specified resource.
86
    *
87
    * {{"@"}}param Request $request
88
    * {{"@"}}param {{$modelBaseName}} ${{$modelVariableName}}
89
    * {{"@"}}return \Inertia\Response|\Illuminate\Http\RedirectResponse
90
    */
91
    public function show(Request $request, {{$modelBaseName}} ${{$modelVariableName}})
92
    {
93
        try {
94
            $this->authorize('view', ${{$modelVariableName}});
95
            $model = $this->repo::init(${{$modelVariableName}})->show($request);
96
            return Inertia::render("{{$modelPlural}}/Show", ["model" => $model]);
97
        } catch (\Throwable $exception) {
98
            \Log::error($exception);
99
            return back()->with([
100
                'error' => $exception->getMessage(),
101
            ]);
102
        }
103
    }
104
105
    /**
106
    * Show Edit Form for the specified resource.
107
    *
108
    * {{"@"}}param Request $request
109
    * {{"@"}}param {{$modelBaseName}} ${{$modelVariableName}}
110
    * {{"@"}}return \Inertia\Response|\Illuminate\Http\RedirectResponse
111
    */
112
    public function edit(Request $request, {{$modelBaseName}} ${{$modelVariableName}})
113
    {
114
        try {
115
            $this->authorize('update', ${{$modelVariableName}});
116
            //Fetch relationships
117
            @if (count($relations)){{ PHP_EOL }}
118
@if (isset($relations['belongsTo']) && count($relations['belongsTo'])){{PHP_EOL}}
119
    @php $parents = $relations['belongsTo']->pluck("function_name")->toArray(); @endphp
120
    ${{$modelVariableName}}->load([
121
    @foreach($parents as $parent)
122
        '{{$parent}}',
123
    @endforeach
124
    ]);
125
@endif
126
            @endif
127
            return Inertia::render("{{$modelPlural}}/Edit", ["model" => ${{$modelVariableName}}]);
128
        } catch (\Throwable $exception) {
129
            \Log::error($exception);
130
            return back()->with([
131
                'error' => $exception->getMessage(),
132
            ]);
133
        }
134
    }
135
136
    /**
137
    * Update the specified resource in storage.
138
    *
139
    * {{"@"}}param Update{{$modelBaseName}} $request
140
    * {{"@"}}param {$modelBaseName} ${{$modelVariableName}}
141
    * {{"@"}}return \Illuminate\Http\RedirectResponse
142
    */
143
    public function update(Update{{$modelBaseName}} $request, {{$modelBaseName}} ${{$modelVariableName}})
144
    {
145
        try {
146
            $data = $request->sanitizedObject();
147
            $res = $this->repo::init(${{$modelVariableName}})->update($data);
148
            return back()->with(['success' => "The {{$modelBaseName}} was updated succesfully."]);
149
        } catch (\Throwable $exception) {
150
            \Log::error($exception);
151
            return back()->with([
152
                'error' => $exception->getMessage(),
153
            ]);
154
        }
155
    }
156
157
    /**
158
    * Remove the specified resource from storage.
159
    *
160
    * {{"@"}}param {{$modelBaseName}} ${{$modelVariableName}}
161
    * {{"@"}}return \Illuminate\Http\RedirectResponse
162
    */
163
    public function destroy(Destroy{{$modelBaseName}} $request, {{$modelBaseName}} ${{$modelVariableName}})
164
    {
165
        $res = $this->repo::init(${{$modelVariableName}})->destroy();
166
        if ($res) {
167
            return back()->with(['success' => "The {{$modelBaseName}} was deleted succesfully."]);
168
        }
169
        else {
170
            return back()->with(['error' => "The {{$modelBaseName}} could not be deleted."]);
171
        }
172
    }
173
}
174