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/expires.php (3 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
 * Controls headers that effect client caching of pages
4
 *
5
 * $Id: expires.php 4272 2009-04-25 21:47:26Z zombor $
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 expires_Core
13
{
14
15
    /**
16
     * Sets the amount of time before a page expires
17
     *
18
     * @param  integer Seconds before the page expires
19
     * @return boolean
0 ignored issues
show
Should the return type not be integer|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...
20
     */
21
    public static function set($seconds = 60)
22
    {
23
        if (expires::check_headers()) {
24
            $now = $expires = time();
25
26
            // Set the expiration timestamp
27
            $expires += $seconds;
28
29
            // Send headers
30
            header('Last-Modified: '.gmdate('D, d M Y H:i:s T', $now));
31
            header('Expires: '.gmdate('D, d M Y H:i:s T', $expires));
32
            header('Cache-Control: max-age='.$seconds);
33
34
            return $expires;
35
        }
36
37
        return false;
38
    }
39
40
    /**
41
     * Checks to see if a page should be updated or send Not Modified status
42
     *
43
     * @param   integer  Seconds added to the modified time received to calculate what should be sent
44
     * @return  null|false     FALSE when the request needs to be updated
45
     */
46
    public static function check($seconds = 60)
0 ignored issues
show
check uses the super-global variable $_SERVER which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
47
    {
48
        if (! empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) and expires::check_headers()) {
49
            if (($strpos = strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], ';')) !== false) {
50
                // IE6 and perhaps other IE versions send length too, compensate here
51
                $mod_time = substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, $strpos);
52
            } else {
53
                $mod_time = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
54
            }
55
56
            $mod_time = strtotime($mod_time);
57
            $mod_time_diff = $mod_time + $seconds - time();
58
59
            if ($mod_time_diff > 0) {
60
                // Re-send headers
61
                header('Last-Modified: '.gmdate('D, d M Y H:i:s T', $mod_time));
62
                header('Expires: '.gmdate('D, d M Y H:i:s T', time() + $mod_time_diff));
63
                header('Cache-Control: max-age='.$mod_time_diff);
64
                header('Status: 304 Not Modified', true, 304);
65
66
                // Prevent any output
67
                Event::add('system.display', array('expires', 'prevent_output'));
68
69
                // Exit to prevent other output
70
                exit;
0 ignored issues
show
Coding Style Compatibility introduced by
The method check() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
71
            }
72
        }
73
74
        return false;
75
    }
76
77
    /**
78
     * Check headers already created to not step on download or Img_lib's feet
79
     *
80
     * @return boolean
81
     */
82
    public static function check_headers()
83
    {
84
        foreach (headers_list() as $header) {
85
            if ((session_cache_limiter() == '' and stripos($header, 'Last-Modified:') === 0)
86
                or stripos($header, 'Expires:') === 0) {
87
                return false;
88
            }
89
        }
90
91
        return true;
92
    }
93
94
    /**
95
     * Prevent any output from being displayed. Executed during system.display.
96
     *
97
     * @return  void
98
     */
99
    public static function prevent_output()
100
    {
101
        Kohana::$output = '';
102
    }
103
} // End expires
104