Issues (1240)

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.

system/helpers/feed.php (5 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 defined('SYSPATH') or die('No direct access allowed.');
2
/**
3
 * Feed helper class.
4
 *
5
 * $Id: feed.php 4152 2009-04-03 23:26:23Z ixmatus $
6
 *
7
 * @package    Core
8
 * @author     Kohana Team
9
 * @copyright  (c) 2007-2008 Kohana Team
10
 * @license    http://kohanaphp.com/license.html
11
 */
12
class feed_Core
13
{
14
15
    /**
16
     * Parses a remote feed into an array.
17
     *
18
     * @param   string   remote feed URL
19
     * @param   integer  item limit to fetch
20
     * @return  array
21
     */
22
    public static function parse($feed, $limit = 0)
23
    {
24
        // Check if SimpleXML is installed
25
        if (! function_exists('simplexml_load_file')) {
26
            throw new Kohana_User_Exception('Feed Error', 'SimpleXML must be installed!');
27
        }
28
        
29
        // Make limit an integer
30
        $limit = (int) $limit;
31
32
        // Disable error reporting while opening the feed
33
        $ER = error_reporting(0);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $ER. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
34
35
        // Allow loading by filename or raw XML string
36
        $load = (is_file($feed) or valid::url($feed)) ? 'simplexml_load_file' : 'simplexml_load_string';
37
38
        // Load the feed
39
        $feed = $load($feed, 'SimpleXMLElement', LIBXML_NOCDATA);
40
41
        // Restore error reporting
42
        error_reporting($ER);
43
44
        // Feed could not be loaded
45
        if ($feed === false) {
46
            return array();
47
        }
48
49
        // Detect the feed type. RSS 1.0/2.0 and Atom 1.0 are supported.
50
        $feed = isset($feed->channel) ? $feed->xpath('//item') : $feed->entry;
51
52
        $i = 0;
53
        $items = array();
54
55
        foreach ($feed as $item) {
56
            if ($limit > 0 and $i++ === $limit) {
57
                break;
58
            }
59
60
            $items[] = (array) $item;
61
        }
62
63
        return $items;
64
    }
65
66
    /**
67
     * Creates a feed from the given parameters.
68
     *
69
     * @param   array   feed information
70
     * @param   array   items to add to the feed
71
     * @param   string  define which format to use
72
     * @param   string  define which encoding to use
73
     * @return  string
0 ignored issues
show
Should the return type not be string|false?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
74
     */
75
    public static function create($info, $items, $format = 'rss2', $encoding = 'UTF-8')
0 ignored issues
show
The parameter $format is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
76
    {
77
        $info += array('title' => 'Generated Feed', 'link' => '', 'generator' => 'KohanaPHP');
78
79
        $feed = '<?xml version="1.0" encoding="'.$encoding.'"?><rss version="2.0"><channel></channel></rss>';
80
        $feed = simplexml_load_string($feed);
81
82 View Code Duplication
        foreach ($info as $name => $value) {
0 ignored issues
show
This code seems to be duplicated across 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...
83
            if (($name === 'pubDate' or $name === 'lastBuildDate') and (is_int($value) or ctype_digit($value))) {
84
                // Convert timestamps to RFC 822 formatted dates
85
                $value = date(DATE_RFC822, $value);
86
            } elseif (($name === 'link' or $name === 'docs') and strpos($value, '://') === false) {
87
                // Convert URIs to URLs
88
                $value = url::site($value, 'http');
89
            }
90
91
            // Add the info to the channel
92
            $feed->channel->addChild($name, $value);
93
        }
94
95
        foreach ($items as $item) {
96
            // Add the item to the channel
97
            $row = $feed->channel->addChild('item');
98
99 View Code Duplication
            foreach ($item as $name => $value) {
0 ignored issues
show
This code seems to be duplicated across 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...
100
                if ($name === 'pubDate' and (is_int($value) or ctype_digit($value))) {
101
                    // Convert timestamps to RFC 822 formatted dates
102
                    $value = date(DATE_RFC822, $value);
103
                } elseif (($name === 'link' or $name === 'guid') and strpos($value, '://') === false) {
104
                    // Convert URIs to URLs
105
                    $value = url::site($value, 'http');
106
                }
107
108
                // Add the info to the row
109
                $row->addChild($name, $value);
110
            }
111
        }
112
113
        return $feed->asXML();
114
    }
115
} // End feed
116