Issues (147)

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/Models/ProviderController.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
2
3
namespace App\Http\Controllers;
4
5
use App\Provider;
6
use Illuminate\Http\Request;
7
8 View Code Duplication
class ProviderController extends Controller
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type App\Http\Controllers\ProviderController has been defined more than once; this definition is ignored, only the first definition in src/Http/Controllers/ProviderController.php (L8-162) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
This class seems to be duplicated in 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...
9
{
10
    /**
11
      * Display a listing of the resource.
12
      *
13
      * @return \Illuminate\Http\Response
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
14
      */
15
     public function __construct()
16
     {
17
         $this->middleware('auth');
18
     }
19
20
    public function index()
21
    {
22
        $providers = Provider::paginate(5);
23
24
        return view('manteniments/providers/index', ['providers' => $providers]);
25
    }
26
27
    /**
28
     * Show the form for creating a new resource.
29
     *
30
     * @return \Illuminate\Http\Response
31
     */
32
    public function create()
33
    {
34
        return view('manteniments/providers/create');
35
    }
36
37
    /**
38
     * Store a newly created resource in storage.
39
     *
40
     * @param \Illuminate\Http\Request $request
41
     *
42
     * @return \Illuminate\Http\Response
43
     */
44
    public function store(Request $request)
45
    {
46
        $this->validateInput($request);
47
        Provider::create([
48
         'name'          => $request['name'],
49
         'shortName'     => $request['shortName'],
50
         'description'   => $request['description'],
51
         'date_entrance' => $request['date_entrance'],
52
         'last_update'   => $request['last_update'],
53
           ]);
54
55
        return redirect()->intended('mnt/provider');
56
    }
57
58
    /**
59
     * Display the specified resource.
60
     *
61
     * @param int $id
62
     *
63
     * @return \Illuminate\Http\Response
64
     */
65
    public function show($id)
66
    {
67
        //
68
    }
69
70
    /**
71
     * Show the form for editing the specified resource.
72
     *
73
     * @param int $id
74
     *
75
     * @return \Illuminate\Http\Response
76
     */
77
    public function edit($id)
78
    {
79
        $provider = Provider::find($id);
80
      // Redirect to country list if updating country wasn't existed
81
      if ($provider == null || count($provider) == 0) {
82
          return redirect()->intended('/mnt/provider');
83
      }
84
85
        return view('manteniments/providers/edit', ['provider' => $provider]);
86
    }
87
88
    /**
89
     * Update the specified resource in storage.
90
     *
91
     * @param \Illuminate\Http\Request $request
92
     * @param int                      $id
93
     *
94
     * @return \Illuminate\Http\Response
95
     */
96
    public function update(Request $request, $id)
97
    {
98
        $provider = Provider::findOrFail($id);
0 ignored issues
show
$provider is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
99
        $input = [
100
        'name'          => $request['name'],
101
        'shortName'     => $request['shortName'],
102
        'description'   => $request['description'],
103
        'date_entrance' => $request['date_entrance'],
104
        'last_update'   => $request['last_update'],
105
      ];
106
        $this->validate($request, [
107
      'name' => 'required|max:60',
108
      ]);
109
        Provider::where('id', $id)
110
          ->update($input);
111
112
        return redirect()->intended('mnt/provider');
113
    }
114
115
    /**
116
     * Remove the specified resource from storage.
117
     *
118
     * @param int $id
119
     *
120
     * @return \Illuminate\Http\Response
121
     */
122
    public function destroy($id)
123
    {
124
        Provider::where('id', $id)->delete();
125
126
        return redirect()->intended('mnt/provider');
127
    }
128
129
    public function search(Request $request)
130
    {
131
        $constraints = [
132
            'name'      => $request['name'],
133
            'shortName' => $request['shortName'],
134
            ];
135
        $providers = $this->doSearchingQuery($constraints);
136
137
        return view('manteniments/providers/index', ['providers' => $providers, 'searchingVals' => $constraints]);
138
    }
139
140
    private function doSearchingQuery($constraints)
141
    {
142
        $query = provider::query();
143
        $fields = array_keys($constraints);
144
        $index = 0;
145
        foreach ($constraints as $constraint) {
146
            if ($constraint != null) {
147
                $query = $query->where($fields[$index], 'like', '%'.$constraint.'%');
148
            }
149
            $index++;
150
        }
151
152
        return $query->paginate(5);
153
    }
154
155
    private function validateInput($request)
156
    {
157
        $this->validate($request, [
158
        'name'      => 'required|max:60|unique:provider',
159
        'shortName' => 'required|max:6|unique:provider',
160
    ]);
161
    }
162
}
163