Issues (661)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  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.
  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.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
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/feedfunc.new.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * @param $param
5
 * @return array
6
 */
7
function mylinks_get_new($param)
8
{
9
    $modulename = basename(dirname(__DIR__));
10
    include_once XOOPS_ROOT_PATH . "/modules/{$modulename}/include/feeddata.inc.php";
11
12
    // parameter
13
    $limit_show  = isset($param['show']) ? (int)$param['show'] : 10;
14
    $limit_image = isset($param['image']) ? (int)$param['image'] : 1;
0 ignored issues
show
$limit_image is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
15
16
    // get new from each module
17
    $i            = 0;
18
    $result_array = array();
19
    $time_array   = array();
20
21
    $limit = $limit_show;
22
23
    $res_array = mylinks_feednew($limit);
24
    $count     = count($res_array);
25
    if (is_array($res_array) && $count > 0) {
26
        for ($j = 0; $j < $count; $j++) {
27
            $result_array[$i] = $res_array[$j];
28
            $time_array[$i]   = $res_array[$j]['time'];
29
            $i++;
30
        }
31
    }
32
33
    // sort by time
34
    arsort($time_array);
35
    $i         = 0;
36
    $new_array = array();
37
38
    foreach ($time_array as $num => $time) {
39
        $new_array[$i++] = $result_array[$num];
40
        if ($i >= $limit_show) {
41
            break;
42
        }
43
    }
44
45
    return $new_array;
46
}
47
48
/**
49
 * @param $title
50
 * @return mixed|string
51
 */
52
function wani_make_html_title($title)
53
{
54
    if (!isset($title) or empty($title)) {
55
        return '';
56
    }
57
    $title = strip_tags($title);
58
    $title = (mb_strlen($title) > 100) ? mb_strimwidth($title, 0, 100, ' ...') : $title;
59
    $title = wani_html_special_chars($title);
60
61
    return $title;
62
}
63
64
/**
65
 * @param $sum
66
 * @param $max
67
 * @return mixed|string
68
 */
69
function wani_make_html_summary($sum, $max)
70
{
71
    $FLAG_STRIP_CONTROL = 1;
72
    $FLAG_STRIP_CRLF    = 1;
73
    $FLAG_STRIP_STYLE   = 1;
74
    $FLAG_STRIP_SPACE   = 1;
75
    $FLAG_ADD_SPACE     = 1;
76
    $FLAG_IMAGE_FORCE   = 1;
0 ignored issues
show
$FLAG_IMAGE_FORCE is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
77
78
    if ($FLAG_STRIP_CONTROL) {
79
        $sum = wani_strip_control_code($sum);
80
    }
81
82
    if ($FLAG_STRIP_CRLF) {
83
        $sum = wani_strip_crlf($sum);
84
    }
85
86
    if ($FLAG_STRIP_STYLE) {
87
        $sum = wani_strip_style_tag($sum);
88
    }
89
90
    if ($FLAG_ADD_SPACE) {
91
        $sum = wani_add_space($sum);
92
    }
93
94
    $sum = strip_tags($sum);
95
96
    if ($FLAG_STRIP_SPACE) {
97
        $sum = wani_strip_space($sum);
98
    }
99
100
    $sum = (mb_strlen($sum) > $max) ? mb_strimwidth($sum, 0, $max, ' ...') : $sum;
101
102
    // sanitize
103
    $sum = wani_html_special_chars($sum);
104
105
    return $sum;
106
}
107
108
/////////////
109
// --------------------------------------------------------
110
// strip return code
111
// --------------------------------------------------------
112
/**
113
 * @param $text
114
 * @return mixed
115
 */
116
function wani_strip_crlf($text)
117
{
118
    $text = preg_replace("/\r/", ' ', $text);
119
    $text = preg_replace("/\n/", ' ', $text);
120
121
    return $text;
122
}
123
124
// --------------------------------------------------------
125
// strip style tag
126
// in strip_tags, cannot strip style tag area well
127
// --------------------------------------------------------
128
/**
129
 * @param $text
130
 * @return mixed
131
 */
132
function wani_strip_style_tag($text)
133
{
134
    return preg_replace('|<\s*style\s?.*?>(.*)<\s*/\s*style\s*>|is', '', $text);
135
}
136
137
// --------------------------------------------------------
138
// strip space code
139
// --------------------------------------------------------
140
/**
141
 * @param $text
142
 * @return mixed|string
143
 */
144
function wani_strip_space($text)
145
{
146
    global $xoopsConfig;
147
148
    if (($xoopsConfig['language'] == 'japanese') && function_exists('mb_convert_kana')) {
149
        // zenkaku to hankaku
150
        $text = mb_convert_kana($text, 's');
151
    }
152
153
    // in MyTextSanitizer, replace "&nbsp;" to "&amp;nbsp;"
154
    $text = preg_replace('/&amp;nbsp;/i', ' ', $text);
155
    $text = preg_replace('/&nbsp;/i', ' ', $text);
156
    $text = preg_replace("/[\x20]+/", ' ', $text);
157
158
    return $text;
159
}
160
161
// --------------------------------------------------------
162
// add space code after end tag
163
// REQ 3509: put into spacing in a summary
164
// --------------------------------------------------------
165
/**
166
 * @param $text
167
 * @return mixed
168
 */
169
function wani_add_space($text)
170
{
171
    $text = preg_replace('/>/', '> ', $text);
172
173
    return $text;
174
}
175
176
// --------------------------------------------------------
177
// convert html_special_chars
178
// in MyTextSanitizer, replace "&nbsp;" to "&amp;nbsp;"
179
// in this, not replace "&nbsp;"
180
//   <  -> &lt;
181
//   >  -> &gt;
182
//   "  -> &quot;
183
//   '  -> &#039;
184
// --------------------------------------------------------
185
/**
186
 * @param $text
187
 * @return mixed|string
188
 */
189 View Code Duplication
function wani_html_special_chars($text)
0 ignored issues
show
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
190
{
191
    $text = wani_strip_control_code($text);
192
    $text = wani_conv_js($text);
193
    $text = htmlspecialchars($text, ENT_QUOTES);
194
    $text = preg_replace("/'/", '&apos;', $text);
195
    //$text = preg_replace("/&amp;/i", '&', $text);
196
    return $text;
197
}
198
199
//---------------------------------------------------------
200
// convert html_special_chars for url
201
//   <     -> &lt;
202
//   >     -> &gt;
203
//   "     -> &quot;
204
//   '     -> &#039;
205
//   &     -> &amp;
206
//   &amp; -> &amp;
207
//---------------------------------------------------------
208
// BUG 3169: need to sanitaize $_SERVER['PHP_SELF']
209
/**
210
 * @param $text
211
 * @return mixed|string
212
 */
213 View Code Duplication
function wani_html_special_chars_url($text)
0 ignored issues
show
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
214
{
215
    $text = wani_strip_control_code($text);
216
    $text = wani_strip_crlf($text);
217
    $text = wani_conv_js($text);
218
    $text = preg_replace('/&amp;/i', '&', $text);
219
    $text = htmlspecialchars($text, ENT_QUOTES);
220
221
    return $text;
222
}
223
224
// BUG 3169: need to sanitaize $_SERVER['PHP_SELF']
225
/**
226
 * @param $text
227
 * @return mixed
228
 */
229
function wani_conv_js($text)
230
{
231
    $text = preg_replace('/javascript:/si', 'java script:', $text);
232
    $text = preg_replace('/about:/si', 'about :', $text);
233
234
    return $text;
235
}
236
237
// --------------------------------------------------------
238
// strip control code
239
// --------------------------------------------------------
240
/**
241
 * @param $text
242
 * @return mixed
243
 */
244
function wani_strip_control_code($text)
245
{
246
    $text = preg_replace('/[\x00-\x09]/', ' ', $text);
247
    $text = preg_replace('/[\x0B-\x0C]/', ' ', $text);
248
    $text = preg_replace('/[\x0E-\x1F]/', ' ', $text);
249
    $text = preg_replace('/[\x7F]/', ' ', $text);
250
251
    return $text;
252
}
253
254
//---------------------------------------------------------
255
// http://www.w3.org/TR/NOTE-datetime
256
// 2003-12-13T18:30:02+09:00
257
//
258
// http://www.php.net/manual/ja/function.date.php
259
// User Contributed Notes
260
//---------------------------------------------------------
261
/**
262
 * @param $time
263
 * @return string
264
 */
265
function wani_iso8601_date($time)
266
{
267
    $tzd  = date('O', $time);
268
    $tzd  = substr(chunk_split($tzd, 3, ':'), 0, 6);
269
    $date = date('Y-m-d\TH:i:s', $time) . $tzd;
270
271
    return $date;
272
}
273
274
/**
275
 * @param $text
276
 * @return string
277
 */
278
function wani_utf8_encode($text)
279
{
280
    if (1 == XOOPS_USE_MULTIBYTES) {
281
        if (function_exists('mb_convert_encoding')) {
282
            return mb_convert_encoding($text, 'UTF-8', _CHARSET);
283
        }
284
285
        return $text;
286
    }
287
288
    return utf8_encode($text);
289
}
290