Issues (340)

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.

admin/index.php (4 issues)

1
<?php declare(strict_types=1);
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.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
15
 * @author       Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, https://xoops.org/, http://jp.xoops.org/
16
 * @author       XOOPS Development Team
17
 */
18
19
use Xmf\Request;
20
use Xmf\Module\Admin;
21
use XoopsModules\Newbb\{
22
    Common\TestdataButtons,
23
    Helper,
24
    ReportHandler,
25
    Utility
26
};
27
28
/** @var Admin $adminObject */
29
/** @var Helper $helper */
30
/** @var Utility $utility */
31
require_once __DIR__ . '/admin_header.php';
32
//require_once  \dirname(__DIR__) . '/class/Utility.php';
33
require_once \dirname(__DIR__) . '/include/functions.stats.php';
34
35
$attach_path = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/');
36
$thumb_path  = $attach_path . 'thumbs/';
37
$folder      = [$attach_path, $thumb_path];
38
39
$adminObject = Admin::getInstance();
40
41
/**
42
 * @param string $target
43
 * @param int    $mode
44
 * @return bool
45
 */
46
function newbb_admin_mkdir(string $target, int $mode = 0777): bool
47
{
48
    $target = str_replace('..', '', $target);
49
50
    // https://www.php.net/manual/en/function.mkdir.php
51
    return is_dir($target) || (newbb_admin_mkdir(dirname($target), $mode) && (!mkdir($target, $mode) && !is_dir($target)));
52
}
53
54
/**
55
 * @param string $target
56
 * @param int    $mode
57
 * @return bool
58
 */
59
function newbb_admin_chmod(string $target, int $mode = 0777): bool
60
{
61
    $target = str_replace('..', '', $target);
62
63
    return @chmod($target, $mode);
64
}
65
66
/**
67
 * @return (mixed|string)[]
68
 *
69
 * @psalm-return array{imagemagick?: string, netpbm?: string, gd?: mixed}
70
 */
71
function newbb_getImageLibs(): array
72
{
73
    $imageLibs = [];
74
    //    unset($output, $status);
75
    if (1 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) {
76
        $path = empty($GLOBALS['xoopsModuleConfig']['path_magick']) ? '' : $GLOBALS['xoopsModuleConfig']['path_magick'] . '/';
77
        @exec($path . 'convert -version', $output, $status);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for exec(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

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

77
        /** @scrutinizer ignore-unhandled */ @exec($path . 'convert -version', $output, $status);

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
78
        if ($status === 0 && $output !== [] && preg_match("/imagemagick[ \t]+([0-9\.]+)/i", $output[0], $matches)) {
79
            $imageLibs['imagemagick'] = $matches[0];
80
        }
81
82
        unset($output, $status);
83
    }
84
    if (2 == $GLOBALS['xoopsModuleConfig']['image_lib'] || 0 == $GLOBALS['xoopsModuleConfig']['image_lib']) {
85
        $path = empty($GLOBALS['xoopsModuleConfig']['path_netpbm']) ? '' : $GLOBALS['xoopsModuleConfig']['path_netpbm'] . '/';
86
        @exec($path . 'jpegtopnm -version 2>&1', $output, $status);
87
        if ($status === 0 && $output !== [] && preg_match("/netpbm[ \t]+([0-9\.]+)/i", $output[0], $matches)) {
88
            $imageLibs['netpbm'] = $matches[0];
89
        }
90
        unset($output, $status);
91
    }
92
93
    if (function_exists('gd_info')) {
94
        $tmpInfo         = gd_info();
95
        $imageLibs['gd'] = $tmpInfo['GD Version'];
96
    }
97
98
    return $imageLibs;
99
}
100
101
xoops_cp_header();
102
103
$imageLibs = newbb_getImageLibs();
104
/** @var \XoopsModuleHandler $moduleHandler */
105
$moduleHandler = xoops_getHandler('module');
106
///** @var ReportHandler $reportHandler */
107
//$reportHandler = Helper::getInstance()->getHandler('Report');
108
109
$isOK = false;
110
// START irmtfan add a poll_module config
111
//XOOPS_POLL
112
$xoopspoll = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']);
113
if (is_object($xoopspoll)) {
114
    $isOK = $xoopspoll->getVar('isactive');
115
}
116
// END irmtfan add a poll_module config
117
118
$memlimit_iniphp    = return_bytes(@ini_get('memory_limit'));
0 ignored issues
show
It seems like @ini_get('memory_limit') can also be of type false; however, parameter $sizeAsString of return_bytes() does only seem to accept string, 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

118
$memlimit_iniphp    = return_bytes(/** @scrutinizer ignore-type */ @ini_get('memory_limit'));
Loading history...
119
$postmaxsize_iniphp = return_bytes(@ini_get('post_max_size'));
120
$uploadlimit        = _AM_NEWBB_MEMLIMITTOLARGE;
121
if ($postmaxsize_iniphp < $memlimit_iniphp) {
122
    $uploadlimit = sprintf(_AM_NEWBB_MEMLIMITOK, return_bytes((string)$postmaxsize_iniphp, true));
123
}
124
125
$adminObject->addInfoBox(_AM_NEWBB_PREFERENCES);
126
// START irmtfan better poll module display link and version - check if xoops poll module is available
127
if ($isOK) {
128
    $pollLink = _AM_NEWBB_AVAILABLE . ': ';
129
    $pollLink .= '<a href="' . XOOPS_URL . '/modules/' . $xoopspoll->getVar('dirname') . '/admin/index.php"';
130
    $pollLink .= ' alt="' . $xoopspoll->getVar('name') . ' ' . _VERSION . ' (' . $xoopspoll->getInfo('version') . ') "';
0 ignored issues
show
Are you sure $xoopspoll->getInfo('version') of type array|string can be used in concatenation? ( Ignorable by Annotation )

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

130
    $pollLink .= ' alt="' . $xoopspoll->getVar('name') . ' ' . _VERSION . ' (' . /** @scrutinizer ignore-type */ $xoopspoll->getInfo('version') . ') "';
Loading history...
131
    $pollLink .= ' title="' . $xoopspoll->getVar('name') . ' ' . _VERSION . ' (' . $xoopspoll->getInfo('version') . ') "';
132
    $pollLink .= '>' . '(' . $xoopspoll->getVar('name') . ')</a>';
133
} else {
134
    $pollLink = _AM_NEWBB_NOTAVAILABLE;
135
}
136
$adminObject->addInfoBoxLine(sprintf(_AM_NEWBB_POLLMODULE . ': %s', $pollLink));
137
// END irmtfan better poll module display link and version - check if xoops poll module is available
138
$adminObject->addInfoBoxLine(sprintf(_AM_NEWBB_IMAGEMAGICK . ' %s', array_key_exists('imagemagick', $imageLibs) ? _AM_NEWBB_AUTODETECTED . $imageLibs['imagemagick'] : _AM_NEWBB_NOTAVAILABLE));
139
$adminObject->addInfoBoxLine(sprintf('NetPBM' . ': %s', array_key_exists('netpbm', $imageLibs) ? _AM_NEWBB_AUTODETECTED . $imageLibs['netpbm'] : _AM_NEWBB_NOTAVAILABLE));
140
$adminObject->addInfoBoxLine(sprintf(_AM_NEWBB_GDLIB . ' %s', array_key_exists('gd', $imageLibs) ? _AM_NEWBB_AUTODETECTED . $imageLibs['gd'] : _AM_NEWBB_NOTAVAILABLE));
141
$adminObject->addInfoBoxLine(sprintf(_AM_NEWBB_UPLOAD . ' %s', $uploadlimit));
142
$adminObject->addInfoBoxLine(sprintf(_AM_NEWBB_INDEX_PDF_PAGE . ' ', ''));
143
144
$adminObject->addInfoBox(_AM_NEWBB_BOARDSUMMARY);
145
$adminObject->addInfoBoxLine(sprintf(_AM_NEWBB_TOTALTOPICS . ': %s', getTotalTopics()));
146
$adminObject->addInfoBoxLine(sprintf(_AM_NEWBB_TOTALPOSTS . ': %s', getTotalPosts()));
147
$adminObject->addInfoBoxLine(sprintf(_AM_NEWBB_TOTALVIEWS . ': %s', getTotalViews()));
0 ignored issues
show
Are you sure the usage of getTotalViews() is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
148
149
$adminObject->addInfoBox(_AM_NEWBB_REPORT);
150
$adminObject->addInfoBoxLine(sprintf(_AM_NEWBB_REPORT_PENDING . ': %s', $reportHandler->getCount(new \Criteria('report_result', '0'))));
151
$adminObject->addInfoBoxLine(sprintf(_AM_NEWBB_REPORT_PROCESSED . ': %s', $reportHandler->getCount(new \Criteria('report_result', '1'))));
152
153
$uploadFolders = $configurator->uploadFolders;
154
foreach ($uploadFolders as $value) {
155
    Utility::prepareFolder($value);
156
    $adminObject->addConfigBoxLine($value, 'folder');
157
}
158
159
$adminObject->displayNavigation(basename(__FILE__));
160
161
//------------- Test Data Buttons ----------------------------
162
if ($helper->getConfig('displaySampleButton')) {
163
    TestdataButtons::loadButtonConfig($adminObject);
164
    $adminObject->displayButton('left', '');
165
}
166
$op = Request::getString('op', '', 'GET');
167
switch ($op) {
168
    case 'hide_buttons':
169
        TestdataButtons::hideButtons();
170
        break;
171
    case 'show_buttons':
172
        TestdataButtons::showButtons();
173
        break;
174
}
175
//------------- End Test Data Buttons ----------------------------
176
177
$adminObject->displayIndex();
178
179
require_once __DIR__ . '/admin_footer.php';
180
181
Utility::cleanCache();
182
//$cacheHelper = new \Xmf\Module\Helper\Cache('newbb');
183
//$cacheHelper->delete('config');
184
//$cacheHelper->delete('permission');
185
186
/**
187
 * @param string $sizeAsString
188
 * @param bool   $b
189
 * @return int|string
190
 */
191
function return_bytes(string $sizeAsString, bool $b = false)
192
{
193
    if ($b) {
194
        $base   = log((int)$sizeAsString) / log(1024);
195
        $suffix = ['', 'KB', 'MB', 'GB', 'TB'];
196
197
        return round(1024 ** ($base - floor($base))) . ' ' . $suffix[(int)floor($base)];
198
    }
199
    switch (mb_substr($sizeAsString, -1)) {
200
        case 'M':
201
        case 'm':
202
            return (int)$sizeAsString * 1048576;
203
        case 'K':
204
        case 'k':
205
            return (int)$sizeAsString * 1024;
206
        case 'G':
207
        case 'g':
208
            return (int)$sizeAsString * 1073741824;
209
        default:
210
            return $sizeAsString;
211
    }
212
}
213