Issues (292)

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.

include/onupdate.php (6 issues)

1
<?php declare(strict_types=1);
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright    XOOPS Project (https://xoops.org)/
14
 * @license      GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
15
 * @author       XOOPS Development Team
16
 */
17
18
use Xmf\Database\Tables;
19
use XoopsModules\Adslight\{
20
    Common\Configurator,
21
    Common\Migrate,
22
    Helper,
23
    Utility
24
};
25
26
/** @var Helper $helper */
27
/** @var Utility $utility */
28
/** @var Configurator $configurator */
29
if ((!defined('XOOPS_ROOT_PATH'))
30
    || !($GLOBALS['xoopsUser'] instanceof \XoopsUser)
31
    || !$GLOBALS['xoopsUser']->isAdmin()) {
32
    exit('Restricted access' . PHP_EOL);
33
}
34
35
/**
36
 * @param string $tablename
37
 */
38
function tableExists($tablename): bool
39
{
40
    $result = $GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '{$tablename}'");
41
42
    return $GLOBALS['xoopsDB']->getRowsNum($result) > 0;
43
}
44
45
/**
46
 * Prepares system prior to attempting to install module
47
 * @param XoopsModule $module {@link XoopsModule}
48
 *
49
 * @return bool true if ready to install, false if not
50
 */
51
function xoops_module_pre_update_adslight(\XoopsModule $module): bool
52
{
53
    $helper  = Helper::getInstance();
0 ignored issues
show
The assignment to $helper is dead and can be removed.
Loading history...
54
    $utility = new Utility();
55
56
    $xoopsSuccess = $utility::checkVerXoops($module);
0 ignored issues
show
The assignment to $xoopsSuccess is dead and can be removed.
Loading history...
57
    $phpSuccess   = $utility::checkVerPhp($module);
0 ignored issues
show
The assignment to $phpSuccess is dead and can be removed.
Loading history...
58
59
    $migrate = new Xmf\Database\Migrate('adslight');
60
    $result  = $migrate->synchronizeSchema();
0 ignored issues
show
The assignment to $result is dead and can be removed.
Loading history...
61
62
    return true;
63
64
    return $xoopsSuccess && $phpSuccess;
0 ignored issues
show
return $xoopsSuccess && $phpSuccess is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
65
}
66
67
/**
68
 * Performs tasks required during update of the module
69
 * @param XoopsModule     $module {@link XoopsModule}
70
 * @param null|string|int $previousVersion
71
 *
72
 * @return bool true if update successful, false if not
73
 */
74
function xoops_module_update_adslight(\XoopsModule $module, $previousVersion = null): bool
75
{
76
    global $xoopsDB;
77
    $moduleDirName = \basename(\dirname(__DIR__));
78
    $helper        = Helper::getInstance();
0 ignored issues
show
The assignment to $helper is dead and can be removed.
Loading history...
79
    $utility       = new Utility();
80
    $configurator  = new Configurator();
81
82
    $migrator = new Migrate();
83
    $migrator->synchronizeSchema();
84
85
    if ($previousVersion < 240) {
86
        //delete old HTML templates
87
        if (count($configurator->templateFolders) > 0) {
88
            foreach ($configurator->templateFolders as $folder) {
89
                $templateFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $folder);
90
                if (is_dir($templateFolder)) {
91
                    $templateList = array_diff(scandir($templateFolder, SCANDIR_SORT_NONE), ['..', '.']);
92
                    foreach ($templateList as $k => $v) {
93
                        $fileInfo = new \SplFileInfo($templateFolder . $v);
94
                        if ('html' === $fileInfo->getExtension() && 'index.html' !== $fileInfo->getFilename()) {
95
                            if (is_file($templateFolder . $v)) {
96
                                unlink($templateFolder . $v);
97
                            }
98
                        }
99
                    }
100
                }
101
            }
102
        }
103
104
        //  ---  DELETE OLD FILES ---------------
105
        if (count($configurator->oldFiles) > 0) {
106
            //    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
107
            foreach (array_keys($configurator->oldFiles) as $i) {
108
                $tempFile = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFiles[$i]);
109
                if (is_file($tempFile)) {
110
                    unlink($tempFile);
111
                }
112
            }
113
        }
114
115
        //  ---  DELETE OLD FOLDERS ---------------
116
        xoops_load('XoopsFile');
117
        if (count($configurator->oldFolders) > 0) {
118
            //    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
119
            foreach (array_keys($configurator->oldFolders) as $i) {
120
                $tempFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFolders[$i]);
121
                /** @var \XoopsObjectHandler $folderHandler */
122
                $folderHandler = XoopsFile::getHandler('folder', $tempFolder);
123
                $folderHandler->delete($tempFolder);
124
            }
125
        }
126
127
        //  ---  CREATE FOLDERS ---------------
128
        if (count($configurator->uploadFolders) > 0) {
129
            //    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
130
            foreach (array_keys($configurator->uploadFolders) as $i) {
131
                $utility::createFolder($configurator->uploadFolders[$i]);
132
            }
133
        }
134
135
        //  ---  COPY blank.png FILES ---------------
136
        if (count($configurator->copyBlankFiles) > 0) {
137
            $file = \dirname(__DIR__) . '/assets/images/blank.png';
138
            foreach (array_keys($configurator->copyBlankFiles) as $i) {
139
                $dest = $configurator->copyBlankFiles[$i] . '/blank.png';
140
                $utility::copyFile($file, $dest);
141
            }
142
        }
143
144
        //delete .html entries from the tpl table
145
        $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'";
146
        $GLOBALS['xoopsDB']->queryF($sql);
147
148
        //delete .tpl entries from the tpl table
149
        $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.tpl%'";
150
        $GLOBALS['xoopsDB']->queryF($sql);
151
152
        //delete tdmdownloads entries from the tpl_source table
153
        $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplsource') . " WHERE `tpl_source` LIKE '%" . $module->getVar('dirname', 'n') . "%'";
154
        $GLOBALS['xoopsDB']->queryF($sql);
155
156
        //delete block entries from the newblocks table
157
        $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('newblocks') . " WHERE `dirname` = '" . $module->getVar('dirname', 'n') . "'";
158
        $GLOBALS['xoopsDB']->queryF($sql);
159
160
        /** @var \XoopsGroupPermHandler $grouppermHandler */
161
        $grouppermHandler = xoops_getHandler('groupperm');
162
163
        return $grouppermHandler->deleteByModule($module->getVar('mid'), 'item_read');
164
    }
165
166
    return true;
167
}
168