Issues (190)

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.

bundles/lib/Cache/File.php (1 issue)

Labels
Severity

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
 * Manage Cache by file
5
 *
6
 * @category  	lib
7
 * @package		lib\Cache
8
 * @author    	Judicaël Paquet <[email protected]>
9
 * @copyright 	Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93)
10
 * @license   	https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël
11
 * @version   	Release: 1.0.0
12
 * @filesource	https://github.com/las93/venus2
13
 * @link      	https://github.com/las93
14
 * @since     	1.0
15
 */
16
namespace Venus\lib\Cache;
17
use \Venus\lib\Cache\CacheInterface;
18
19
/**
20
 * This class manage the Cache by file
21
 *
22
 * @category  	lib
23
 * @package		lib\Cache
24
 * @author    	Judicaël Paquet <[email protected]>
25
 * @copyright 	Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93)
26
 * @license   	https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël
27
 * @version   	Release: 1.0.0
28
 * @filesource	https://github.com/las93/venus2
29
 * @link      	https://github.com/las93
30
 * @since     	1.0
31
 */
32
class File implements CacheInterface
33
{
34
    /**
35
     * var containe this folder of cache
36
     *
37
     * @access private
38
     * @var    string
39
     */
40
    private $_sFolder = '';
41
42
    /**
43
     * constructor
44
     *
45
     * @access public
46
     */
47
    public function __construct()
48
    {
49
        $this->_sFolder = str_replace('bundles'.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'Cache', CACHE_DIR, __DIR__).DIRECTORY_SEPARATOR;
50
    }
51
52
    /**
53
     * set a value
54
     *
55
     * @access public
56
     * @param  string $sName name of the session
57
     * @param  mixed $mValue value of this sesion var
58
     * @param  int $iFlag flags
59
     * @param  int $iExpire expiration of cache
60
     * @return \Venus\lib\Cache\File
61
     */
62
    public function set(string $sName, $mValue, int $iFlag, int $iExpire)
63
    {
64
        file_put_contents($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac', serialize($mValue));
65
        return $this;
66
    }
67
68
    /**
69
     * get a value
70
     *
71
     * @access public
72
     * @param  string $sName name of the session
73
     * @param  int $iFlags flags
74
     * @param  int $iTimeout expiration of cache
75
     * @return mixed
76
     */
77
    public function get(string $sName, int &$iFlags = null, int $iTimeout = 0)
78
    {
79
        if ($iTimeout > 0 && file_exists($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac')
80
            && time() - filemtime($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac') > $iTimeout) {
81
82
            unlink($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac');
83
        }
84
85
        if (file_exists($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac')) {
86
87
            return unserialize(file_get_contents($this->_sFolder . $this->_getSubDirectory($sName) . md5($sName) . '.fil.cac'));
88
        } else {
89
90
            return false;
91
        }
92
    }
93
94
    /**
95
     * delete a value
96
     *
97
     * @access public
98
     * @param  string $sName name of the session
99
     * @return mixed
100
     */
101
    public function delete(string $sName)
102
    {
103
        return unlink($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac');
104
    }
105
106
    /**
107
     * flush the cache
108
     *
109
     * @access public
110
     * @param  string $sName name of the session
0 ignored issues
show
There is no parameter named $sName. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
111
     * @return mixed
112
     */
113
    public function flush()
114
    {
115
        $this->_removeDirectory($this->_sFolder);
116
    }
117
118
    /**
119
     *
120
     *
121
     * @access public
122
     * @param  string $sName name of the session
123
     * @return mixed
124
     */
125
    private function _getSubDirectory($sName)
126
    {
127
        if (!file_exists($this->_sFolder.substr(md5($sName), 0, 2).DIRECTORY_SEPARATOR.substr(md5($sName), 2, 2))) {
128
129
            mkdir($this->_sFolder.substr(md5($sName), 0, 2).DIRECTORY_SEPARATOR.substr(md5($sName), 2, 2), 0777, true);
130
        }
131
132
        return substr(md5($sName), 0, 2).DIRECTORY_SEPARATOR.substr(md5($sName), 2, 2).DIRECTORY_SEPARATOR;
133
    }
134
135
    /**
136
     * remove a directory recursivly
137
     *
138
     * @access private
139
     * @param  string $sName nom du répertoire
140
     * @return void
141
     */
142
    private function _removeDirectory($sName)
143
    {
144
        if ($rDirectory = opendir($sName)) {
145
146
            while (($sFile = readdir($rDirectory)) !== false) {
147
148
                if ($sFile > '0' && filetype($sName.$sFile) == "file") { unlink($sName.$sFile); } elseif ($sFile > '0' && filetype($sName.$sFile) == "dir") { remove_dir($sName.$sFile."\\"); }
149
            }
150
151
            closedir($rDirectory);
152
            rmdir($sName);
153
        }
154
    }
155
}
156