Issues (179)

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.

app/Http/Controllers/DeviceGroupController.php (7 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
2
/**
3
 * DeviceGroupController.php
4
 *
5
 * -Description-
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 * @package    LibreNMS
21
 * @link       http://librenms.org
22
 * @copyright  2016 Tony Murray
23
 * @author     Tony Murray <[email protected]>
24
 */
25
26
namespace App\Http\Controllers;
27
28
use App\DataTables\DeviceGroupDataTable;
29
use App\Http\Requests\AdminOnlyRequest;
30
use App\Http\Requests\DeviceGroupRequest;
31
use App\Models\DeviceGroup;
32
33
class DeviceGroupController extends Controller
34
{
35
    /**
36
     * Display a listing of the resource.
37
     *
38
     * @param DeviceGroupDataTable $dataTable
39
     * @return \Illuminate\Http\Response
0 ignored issues
show
Should the return type not be \Illuminate\Http\JsonRes...e|\Illuminate\View\View?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
40
     */
41 1
    public function index(DeviceGroupDataTable $dataTable)
42
    {
43 1
        return $dataTable->render('devices.group-list');
44
    }
45
46
    /**
47
     * Show the form for creating a new resource.
48
     *
49
     * @return \Illuminate\Http\Response
0 ignored issues
show
Should the return type not be \Illuminate\View\View|\I...\Contracts\View\Factory?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
50
     */
51
    public function create()
52
    {
53
        return view('devices.group-edit');
54
    }
55
56
    /**
57
     * Store a newly created resource in storage.
58
     *
59
     * @param  \Illuminate\Http\Request $request
60
     * @return \Illuminate\Http\Response
0 ignored issues
show
Should the return type not be \Illuminate\Http\JsonResponse?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
61
     */
62
    public function store(DeviceGroupRequest $request)
63
    {
64
        $group = DeviceGroup::create($request->all());
0 ignored issues
show
The method create() does not exist on App\Models\DeviceGroup. Did you maybe mean created()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
65
66
        return response()->json(['message' => trans('devices.groups.created', ['name' => $group->name])]);
67
    }
68
69
    /**
70
     * Display the specified resource.
71
     *
72
     * @param  int $id
73
     * @return \Illuminate\Http\Response
0 ignored issues
show
Should the return type not be \Illuminate\Http\RedirectResponse?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
74
     */
75
    public function show($id)
76
    {
77
        return redirect('devices/group='.$id);
78
    }
79
80
    /**
81
     * Show the form for editing the specified resource.
82
     *
83
     * @param  int $id
84
     * @return \Illuminate\Http\Response
85
     */
86
    public function edit($id)
87
    {
88
        $group = DeviceGroup::findOrFail($id);
89
        return view('devices.group-edit')->withGroup($group);
90
    }
91
92
    /**
93
     * Update the specified resource in storage.
94
     *
95
     * @param  \Illuminate\Http\Request $request
96
     * @param  int $id
97
     * @return \Illuminate\Http\Response
0 ignored issues
show
Should the return type not be \Illuminate\Http\JsonResponse?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
98
     */
99
    public function update(DeviceGroupRequest $request, $id)
100
    {
101
        $group = DeviceGroup::find($id);
102
        $group->update($request->all());
103
        $group->updateRelations();
104
105
        return response()->json(['message' => trans('devices.groups.updated', ['name' => $group->name])]);
106
    }
107
108
    /**
109
     * Remove the specified resource from storage.
110
     *
111
     * @param \Illuminate\Http\Request $request
112
     * @param  int $id
113
     * @return \Illuminate\Http\Response
0 ignored issues
show
Should the return type not be \Illuminate\Http\JsonResponse?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
114
     * @throws \Exception
115
     */
116
    public function destroy(AdminOnlyRequest $request, $id)
117
    {
118
        $group = DeviceGroup::find($id);
119
        if ($group && $group->delete()) {
120
            return response()->json(['message' => trans('devices.groups.deleted', ['name' => $group->name])]);
121
        } else {
122
            return response()->json(['message' => trans('devices.groups.deletefailed', ['name' => $group ? $group->name : ""])], 422);
123
        }
124
    }
125
}
126