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 (31)

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/Services/CrudEntry.php (4 issues)

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 Akibatech\Crud\Services;
4
5
use Akibatech\Crud\Exceptions\InvalidModelException;
6
use Akibatech\Crud\Exceptions\NoFieldsException;
7
use Akibatech\Crud\Traits\Crudable;
8
use Illuminate\Database\Eloquent\Model;
9
use Illuminate\Support\Facades\View;
10
11
/**
12
 * Class CrudEntry
13
 *
14
 * @package Akibatech\Crud\Services
15
 */
16
class CrudEntry
17
{
18
    /**
19
     * @var CrudFields
20
     */
21
    protected $fields = [];
22
23
    /**
24
     * @var Crudable|Model
25
     */
26
    protected $model;
27
28
    /**
29
     * @var CrudManager
30
     */
31
    protected $manager;
32
33
    /**
34
     * @var CrudValidator
35
     */
36
    protected $validator;
37
38
    /**
39
     * CrudEntry constructor.
40
     *
41
     * @param   Model|Crudable $model
42
     * @throws  \InvalidArgumentException
43
     */
44
    public function __construct(Model $model)
45
    {
46
        if (in_array(Crudable::class, class_uses($model)))
47
        {
48
            $this->model = $model;
49
            $this->manager = $model->getCrudManager()->setEntry($this);
50
            $this->fields = $model->getCrudFields()->setEntry($this);
51
52
            if ($this->fields->count() === 0)
53
            {
54
                throw new NoFieldsException(get_class($model) . ' has no fields.');
55
            }
56
57
            if (!app()->runningUnitTests() && !app()->runningInConsole())
58
            {
59
                $this->fields->hydrateErrorsFromSession();
60
                $this->fields->hydrateFieldsFromSession();
61
            }
62
        }
63
        else
64
        {
65
            throw new InvalidModelException("The model must use Crudable trait.");
66
        }
67
    }
68
69
    /**
70
     * @param   void
71
     * @return  \Generator
72
     */
73
    public function fields()
74
    {
75
        foreach ($this->fields->loop() as $field)
76
        {
77
            if ($field->isDisplayedInColumns())
78
            {
79
                yield $field;
80
            }
81
        }
82
    }
83
84
    /**
85
     * @param   void
86
     * @return  \Generator
87
     */
88
    public function formFields()
89
    {
90
        foreach ($this->fields->loop() as $field)
91
        {
92
            yield $field;
93
        }
94
    }
95
96
    /**
97
     * Get the entry ID.
98
     *
99
     * @param   void
100
     * @return  int|mixed
101
     */
102
    public function getId()
103
    {
104
        return $this->model->getAttribute($this->model->getKeyName());
0 ignored issues
show
The method getKeyName does only exist in Illuminate\Database\Eloquent\Model, but not in Akibatech\Crud\Traits\Crudable.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
The method getAttribute does only exist in Illuminate\Database\Eloquent\Model, but not in Akibatech\Crud\Traits\Crudable.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
105
    }
106
107
    /**
108
     * @param   void
109
     * @return  string
110
     */
111
    public function row()
112
    {
113
        $actions = [
114
            [
115
                'value' => trans('crud::buttons.edit'),
116
                'class' => 'btn btn-primary btn-xs',
117
                'uri'   => $this->manager->getActionRoute('edit')
118
            ],
119
            [
120
                'value' => trans('crud::buttons.destroy'),
121
                'class' => 'btn btn-danger btn-xs',
122
                'uri'   => $this->manager->getActionRoute('destroy')
123
            ],
124
        ];
125
126
        $view = view()->make('crud::row')->with([
0 ignored issues
show
The method make does only exist in Illuminate\Contracts\View\Factory, but not in Illuminate\View\View.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
127
            'entry'   => $this,
128
            'manager' => $this->manager,
129
            'actions' => $actions,
130
        ]);
131
132
        return $view->render();
133
    }
134
135
    /**
136
     * @param   void
137
     * @return  CrudFields
138
     */
139
    public function getFields()
140
    {
141
        return $this->fields;
142
    }
143
144
    /**
145
     * Resets the validator.
146
     *
147
     * @param   void
148
     * @return  self
149
     */
150
    public function resetValidator()
151
    {
152
        $this->validator = null;
153
154
        return $this;
155
    }
156
157
    /**
158
     * Shortcut to self validate.
159
     *
160
     * @param   array $data
161
     * @return  CrudValidator
162
     */
163
    public function validate(array $data)
164
    {
165
        return $this->getValidator()->validate($data);
166
    }
167
168
    /**
169
     * Gets the validator.
170
     *
171
     * @param   void
172
     * @return  CrudValidator
173
     */
174
    public function getValidator()
175
    {
176
        if (is_null($this->validator))
177
        {
178
            $this->validator = new CrudValidator($this);
179
        }
180
181
        return $this->validator;
182
    }
183
184
    /**
185
     * Saves the model.
186
     *
187
     * @param   void
188
     * @return  bool
189
     */
190
    public function save()
191
    {
192
        foreach ($this->fields->loop() as $field)
193
        {
194
            $field->beforeSave();
195
        }
196
197
        return $this->model->save();
0 ignored issues
show
The method save does only exist in Illuminate\Database\Eloquent\Model, but not in Akibatech\Crud\Traits\Crudable.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
198
    }
199
200
    /**
201
     * @param   void
202
     * @return  string
203
     */
204
    public function __toString()
205
    {
206
        return $this->form();
207
    }
208
209
    /**
210
     * @param   void
211
     * @return  string
212
     */
213
    public function form()
214
    {
215
        $is_new = !$this->getModel()->exists;
216
        $name = $this->getManager()->getName();
217
218
        $with = [
219
            'back_url'  => $this->manager->getActionRoute('index'),
220
            'entry'     => $this,
221
            'manager'   => $this->manager,
222
            'errors'    => $this->fields->getErrors(),
223
            'old'       => $this->fields->getOldInput(),
224
            'crud_js'   => $this->fields->getFieldsScripts(),
225
            'crud_css'  => $this->fields->getFieldsCss(),
226
            'multipart' => $this->fields->getMultipart() ? ' enctype="multipart/form-data"' : ''
227
        ];
228
229
        if ($is_new)
230
        {
231
            $view_name = 'crud::form-create';
232
            $method = $this->manager->getActionMethod('store');
233
234
            $with += [
235
                'title'        => trans('crud::form.create_title', ['name' => $name]),
236
                'form_url'     => $this->manager->getActionRoute('store'),
237
                'form_method'  => $method,
238
                'csrf_field'   => csrf_field(),
239
                'method_field' => method_field($method),
240
            ];
241
        }
242
        else
243
        {
244
            $view_name = 'crud::form-update';
245
            $method = $this->manager->getActionMethod('update');
246
247
            $with += [
248
                'title'        => trans('crud::form.update_title', ['name' => $name]),
249
                'form_url'     => $this->manager->getActionRoute('update'),
250
                'form_method'  => $method,
251
                'csrf_field'   => csrf_field(),
252
                'method_field' => method_field($method),
253
            ];
254
        }
255
256
        $view = View::make($view_name)->with($with);
257
258
        return $view->render();
259
    }
260
261
    /**
262
     * Get the entry's model.
263
     *
264
     * @param   void
265
     * @return  Crudable|Model
266
     */
267
    public function getModel()
268
    {
269
        return $this->model;
270
    }
271
272
    /**
273
     * @param   void
274
     * @return  CrudManager
275
     */
276
    public function getManager()
277
    {
278
        return $this->manager;
279
    }
280
}
281