Issues (111)

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/Models/Port.php (1 issue)

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\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
/**
8
 * App\Models\Port
9
 *
10
 * @property integer $port_id
11
 * @property integer $device_id
12
 * @property string $port_descr_type
13
 * @property string $port_descr_descr
14
 * @property string $port_descr_circuit
15
 * @property string $port_descr_speed
16
 * @property string $port_descr_notes
17
 * @property string $ifDescr
18
 * @property string $ifName
19
 * @property string $portName
20
 * @property integer $ifIndex
21
 * @property integer $ifSpeed
22
 * @property string $ifConnectorPresent
23
 * @property string $ifPromiscuousMode
24
 * @property integer $ifHighSpeed
25
 * @property string $ifOperStatus
26
 * @property string $ifOperStatus_prev
27
 * @property string $ifAdminStatus
28
 * @property string $ifAdminStatus_prev
29
 * @property string $ifDuplex
30
 * @property integer $ifMtu
31
 * @property string $ifType
32
 * @property string $ifAlias
33
 * @property string $ifPhysAddress
34
 * @property string $ifHardType
35
 * @property string $ifLastChange
36
 * @property string $ifVlan
37
 * @property string $ifTrunk
38
 * @property integer $ifVrf
39
 * @property integer $counter_in
40
 * @property integer $counter_out
41
 * @property boolean $ignore
42
 * @property boolean $disabled
43
 * @property boolean $detailed
44
 * @property boolean $deleted
45
 * @property string $pagpOperationMode
46
 * @property string $pagpPortState
47
 * @property string $pagpPartnerDeviceId
48
 * @property string $pagpPartnerLearnMethod
49
 * @property integer $pagpPartnerIfIndex
50
 * @property integer $pagpPartnerGroupIfIndex
51
 * @property string $pagpPartnerDeviceName
52
 * @property string $pagpEthcOperationMode
53
 * @property string $pagpDeviceId
54
 * @property integer $pagpGroupIfIndex
55
 * @property integer $ifInUcastPkts
56
 * @property integer $ifInUcastPkts_prev
57
 * @property integer $ifInUcastPkts_delta
58
 * @property integer $ifInUcastPkts_rate
59
 * @property integer $ifOutUcastPkts
60
 * @property integer $ifOutUcastPkts_prev
61
 * @property integer $ifOutUcastPkts_delta
62
 * @property integer $ifOutUcastPkts_rate
63
 * @property integer $ifInErrors
64
 * @property integer $ifInErrors_prev
65
 * @property integer $ifInErrors_delta
66
 * @property integer $ifInErrors_rate
67
 * @property integer $ifOutErrors
68
 * @property integer $ifOutErrors_prev
69
 * @property integer $ifOutErrors_delta
70
 * @property integer $ifOutErrors_rate
71
 * @property integer $ifInOctets
72
 * @property integer $ifInOctets_prev
73
 * @property integer $ifInOctets_delta
74
 * @property integer $ifInOctets_rate
75
 * @property integer $ifOutOctets
76
 * @property integer $ifOutOctets_prev
77
 * @property integer $ifOutOctets_delta
78
 * @property integer $ifOutOctets_rate
79
 * @property integer $poll_time
80
 * @property integer $poll_prev
81
 * @property integer $poll_period
82
 * @property-read \App\Models\Device $device
83
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\User[] $users
84
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\General\IPv4[] $ipv4
85
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\General\IPv6[] $ipv6
86
 * @property-read mixed $if_phys_address
87
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePortId($value)
88
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereDeviceId($value)
89
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePortDescrType($value)
90
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePortDescrDescr($value)
91
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePortDescrCircuit($value)
92
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePortDescrSpeed($value)
93
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePortDescrNotes($value)
94
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfDescr($value)
95
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfName($value)
96
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePortName($value)
97
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfIndex($value)
98
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfSpeed($value)
99
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfConnectorPresent($value)
100
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfPromiscuousMode($value)
101
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfHighSpeed($value)
102
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfOperStatus($value)
103
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfOperStatusPrev($value)
104
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfAdminStatus($value)
105
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfAdminStatusPrev($value)
106
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfDuplex($value)
107
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfMtu($value)
108
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfType($value)
109
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfAlias($value)
110
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfPhysAddress($value)
111
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfHardType($value)
112
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfLastChange($value)
113
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfVlan($value)
114
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfTrunk($value)
115
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfVrf($value)
116
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereCounterIn($value)
117
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereCounterOut($value)
118
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIgnore($value)
119
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereDisabled($value)
120
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereDetailed($value)
121
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereDeleted($value)
122
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePagpOperationMode($value)
123
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePagpPortState($value)
124
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePagpPartnerDeviceId($value)
125
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePagpPartnerLearnMethod($value)
126
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePagpPartnerIfIndex($value)
127
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePagpPartnerGroupIfIndex($value)
128
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePagpPartnerDeviceName($value)
129
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePagpEthcOperationMode($value)
130
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePagpDeviceId($value)
131
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePagpGroupIfIndex($value)
132
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfInUcastPkts($value)
133
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfInUcastPktsPrev($value)
134
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfInUcastPktsDelta($value)
135
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfInUcastPktsRate($value)
136
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfOutUcastPkts($value)
137
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfOutUcastPktsPrev($value)
138
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfOutUcastPktsDelta($value)
139
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfOutUcastPktsRate($value)
140
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfInErrors($value)
141
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfInErrorsPrev($value)
142
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfInErrorsDelta($value)
143
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfInErrorsRate($value)
144
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfOutErrors($value)
145
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfOutErrorsPrev($value)
146
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfOutErrorsDelta($value)
147
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfOutErrorsRate($value)
148
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfInOctets($value)
149
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfInOctetsPrev($value)
150
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfInOctetsDelta($value)
151
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfInOctetsRate($value)
152
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfOutOctets($value)
153
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfOutOctetsPrev($value)
154
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfOutOctetsDelta($value)
155
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port whereIfOutOctetsRate($value)
156
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePollTime($value)
157
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePollPrev($value)
158
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port wherePollPeriod($value)
159
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port notDeleted()
160
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port isUp()
161
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port isDown()
162
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port isIgnored()
163
 * @method static \Illuminate\Database\Query\Builder|\App\Models\Port isDisabled()
164
 * @mixin \Eloquent
165
 */
166
class Port extends Model
167
{
168
    /**
169
     * Indicates if the model should be timestamped.
170
     *
171
     * @var bool
172
     */
173
    public $timestamps = false;
174
    /**
175
     * The table associated with the model.
176
     *
177
     * @var string
178
     */
179
    protected $table = 'ports';
180
    /**
181
     * The primary key column name.
182
     *
183
     * @var string
184
     */
185
    protected $primaryKey = 'port_id';
186
187
    // ---- Helper Functions ----
188
189
    /**
190
     * Returns a human readable label for this port
191
     *
192
     * @return string
0 ignored issues
show
Should the return type not be string|integer?

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...
193
     */
194 1
    public function getLabel()
195
    {
196 1
        if ($this->ifName) {
197 1
            return $this->ifName;
198
        }
199
200
        if ($this->ifDescr) {
201
            return $this->ifDescr;
202
        }
203
204
        return $this->ifIndex;
205
    }
206
207
    // ---- Accessors/Mutators ----
208
209
    public function getIfPhysAddressAttribute($mac)
210
    {
211
        if (!empty($mac)) {
212
            return preg_replace('/(..)(..)(..)(..)(..)(..)/', '\\1:\\2:\\3:\\4:\\5:\\6', $mac);
213
        }
214
        return null;
215
    }
216
217
    // ---- Query scopes ----
218
219
    public function scopeNotDeleted($query)
220
    {
221
        return $query->where([
222
            ['deleted', '=', 0],
223
        ]);
224
    }
225
226
    public function scopeIsUp($query)
227
    {
228
        return $query->where([
229
            ['deleted', '=', 0],
230
            ['ignore', '=', 0],
231
            ['ifOperStatus', '=', 'up'],
232
        ]);
233
    }
234
235
    public function scopeIsDown($query)
236
    {
237
        return $query->where([
238
            ['deleted', '=', 0],
239
            ['ignore', '=', 0],
240
            ['ifOperStatus', '=', 'down'],
241
            ['ifAdminStatus', '=', 'up'],
242
        ]);
243
    }
244
245
    public function scopeIsIgnored($query)
246
    {
247
        return $query->where([
248
            ['deleted', '=', 0],
249
            ['ignore', '=', 1],
250
        ]);
251
    }
252
253
    public function scopeIsDisabled($query)
254
    {
255
        return $query->where([
256
            ['deleted', '=', 0],
257
            ['ignore', '=', 0],
258
            ['ifAdminStatus', '=', 'down'],
259
        ]);
260
    }
261
262
    // ---- Define Relationships ----
263
264
    /**
265
     * Get the device this port belongs to.
266
     *
267
     */
268 1
    public function device()
269
    {
270 1
        return $this->belongsTo('App\Models\Device', 'device_id', 'device_id');
271
    }
272
273
    /**
274
     * Returns a list of users that can access this port.
275
     */
276
    public function users()
277
    {
278
        return $this->belongsToMany('App\Models\User', 'ports_perms', 'port_id', 'user_id');
279
    }
280
281
    /**
282
     * @return \Illuminate\Database\Eloquent\Relations\hasMany
283
     */
284
    public function ipv4()
285
    {
286
        return $this->hasMany('App\Models\General\IPv4', 'port_id');
287
    }
288
289
    /**
290
     * @return \Illuminate\Database\Eloquent\Relations\hasMany
291
     */
292
    public function ipv6()
293
    {
294
        return $this->hasMany('App\Models\General\IPv6', 'port_id');
295
    }
296
}
297