Issues (632)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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.

Apps/Controller/Admin/Widget.php (3 issues)

Labels
1
<?php
2
3
namespace Apps\Controller\Admin;
4
5
use Apps\Model\Admin\Application\FormInstall;
6
use Apps\Model\Admin\Application\FormTurn;
7
use Apps\Model\Admin\Application\FormUpdate;
8
use Extend\Core\Arch\AdminController;
9
use Ffcms\Core\App;
10
use Ffcms\Core\Exception\ForbiddenException;
11
use Ffcms\Core\Exception\NotFoundException;
12
use Ffcms\Core\Helper\Type\Str;
13
14
/**
15
 * Class Widget. Control installed and not-installed widgets.
16
 * @package Apps\Controller\Admin
17
 */
18
class Widget extends AdminController
19
{
20
    public $type = 'widget';
21
22
    /**
23
     * Widget constructor. Disable installation checking for this controller
24
     */
25
    public function __construct()
26
    {
27
        parent::__construct(false);
28
    }
29
30
    /**
31
     * Show all installed widgets
32
     * @return string|null
33
     */
34
    public function actionIndex(): ?string
35
    {
36
        return $this->view->render('widget/index', [
37
            'widgets' => $this->widgets
38
        ]);
39
    }
40
41
    /**
42
     * Show installation form for widget
43
     * @return string|null
44
     * @throws \Ffcms\Core\Exception\SyntaxException
45
     */
46
    public function actionInstall(): ?string
47
    {
48
        $model = new FormInstall($this->applications, 'widget');
49
50
        // check if model is sended
51
        if ($model->send()) {
52
            // validate app name
53
            if ($model->validate()) {
54
                // try to run ::install method from remoute controller
55
                if ($model->make()) {
56
                    App::$Session->getFlashBag()->add('success', __('Widget "%widget%" is successful installed!', ['widget' => $model->sysname]));
57
                    $this->response->redirect('widget/index');
58
                } else {
59
                    App::$Session->getFlashBag()->add('error', __('During the installation process an error has occurred! Please contact with widget developer.'));
60
                }
61
            } else {
62
                App::$Session->getFlashBag()->add('error', __('Probably, app or widget with the same name is always used! Try to solve this conflict.'));
63
            }
64
        }
65
66
        return $this->view->render('widget/install', [
67
            'model' => $model
68
        ]);
69
    }
70
71
    /**
72
     * Run widget update - display submit form & callback execution
73
     * @param string $sys
74
     * @return string|null
75
     * @throws NotFoundException
76
     * @throws \Ffcms\Core\Exception\SyntaxException
77
     */
78
    public function actionUpdate($sys): ?string
79
    {
80
        // get controller name and try to find app in db
81
        $controller = ucfirst(Str::lowerCase($sys));
82
        $search = \Apps\ActiveRecord\App::getItem('widget', $controller);
0 ignored issues
show
Are you sure the assignment to $search is correct as Apps\ActiveRecord\App::g...('widget', $controller) targeting Apps\ActiveRecord\App::getItem() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
83
84
        // check what we got
85
        if (!$search || (int)$search->id < 1) {
0 ignored issues
show
$search is of type null, thus it always evaluated to false.
Loading history...
86
            throw new NotFoundException('Widget is not founded');
87
        }
88
89
        // init model and make update with notification
90
        $model = new FormUpdate($search);
91
92
        if ($model->send() && $model->validate()) {
93
            $model->make();
94
            App::$Session->getFlashBag()->add('success', __('Widget %w% is successful updated to %v% version', ['w' => $sys, 'v' => $model->scriptVersion]));
95
            $this->response->redirect('application/index');
96
        }
97
98
        // render response
99
        return $this->view->render('widget/update', [
100
            'model' => $model
101
        ]);
102
    }
103
104
    /**
105
     * Allow turn on/off widget
106
     * @param string $controllerName
107
     * @return string
108
     * @throws ForbiddenException
109
     */
110
    public function actionTurn($controllerName): ?string
111
    {
112
        // get controller name & find object in db
113
        $controllerName = ucfirst(Str::lowerCase($controllerName));
114
        /** @var \Apps\ActiveRecord\App $record */
115
        $record = \Apps\ActiveRecord\App::where('sys_name', $controllerName)
116
            ->where('type', 'widget')
117
            ->first();
118
119
        // check if widget admin controller exists
120
        if (!$record || (int)$record->id < 1) {
0 ignored issues
show
$record is of type Apps\ActiveRecord\App, thus it always evaluated to true.
Loading history...
121
            throw new ForbiddenException('Widget is not founded');
122
        }
123
124
        // initialize turn on/off model
125
        $model = new FormTurn($record);
126
        if ($model->send()) {
127
            $model->update();
128
            App::$Session->getFlashBag()->add('success', __('Widget status was changed'));
129
        }
130
131
        // render view
132
        return $this->view->render('widget/turn', [
133
            'widget' => $record,
134
            'model' => $model
135
        ]);
136
    }
137
}
138