Issues (91)

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.

class/InstallWizard.php (4 issues)

1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Moduleinstaller;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
*/
14
15
/**
16
 * See the enclosed file license.txt for licensing information.
17
 * If you did not receive this file, get it at https://www.gnu.org/licenses/gpl-2.0.html
18
 *
19
 * @copyright   XOOPS Project (https://xoops.org)
20
 * @license     https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License (GPL)
21
 * @since       2.3.0
22
 * @author      Haruki Setoyama  <[email protected]>
23
 * @author      Kazumi Ono <[email protected]>
24
 * @author      Skalpa Keo <[email protected]>
25
 * @author      Taiwen Jiang <[email protected]>
26
 * @author      DuGris (aka L. JEN) <[email protected]>
27
 */
28
class InstallWizard
29
{
30
    public $language    = 'english';
31
    public $pages       = [];
32
    public $currentPage = 'langselect';
33
    public $pageIndex   = 0;
34
    public $configs     = [];
35
36
    /**
37
     * @return bool
38
     */
39
    public function xoInit()
40
    {
41
        if (@empty($_SERVER['REQUEST_URI'])) {
42
            $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
43
        }
44
45
        // Load the main language file
46
        $this->initLanguage(!empty($_COOKIE['xo_install_lang']) ? $_COOKIE['xo_install_lang'] : 'english');
47
        // Setup pages
48
        require_once \dirname(__DIR__) . '/include/page.php';
49
        $this->pages = $pages;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $pages seems to be never defined.
Loading history...
50
51
        // Load default configs
52
53
        $this->configs = [];
54
        /*
55
        // Database type
56
        $this->db_types  = $db_types;
57
58
        // setup config site info
59
        $this->conf_names  = $conf_names;
60
61
        // languages config files
62
        $this->language_files = $language_files;
63
64
        // extension_loaded
65
        $this->extensions = $extensions;
66
67
        // Modules to be installed by default
68
        $this->modules = $modules;
69
70
        // xoops_lib, xoops_data directories
71
        $this->xoopsPathDefault = $xoopsPathDefault;
72
73
        // writable xoops_lib, xoops_data directories
74
        $this->dataPath = $dataPath;
75
76
        // Protector default trust_path
77
        $this->trust_path = isset($trust_path) ? $trust_path : false;
78
79
        // Writable files and directories
80
        $this->writable = $writable;
81
        */
82
83
        if (!$this->checkAccess()) {
84
            return false;
85
        }
86
87
        $pagename = \preg_replace('~(page_)(.*)~', '$2', \basename((string) $_SERVER['SCRIPT_NAME'], '.php'));
88
        $this->setPage($pagename);
89
90
        // Prevent client caching
91
        \header('Cache-Control: no-store, no-cache, must-revalidate', false);
92
        \header('Pragma: no-cache');
93
94
        return true;
95
    }
96
97
    /**
98
     * @return bool
99
     */
100
    public function checkAccess()
101
    {
102
        if (INSTALL_USER != '' && INSTALL_PASSWORD != '') {
0 ignored issues
show
The condition XoopsModules\Moduleinstaller\INSTALL_USER != '' is always false.
Loading history...
103
            if (!isset($_SERVER['PHP_AUTH_USER'])) {
104
                \header('WWW-Authenticate: Basic realm="XOOPS Installer"');
105
                \header('HTTP/1.0 401 Unauthorized');
106
                echo 'You can not access this XOOPS installer.';
107
108
                return false;
109
            }
110
            if (INSTALL_USER != '' && INSTALL_USER != $_SERVER['PHP_AUTH_USER']) {
111
                \header('HTTP/1.0 401 Unauthorized');
112
                echo 'You can not access this XOOPS installer.';
113
114
                return false;
115
            }
116
            if (INSTALL_PASSWORD != $_SERVER['PHP_AUTH_PW']) {
117
                \header('HTTP/1.0 401 Unauthorized');
118
                echo 'You can not access this XOOPS installer.';
119
120
                return false;
121
            }
122
        }
123
124
        if (empty($GLOBALS['xoopsOption']['checkadmin'])) {
125
            return true;
126
        }
127
128
        if (empty($GLOBALS['xoopsUser']) && !empty($_COOKIE['xo_install_user'])) {
129
            install_acceptUser($_COOKIE['xo_install_user']);
130
        }
131
        if (empty($GLOBALS['xoopsUser'])) {
132
            \redirect_header('../user.php');
133
        }
134
        if (!$GLOBALS['xoopsUser']->isAdmin()) {
135
            return false;
136
        }
137
138
        return true;
139
    }
140
141
    /**
142
     * @param $file
143
     */
144
    public function loadLangFile($file): void
145
    {
146
        \xoops_loadLanguage($file, 'moduleinstaller');
147
    }
148
149
    /**
150
     * @param $language
151
     */
152
    public function initLanguage($language): void
153
    {
154
        $language = \preg_replace('/[^a-z0-9_\-]/i', '', (string) $language);
155
        if (!\file_exists("./language/{$language}/install.php")) {
156
            $language = 'english';
157
        }
158
        $this->language = $language;
159
        $this->loadLangFile('install');
160
    }
161
162
    /**
163
     * @param $page
164
     *
165
     * @return false|int|string
166
     */
167
    public function setPage($page)
168
    {
169
        $pages = \array_keys($this->pages);
170
        if ((int)$page && $page >= 0 && $page < \count($pages)) {
171
            $this->pageIndex   = $page;
172
            $this->currentPage = $pages[$page];
173
        } elseif (isset($this->pages[$page])) {
174
            $this->currentPage = $page;
175
            $this->pageIndex   = \array_search($this->currentPage, $pages, true);
176
        } else {
177
            return false;
178
        }
179
180
        if ($this->pageIndex > 0 && !isset($_COOKIE['xo_install_lang'])) {
181
            \header('Location: index.php');
182
        }
183
184
        return $this->pageIndex;
185
    }
186
187
    /**
188
     * @return string
189
     */
190
    public function baseLocation()
191
    {
192
        $proto = ('on' === @$_SERVER['HTTPS']) ? 'https' : 'http';
193
        $host  = $_SERVER['HTTP_HOST'];
194
        $base  = mb_substr((string) $_SERVER['SCRIPT_NAME'], 0, mb_strrpos((string) $_SERVER['SCRIPT_NAME'], '/'));
195
196
        return $proto . '://' . $host . $base;
197
    }
198
199
    /**
200
     * @param $page
201
     *
202
     * @return string
203
     */
204
    public function pageURI($page)
205
    {
206
        $pages     = \array_keys($this->pages);
207
        $pageIndex = $this->pageIndex;
208
        if (!(int)$page[0]) {
209
            if ('+' == $page[0]) {
210
                $pageIndex += mb_substr((string) $page, 1);
211
            } elseif ('-' == $page[0]) {
212
                $pageIndex -= mb_substr((string) $page, 1);
213
            } else {
214
                $pageIndex = (int)\array_search($page, $pages, true);
215
            }
216
        }
217
        if (!isset($pages[$pageIndex])) {
218
            if (\defined('XOOPS_URL')) {
219
                return XOOPS_URL;
220
            }
221
222
            return $this->baseLocation();
223
        }
224
        $page = $pages[$pageIndex];
225
226
        return $this->baseLocation() . "/page_{$page}.php";
227
    }
228
229
    /**
230
     * @param        $page
231
     * @param int    $status
232
     * @param string $message
233
     */
234
    public function redirectToPage($page, $status = 303, $message = 'See other'): void
235
    {
236
        $location = $this->pageURI($page);
237
        $proto    = !@empty($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
238
        \header("{$proto} {$status} {$message}");
239
        //header( "Status: $status $message" );
240
        \header("Location: {$location}");
241
    }
242
243
    /**
244
     * @return string
245
     */
246
    public function createForm()
247
    {
248
        $hidden = '';
249
        $ret    = '';
250
251
        foreach ($this->form as $form) {
0 ignored issues
show
Bug Best Practice introduced by
The property form does not exist on XoopsModules\Moduleinstaller\InstallWizard. Did you maybe forget to declare it?
Loading history...
252
            $ret .= '<fieldset><legend>' . $form->getTitle() . "</legend>\n";
253
254
            foreach ($form->getElements() as $ele) {
255
                if (\is_object($ele)) {
256
                    if (!$ele->isHidden()) {
257
                        if ('' != ($caption = $ele->getCaption())) {
258
                            $name = $ele->getName();
0 ignored issues
show
The assignment to $name is dead and can be removed.
Loading history...
259
                            $ret  .= "<label class='xolabel' for='" . $ele->getName() . "'>" . $caption . '</label>';
260
                            if ('' != ($desc = $ele->getDescription())) {
261
                                $ret .= "<div class='xoform-help'>";
262
                                $ret .= $desc;
263
                                $ret .= '</div>';
264
                            }
265
                        }
266
                        $ret .= $ele->render() . "\n";
267
                    } else {
268
                        $hidden .= $ele->render() . "\n";
269
                    }
270
                }
271
            }
272
            $ret .= "</fieldset>\n" . $hidden . "\n" . $form->renderValidationJS(true);
273
        }
274
275
        return $ret;
276
    }
277
}
278