Issues (16)

Security Analysis    no request data  

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/Directory.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
 * @package    Fuel\FileSystem
4
 * @version    2.0
5
 * @author     Fuel Development Team
6
 * @license    MIT License
7
 * @copyright  2010 - 2015 Fuel Development Team
8
 * @link       http://fuelphp.com
9
 */
10
11
namespace Fuel\FileSystem;
12
13
14
class Directory extends Handler
15
{
16
	/**
17
	 * Deletes a directory recursively
18
	 *
19
	 * @return boolean
20
	 */
21
	public function deleteRecursive()
22
	{
23
		return $this->delete(true);
24
	}
25
26
	/**
27
	 * Deletes a directory
28
	 *
29
	 * @param boolean $recursive
30
	 *
31
	 * @return boolean
32
	 */
33
	public function delete($recursive = false)
34
	{
35
		if ( ! $recursive)
36
		{
37
			return parent::delete();
38
		}
39
40
		$finder = new Finder();
41
		$contents = $finder->listContents($this->path);
0 ignored issues
show
The method listContents() does not seem to exist on object<Fuel\FileSystem\Finder>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
42
43
		foreach($contents as $item)
44
		{
45
			$item->delete(true);
46
		}
47
48
		return parent::delete();
49
	}
50
51
	/**
52
	 * Lists all files in a directory
53
	 *
54
	 * @param integer $depth
55
	 * @param mixed   $filter
56
	 * @param boolean $asHandlers
57
	 *
58
	 * @return array
59
	 */
60
	public function listFiles($depth = 0, $filter = null, $asHandlers = false)
61
	{
62
		return $this->listContents($depth, $filter, 'file', $asHandlers);
63
	}
64
65
	/**
66
	 * Lists all files in a directory as Handlers
67
	 *
68
	 * @param integer $depth
69
	 * @param mixed   $filter
70
	 *
71
	 * @return array
72
	 */
73
	public function listFileHandlers($depth = 0, $filter = null)
74
	{
75
		return $this->listContents($depth, $filter, 'file', true);
76
	}
77
78
	/**
79
	 * Lists all directories in a directory
80
	 *
81
	 * @param integer $depth
82
	 * @param mixed   $filter
83
	 * @param boolean $asHandlers
84
	 *
85
	 * @return array
86
	 */
87
	public function listDirs($depth = 0, $filter = null, $asHandlers = false)
88
	{
89
		return $this->listContents($depth, $filter, 'dir', $asHandlers);
90
	}
91
92
	/**
93
	 * Lists all directories in a directory
94
	 *
95
	 * @param integer $depth
96
	 * @param mixed   $filter
97
	 *
98
	 * @return array
99
	 */
100
	public function listDirHandlers($depth = 0, $filter = null)
101
	{
102
		return $this->listContents($depth, $filter, 'dir', true);
103
	}
104
105
	/**
106
	 * Lists all files and directories in a directory
107
	 *
108
	 * @param integer  $depth
109
	 * @param mixed    $filter
110
	 * @param string   $type
111
	 * @param boolean  $asHandlers
112
	 *
113
	 * @return array
114
	 */
115
	public function listContents($depth = 0, $filter = null, $type = 'all', $asHandlers = false)
116
	{
117
		$pattern = $this->path.'/*';
118
119
		if (is_array($filter))
120
		{
121
			$filters = $filter;
122
			$filter = new Filter;
123
124
			foreach ($filters as $f => $type)
125
			{
126
				if ( ! is_int($f))
127
				{
128
					$f = $type;
129
					$type = null;
130
				}
131
132
				$expected = true;
133
134
				if (strpos($f, '!') === 0)
135
				{
136
					$f = substr($f, 1);
137
					$expected = false;
138
				}
139
140
				$filter->addFilter($f, $expected, $type);
141
			}
142
		}
143
144
		if ($filter instanceof \Closure)
145
		{
146
			$callback = $filter;
147
			$filter = new Filter();
148
			$callback($filter);
149
		}
150
151
		if ( ! $filter)
152
		{
153
			$filter = new Filter;
154
		}
155
156
		$flags = GLOB_MARK;
157
158
		if ($type === 'file' and ! pathinfo($pattern, PATHINFO_EXTENSION))
159
		{
160
			// Add an extension wildcard
161
			$pattern .= '.*';
162
		}
163
		elseif ($type === 'dir')
164
		{
165
			$flags = GLOB_MARK | GLOB_ONLYDIR;
166
		}
167
168
		$contents = glob($pattern, $flags);
169
170
		// Filter the content.
171
		$contents = $filter->filter($contents);
172
173
		// Lower the depth for a recursive call
174
		if ($depth and $depth !== true)
175
		{
176
			$depth--;
177
		}
178
179
		$formatted = array();
180
181
		foreach ($contents as $item)
182
		{
183
			if ($filter->isCorrectType('dir', $item))
184
			{
185
				$_contents = array();
186
187
				if (($depth === true or $depth === 0) and ! $asHandlers)
188
				{
189
					$dir = new Directory($item);
190
191
					$_contents = $dir->listContents($item, $filter, $depth, $type);
192
				}
193
194
				if ($asHandlers)
195
				{
196
					$formatted[] = new Directory($item);
197
				}
198
				else
199
				{
200
					$formatted[$item] = $_contents;
201
				}
202
			}
203
			elseif ($filter->isCorrectType('file', $item))
204
			{
205
				if ($asHandlers)
206
				{
207
					$item = new File($item);
208
				}
209
210
				$formatted[] = $item;
211
			}
212
		}
213
214
		return $formatted;
215
	}
216
}
217