Issues (10)

Security Analysis    no request data  

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/Http/Controllers/MasterTarifController.php (4 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 namespace Bantenprov\MasterTarif\Http\Controllers;
2
3
use App\Http\Controllers\Controller;
4
use Illuminate\Http\Request;
5
use Bantenprov\MasterTarif\Facades\MasterTarif;
6
use Bantenprov\MasterTarif\Models\MasterTarifModel;
7
use Bantenprov\DaftarRetribusi\Models\DaftarRetribusiModel;
8
use Ramsey\Uuid\Uuid;
9
10
/**
11
 * Class MasterTarifController
12
 * @package Bantenprov\MasterTarif\Http\Controllers
13
 * @author  bantenprov <[email protected]>
14
 */
15
class MasterTarifController extends Controller
16
{
17
18
    /**
19
     * @return mixed
20
     */
21
    public function index()
22
    {
23
        $master_tarifs = MasterTarifModel::all();
24
25
        return view('master-tarif::index', compact('master_tarifs'));
26
    }
27
28
    /**
29
     * @param Request $request
30
     * @return mixed
31
     */
32
    public function create(Request $request)
33
    {
34
        $daftar_retribusies = DaftarRetribusiModel::all();
35
36
        return view('master-tarif::create', compact('daftar_retribusies'));
37
    }
38
39
    /**
40
     * @param Request $request
41
     * @return mixed
42
     */
43
    public function createChild(Request $request, $parent_id)
44
    {
45
        $master_tarif_parent = MasterTarifModel::find($parent_id);
46
47
        return view('master-tarif::create-child', compact('master_tarif_parent'));
48
    }
49
50
    /**
51
     * @param Request $request
52
     */
53
    public function store(Request $request)
54
    {
55
56
        $daftar_retribusi = DaftarRetribusiModel::find($request->daftar_retribusi_id);
57
58
        $request->validate([            
59
            'nama'                  => 'required',
60
            'dasar_hukum'           => 'required',
61
            'daftar_retribusi_id'   => 'required',
62
        ]);
63
64
        if(is_null($daftar_retribusi)){
65
            return redirect()->back()->withErrors('Error : retribusi yang dipilih tidak ditemukan');
66
        }
67
68
        // if($request->status > 1 && $request->status < 0){
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
69
        //     return redirect()->back()->withErrors('Error : status salah');
0 ignored issues
show
Unused Code Comprehensibility introduced by
69% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
70
        // }
71
72
        MasterTarifModel::create([
73
            'uuid'                  => Uuid::uuid5(Uuid::NAMESPACE_DNS, 'bantenprov.go.id'.date('YmdHis')),
74
            'nama'                  => $request->nama,
75
            'dasar_hukum'           => $request->dasar_hukum,
76
            'level'                 => 1,
77
            'daftar_retribusi_id'   => $request->daftar_retribusi_id,
78
            'daftar_retribusi_uuid' => $daftar_retribusi->uuid,
79
            'user_id'               => \Auth::user()->id,
80
            'user_update'           => \Auth::user()->id,
81
        ]);
82
83
        $request->session()->flash('message', 'Successfully add new data');
84
85
        return redirect()->route('master-tarif.index');
86
87
    }
88
89
    /**
90
     * @param Request $request
91
     */
92
    public function storeChild(Request $request, $parent_id)
93
    {
94
        $master_tarif_parent = MasterTarifModel::find($parent_id);        
95
96
        $request->validate([            
97
            'nama'                  => 'required',
98
            'status'                => 'required',
99
        ]);
100
101 View Code Duplication
        if($request->status > 1 && $request->status < 0){
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
102
            return redirect()->back()->withErrors('Error : status salah');
103
        }
104
105
        MasterTarifModel::create([
106
            'uuid'                  => Uuid::uuid5(Uuid::NAMESPACE_DNS, 'bantenprov.go.id'.date('YmdHis')),
107
            'nama'                  => $request->nama,
108
            'status'                => $request->status,            
109
            'level'                 => $master_tarif_parent->level + 1,
110
            'daftar_retribusi_id'   => $master_tarif_parent->daftar_retribusi_id,
111
            'daftar_retribusi_uuid' => $master_tarif_parent->daftar_retribusi_uuid,
112
            'user_id'               => \Auth::user()->id,
113
            'user_update'           => \Auth::user()->id,
114
        ]);
115
116
        $request->session()->flash('message', 'Successfully add new data');
117
118
        return redirect()->route('master-tarif.index');
119
120
    }
121
122
    /**
123
     * @param $id
124
     * @return mixed
125
     */
126
    public function edit($id)
127
    {
128
        $daftar_retribusies = DaftarRetribusiModel::all();
129
130
        $master_tarif = MasterTarifModel::find($id);
131
132
        return view('master-tarif::edit',compact('daftar_retribusies','master_tarif'));
133
    }
134
135
    /**
136
     * @param Request $request
137
     * @param $id
138
     */
139
    public function update(Request $request, $id)
140
    {
141
        $daftar_retribusi = DaftarRetribusiModel::find($request->daftar_retribusi_id);
142
143
        $request->validate([            
144
            'nama'                  => 'required',
145
            'dasar_hukum'           => 'required',
146
            'status'                => 'required',
147
            'daftar_retribusi_id'   => 'required',
148
        ]);
149
150
        if(is_null($daftar_retribusi)){
151
            return redirect()->back()->withErrors('Error : retribusi yang dipilih tidak ditemukan');
152
        }
153
154 View Code Duplication
        if($request->status > 1 && $request->status < 0){
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
155
            return redirect()->back()->withErrors('Error : status salah');
156
        }
157
158
        MasterTarifModel::find($id)->update([            
159
            'nama'                  => $request->nama,
160
            'dasar_hukum'           => $request->dasar_hukum,
161
            'status'                => $request->status,
162
            'daftar_retribusi_id'   => $request->daftar_retribusi_id,
163
            'daftar_retribusi_uuid' => $daftar_retribusi->uuid,
164
            'user_update'           => \Auth::user()->id,
165
        ]);
166
167
        $request->session()->flash('message', 'Successfully add new data');
168
169
        return redirect()->route('master-tarif.index');
170
    }
171
172
    /**
173
     * @param $id
174
     * @return mixed
175
     */
176
    public function show($id)
177
    {
178
        $master_tarif = MasterTarifModel::find($id);
179
180
        return view('master-tarif::show', compact('master_tarif'));
181
    }
182
183
    /**
184
     * @param $id
185
     */
186
    public function destroy(Request $request, $id)
187
    {
188
        MasterTarifModel::find($id)->delete();
189
190
        $request->session()->flash('message', 'Successfully delete data');
191
192
        return redirect()->route('master-tarif.index');
193
    }
194
195
}
196