Issues (847)

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.

lib/plugins/extension/admin.php (1 issue)

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
 * DokuWiki Plugin extension (Admin Component)
4
 *
5
 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6
 * @author  Michael Hamann <[email protected]>
7
 */
8
9
/**
10
 * Admin part of the extension manager
11
 */
12
class admin_plugin_extension extends DokuWiki_Admin_Plugin
13
{
14
    protected $infoFor = null;
15
    /** @var  helper_plugin_extension_gui */
16
    protected $gui;
17
18
    /**
19
     * Constructor
20
     *
21
     * loads additional helpers
22
     */
23
    public function __construct()
24
    {
25
        $this->gui = plugin_load('helper', 'extension_gui');
0 ignored issues
show
Documentation Bug introduced by
It seems like plugin_load('helper', 'extension_gui') can also be of type object<dokuwiki\Extension\PluginInterface>. However, the property $gui is declared as type object<helper_plugin_extension_gui>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
26
    }
27
28
    /**
29
     * @return int sort number in admin menu
30
     */
31
    public function getMenuSort()
32
    {
33
        return 0;
34
    }
35
36
    /**
37
     * @return bool true if only access for superuser, false is for superusers and moderators
38
     */
39
    public function forAdminOnly()
40
    {
41
        return true;
42
    }
43
44
    /**
45
     * Execute the requested action(s) and initialize the plugin repository
46
     */
47
    public function handle()
48
    {
49
        global $INPUT;
50
        // initialize the remote repository
51
        /* @var helper_plugin_extension_repository $repository */
52
        $repository = $this->loadHelper('extension_repository');
53
54
        if (!$repository->hasAccess(!$INPUT->bool('purge'))) {
55
            $url = $this->gui->tabURL('', ['purge' => 1], '&');
56
            msg($this->getLang('repo_error').
57
                ' [<a href="'.$url.'">'.$this->getLang('repo_retry').'</a>]', -1
58
            );
59
        }
60
61
        if (!in_array('ssl', stream_get_transports())) {
62
            msg($this->getLang('nossl'), -1);
63
        }
64
65
        /* @var helper_plugin_extension_extension $extension */
66
        $extension = $this->loadHelper('extension_extension');
67
68
        try {
69
            if ($INPUT->post->has('fn') && checkSecurityToken()) {
70
                $actions = $INPUT->post->arr('fn');
71
                foreach ($actions as $action => $extensions) {
72
                    foreach ($extensions as $extname => $label) {
73
                        switch ($action) {
74
                            case 'install':
75
                            case 'reinstall':
76
                            case 'update':
77
                                $extension->setExtension($extname);
78
                                $installed = $extension->installOrUpdate();
79
                                foreach ($installed as $ext => $info) {
80
                                    msg(sprintf(
81
                                        $this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
82
                                        $info['base']), 1
83
                                    );
84
                                }
85
                                break;
86
                            case 'uninstall':
87
                                $extension->setExtension($extname);
88
                                $status = $extension->uninstall();
89
                                if ($status) {
90
                                    msg(sprintf(
91
                                        $this->getLang('msg_delete_success'),
92
                                        hsc($extension->getDisplayName())), 1
93
                                    );
94
                                } else {
95
                                    msg(sprintf(
96
                                        $this->getLang('msg_delete_failed'),
97
                                        hsc($extension->getDisplayName())), -1
98
                                    );
99
                                }
100
                                break;
101
                            case 'enable':
102
                                $extension->setExtension($extname);
103
                                $status = $extension->enable();
104
                                if ($status !== true) {
105
                                    msg($status, -1);
106
                                } else {
107
                                    msg(sprintf(
108
                                        $this->getLang('msg_enabled'),
109
                                        hsc($extension->getDisplayName())), 1
110
                                    );
111
                                }
112
                                break;
113
                            case 'disable':
114
                                $extension->setExtension($extname);
115
                                $status = $extension->disable();
116
                                if ($status !== true) {
117
                                    msg($status, -1);
118
                                } else {
119
                                    msg(sprintf(
120
                                        $this->getLang('msg_disabled'),
121
                                        hsc($extension->getDisplayName())), 1
122
                                    );
123
                                }
124
                                break;
125
                        }
126
                    }
127
                }
128
                send_redirect($this->gui->tabURL('', [], '&', true));
129
            } elseif ($INPUT->post->str('installurl') && checkSecurityToken()) {
130
                $installed = $extension->installFromURL(
131
                    $INPUT->post->str('installurl'),
132
                    $INPUT->post->bool('overwrite'));
133
                foreach ($installed as $ext => $info) {
134
                    msg(sprintf(
135
                        $this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
136
                        $info['base']), 1
137
                    );
138
                }
139
                send_redirect($this->gui->tabURL('', [], '&', true));
140
            } elseif (isset($_FILES['installfile']) && checkSecurityToken()) {
141
                $installed = $extension->installFromUpload('installfile', $INPUT->post->bool('overwrite'));
142
                foreach ($installed as $ext => $info) {
143
                    msg(sprintf(
144
                        $this->getLang('msg_'.$info['type'].'_'.$info['action'].'_success'),
145
                        $info['base']), 1
146
                    );
147
                }
148
                send_redirect($this->gui->tabURL('', [], '&', true));
149
            }
150
        } catch (Exception $e) {
151
            msg($e->getMessage(), -1);
152
            send_redirect($this->gui->tabURL('', [], '&', true));
153
        }
154
    }
155
156
    /**
157
     * Render HTML output
158
     */
159
    public function html()
160
    {
161
        echo '<h1>'.$this->getLang('menu').'</h1>'.DOKU_LF;
162
        echo '<div id="extension__manager">'.DOKU_LF;
163
164
        $this->gui->tabNavigation();
165
166
        switch ($this->gui->currentTab()) {
167
            case 'search':
168
                $this->gui->tabSearch();
169
                break;
170
            case 'templates':
171
                $this->gui->tabTemplates();
172
                break;
173
            case 'install':
174
                $this->gui->tabInstall();
175
                break;
176
            case 'plugins':
177
            default:
178
                $this->gui->tabPlugins();
179
        }
180
181
        echo '</div>'.DOKU_LF;
182
    }
183
}
184
185
// vim:ts=4:sw=4:et:
186