Issues (337)

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.

src/component/Feed/RSS2Item.php (1 issue)

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
namespace Rudolf\Component\Feed;
4
5
/**
6
 * This file is part of Rudolf articles module.
7
 *
8
 * RSS2 Feed generator
9
 *
10
 * @see http://cyber.law.harvard.edu/rss/rss.html
11
 *
12
 * @author Mikołaj Pich <[email protected]>
13
 *
14
 * @version 0.1
15
 */
16
class RSS2Item implements IRSS2Item
17
{
18
    /**
19
     * @var string
20
     */
21
    private $title;
22
23
    /**
24
     * @var string
25
     */
26
    private $link;
27
28
    /**
29
     * @var string
30
     */
31
    private $description;
32
33
    /**
34
     * @var string
35
     */
36
    private $author;
37
38
    /**
39
     * @var string
40
     */
41
    private $category;
42
43
    /**
44
     * @var string
45
     */
46
    private $comments;
47
48
    /**
49
     * @var string
50
     */
51
    private $enclosure;
52
53
    /**
54
     * @var string
55
     */
56
    private $guid;
57
58
    /**
59
     * @var string
60
     */
61
    private $pubDate;
62
63
    /**
64
     * @var string
65
     */
66
    private $source;
67
68
    /**
69
     * Set item title.
70
     *
71
     * @param string $title
72
     */
73
    public function setTitle($title)
74
    {
75
        $this->title = $title;
76
    }
77
78
    /**
79
     * Set item link.
80
     *
81
     * @param string $link
82
     */
83
    public function setLink($link)
84
    {
85
        $this->link = $link;
86
    }
87
88
    /**
89
     * Set item description.
90
     *
91
     * @param string $description
92
     */
93
    public function setDescription($description)
94
    {
95
        $this->description = $description;
96
    }
97
98
    /**
99
     * Set item author.
100
     *
101
     * @param string $author
102
     */
103
    public function setAuthor($author)
104
    {
105
        $this->author = $author;
106
    }
107
108
    /**
109
     * Set item category.
110
     *
111
     * @param string $category
112
     */
113
    public function setCategory($category)
114
    {
115
        $this->category = $category;
116
    }
117
118
    public function setComments($comments)
119
    {
120
        $this->comments = $comments;
121
    }
122
123
    public function setEnclosure($enclosure)
124
    {
125
        $this->enclosure = $enclosure;
126
    }
127
128
    public function setGuid($guid)
129
    {
130
        $this->guid = $guid;
131
    }
132
133
    public function setPubDate($pubDate)
134
    {
135
        $this->pubDate = $pubDate;
136
    }
137
138
    public function setSource($source)
139
    {
140
        $this->source = $source;
141
    }
142
143
    /**
144
     * Get item title.
145
     *
146
     * @return bool|string
147
     */
148
    public function getTitle()
149
    {
150
        if (empty($this->title)) {
151
            return false;
152
        }
153
154
        return '<title>'.strip_tags($this->title).'</title>';
155
    }
156
157
    /**
158
     * Get item link.
159
     *
160
     * @return bool|string
161
     */
162
    public function getLink()
163
    {
164
        if (empty($this->link)) {
165
            return false;
166
        }
167
168
        return '<link>'.$this->link.'</link>';
169
    }
170
171
    /**
172
     * Get item description.
173
     *
174
     * @return bool|string
175
     */
176
    public function getDescription()
177
    {
178
        if (empty($this->description)) {
179
            return false;
180
        }
181
182
        $content = str_replace(array("\n", "\r"), '', $this->description);
183
184
        return '<description>'.htmlspecialchars($content).'</description>';
185
    }
186
187
    /**
188
     * Get item author.
189
     *
190
     * @return bool|string
191
     */
192
    public function getAuthor()
193
    {
194
        if (empty($this->author)) {
195
            return false;
196
        }
197
198
        return '<author>'.$this->author.'</author>';
199
    }
200
201
    /**
202
     * Get item category.
203
     *
204
     * @return bool|string
205
     */
206
    public function getCategory()
207
    {
208
        if (empty($this->category)) {
209
            return false;
210
        }
211
212
        return '<category>'.$this->category.'</category>';
213
    }
214
215
    /**
216
     * Get item pub date.
217
     *
218
     * @return bool|string
219
     */
220
    public function getPubDate()
221
    {
222
        if (empty($this->pubDate)) {
223
            return false;
224
        }
225
226
        return '<pubDate>'.$this->pubDate.'</pubDate>';
227
    }
228
229
    /**
230
     * Get <item> element.
231
     *
232
     * @return string
233
     */
234
    public function getItem()
235
    {
236
        $xml[] = $this->getTitle();
0 ignored issues
show
Coding Style Comprehensibility introduced by
$xml was never initialized. Although not strictly required by PHP, it is generally a good practice to add $xml = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
237
        $xml[] = $this->getLink();
238
        $xml[] = $this->getDescription();
239
        $xml[] = $this->getAuthor();
240
        $xml[] = $this->getPubDate();
241
        $xml[] = $this->getCategory();
242
243
        $xml = array_filter($xml);
244
245
        foreach ($xml as $key => $value) {
246
            $xml[$key] = "\t\t\t".$value;
247
        }
248
249
        array_unshift($xml, "\t\t".'<item>');
250
251
        $xml[] = "\t\t".'</item>';
252
253
        return implode("\n", array_filter($xml));
254
    }
255
}
256