Issues (7)

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/File.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
2
/**
3
 * Class File
4
 *
5
 * @filesource   File.php
6
 * @created      03.03.2017
7
 * @package      chillerlan\Filereader
8
 * @author       Smiley <[email protected]>
9
 * @copyright    2017 Smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\Filereader;
14
15
use chillerlan\Filereader\Drivers\FSDriverInterface;
16
17
/**
18
 * @property string $name
19
 * @property \chillerlan\Filereader\Directory $directory
20
 */
21
class File extends FSAbstract{
22
23
	/**
24
	 * @var string
25
	 */
26
	protected $name;
27
28
	/**
29
	 * @var \chillerlan\Filereader\Directory
30
	 */
31
	protected $directory;
32
33
	/**
34
	 * File constructor.
35
	 *
36
	 * @param \chillerlan\Filereader\Drivers\FSDriverInterface $driver
37
	 * @param \chillerlan\Filereader\Directory                 $directory
38
	 * @param string                                           $name
39
	 */
40
	public function __construct(FSDriverInterface $driver, Directory $directory, string $name){
41
		parent::__construct($driver);
42
43
		$this->directory  = $directory;
44
		$this->name       = $name;
45
		$this->path       = $this->directory->path.DIRECTORY_SEPARATOR.$this->name;
46
	}
47
48
	/**
49
	 * @return bool
50
	 */
51
	public function exists():bool{
52
		return $this->filereader->fileExists($this->path);
53
	}
54
55
	/**
56
	 * @return string
57
	 */
58
	public function content():string{
59
		return $this->filereader->fileContents($this->path);
60
	}
61
62
	/**
63
	 * @return mixed
64
	 */
65
	public function getRequire(){
66
		return $this->filereader->getRequire($this->path);
67
	}
68
69
	/**
70
	 * @param string $destination
71
	 * @param bool   $overwrite
72
	 *
73
	 * @return bool
74
	 */
75
	public function copy(string $destination, bool $overwrite = true):bool{
76
		return $this->filereader->copyFile($this->path, $destination, $overwrite);
77
	}
78
79
	/**
80
	 * @param string $newname
81
	 * @param bool   $overwrite
82
	 *
83
	 * @return \chillerlan\Filereader\File
84
	 * @throws \chillerlan\Filereader\FilereaderException
85
	 */
86
	public function rename(string $newname, bool $overwrite = true):File{
87
88 View Code Duplication
		if(!$this->filereader->rename($this->path, $newname, $overwrite)){
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...
89
			throw new FilereaderException('cannot rename '.$this->path.' to '.$newname); // @codeCoverageIgnore
90
		}
91
92
		if(!$this->filereader->isFile($newname)){
93
			throw new FilereaderException('file not found: '.$newname); // @codeCoverageIgnore
94
		}
95
96
		$this->path = $newname;
97
98
		$info = pathinfo($this->path);
99
100
		$this->name  = isset($info['filename']) ? $info['filename'] : '';
101
		$this->name .= '.'.$info['extension'];
102
		$this->directory = new Directory($this->filereader, $info['dirname']);
103
104
		return $this;
105
	}
106
107
	/**
108
	 * @return bool
109
	 */
110
	public function delete():bool{
111
		return $this->filereader->deleteFile($this->path);
112
	}
113
114
}
115