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_rand.php (3 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
 * Display/Edit Random Term Block file
15
 *
16
 * @author    hsalazar
17
 * @author    ZySpec
18
 * @author    XOOPS Module Development Team
19
 * @copyright Copyright (c) 2001-2017 {@link https://xoops.org XOOPS Project}
20
 * @license   https://www.gnu.org/licenses/gpl-2.0.html GNU Public License
21
 * @since     ::   1.23
22
 *
23
 * @see       \XoopsModules\Xoopsfaq\Helper
24
 */
25
26
use Xmf\Module\Helper\Permission;
27
use XoopsModules\Xoopsfaq\{
28
    Constants,
29
    CategoryHandler,
30
    ContentsHandler,
31
    Helper
32
};
33
34
/**
35
 * Display Random FAQ Block
36
 *
37
 * @param array $options
38
 *              [0] - number of chars in title to show (0 = unlimited)
39
 *              [1] - comma separated list of categories to use/select from
40
 * @return array contains random FAQ parameters
41
 */
42
function b_xoopsfaq_random_show(array $options)
43
{
44
    $moduleDirName = \basename(\dirname(__DIR__));
45
    $myts          = \MyTextSanitizer::getInstance();
46
47
    /** @var CategoryHandler $categoryHandler */
48
    /** @var ContentsHandler $contentsHandler */
49
    /** @var Helper $helper */
50
    $helper          = Helper::getInstance();
51
    $permHelper      = new Permission($moduleDirName);
52
    $contentsHandler = $helper->getHandler('Contents');
53
    $block           = [];
54
55
    $criteria = new \CriteriaCompo();
56
    $criteria->add(new \Criteria('contents_active', Constants::ACTIVE, '='));
57
58
    // Filter out cats based on group permissions
59
    $options[1] = $options[1] ?? [0];
60
    $cTu        = $catsToUse = (false === mb_strpos($options[1], ',')) ? (array)$options[1] : explode(',', $options[1]);
0 ignored issues
show
It seems like $options[1] 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

60
    $cTu        = $catsToUse = (false === mb_strpos($options[1], ',')) ? (array)$options[1] : explode(',', /** @scrutinizer ignore-type */ $options[1]);
Loading history...
It seems like $options[1] 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

60
    $cTu        = $catsToUse = (false === mb_strpos(/** @scrutinizer ignore-type */ $options[1], ',')) ? (array)$options[1] : explode(',', $options[1]);
Loading history...
61
    if (in_array(0, $catsToUse, true) || empty($catsToUse)) {
62
        // Get a list of all cats
63
        $categoryHandler = $helper->getHandler('Category');
64
        $catListArray    = $categoryHandler->getList();
65
        $cTu             = $catsToUse = array_keys($catListArray);
66
    }
67
    // Remove any cats this user doesn't have rights to view
68
    foreach ($cTu as $key => $thisCat) {
69
        if (false === $permHelper->checkPermission('viewcat', $thisCat)) {
70
            unset($catsToUse[$key]);
71
        }
72
    }
73
    if (!empty($catsToUse)) {
74
        $criteria->add(new \Criteria('contents_cid', '(' . implode(',', $catsToUse) . ')', 'IN'));
75
    } else {
76
        return $block;
77
    }
78
    $xpFaqObjArray = $contentsHandler->getAll($criteria);
79
    $faqCount      = (is_array($xpFaqObjArray) && !empty($xpFaqObjArray)) ? count($xpFaqObjArray) : 0;
80
81
    if ($faqCount > 0) {
82
        $faqNum   = array_rand($xpFaqObjArray, 1);
83
        $xpFaqObj = $xpFaqObjArray[$faqNum];
84
        $faq      = $myts->displayTarea($xpFaqObj->getVar('contents_title'));
85
        $txtAns   = strip_tags($xpFaqObj->getVar('contents_contents')); // get rid of html for block
86
        $faqAns   = $myts->displayTarea(xoops_substr($txtAns, 0, $options[0]), 0, 0, 0, 0, 0);
87
88
        $categoryHandler = $helper->getHandler('Category');
89
        $catObj          = $categoryHandler->get($xpFaqObj->getVar('contents_cid'));
90
        $cid             = $catObj->getVar('category_id');
91
        $block           = [
92
            'title'    => _MB_XOOPSFAQ_RANDOM_TITLE,
93
            'faq'      => $faq,
94
            'faqans'   => $faqAns,
95
            'morelink' => $helper->url('index.php?cat_id=' . $cid . '#q' . $xpFaqObj->getVar('contents_id')),
96
            'linktxt'  => _MB_XOOPSFAQ_SEE_MORE,
97
            'catlink'  => $helper->url('index.php?cat_id=' . $cid),
98
            'cattxt'   => $catObj->getVar('category_title'),
99
        ];
100
        unset($xpFaqObj, $catObj);
101
    }
102
103
    return $block;
104
}
105
106
/**
107
 * Edit Random FAQ Block preferences
108
 *
109
 * @param array $options
110
 *              [0] - number of chars in title to show (0 = unlimited)
111
 *              [1] - comma separated list of categories to use/select from
112
 * @return string HTML entities to display for user input
113
 */
114
function b_xoopsfaq_rand_edit(array $options)
115
{
116
    $moduleDirName = \basename(\dirname(__DIR__));
0 ignored issues
show
The assignment to $moduleDirName is dead and can be removed.
Loading history...
117
    xoops_load('XoopsFormSelect');
118
119
    /** @var CategoryHandler $categoryHandler */
120
    /** @var Helper $helper */
121
    $helper          = Helper::getInstance();
122
    $categoryHandler = $helper->getHandler('Category');
123
124
    $catList     = $categoryHandler->getList();
125
    $optionArray = array_merge([0 => _MB_XOOPSFAQ_ALL_CATS], $catList);
126
    $formSelect  = new \XoopsFormSelect('category', 'options[1]', null, 3, true);
127
    $formSelect->addOptionArray($optionArray);
128
    $selOptions = (false === mb_strpos($options[1], ',')) ? $options[1] : explode(',', $options[1]);
129
    $formSelect->setValue($selOptions);
130
    $selectCat = $formSelect->render();
131
132
    $form = '<div class="line140">' . _MB_XOOPSFAQ_CHARS . '&nbsp;' . '<input type="number" name="options[0]" value="' . $options[0] . '" style="width: 5em;" min="0" class="right">&nbsp;' . _MB_XOOPSFAQ_LENGTH . '<br><br>' . _MB_XOOPSFAQ_ALL_CATS_INTRO . '&nbsp;&nbsp;' . $selectCat . '</div>';
133
134
    return $form;
135
}
136