Issues (212)

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.

class/xmlparser.php (2 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
// This program is free software; you can redistribute it and/or modify     //
5
// it under the terms of the GNU General Public License as published by     //
6
// the Free Software Foundation; either version 2 of the License, or        //
7
// (at your option) any later version.                                      //
8
//                                                                          //
9
// You may not change or alter any portion of this comment or credits       //
10
// of supporting developers from this source code or any supporting         //
11
// source code which is considered copyrighted (c) material of the          //
12
// original comment or credit authors.                                      //
13
//                                                                          //
14
// This program is distributed in the hope that it will be useful,          //
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of           //
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
17
// GNU General Public License for more details.                             //
18
//                                                                          //
19
// You should have received a copy of the GNU General Public License        //
20
// along with this program; if not, write to the Free Software              //
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
22
// ------------------------------------------------------------------------ //
23
// Author: phppp (D.J., [email protected])                                  //
24
// URL: https://xoops.org                         //
25
// Project: Article Project                                                 //
26
// ------------------------------------------------------------------------ //
27
/**
28
 * @package   module::blogline
29
 * @copyright copyright &copy; 2005 XoopsForge.com
30
 */
31
global $msg;
32
33
require_once XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/class/magpie.inc.php';
34
35
/**
36
 * XmlParser
37
 *
38
 * @author    D.J. (phppp)
39
 * @copyright copyright &copy; 2005 XoopsForge.com
40
 * @package   module::article
41
 *
42
 * {@link MagpieRSS}
43
 **/
44
class xmlparser extends MagpieRSS
45
{
46
    public $content;
47
    public $charset_in;
48
    public $charset_out;
49
50
    /**
51
     *  Set up XML parser, parse source, and return populated RSS object..
52
     *
53
     * @param string      $content    string containing the RSS to be parsed
54
     *
55
     *
56
     * @param string      $input_charset
57
     * @param null|string $output_charset
58
     * @param array       $tags
59
     * @internal param string $output_encoding output the parsed RSS in this character
60
     *                                set defaults to ISO-8859-1 as this is PHP's
61
     *                                default.
62
     *
63
     * @internal param string $input_encoding the character set of the incoming RSS source.
64
     *                                Leave blank and Magpie will try to figure it
65
     *                                out.
66
     */
67
    public function __construct($content, $input_charset, $output_charset = _CHARSET, $tags = [])
68
    {
69
        if (!in_array(strtoupper($input_charset), ['UTF-8', 'US-ASCII', 'ISO-8859-1'])) {
70
            $content       = XoopsLocal::convert_encoding($content, 'UTF-8', $input_charset);
71
            $content       = preg_replace('/(<\?xml.*encoding=[\'"])(.*?)([\'"].*\?>)/m', '$1UTF-8$3', $content);
72
            $input_charset = 'UTF-8';
73
        }
74
        $this->content     = $content;
75
        $this->charset_in  = $input_charset;
76
        $this->charset_out = $output_charset;
77
78
        /* TODO: parse specified tags only */
79
        parent::__construct($content, $input_charset, $input_charset, false);
80
81
        //xoops_message($this);
82
        unset($this->content);
83
        $this->encoding_convert($tags);
84
    }
85
86
    /**
87
     * @return bool|string
88
     */
89
    public function is_atom()
90
    {
91
        if (ATOM == $this->feed_type) {
92
            $this->feed_version = empty($this->feed_version) ? '0.3' : $this->feed_version;
93
94
            return $this->feed_version;
95
        } else {
96
            return false;
97
        }
98
    }
99
100
    public function normalize()
101
    {
102
        if ($this->is_atom()):
103
            if (empty($this->channel['tagline'])) {
104
                /* ATOM */
105
                $this->channel['tagline'] = @$this->channel['subtitle'];
106
                unset($this->channel['subtitle']);
107
            }
108
        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
109
            // ATOM time
110
            if ($date = @$this->items[$i]['modified']) {
111
                continue;
112
            }
113
            if (empty($date)) {
114
                $date = @$this->items[$i]['updated'];
115
            }
116
            if (empty($date)) {
117
                $date = @$this->items[$i]['issued'];
118
            }
119
            if (empty($date)) {
120
                $date = @$this->items[$i]['created'];
121
            }
122
            if (empty($date)) {
123
                $date = @$this->items[$i]['created'];
124
            }
125
            $this->items[$i]['modified'] = $date;
126
        } elseif ('1.0' !== $this->is_rss()):
127
            for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
128
                if ($date = @$this->items[$i]['pubdate']) {
0 ignored issues
show
$date 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...
129
                    continue;
130
                }
131
                $this->items[$i]['pubdate'] = @$this->items[$i]['dc']['date'];
132
            }
133
        endif;
134
        parent::normalize();
135
        /* ATOM */
136
        if (empty($this->channel['language']) && !empty($this->channel['dc']['language'])) {
137
            $this->channel['language'] = $this->channel['dc']['language'];
138
            unset($this->channel['dc']['language']);
139
        }
140 View Code Duplication
        if (empty($this->channel['language'])
141
            && preg_match('/<link.*hreflang=[\'"](.*?)[\'"].*?>/m', $this->content, $match)) {
142
            $this->channel['language'] = $match[1];
143
        }
144 View Code Duplication
        if (empty($this->channel['language'])
145
            && preg_match('/<feed.*xml:lang=[\'"](.*?)[\'"].*?>/m', $this->content, $match)) {
146
            $this->channel['language'] = $match[1];
147
        }
148
        /* remove to avoid redundant encoding conversion */
149
        if (!empty($this->channel['tagline'])) {
150
            unset($this->channel['tagline']);
151
        }
152
153
        for ($i = 0, $iMax = count($this->items); $i < $iMax; ++$i) {
154
            if ($date_timestamp = @$this->items[$i]['date_timestamp']) {
0 ignored issues
show
$date_timestamp 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...
155
                continue;
156
            }
157
            if ($date_timestamp = @$this->items[$i]['pubdate']) {
158
                $this->items[$i]['date_timestamp'] = $date_timestamp;
159
            } elseif ($date_timestamp = @$this->items[$i]['dc']['date']) {
160
                $this->items[$i]['date_timestamp'] = $date_timestamp;
161
            } else {
162
                $this->items[$i]['date_timestamp'] = time();
163
            }
164
            if (!is_numeric($this->items[$i]['date_timestamp'])) {
165
                if ($date = parse_w3cdtf($this->items[$i]['date_timestamp'])) {
166
                    $this->items[$i]['date_timestamp'] = $date;
167
                } elseif ($date = strtotime($this->items[$i]['date_timestamp'])) {
168
                    $this->items[$i]['date_timestamp'] = $date;
169
                }
170
            }
171
172
            /* remove to avoid redundant encoding conversion */
173
            if (isset($this->items[$i]['summary'])) {
174
                unset($this->items[$i]['summary']);
175
            }
176
            if (isset($this->items[$i]['atom_content'])) {
177
                unset($this->items[$i]['atom_content']);
178
            }
179
        }
180
181
        return;
182
    }
183
184
    /**
185
     * @param array $tags
186
     */
187
    public function encoding_convert($tags = [])
188
    {
189
        if (empty($tags) || in_array('channel', $tags)) {
190
            $this->channel = $this->_encoding($this->channel);
191
        }
192
        if (empty($tags) || in_array('items', $tags)) {
193
            $this->items = $this->_encoding($this->items);
194
        }
195
    }
196
197
    /**
198
     * @param $val
199
     * @return array|mixed|string
200
     */
201 View Code Duplication
    public function _encoding($val)
202
    {
203
        if (is_array($val)) {
204
            foreach (array_keys($val) as $key) {
205
                $val[$key] = $this->_encoding($val[$key]);
206
            }
207
        } else {
208
            $val = XoopsLocal::convert_encoding($val, $this->charset_out, $this->charset_in);
209
        }
210
211
        return $val;
212
    }
213
}
214