Issues (314)

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