Issues (27)

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.

src/Models/Url.php (1 issue)

Labels
Severity

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 Neurony\Url\Models;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Database\Eloquent\ModelNotFoundException;
8
use Illuminate\Database\Eloquent\Relations\MorphTo;
9
use Illuminate\Support\Facades\Request;
10
use Neurony\Url\Contracts\UrlModelContract;
11
12
class Url extends Model implements UrlModelContract
13
{
14
    /**
15
     * The database table.
16
     *
17
     * @var string
18
     */
19
    protected $table = 'urls';
20
21
    /**
22
     * The attributes that are mass assignable.
23
     *
24
     * @var array
25
     */
26
    protected $fillable = [
27
        'url',
28
        'urlable_id',
29
        'urlable_type',
30
    ];
31
32
    /**
33
     * Get all of the owning urlable models.
34
     *
35
     * @return MorphTo
36
     */
37
    public function urlable() : MorphTo
38
    {
39
        return $this->morphTo();
40
    }
41
42
    /**
43
     * Filter the query by url.
44
     *
45
     * @param Builder $query
46
     * @param string $url
47
     */
48
    public function scopeWhereUrl(Builder $query, string $url)
49
    {
50
        $query->where('url', $url);
51
    }
52
53
    /**
54
     * Filter the query by the urlable morph relation.
55
     *
56
     * @param Builder $query
57
     * @param int $id
58
     * @param string $type
59
     */
60
    public function scopeWhereUrlable(Builder $query, int $id, string $type)
61
    {
62
        $query->where([
63
            'urlable_id' => $id,
64
            'urlable_type' => $type,
65
        ]);
66
    }
67
68
    /**
69
     * Sort the query alphabetically by url.
70
     *
71
     * @param Builder $query
72
     */
73
    public function scopeInAlphabeticalOrder(Builder $query)
74
    {
75
        $query->orderBy('url', 'asc');
0 ignored issues
show
The method orderBy() does not exist on Illuminate\Database\Eloquent\Builder. Did you maybe mean enforceOrderBy()?

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...
76
    }
77
78
    /**
79
     * Get the model instance correlated with the accessed url.
80
     *
81
     * @param bool $silent
82
     * @return Model|null
83
     * @throws ModelNotFoundException
84
     */
85
    public static function getUrlable(bool $silent = true): ?Model
86
    {
87
        $model = Request::route()->action['model'] ?? null;
88
89
        if ($model && $model instanceof Model && $model->exists) {
90
            return $model;
91
        }
92
93
        if ($silent === false) {
94
            throw new ModelNotFoundException;
95
        }
96
    }
97
98
    /**
99
     * Get the model instance correlated with the accessed url.
100
     * Throw a ModelNotFoundException if the model doesn't exist.
101
     *
102
     * @return Model|null
103
     * @throws ModelNotFoundException
104
     */
105
    public static function getUrlableOrFail(): ?Model
106
    {
107
        return static::getUrlable(false);
108
    }
109
}
110