Issues (58)

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

1
<?php
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 or later (https://www.gnu.org/licenses/gpl-2.0.html)
15
 * @package
16
 * @since
17
 * @author       XOOPS Development Team
18
 */
19
20
use XoopsModules\Xoopspartners;
21
use XoopsModules\Xoopspartners\Helper;
22
use XoopsModules\Xoopspartners\Utility;
23
use XoopsModules\Xoopspartners\Common;
24
25
if ((!defined('XOOPS_ROOT_PATH')) || !($GLOBALS['xoopsUser'] instanceof \XoopsUser)
26
    || !$GLOBALS['xoopsUser']->isAdmin()) {
27
    exit('Restricted access' . PHP_EOL);
28
}
29
30
/**
31
 * @param string $tablename
32
 *
33
 * @return bool
34
 */
35
function tableExists($tablename)
36
{
37
    $result = $GLOBALS['xoopsDB']->queryF("SHOW TABLES LIKE '$tablename'");
38
39
    return $GLOBALS['xoopsDB']->getRowsNum($result) > 0;
40
}
41
42
/**
43
 * Prepares system prior to attempting to install module
44
 * @param \XoopsModule $module {@link XoopsModule}
45
 *
46
 * @return bool true if ready to install, false if not
47
 */
48
function xoops_module_pre_update_xoopspartners(\XoopsModule $module)
49
{
50
    $moduleDirName = basename(dirname(__DIR__));
0 ignored issues
show
The assignment to $moduleDirName is dead and can be removed.
Loading history...
51
    /** @var Helper $helper */
52
    /** @var Utility $utility */
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);
57
    $phpSuccess   = $utility::checkVerPhp($module);
58
59
    return $xoopsSuccess && $phpSuccess;
60
}
61
62
/**
63
 * Performs tasks required during update of the module
64
 * @param \XoopsModule $module {@link XoopsModule}
65
 * @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...
66
 *
67
 * @return bool true if update successful, false if not
68
 */
69
function xoops_module_update_xoopspartners(\XoopsModule $module, $previousVersion = null)
70
{
71
    $moduleDirName      = basename(dirname(__DIR__));
72
    $moduleDirNameUpper = mb_strtoupper($moduleDirName);
0 ignored issues
show
The assignment to $moduleDirNameUpper is dead and can be removed.
Loading history...
73
74
    /** @var Helper $helper */ /** @var Utility $utility */
75
    /** @var Common\Configurator $configurator */
76
    $helper       = Helper::getInstance();
0 ignored issues
show
The assignment to $helper is dead and can be removed.
Loading history...
77
    $utility      = new Utility();
78
    $configurator = new Common\Configurator();
79
80
    if ($previousVersion < 240) {
81
        //rename column EXAMPLE
82
        $tables     = new \Xmf\Database\Tables();
83
        $table      = 'xoopspartnersx_categories';
84
        $column     = 'ordre';
85
        $newName    = 'order';
86
        $attributes = "INT(5) NOT NULL DEFAULT '0'";
87
        if ($tables->useTable($table)) {
88
            $tables->alterColumn($table, $column, $attributes, $newName);
89
            if (!$tables->executeQueue()) {
90
                echo '<br>' . _AM_XOOPSPARTNERS_UPGRADEFAILED0 . ' ' . $tables->getLastError();
0 ignored issues
show
The constant _AM_XOOPSPARTNERS_UPGRADEFAILED0 was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
91
            }
92
        }
93
94
        //delete old HTML templates
95
        if (count($configurator->templateFolders) > 0) {
96
            foreach ($configurator->templateFolders as $folder) {
97
                $templateFolder = $GLOBALS['xoops']->path('modules/' . $moduleDirName . $folder);
98
                if (is_dir($templateFolder)) {
99
                    $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

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