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.

modules/archive/libraries/Archive.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 defined('SYSPATH') or die('No direct access allowed.');
2
/**
3
 * Archive library.
4
 *
5
 * $Id: Archive.php 4367 2009-05-27 21:23:57Z samsoir $
6
 *
7
 * @package    Archive
8
 * @author     Kohana Team
9
 * @copyright  (c) 2007-2008 Kohana Team
10
 * @license    http://kohanaphp.com/license.html
11
 */
12
class Archive_Core
13
{
14
15
    // Files and directories
16
    protected $paths;
17
18
    // Driver instance
19
    protected $driver;
20
21
    /**
22
     * Loads the archive driver.
23
     *
24
     * @throws  Kohana_Exception
25
     * @param   string   type of archive to create
26
     * @return  void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
27
     */
28
    public function __construct($type = null)
29
    {
30
        $type = empty($type) ? 'zip' : $type;
31
32
        // Set driver name
33
        $driver = 'Archive_'.ucfirst($type).'_Driver';
34
35
        // Load the driver
36
        if (! Kohana::auto_load($driver)) {
37
            throw new Kohana_Exception('core.driver_not_found', $type, get_class($this));
38
        }
39
40
        // Initialize the driver
41
        $this->driver = new $driver();
42
43
        // Validate the driver
44
        if (! ($this->driver instanceof Archive_Driver)) {
45
            throw new Kohana_Exception('core.driver_implements', $type, get_class($this), 'Archive_Driver');
46
        }
47
48
        Kohana::log('debug', 'Archive Library initialized');
49
    }
50
51
    /**
52
     * Adds files or directories, recursively, to an archive.
53
     *
54
     * @param   string   file or directory to add
55
     * @param   string   name to use for the given file or directory
56
     * @param   bool     add files recursively, used with directories
57
     * @return  Archive_Core
58
     */
59
    public function add($path, $name = null, $recursive = null)
60
    {
61
        // Normalize to forward slashes
62
        $path = str_replace('\\', '/', $path);
63
64
        // Set the name
65
        empty($name) and $name = $path;
66
67
        if (is_dir($path)) {
68
            // Force directories to end with a slash
69
            $path = rtrim($path, '/').'/';
70
            $name = rtrim($name, '/').'/';
71
72
            // Add the directory to the paths
73
            $this->paths[] = array($path, $name);
74
75
            if ($recursive === true) {
76
                $dir = opendir($path);
77
                while (($file = readdir($dir)) !== false) {
78
                    // Do not add hidden files or directories
79
                    if ($file[0] === '.') {
80
                        continue;
81
                    }
82
83
                    // Add directory contents
84
                    $this->add($path.$file, $name.$file, true);
85
                }
86
                closedir($dir);
87
            }
88
        } else {
89
            $this->paths[] = array($path, $name);
90
        }
91
92
        return $this;
93
    }
94
95
    /**
96
     * Creates an archive and saves it into a file.
97
     *
98
     * @throws  Kohana_Exception
99
     * @param   string   archive filename
100
     * @return  boolean
101
     */
102
    public function save($filename)
103
    {
104
        // Get the directory name
105
        $directory = pathinfo($filename, PATHINFO_DIRNAME);
106
107
        if (! is_writable($directory)) {
108
            throw new Kohana_Exception('archive.directory_unwritable', $directory);
109
        }
110
111
        if (is_file($filename)) {
112
            // Unable to write to the file
113
            if (! is_writable($filename)) {
114
                throw new Kohana_Exception('archive.filename_conflict', $filename);
115
            }
116
117
            // Remove the file
118
            unlink($filename);
119
        }
120
121
        return $this->driver->create($this->paths, $filename);
122
    }
123
124
    /**
125
     * Creates a raw archive file and returns it.
126
     *
127
     * @return  string
128
     */
129
    public function create()
130
    {
131
        return $this->driver->create($this->paths);
132
    }
133
134
    /**
135
     * Forces a download of a created archive.
136
     *
137
     * @param   string   name of the file that will be downloaded
138
     * @return  void
139
     */
140
    public function download($filename)
141
    {
142
        download::force($filename, $this->driver->create($this->paths));
143
    }
144
} // End Archive
145