Issues (144)

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/Http/Controllers/LocationController.php (6 issues)

1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\DataTables\LocationDataTable;
6
use App\Location;
7
use App\Site;
8
use App\Http\Requests\EditLocation;
9
10
class LocationController extends Controller
11
{
12
    /**
13
     * Create a new controller instance.
14
     */
15
    public function __construct()
16
    {
17
        $this->middleware('auth');
18
    }
19
    
20
    /**
21
     * Display a listing of the resource.
22
     *
23
     * @param  LocationDataTable   $dataTable
24
     * @return \Illuminate\Http\JsonResponse|\Illuminate\View\View
25
     */
26
    public function index(LocationDataTable $dataTable)
27
    {
28
        $this->authorize('index', Location::class);
29
        
30
        return $dataTable->render('location.index');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $dataTable->render('location.index') also could return the type callable which is incompatible with the documented return type Illuminate\Http\JsonResponse|Illuminate\View\View.
Loading history...
31
    }
32
33
    /**
34
     * Show the form for creating a new resource.
35
     *
36
     * @return \Illuminate\Http\Response
37
     */
38
    public function create()
39
    {
40
        $this->authorize('create', Location::class);
41
        
42
        $sites = Site::orderBy('name', 'ASC')->get();
43
        return view('location.create', [ 'sites' => $sites ]);
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('location.cr...ray('sites' => $sites)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
44
    }
45
46
    /**
47
     * Store a newly created resource in storage.
48
     *
49
     * @param  EditLocation $request
50
     * @return \Illuminate\Http\RedirectResponse
51
     */
52 View Code Duplication
    public function store(EditLocation $request)
53
    {
54
        $this->authorize('store', Location::class);
55
        
56
        //Get the site id of the old or newly created site
57
        if (!empty($request->input('new_site_name')))
58
        {
59
            //Create a new site
60
            $site = Site::create([ 'name' => $request->input('new_site_name') ]);
61
            $site_id = $site->id;
62
        } else {
63
                    $site_id = $request->input('site');
64
        }
65
    
66
        $location = Location::create([ 'name' => $request->input('name'), 'site_id' => $site_id ]);
67
    
68
        return redirect()->route('location.show', $location->id)
0 ignored issues
show
$location->id of type integer is incompatible with the type array expected by parameter $parameters of Illuminate\Routing\Redirector::route(). ( Ignorable by Annotation )

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

68
        return redirect()->route('location.show', /** @scrutinizer ignore-type */ $location->id)
Loading history...
69
            ->with('success', 'Location created successfully');
70
    }
71
72
    /**
73
     * Display the specified resource.
74
     *
75
     * @param  int  $id
76
     * @return \Illuminate\Http\Response
77
     */
78
    public function show($id)
79
    {
80
        $this->authorize('show', Location::class);
81
        
82
        $location = Location::findOrFail($id);
83
        $devices = $location->devices()->orderBy('name', 'ASC')->paginate(15);
84
    
85
        return view('location.show', [ 'location' => $location, 'devices' => $devices ]);
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('location.sh...'devices' => $devices)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
86
    }
87
88
    /**
89
     * Show the form for editing the specified resource.
90
     *
91
     * @param  int  $id
92
     * @return \Illuminate\Http\Response
93
     */
94
    public function edit($id)
95
    {
96
        $this->authorize('edit', Location::class);
97
        
98
        $location = Location::findOrFail($id);
99
        $sites = Site::orderByRaw("id = ? DESC", $location->site_id)->orderBy('name', 'ASC')->get();
100
    
101
        return view('location.edit', [ 'location' => $location, 'sites' => $sites ]);
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('location.ed...on, 'sites' => $sites)) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
102
    }
103
104
    /**
105
     * Update the specified resource in storage.
106
     *
107
     * @param  EditLocation  $request
108
     * @param  int  $id
109
     * @return \Illuminate\Http\RedirectResponse
110
     */
111 View Code Duplication
    public function update(EditLocation $request, $id)
112
    {
113
        $this->authorize('update', Location::class);
114
        
115
        //Get the site id of the old or newly created site
116
        if (!empty($request->input('new_site_name')))
117
        {
118
            //Create a new site
119
            $site = Site::create([ 'name' => $request->input('new_site_name') ]);
120
            $site_id = $site->id;
121
        } else {
122
                    $site_id = $request->input('site');
123
        }
124
        
125
        //Update the location with the supplied name and the site
126
        Location::findOrFail($id)->update([ 'name' => $request->input('name'), 'site_id' => $site_id ]);
127
        
128
        return redirect()->route('location.show', $id)
0 ignored issues
show
$id of type integer is incompatible with the type array expected by parameter $parameters of Illuminate\Routing\Redirector::route(). ( Ignorable by Annotation )

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

128
        return redirect()->route('location.show', /** @scrutinizer ignore-type */ $id)
Loading history...
129
            ->with('success', 'Location updated successfully');
130
    }
131
132
    /**
133
     * Remove the specified resource from storage.
134
     *
135
     * @param  int  $id
136
     * @return \Illuminate\Http\RedirectResponse
137
     */
138
    public function destroy($id)
139
    {
140
        $this->authorize('destroy', Location::class);
141
        
142
        Location::findOrFail($id)->delete();
143
        return redirect()->route('location.index')
144
            ->with('success', 'Location deleted successfully');
145
    }
146
}
147