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/DeviceController.php (6 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
namespace App\Http\Controllers;
4
5
use App\DataTables\DeviceDataTable;
6
use App\Models\Device;
7
use App\Models\DeviceGroup;
8
use Dingo\Api\Routing\Helpers;
9
use Illuminate\Http\Request;
10
11
class DeviceController extends Controller
12
{
13
    use Helpers;
14
15
    /**
16
     * Display a listing of the resource.
17
     *
18
     * @return \Illuminate\Http\JsonResponse|\Illuminate\View\View
19
     */
20 3
    public function index(DeviceDataTable $dataTable, $group_id = -1)
21
    {
22 3
        $group_name = "";
23 3
        if ($group_id >= 0) {
24 1
            $dataTable->addScope(new \App\DataTables\Scopes\DeviceGroup($group_id));
25 1
            $group_name = DeviceGroup::find($group_id)->name;
26
        }
27
28 3
        return $dataTable->render('devices.list', compact('group_name'));
29
    }
30
31
    /**
32
     * Show the form for creating a new resource.
33
     *
34
     * @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...
35
     */
36
    public function create()
37
    {
38
        // add new device form
39
        return view('devices.create');
40
    }
41
42
    /**
43
     * Store a newly created resource in storage.
44
     *
45
     * @param  \Illuminate\Http\Request  $request
46
     * @return \Illuminate\Http\RedirectResponse
47
     */
48
    public function store(Request $request)
49
    {
50
        // save device
51
52
        $this->validate($request, [
53
            'hostname'        => 'required|unique:devices|max:128',
54
            'snmpver'         => 'required|alpha_num|max:4',
55
            'transport'       => 'required|alpha_num|max:16',
56
            'port_assoc_mode' => 'required|alpha',
57
            'community'       => 'required_if:snmpver,v1,v2c|max:255',
58
            'authlevel'       => 'required_if:snmpver,v3|alpha|max:15',
59
            'authname'        => 'required_if:authlevel,authNoPriv|max:64',
60
            'authalgo'        => 'required_if:authlevel,authNoPriv|in:MD5,SHA|max:3',
61
            'cryptopass'      => 'required_if:authlevel,authPriv|max:64',
62
            'cryptoalgo'      => 'required_if:authlevel,authPriv|in:AES,DES|max:3',
63
        ]);
64
        return redirect()->route('devices.index');
65
    }
66
67
    /**
68
     * Display the specified resource.
69
     *
70
     * @param  \Illuminate\Http\Request $request
71
     * @param  int $id
72
     * @param string $page
73
     * @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...
74
     */
75
    public function show(Request $request, $id, $page = 'overview')
76
    {
77
        $device = Device::find($id);
78
        $device_url = url('devices/'.$device->device_id);
79
80
        $page_setup['navbar'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$page_setup was never initialized. Although not strictly required by PHP, it is generally a good practice to add $page_setup = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
81
            'Overview' => $device_url,
82
            'Graphs'   => $device_url . '/graphs',
83
            'Health'   => $device_url . '/health',
84
        ];
85
        return view('devices.show', compact(['device', 'page_setup', 'request', 'page']));
86
    }
87
88
    /**
89
     * Show the form for editing the specified resource.
90
     *
91
     * @param  int  $id
92
     * @return \Illuminate\Http\Response
0 ignored issues
show
Should the return type not be \Illuminate\Http\Response|null?

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...
93
     */
94
    public function edit($id)
95
    {
96
        //edit device form??
97
    }
98
99
    /**
100
     * Update the specified resource in storage.
101
     *
102
     * @param  \Illuminate\Http\Request  $request
103
     * @param  int  $id
104
     * @return \Illuminate\Http\Response
0 ignored issues
show
Should the return type not be \Illuminate\Http\Response|null?

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...
105
     */
106
    public function update(Request $request, $id)
107
    {
108
        //process device modify
109
    }
110
111
    /**
112
     * Remove the specified resource from storage.
113
     *
114
     * @param  int  $id
115
     * @return \Illuminate\Http\Response
0 ignored issues
show
Should the return type not be \Illuminate\Http\Response|null?

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...
116
     */
117
    public function destroy($id)
118
    {
119
        // delete device
120
    }
121
}
122