GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (2)

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/Redirect.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\Redirects\Models;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Model;
7
use Neurony\Redirects\Contracts\RedirectModelContract;
8
use Neurony\Redirects\Exceptions\RedirectException;
9
10
class Redirect extends Model implements RedirectModelContract
11
{
12
    /**
13
     * The database table.
14
     *
15
     * @var string
16
     */
17
    protected $table = 'redirects';
18
19
    /**
20
     * The attributes that are mass assignable.
21
     *
22
     * @var array
23
     */
24
    protected $fillable = [
25
        'old_url',
26
        'new_url',
27
        'status',
28
    ];
29
30
    /**
31
     * Boot the model.
32
     *
33
     * @return void
34
     */
35
    public static function boot()
36
    {
37
        parent::boot();
38
39
        static::saving(function (self $model) {
40
            if (trim(strtolower($model->old_url), '/') == trim(strtolower($model->new_url), '/')) {
41
                throw RedirectException::sameUrls();
42
            }
43
44
            static::whereOldUrl($model->new_url)->whereNewUrl($model->old_url)->delete();
45
46
            $model->syncOldRedirects($model, $model->new_url);
47
        });
48
    }
49
50
    /**
51
     * The mutator to set the "old_url" attribute.
52
     *
53
     * @param string $value
54
     */
55
    public function setOldUrlAttribute($value)
56
    {
57
        $this->attributes['old_url'] = trim(parse_url($value)['path'], '/');
58
    }
59
60
    /**
61
     * The mutator to set the "new_url" attribute.
62
     *
63
     * @param string $value
64
     */
65
    public function setNewUrlAttribute($value)
66
    {
67
        $this->attributes['new_url'] = trim(parse_url($value)['path'], '/');
68
    }
69
70
    /**
71
     * Filter the query by an old url.
72
     *
73
     * @param Builder $query
74
     * @param string $url
75
     *
76
     * @return mixed
77
     */
78
    public function scopeWhereOldUrl($query, string $url)
79
    {
80
        return $query->where('old_url', $url);
81
    }
82
83
    /**
84
     * Filter the query by a new url.
85
     *
86
     * @param Builder $query
87
     * @param string $url
88
     *
89
     * @return mixed
90
     */
91
    public function scopeWhereNewUrl($query, string $url)
92
    {
93
        return $query->where('new_url', $url);
94
    }
95
96
    /**
97
     * Get all redirect statuses defined inside the "config/redirects.php" file.
98
     *
99
     * @return array
100
     */
101
    public static function getStatuses(): array
102
    {
103
        return (array) config('redirects.statuses', []);
104
    }
105
106
    /**
107
     * Sync old redirects to point to the new (final) url.
108
     *
109
     * @param RedirectModelContract $model
110
     * @param string $finalUrl
111
     * @return void
112
     */
113
    public function syncOldRedirects(RedirectModelContract $model, string $finalUrl): void
114
    {
115
        $items = static::whereNewUrl($model->old_url)->get();
0 ignored issues
show
Accessing old_url on the interface Neurony\Redirects\Contracts\RedirectModelContract suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
116
117
        foreach ($items as $item) {
118
            $item->update(['new_url' => $finalUrl]);
119
            $item->syncOldRedirects($model, $finalUrl);
120
        }
121
    }
122
123
    /**
124
     * Return a valid redirect entity for a given path (old url).
125
     * A redirect is valid if:
126
     * - it has an url to redirect to (new url)
127
     * - it's status code is one of the statuses defined on this model.
128
     *
129
     * @param string $path
130
     * @return Redirect|null
131
     */
132
    public static function findValidOrNull($path): ?RedirectModelContract
133
    {
134
        return static::where('old_url', $path === '/' ? $path : trim($path, '/'))
135
            ->whereNotNull('new_url')
136
            ->whereIn('status', array_keys(self::getStatuses()))
137
            ->latest()->first();
138
    }
139
}
140