Issues (76)

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.

blocks/xoopsfaq_recent.php (4 issues)

1
<?php declare(strict_types=1);
2
/*
3
 You may not change or alter any portion of this comment or credits of
4
 supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit
6
 authors.
7
8
 This program is distributed in the hope that it will be useful, but
9
 WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * Recent Term Block file
15
 *
16
 * @author    ZySpec
17
 * @author    XOOPS Module Development Team
18
 * @copyright Copyright (c) 2001-2020 {@link https://xoops.org XOOPS Project}
19
 * @license   https://www.gnu.org/licenses/gpl-2.0.html GNU Public License
20
 * @since     ::   1.25
21
 *
22
 * @see       Xmf\Module\Helper
23
 * @see       MyTextSanitizer
24
 */
25
26
use Xmf\Module\Helper\Permission;
27
use XoopsModules\Xoopsfaq\{
28
    Constants,
29
    CategoryHandler,
30
    Helper
31
};
32
33
/**
34
 * Display the most recent FAQs added
35
 *
36
 * @param array $options for display parameters
37
 *                       [0] = num of FAQs to show
38
 *                       [1] = num chars in answer(s) to show
39
 *                       [2] = display date added
40
 *                       [3] = FAQ categories to use
41
 *
42
 * @return array contains recent FAQ(s) parameters
43
 */
44
function b_xoopsfaq_recent_show(array $options)
45
{
46
    $moduleDirName = \basename(\dirname(__DIR__));
47
48
    $myts = \MyTextSanitizer::getInstance();
49
50
    /** @var Helper $helper */
51
    $helper          = Helper::getInstance();
52
    $contentsHandler = $helper->getHandler('Contents');
53
    $permHelper      = new Permission($moduleDirName);
54
    $block           = [];
55
56
    $criteria = new \CriteriaCompo();
57
    $criteria->add(new \Criteria('contents_active', Constants::ACTIVE, '='));
58
    $criteria->setSort('contents_publish DESC, contents_weight');
59
    $criteria->order = 'ASC';
60
    $criteria->setLimit($options[0]);
61
62
    $options[3] = $options[3] ?? [0];
63
    $cTu        = $catsToUse = (false === mb_strpos($options[3], ',')) ? (array)$options[3] : explode(',', $options[3]);
0 ignored issues
show
It seems like $options[3] can also be of type array<integer,integer>; however, parameter $string of explode() 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

63
    $cTu        = $catsToUse = (false === mb_strpos($options[3], ',')) ? (array)$options[3] : explode(',', /** @scrutinizer ignore-type */ $options[3]);
Loading history...
It seems like $options[3] can also be of type array<integer,integer>; however, parameter $haystack of mb_strpos() 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

63
    $cTu        = $catsToUse = (false === mb_strpos(/** @scrutinizer ignore-type */ $options[3], ',')) ? (array)$options[3] : explode(',', $options[3]);
Loading history...
64
    if (in_array(0, $catsToUse, true) || empty($catsToUse)) {
65
        // Get a list of all cats
66
        $categoryHandler = $helper->getHandler('Category');
67
        $catListArray    = $categoryHandler->getList();
68
        $cTu             = $catsToUse = array_keys($catListArray);
69
    }
70
    // Remove any cats this user doesn't have rights to view
71
    foreach ($cTu as $key => $thisCat) {
72
        if (false === $permHelper->checkPermission('viewcat', $thisCat)) {
73
            unset($catsToUse[$key]);
74
        }
75
    }
76
    if (!empty($catsToUse)) {
77
        $criteria->add(new \Criteria('contents_cid', '(' . implode(',', $catsToUse) . ')', 'IN'));
78
    } else {
79
        return $block;
80
    }
81
82
    $fieldsArray = ['contents_cid', 'contents_title', 'contents_contents'];
83
    $faqObjArray = $contentsHandler->getAll($criteria, $fieldsArray);
84
    $faqCount    = is_array($faqObjArray) ? count($faqObjArray) : 0;
0 ignored issues
show
The condition is_array($faqObjArray) is always true.
Loading history...
85
    if ($faqCount > 0) {
86
        $block['title']     = _MB_XOOPSFAQ_RECENT_TITLE;
87
        $block['show_date'] = (isset($options[2]) && $options[2] > 0) ? 1 : 0;
88
        foreach ($faqObjArray as $fId => $faqObj) {
89
            $faqTitle = $myts->displayTarea($faqObj->getVar('contents_title'));
90
            if (!empty($options[1])) {
91
                $txtAns = strip_tags($faqObj->getVar('contents_contents')); // get rid of html for block
92
                $faqAns = $myts->displayTarea(xoops_substr($txtAns, 0, $options[1]), 0, 0, 0, 0, 0);
93
            } else {
94
                $faqAns = $myts->displayTarea(
95
                    $faqObj->getVar('contents_contents'),
96
                    (int)$faqObj->getVar('dohtml'),
97
                    (int)$faqObj->getVar('dosmiley'),
98
                    (int)$faqObj->getVar('doxcode'),
99
                    1,
100
                    (int)$faqObj->getVar('dobr')
101
                );
102
            }
103
            $block['faq'][] = [
104
                'title'     => $faqTitle,
105
                'ans'       => $faqAns,
106
                'published' => $faqObj->getPublished(_SHORTDATESTRING),
107
                'id'        => $faqObj->getVar('contents_id'),
108
                'cid'       => $faqObj->getVar('contents_cid'),
109
            ];
110
        }
111
    }
112
113
    return $block;
114
}
115
116
/**
117
 * Edit the most recent FAQs block parameters
118
 *
119
 * @param array $options for display parameters
120
 *                       [0] = num of FAQs to show
121
 *                       [1] = num chars in answer(s) to show
122
 *                       [2] = display date added
123
 *                       [3] = FAQ categories to use
124
 *
125
 * @return string HTML to display to get input from user
126
 */
127
function b_xoopsfaq_recent_edit(array $options)
128
{
129
    $moduleDirName = \basename(\dirname(__DIR__));
0 ignored issues
show
The assignment to $moduleDirName is dead and can be removed.
Loading history...
130
    xoops_load('XoopsFormSelect');
131
132
    /** @var CategoryHandler $categoryHandler */
133
    /** @var Helper $helper */
134
    $helper          = Helper::getInstance();
135
    $categoryHandler = $helper->getHandler('Category');
136
137
    $catList     = $categoryHandler->getList();
138
    $optionArray = array_merge([0 => _MB_XOOPSFAQ_ALL_CATS], $catList);
139
    $formSelect  = new \XoopsFormSelect('category', 'options[3]', null, 3, true);
140
    $formSelect->addOptionArray($optionArray);
141
    $selOptions = (false === mb_strpos($options[3], ',')) ? $options[3] : explode(',', $options[3]);
142
    $formSelect->setValue($selOptions);
143
    $selectCat = $formSelect->render();
144
145
    $ychck = (isset($options[2]) && ($options[2] > 0)) ? ' checked' : '';
146
    $nchck = !empty($ychck) ? '' : ' checked';
147
148
    $form = '<div class="line140">'
149
            . _MB_XOOPSFAQ_NUM_FAQS
150
            . '&nbsp;'
151
            . '<input type="number" name="options[0]" value="'
152
            . $options[0]
153
            . '" style="width: 5em;" min="0" class="right"><br>'
154
            . _MB_XOOPSFAQ_CHARS
155
            . '&nbsp;<input type="number" name="options[1]" value="'
156
            . $options[1]
157
            . '" style="width: 5em;" min="0" class="right">&nbsp;'
158
            . _MB_XOOPSFAQ_LENGTH
159
            . '<br>'
160
            . _MB_XOOPSFAQ_SHOW_DATE
161
            . '&nbsp;'
162
            . '<label for="r0">'
163
            . _NO
164
            . '</label>'
165
            . '<input type="radio" name="options[2]" id="r0" value="0"'
166
            . $nchck
167
            . '>&nbsp;'
168
            . '<label for="r1">'
169
            . _YES
170
            . '</label>'
171
            . '<input type="radio" name="options[2]" id="r1" value="1"'
172
            . $ychck
173
            . '>'
174
            . '<br><br>'
175
            . _MB_XOOPSFAQ_ALL_CATS_INTRO
176
            . '&nbsp;&nbsp;'
177
            . $selectCat
178
            . '</div>';
179
180
    return $form;
181
}
182