Issues (555)

Branch: main

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/Phing/Io/ExtendedFileStream.php (10 issues)

1
<?php
2
3
/**
4
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
5
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
6
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
7
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
8
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
9
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
10
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
11
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
12
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
13
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
14
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15
 *
16
 * This software consists of voluntary contributions made by many individuals
17
 * and is licensed under the LGPL. For more information please see
18
 * <http://phing.info>.
19
 */
20
21
namespace Phing\Io;
22
23
use Phing\Exception\BuildException;
24
25
/**
26
 * Extended file stream wrapper class which auto-creates directories.
27
 *
28
 * @author  Michiel Rook <[email protected]>
29
 * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
30
 */
31
class ExtendedFileStream
32
{
33
    private $fp;
34
35
    public static function registerStream()
36
    {
37
        if (!in_array('efile', stream_get_wrappers())) {
38
            stream_wrapper_register('efile', __CLASS__);
39
        }
40
    }
41
42
    public static function unregisterStream()
43
    {
44
        stream_wrapper_unregister('efile');
45
    }
46
47
    // @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
48
49
    /**
50
     * @param $path
51
     * @param $mode
52
     * @param $options
53
     * @param $opened_path
54
     *
55
     * @throws IOException
56
     *
57
     * @return bool
58
     */
59
    public function stream_open($path, $mode, $options, &$opened_path)
0 ignored issues
show
The parameter $options is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

59
    public function stream_open($path, $mode, /** @scrutinizer ignore-unused */ $options, &$opened_path)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $opened_path is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

59
    public function stream_open($path, $mode, $options, /** @scrutinizer ignore-unused */ &$opened_path)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
60
    {
61
        // if we're on Windows, urldecode() the path again
62
        if ('\\' == FileSystem::getFileSystem()->getSeparator()) {
63
            $path = urldecode($path);
64
        }
65
66
        $filepath = substr($path, 8);
67
68
        $this->createDirectories(dirname($filepath));
69
70
        $this->fp = fopen($filepath, $mode);
71
72
        if (!$this->fp) {
73
            throw new BuildException("Unable to open stream for path {$path}");
74
        }
75
76
        return true;
77
    }
78
79
    public function stream_close()
80
    {
81
        fclose($this->fp);
82
        $this->fp = null;
83
    }
84
85
    /**
86
     * @param $count
87
     *
88
     * @return string
89
     */
90
    public function stream_read($count)
91
    {
92
        return fread($this->fp, $count);
93
    }
94
95
    /**
96
     * @param $data
97
     *
98
     * @return int
99
     */
100
    public function stream_write($data)
101
    {
102
        return fwrite($this->fp, $data);
103
    }
104
105
    /**
106
     * @return bool
107
     */
108
    public function stream_eof()
109
    {
110
        return feof($this->fp);
111
    }
112
113
    /**
114
     * @return int
115
     */
116
    public function stream_tell()
117
    {
118
        return ftell($this->fp);
119
    }
120
121
    /**
122
     * @param $offset
123
     * @param $whence
124
     *
125
     * @return int
126
     */
127
    public function stream_seek($offset, $whence)
128
    {
129
        return fseek($this->fp, $offset, $whence);
130
    }
131
132
    /**
133
     * @return bool
134
     */
135
    public function stream_flush()
136
    {
137
        return fflush($this->fp);
138
    }
139
140
    /**
141
     * @return array
142
     */
143
    public function stream_stat()
144
    {
145
        return fstat($this->fp);
146
    }
147
148
    // @phpcs:enable
149
150
    /**
151
     * @param  $path
152
     *
153
     * @return bool
154
     */
155
    public function unlink($path)
0 ignored issues
show
The parameter $path is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

155
    public function unlink(/** @scrutinizer ignore-unused */ $path)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
156
    {
157
        return false;
158
    }
159
160
    /**
161
     * @param  $path_from
162
     * @param  $path_to
163
     *
164
     * @return bool
165
     */
166
    public function rename($path_from, $path_to)
0 ignored issues
show
The parameter $path_from is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

166
    public function rename(/** @scrutinizer ignore-unused */ $path_from, $path_to)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $path_to is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

166
    public function rename($path_from, /** @scrutinizer ignore-unused */ $path_to)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
167
    {
168
        return false;
169
    }
170
171
    /**
172
     * @param  $path
173
     * @param  $mode
174
     * @param  $options
175
     *
176
     * @return bool
177
     */
178
    public function mkdir($path, $mode, $options)
0 ignored issues
show
The parameter $path is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

178
    public function mkdir(/** @scrutinizer ignore-unused */ $path, $mode, $options)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $mode is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

178
    public function mkdir($path, /** @scrutinizer ignore-unused */ $mode, $options)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $options is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

178
    public function mkdir($path, $mode, /** @scrutinizer ignore-unused */ $options)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
179
    {
180
        return false;
181
    }
182
183
    /**
184
     * @param  $path
185
     * @param  $options
186
     *
187
     * @return bool
188
     */
189
    public function rmdir($path, $options)
0 ignored issues
show
The parameter $options is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

189
    public function rmdir($path, /** @scrutinizer ignore-unused */ $options)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $path is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

189
    public function rmdir(/** @scrutinizer ignore-unused */ $path, $options)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
190
    {
191
        return false;
192
    }
193
194
    /**
195
     * @param $path
196
     */
197
    private function createDirectories($path)
198
    {
199
        $f = new File($path);
200
        if (!$f->exists()) {
201
            $f->mkdirs();
202
        }
203
    }
204
}
205