Issues (130)

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 (5 issues)

1
<?php
2
3
/*
4
 * You may not change or alter any portion of this comment or credits
5
 * of supporting developers from this source code or any supporting source code
6
 * which is considered copyrighted (c) material of the original comment or credit authors.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * @copyright    {@link https://xoops.org/ XOOPS Project}
15
 * @license      {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
16
 * @package      Chess
17
 * @since        2.01
18
 * @author       XOOPS Development Team
19
 */
20
21
use XoopsModules\Chess;
22
23
if ((!defined('XOOPS_ROOT_PATH')) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser)
24
    || !$GLOBALS['xoopsUser']->isAdmin()) {
25
    exit('Restricted access' . PHP_EOL);
26
}
27
28
/**
29
 * @param string $tablename
30
 *
31
 * @return bool
32
 */
33
function tableExists($tablename)
34
{
35
    $result = $GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '$tablename'");
36
37
    return $GLOBALS['xoopsDB']->getRowsNum($result) > 0;
38
}
39
40
/**
41
 * Prepares system prior to attempting to install module
42
 * @param \XoopsModule $module {@link XoopsModule}
43
 * @return bool true if ready to install, false if not
44
 */
45
function xoops_module_pre_update_chess(\XoopsModule $module)
46
{
47
    $moduleDirName = basename(dirname(__DIR__));
0 ignored issues
show
The assignment to $moduleDirName is dead and can be removed.
Loading history...
48
49
    /** @var Chess\Helper $helper */
50
51
    /** @var Chess\Utility $utility */
52
53
    $helper = Chess\Helper::getInstance();
0 ignored issues
show
The assignment to $helper is dead and can be removed.
Loading history...
54
55
    $utility = new Chess\Utility();
56
57
    $xoopsSuccess = $utility::checkVerXoops($module);
58
59
    $phpSuccess = $utility::checkVerPhp($module);
60
61
    $migrator = new \XoopsModules\Chess\Common\Migrate();
62
63
    $migrator->synchronizeSchema();
64
65
    return $xoopsSuccess && $phpSuccess;
66
}
67
68
/**
69
 * Performs tasks required during update of the module
70
 * @param \XoopsModule $module {@link XoopsModule}
71
 * @param null         $previousVersion
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $previousVersion is correct as it would always require null to be passed?
Loading history...
72
 *
73
 * @return bool true if update successful, false if not
74
 */
75
function xoops_module_update_chess(\XoopsModule $module, $previousVersion = null)
76
{
77
    $moduleDirName = basename(dirname(__DIR__));
78
79
    $moduleDirNameUpper = mb_strtoupper($moduleDirName);
0 ignored issues
show
The assignment to $moduleDirNameUpper is dead and can be removed.
Loading history...
80
81
    /** @var Chess\Helper $helper */
82
83
    /** @var Chess\Utility $utility */
84
85
    /** @var Chess\Common\Configurator $configurator */
86
87
    $helper = Chess\Helper::getInstance();
88
89
    $utility = new Chess\Utility();
90
91
    $configurator = new Chess\Common\Configurator();
92
93
    $helper->loadLanguage('common');
94
95
    if ($previousVersion < 201) {
96
97
        //delete old HTML templates
98
99
        if (count($configurator->templateFolders) > 0) {
100
            foreach ($configurator->templateFolders as $folder) {
101
                $templateFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $folder);
102
103
                if (is_dir($templateFolder)) {
104
                    $templateList = array_diff(scandir($templateFolder, SCANDIR_SORT_NONE), ['..', '.']);
0 ignored issues
show
It seems like scandir($templateFolder, SCANDIR_SORT_NONE) can also be of type false; however, parameter $array1 of array_diff() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

104
                    $templateList = array_diff(/** @scrutinizer ignore-type */ scandir($templateFolder, SCANDIR_SORT_NONE), ['..', '.']);
Loading history...
105
106
                    foreach ($templateList as $k => $v) {
107
                        $fileInfo = new SplFileInfo($templateFolder . $v);
108
109
                        if ('html' === $fileInfo->getExtension() && 'index.html' !== $fileInfo->getFilename()) {
110
                            if (file_exists($templateFolder . $v)) {
111
                                unlink($templateFolder . $v);
112
                            }
113
                        }
114
                    }
115
                }
116
            }
117
        }
118
119
        //  ---  DELETE OLD FILES ---------------
120
121
        if (count($configurator->oldFiles) > 0) {
122
            //    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
123
124
            foreach (array_keys($configurator->oldFiles) as $i) {
125
                $tempFile = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFiles[$i]);
126
127
                if (is_file($tempFile)) {
128
                    unlink($tempFile);
129
                }
130
            }
131
        }
132
133
        //  ---  DELETE OLD FOLDERS ---------------
134
135
        xoops_load('XoopsFile');
136
137
        if (count($configurator->oldFolders) > 0) {
138
            //    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
139
140
            foreach (array_keys($configurator->oldFolders) as $i) {
141
                $tempFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $configurator->oldFolders[$i]);
142
143
                /** @var XoopsObjectHandler $folderHandler */
144
145
                $folderHandler = \XoopsFile::getHandler('folder', $tempFolder);
146
147
                $folderHandler->delete($tempFolder);
148
            }
149
        }
150
151
        //  ---  CREATE UPLOAD FOLDERS ---------------
152
153
        if (count($configurator->uploadFolders) > 0) {
154
            //    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
155
156
            foreach (array_keys($configurator->uploadFolders) as $i) {
157
                $utility::createFolder($configurator->uploadFolders[$i]);
158
            }
159
        }
160
161
        //  ---  COPY blank.png FILES ---------------
162
163
        if (count($configurator->copyBlankFiles) > 0) {
164
            $file = dirname(__DIR__) . '/assets/images/blank.png';
165
166
            foreach (array_keys($configurator->copyBlankFiles) as $i) {
167
                $dest = $configurator->copyBlankFiles[$i] . '/blank.png';
168
169
                $utility::copyFile($file, $dest);
170
            }
171
        }
172
173
        //delete .html entries from the tpl table
174
175
        $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('tplfile') . " WHERE `tpl_module` = '" . $module->getVar('dirname', 'n') . "' AND `tpl_file` LIKE '%.html%'";
176
177
        $GLOBALS['xoopsDB']->queryF($sql);
178
179
        /** @var XoopsGroupPermHandler $gpermHandler */
180
181
        $gpermHandler = xoops_getHandler('groupperm');
182
183
        return $gpermHandler->deleteByModule($module->getVar('mid'), 'item_read');
184
    }
185
186
    return true;
187
}
188