Issues (80)

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 (1 issue)

1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
 *
13
 * @copyright       XOOPS Project (https://xoops.org)
14
 * @license         GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
15
 * @since           2.5.9
16
 * @author          Michael Beck (aka Mamba)
17
 */
18
19
use Xmf\Database\TableLoad;
20
use Xmf\Request;
21
use Xmf\Yaml;
22
use XoopsModules\Rssfit\{
23
    Common\Configurator,
24
    Helper,
25
    Utility
26
};
27
28
/** @var Helper $helper */
29
/** @var Utility $utility */
30
/** @var Configurator $configurator */
31
32
require \dirname(__DIR__, 3) . '/include/cp_header.php';
33
require \dirname(__DIR__) . '/preloads/autoloader.php';
34
35
$op = Request::getCmd('op', '');
36
37
$moduleDirName      = \basename(\dirname(__DIR__));
38
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
39
40
$helper = Helper::getInstance();
41
// Load language files
42
$helper->loadLanguage('common');
43
44
switch ($op) {
45
    case 'load':
46
        if (Request::hasVar('ok', 'REQUEST') && 1 === Request::getInt('ok', 0)) {
47
            if (!$GLOBALS['xoopsSecurity']->check()) {
48
                redirect_header($helper->url('admin/index.php'), 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
49
            }
50
            loadSampleData();
51
        } else {
52
            xoops_cp_header();
53
            xoops_confirm(['ok' => 1, 'op' => 'load'], 'index.php', constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_CONFIRM'), constant('CO_' . $moduleDirNameUpper . '_' . 'CONFIRM'), true);
54
            xoops_cp_footer();
55
        }
56
        break;
57
    case 'save':
58
        saveSampleData();
59
        break;
60
    case 'clear':
61
        clearSampleData();
62
        break;
63
}
64
65
// XMF TableLoad for SAMPLE data
66
67
function loadSampleData(): void
68
{
69
    global $xoopsConfig;
70
    $moduleDirName      = \basename(\dirname(__DIR__));
71
    $moduleDirNameUpper = mb_strtoupper($moduleDirName);
72
73
    $utility      = new Utility();
74
    $configurator = new Configurator();
75
76
    $tables = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getInfo('tables');
77
78
    $language = 'english/';
79
    if (is_dir(__DIR__ . '/' . $xoopsConfig['language'])) {
80
        $language = $xoopsConfig['language'] . '/';
81
    }
82
83
    // load module tables
84
    foreach ($tables as $table) {
85
        $tabledata = Yaml::readWrapped($language . $table . '.yml');
86
        TableLoad::truncateTable($table);
87
        TableLoad::loadTableFromArray($table, $tabledata);
88
    }
89
90
    // load permissions
91
    $table     = 'group_permission';
92
    $tabledata = Yaml::readWrapped($language . $table . '.yml');
93
    $mid       = \Xmf\Module\Helper::getHelper($moduleDirName)->getModule()->getVar('mid');
94
    loadTableFromArrayWithReplace($table, $tabledata, 'gperm_modid', $mid);
95
96
    //  ---  COPY test folder files ---------------
97
    if (is_array($configurator->copyTestFolders) && count($configurator->copyTestFolders) > 0) {
98
        //        $file =  \dirname(__DIR__) . '/testdata/images/';
99
        foreach (array_keys($configurator->copyTestFolders) as $i) {
100
            $src  = $configurator->copyTestFolders[$i][0];
101
            $dest = $configurator->copyTestFolders[$i][1];
102
            $utility::rcopy($src, $dest);
103
        }
104
    }
105
    \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA_SUCCESS'));
106
}
107
108
function saveSampleData(): void
109
{
110
    global $xoopsConfig;
111
    $moduleDirName      = \basename(\dirname(__DIR__));
112
    $moduleDirNameUpper = mb_strtoupper($moduleDirName);
113
    $helper             = Helper::getInstance();
114
    $tables             = $helper->getModule()->getInfo('tables');
115
116
    $languageFolder = __DIR__ . '/' . $xoopsConfig['language'];
117
    if (!file_exists($languageFolder . '/')) {
118
        Utility::createFolder($languageFolder . '/');
119
    }
120
    $exportFolder = $languageFolder . '/Exports-' . date('Y-m-d-H-i-s') . '/';
121
    Utility::createFolder($exportFolder);
122
123
    // save module tables
124
    foreach ($tables as $table) {
125
        TableLoad::saveTableToYamlFile($table, $exportFolder . $table . '.yml');
126
    }
127
128
    // save permissions
129
    $criteria = new \CriteriaCompo();
130
    $criteria->add(new \Criteria('gperm_modid', $helper->getModule()->getVar('mid')));
131
    $skipColumns[] = 'gperm_id';
0 ignored issues
show
Comprehensibility Best Practice introduced by
$skipColumns was never initialized. Although not strictly required by PHP, it is generally a good practice to add $skipColumns = array(); before regardless.
Loading history...
132
    TableLoad::saveTableToYamlFile('group_permission', $exportFolder . 'group_permission.yml', $criteria, $skipColumns);
133
    unset($criteria);
134
135
    \redirect_header('../admin/index.php', 1, \constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA_SUCCESS'));
136
}
137
138
function exportSchema(): void
139
{
140
    $moduleDirName      = \basename(\dirname(__DIR__));
141
    $moduleDirNameUpper = mb_strtoupper($moduleDirName);
142
143
    try {
144
        // TODO set exportSchema
145
        //        $migrate = new Migrate($moduleDirName);
146
        //        $migrate->saveCurrentSchema();
147
        //
148
        //        redirect_header('../admin/index.php', 1, constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS'));
149
    } catch (\Throwable $e) {
150
        exit(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR'));
151
    }
152
}
153
154
/**
155
 * loadTableFromArrayWithReplace
156
 *
157
 * @param string $table  value with should be used insead of original value of $search
158
 *
159
 * @param array  $data   array of rows to insert
160
 *                       Each element of the outer array represents a single table row.
161
 *                       Each row is an associative array in 'column' => 'value' format.
162
 * @param string $search name of column for which the value should be replaced
163
 * @return int number of rows inserted
164
 */
165
function loadTableFromArrayWithReplace(string $table, array $data, string $search, string $replace): int
166
{
167
    /** @var \XoopsMySQLDatabase $db */
168
    $db = \XoopsDatabaseFactory::getDatabaseConnection();
169
170
    $prefixedTable = $db->prefix($table);
171
    $count         = 0;
172
173
    $sql = 'DELETE FROM ' . $prefixedTable . ' WHERE `' . $search . '`=' . $db->quote($replace);
174
175
    $result = $db->queryF($sql);
176
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(): void
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