Issues (127)

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.

testdata/index.php (2 issues)

1
<?php declare(strict_types=1);
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
 * 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
 * @copyright       The XOOPS Project https://xoops.org/
12
 * @license         GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
13
 * @since           2.5.11
14
 * @author          Michael Beck (aka Mamba)
15
 */
16
17
use Xmf\Database\TableLoad;
18
use Xmf\Module\Helper;
19
use Xmf\Request;
20
use Xmf\Yaml;
21
use XoopsModules\Wgfilemanager;
22
use XoopsModules\Wgfilemanager\{
23
    Common,
24
    Utility
25
};
26
27
require_once dirname(__DIR__, 3) . '/include/cp_header.php';
28
require \dirname(__DIR__) . '/preloads/autoloader.php';
29
30
$op = \Xmf\Request::getCmd('op');
31
32
$moduleDirName      = \basename(\dirname(__DIR__));
33
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
34
35
$helper = Wgfilemanager\Helper::getInstance();
36
// Load language files
37
$helper->loadLanguage('common');
38
39
switch ($op) {
40
    case 'load':
41
        if (\Xmf\Request::hasVar('ok', 'REQUEST') && 1 == $_REQUEST['ok']) {
42
            if (!$GLOBALS['xoopsSecurity']->check()) {
43
                \redirect_header('../admin/index.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
44
            }
45
            loadSampleData();
46
        } else {
47
            xoops_cp_header();
48
            xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', \constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA_OK'), \constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'));
49
            xoops_cp_footer();
50
        }
51
        break;
52
    case 'save':
53
        saveSampleData();
54
        break;
55
}
56
57
// XMF TableLoad for SAMPLE data
58
function loadSampleData(): void
59
{
60
    global $xoopsConfig;
61
62
    $moduleDirName      = \basename(\dirname(__DIR__));
63
    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
64
65
    $utility      = new Wgfilemanager\Utility();
66
    $configurator = new Common\Configurator();
67
68
    $tables = Helper::getHelper($moduleDirName)->getModule()->getInfo('tables');
69
70
    $language = 'english/';
71
    if (\is_dir(__DIR__ . '/' . $xoopsConfig['language'])) {
72
        $language = $xoopsConfig['language'] . '/';
73
    }
74
75
    // load module tables
76
    foreach ($tables as $table) {
77
        $tabledata = Yaml::readWrapped($language . $table . '.yml');
78
        TableLoad::truncateTable($table);
79
        TableLoad::loadTableFromArray($table, $tabledata);
80
    }
81
82
    // load permissions
83
    $table     = 'group_permission';
84
    $tabledata = Yaml::readWrapped($language . $table . '.yml');
85
    $mid       = Helper::getHelper($moduleDirName)->getModule()->getVar('mid');
86
    loadTableFromArrayWithReplace($table, $tabledata, 'gperm_modid', $mid);
87
88
    //  ---  COPY test folder files ---------------
89
    if (\is_array($configurator->copyTestFolders) && \count($configurator->copyTestFolders) > 0) {
90
        foreach (\array_keys($configurator->copyTestFolders) as $i) {
91
            $src  = $configurator->copyTestFolders[$i][0];
92
            $dest = $configurator->copyTestFolders[$i][1];
93
            $utility::rcopy($src, $dest);
94
        }
95
    }
96
    \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'SAMPLEDATA_SUCCESS'));
97
}
98
99
function saveSampleData(): void
100
{
101
    global $xoopsConfig;
102
103
    $configurator = new Common\Configurator();
104
105
    $moduleDirName      = \basename(\dirname(__DIR__));
106
    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
107
108
    $tables = Helper::getHelper($moduleDirName)->getModule()->getInfo('tables');
109
110
    $languageFolder = __DIR__ . '/' . $xoopsConfig['language'];
111
    if (!\file_exists($languageFolder . '/')) {
112
        Utility::createFolder($languageFolder . '/');
113
    }
114
    $exportFolder = $languageFolder . '/Exports-' . date('Y-m-d-H-i-s') . '/';
115
    Utility::createFolder($exportFolder);
116
117
    // save module tables
118
    foreach ($tables as $table) {
119
        TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml');
120
    }
121
122
    // save permissions
123
    $skipColumns = [];
124
    $criteria    = new \CriteriaCompo();
125
    $criteria->add(new \Criteria('gperm_modid', Helper::getHelper($moduleDirName)->getModule()->getVar('mid')));
126
    $skipColumns[] = 'gperm_id';
127
    TableLoad::saveTableToYamlFile('group_permission', $exportFolder . 'group_permission.yml', $criteria, $skipColumns);
128
    unset($criteria);
129
130
    //  ---  COPY test folder files ---------------
131
    if (\is_array($configurator->copyTestFolders) && \count($configurator->copyTestFolders) > 0) {
132
        foreach (\array_keys($configurator->copyTestFolders) as $i) {
133
            $src  = $configurator->copyTestFolders[$i][1];
134
            $dest = $configurator->copyTestFolders[$i][0];
135
            Utility::rcopy($src, $dest);
136
        }
137
    }
138
    \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA_SUCCESS'));
139
}
140
141
function exportSchema(): void
142
{
143
    $moduleDirName      = \basename(\dirname(__DIR__));
144
    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
0 ignored issues
show
The assignment to $moduleDirNameUpper is dead and can be removed.
Loading history...
145
146
    try {
147
        // TODO set exportSchema
148
        //        $migrate = new Wgfilemanager\Migrate($moduleDirName);
149
        //        $migrate->saveCurrentSchema();
150
        //
151
        //        \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS'));
152
    } catch (\Exception $e) {
0 ignored issues
show
catch (\Exception $e) 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...
153
        exit(\constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR'));
154
    }
155
}
156
157
/**
158
 * loadTableFromArrayWithReplace
159
 *
160
 * @param string $table  value with should be used insead of original value of $search
161
 *
162
 * @param array  $data   array of rows to insert
163
 *                       Each element of the outer array represents a single table row.
164
 *                       Each row is an associative array in 'column' => 'value' format.
165
 * @param string $search name of column for which the value should be replaced
166
 * @param        $replace
167
 * @return int number of rows inserted
168
 */
169
function loadTableFromArrayWithReplace($table, $data, $search, $replace)
170
{
171
    $db            = \XoopsDatabaseFactory::getDatabaseConnection();
172
    $prefixedTable = $db->prefix($table);
173
    $count         = 0;
174
    $sql           = 'DELETE FROM ' . $prefixedTable . ' WHERE `' . $search . '`=' . $db->quote($replace);
175
    $db->queryF($sql);
176
    foreach ($data as $row) {
177
        $insertInto  = 'INSERT INTO ' . $prefixedTable . ' (';
178
        $valueClause = ' VALUES (';
179
        $first       = true;
180
        foreach ($row as $column => $value) {
181
            if ($first) {
182
                $first = false;
183
            } else {
184
                $insertInto  .= ', ';
185
                $valueClause .= ', ';
186
            }
187
            $insertInto .= $column;
188
            if ($search === $column) {
189
                $valueClause .= $db->quote($replace);
190
            } else {
191
                $valueClause .= $db->quote($value);
192
            }
193
        }
194
        $sql    = $insertInto . ') ' . $valueClause . ')';
195
        $result = $db->queryF($sql);
196
        if (false !== $result) {
197
            ++$count;
198
        }
199
    }
200
201
    return $count;
202
}
203