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.

include/functions.text.php (2 issues)

1
<?php declare(strict_types=1);
2
/**
3
 * NewBB 4.3x, the forum module for XOOPS project
4
 *
5
 * @copyright      XOOPS Project (https://xoops.org)
6
 * @license        GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
7
 * @author         Taiwen Jiang (phppp or D.J.) <[email protected]>, irmtfan <[email protected]>
8
 * @since          4.3
9
 */
10
define('NEWBB_FUNCTIONS_TEXT_LOADED', true);
11
12
if (!defined('NEWBB_FUNCTIONS_TEXT')) {
13
    define('NEWBB_FUNCTIONS_TEXT', 1);
14
    /**
15
     * function for select from a text where it have some keywords
16
     *
17
     * @param string       $text
18
     * @param mixed[]|string $queryarray
19
     * @param int          $selectstartlag
20
     * @param int          $selectlength
21
     * @param bool         $striptags
22
     * @param string       $excludetags
23
     * @param string       $start_trimmarker
24
     * @param string       $end_trimmarker
25
     * @return string
26
     */
27
    function newbb_selectText(
28
        string $text,
29
               $queryarray,
30
        int    $selectstartlag = 100,
31
        int    $selectlength = 200,
32
        bool   $striptags = true,
33
        string $excludetags = '<br>',
34
        string $start_trimmarker = '[...]',
35
        string $end_trimmarker = '[...]'
36
    ): string {
37
        $sanitized_text       = $striptags ? strip_tags($text, $excludetags) : $text;
38
        $queryarray           = newbb_str2array($queryarray);
39
        $text_i               = mb_strtolower($sanitized_text);
40
        $queryarray           = array_map('\strtolower', $queryarray);
41
        $lengtharray          = array_map('\strlen', $queryarray);
42
        $maxlengthquery       = max($lengtharray);
43
        $lengthend_trimmarker = mb_strlen($end_trimmarker);
44
        $select_text          = '';
45
        $startpos             = 0;
46
        $endpos               = mb_strlen($sanitized_text);
47
        while ($startpos < $endpos) {
48
            $pos = $endpos;
49
            foreach ($queryarray as $query) {
50
                if (false !== ($thispos = mb_strpos($text_i, $query, $startpos))) {
51
                    $pos = min($thispos, $pos);
52
                }
53
            }
54
            if ($pos == $endpos) {
55
                break;
56
            }
57
            $start       = max($pos - $selectstartlag, $startpos - $maxlengthquery, 0); // $startpos is the last position in the previous select text
58
            $length      = $maxlengthquery + $selectlength; //xoops_local("strlen", $query) + 200;
59
            $select_text .= '<p>';
60
            $select_text .= ($start > 0) ? $start_trimmarker . ' ' : ' ';
61
            $select_text .= xoops_substr($sanitized_text, $start, $length + $lengthend_trimmarker + 1, ' ' . $end_trimmarker) . '</p>';
62
            $startpos    = $start + $length + 1; // start searching from next position.
63
        }
64
        if (($select_text === '' || $select_text === '0')) {
65
            return '';
66
        } // if no text return empty string
67
68
        return '<span class="newbb_select_text">' . $select_text . '</span>';
69
    }
70
71
    /**
72
     *  function for highlight a text when it have some keywords
73
     *
74
     * @param string|mixed[] $text
75
     * @param mixed[]|string $queryarray
76
     *
77
     * @return string
78
     */
79
    function newbb_highlightText($text, $queryarray): string
80
    {
81
        if (empty($GLOBALS['xoopsModuleConfig']['highlight_search_enable'])) {
82
            return $text;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $text could return the type array<mixed,mixed> which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
83
        }
84
        $queryarray = newbb_str2array($queryarray);
85
        // if $queryarray is string
86
        $highlight_text = $text;
87
        foreach ($queryarray as $key => $query) {
88
            // use preg_replace instead of str_replace to exclude all $queries inside html span tag
89
            $highlight_text = preg_replace('/(?!(?:[^<]+>|[^>]+<\/a>))(' . preg_quote((string) $query, '/') . ')/si', newbb_highlighter($query, $key), $highlight_text);
90
        }
91
92
        return $highlight_text;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $highlight_text could return the type array<mixed,mixed> which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
93
    }
94
95
    /**
96
     * function for highlighting search results
97
     *
98
     * @param string $query
99
     * @param int    $i
100
     * @return string
101
     */
102
    function newbb_highlighter(string $query, int $i): string
103
    {
104
        return '<span class="newbb_highlight term' . $i . '">' . $query . '</span>';
105
    }
106
107
    /**
108
     * function for convert string to array
109
     * @param string|mixed[] $str
110
     * @return array
111
     */
112
    function newbb_str2array($str): array
113
    {
114
        if (is_array($str)) {
115
            return $str;
116
        }
117
118
        // split the phrase by any number of commas or space characters,
119
        // which include " ", \r, \t, \n and \f
120
        $temp_str = preg_split('/[\s,]+/', $str);
121
        $strarray = [];
122
        foreach ($temp_str as $s) {
123
            $strarray[] = addslashes((string) $s);
124
        }
125
126
        return $strarray;
127
    }
128
}
129