Issues (133)

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/presenters/ItemPresenter.php (7 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 UniMan\Presenters;
4
5
use UniMan\Components\DatabaseSelect\TablesSideBarControl;
6
use UniMan\Core\Forms\FilterForm\FilterForm;
7
use UniMan\Core\Forms\ItemForm;
8
use App\Component\VisualPaginator;
9
use Nette\Application\ForbiddenRequestException;
10
11
class ItemPresenter extends BasePresenter
12
{
13
    private $onPage;
14
15
    private $sorting = [];
16
17
    private $filter = [];
18
19
    private $columns = [];
20
21
    public function actionDefault($driver, $database, $type, $table, $page = 1, $onPage = FilterForm::DEFAULT_ON_PAGE, array $filter = [], array $sorting = [])
0 ignored issues
show
The parameter $driver is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $page is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23
        ksort($sorting);
24
        $this->database = $database;
25
        $this->type = $type;
26
        $this->table = $table;
27
        $this->onPage = $onPage;
28
        $this->sorting = $sorting;
29
        $this->filter = $filter;
30
        $this->columns = $this->driver->headerManager()->itemsHeaders($type, $table);
31
    }
32
33
    public function renderDefault($driver, $database, $type, $table, $page = 1, $onPage = FilterForm::DEFAULT_ON_PAGE, array $filter = [], array $sorting = [])
34
    {
35
        $this->template->driver = $driver;
36
        $this->template->database = $database;
37
        $this->template->type = $type;
38
        $this->template->table = $table;
39
        $this->template->sorting = $sorting;
40
        $this->template->filter = $filter;
41
        
42
        $itemsCount = $this->driver->dataManager()->itemsCount($type, $table, $filter);
43
        $this->template->itemsCount = $itemsCount;
44
        $this->template->items = $this->driver->dataManager()->items($type, $table, $page, $onPage, $filter, $sorting);
45
46
        $this->template->columns = $this->columns;
47
48
        $visualPaginator = $this['paginator'];
49
        $paginator = $visualPaginator->getPaginator();
50
        $paginator->setItemCount($itemsCount);
51
        $paginator->setItemsPerPage($onPage);
52
        $paginator->page = $page;
53
54
        foreach ($this->driver->dataManager()->getMessages() as $message => $type) {
55
            $type = $type ?: 'info';
56
            $this->flashMessage($message, $type);
57
        }
58
    }
59
60 View Code Duplication
    public function actionCreate($driver, $database, $type, $table)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
61
    {
62
        if (!$this->driver->permissions()->canCreateItem($database, $type, $table)) {
63
            throw new ForbiddenRequestException('Create item is not allowed');
64
        }
65
        $this->template->driver = $driver;
66
        $this->database = $database;
67
        $this->template->type = $this->type = $type;
68
        $this->table = $table;
69
    }
70
71 View Code Duplication
    public function actionEdit($driver, $database, $type, $table, $item)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
72
    {
73
        if (!$this->driver->permissions()->canEditItem($database, $type, $table, $item)) {
74
            throw new ForbiddenRequestException('Edit item is not allowed');
75
        }
76
        $this->template->driver = $driver;
77
        $this->database = $database;
78
        $this->template->type = $this->type = $type;
79
        $this->table = $table;
80
        $this->item = $item;
81
    }
82
83
    public function handleDelete($driver, $database, $type, $table, $item)
84
    {
85
        if (!$this->driver->permissions()->canDeleteItem($database, $type, $table, $item)) {
86
            throw new ForbiddenRequestException('Delete item is not allowed');
87
        }
88 View Code Duplication
        if ($this->driver->dataManager()->deleteItem($type, $table, $item)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
89
            $this->flashMessage('Item was successfully deleted', 'success');
90
        } else {
91
            $this->flashMessage('Item was not deleted', 'danger');
92
        }
93
        $this->redirect('this', $driver, $database, $type, $table);
94
    }
95
96
    protected function createComponentForm()
97
    {
98
        return new ItemForm($this->translator, $this->driver, $this->database, $this->type, $this->table, $this->item);
99
    }
100
101
    protected function createComponentFilterForm()
102
    {
103
        $form = $this->driver->formManager()->filterForm($this->translator, $this->columns, $this->filter, $this->sorting, $this->onPage);
104
        $form->doRedirect[] = function ($onPage, $filter, $sorting) {
0 ignored issues
show
Accessing doRedirect on the interface UniMan\Core\Forms\FilterForm\FilterFormInterface 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...
105
            $this->redirect('Item:default', $this->driver->type(), $this->database, $this->type, $this->table, 1, $onPage, $filter, $sorting);
106
        };
107
        $form->doReset[] = function () {
0 ignored issues
show
Accessing doReset on the interface UniMan\Core\Forms\FilterForm\FilterFormInterface 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...
108
            $this->redirect('Item:default', $this->driver->type(), $this->database, $this->type, $this->table);
109
        };
110
        return $form;
111
    }
112
113
    protected function createComponentPaginator()
114
    {
115
        return new VisualPaginator();
116
    }
117
118
    protected function createComponentTablesSideBar()
119
    {
120
        return new TablesSideBarControl($this->driver, $this->database, $this->table);
121
    }
122
}
123