Issues (15)

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/Controllers/DocumentCrudController.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 Webfactor\Laravel\Backpack\Documents\Controllers;
4
5
use Backpack\CRUD\app\Http\Controllers\CrudController;
6
use Webfactor\Laravel\Backpack\Documents\Requests\DocumentRequest as StoreRequest;
7
use Webfactor\Laravel\Backpack\Documents\Requests\DocumentUpdateRequest as UpdateRequest;
8
9
class DocumentCrudController extends CrudController
10
{
11
    protected $types = [
12
        'plaintext' => [
13
            'field' => 'textarea',
14
            'attrLabel' => 'textareaAttributes'
15
        ],
16
        'html'      => [
17
            'field' => 'summernote',
18
            'attrLabel' => 'options'
19
        ],
20
        'md'        => [
21
            'field' => 'simplemde',
22
            'attrLabel' => 'simplemdeAttributesRaw'
23
        ],
24
    ];
25
26
    public function setup()
27
    {
28
        /*
29
        |--------------------------------------------------------------------------
30
        | BASIC CRUD INFORMATION
31
        |--------------------------------------------------------------------------
32
        */
33
        $this->crud->setModel(config('webfactor.documents.model_class'));
34
        $this->crud->setRoute(config('webfactor.documents.backend.route_prefix') . '/' . config('webfactor.documents.backend.route'));
35
        $this->crud->setEntityNameStrings(trans('webfactor::documents.entity_name_singular'),
36
            trans('webfactor::documents.entity_name_plural'));
37
38
        /*
39
        |--------------------------------------------------------------------------
40
        | BASIC CRUD INFORMATION
41
        |--------------------------------------------------------------------------
42
        */
43
44
        // ------ CRUD FIELDS
45
46
        $this->crud->addField([
47
            'name'            => 'type',
48
            'label'           => 'Dokumentenart',
49
            'type'            => 'select_from_array',
50
            'options'         => $this->getTypeOptions(),
51
            'allows_null'     => false,
52
            'allows_multiple' => false,
53
        ]);
54
55
        $this->crud->addField([
56
            'name'  => 'title',
57
            'label' => trans('webfactor::documents.title'),
58
        ]);
59
60
        $this->crud->addField([
61
            'name'                            => 'body',
62
            'label'                           => trans('webfactor::documents.body'),
63
            'type'                            => $this->bodyFieldType(),
64
            $this->bodyFieldAttributesLabel() => $this->bodyFieldAttributes(),
65
        ]);
66
67
        // ------ CRUD COLUMNS
68
69
        $this->crud->addColumns([
70
            [
71
                'name'  => 'translated_type',
72
                'label' => trans('webfactor::documents.type'),
73
            ],
74
            [
75
                'name'  => 'title',
76
                'label' => trans('webfactor::documents.title'),
77
            ],
78
            [
79
                'name'  => 'body',
80
                'label' => trans('webfactor::documents.body'),
81
            ],
82
        ]);
83
84
        // ------ CRUD BUTTONS
85
86
        // ------ CRUD ACCESS
87
88
        collect(config('webfactor.documents.access', []))->each(function ($enabled, $key) {
89
            if ($enabled) {
90
                $this->crud->allowAccess($key);
91
            } else {
92
                $this->crud->denyAccess($key);
93
            }
94
        });
95
96
        // ------ CRUD REORDER
97
98
        // ------ CRUD DETAILS ROW
99
100
        // ------ REVISIONS
101
102
        // ------ AJAX TABLE VIEW
103
104
        // ------ DATATABLE EXPORT BUTTONS
105
106
        // ------ ADVANCED QUERIES
107
    }
108
109
    public function getTypeOptions()
110
    {
111
        $types = collect(config('webfactor.documents.types'));
112
113
        return $types->mapWithKeys(function ($type) {
114
            return [$type => trans('webfactor::documents.types.' . $type)];
115
        });
116
    }
117
118
    public function bodyFieldType()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
119
    {
120
        return $this->types[config('webfactor.documents.body_type', 'plaintext')]['field'];
121
    }
122
123
    public function bodyFieldAttributesLabel()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
124
    {
125
        return $this->types[config('webfactor.documents.body_type', 'plaintext')]['attrLabel'];
126
    }
127
128
    public function bodyFieldAttributes()
129
    {
130
        $type = config('webfactor.documents.body_type', 'plaintext');
131
        return config('webfactor.documents.field_editor_attributes.'.$type, []);
132
    }
133
134
    public function store(StoreRequest $request)
135
    {
136
        // your additional operations before save here
137
        $redirect_location = parent::storeCrud($request);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (storeCrud() instead of store()). Are you sure this is correct? If so, you might want to change this to $this->storeCrud().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
138
        // your additional operations after save here
139
        // use $this->data['entry'] or $this->crud->entry
140
        return $redirect_location;
141
    }
142
143
    public function update(UpdateRequest $request)
144
    {
145
        // your additional operations before save here
146
        $redirect_location = parent::updateCrud($request);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (updateCrud() instead of update()). Are you sure this is correct? If so, you might want to change this to $this->updateCrud().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
147
        // your additional operations after save here
148
        // use $this->data['entry'] or $this->crud->entry
149
        return $redirect_location;
150
    }
151
}
152