Issues (8)

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/Filesystem/Driver/DriverStandard.php (2 issues)

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
namespace Dazzle\Filesystem\Driver;
4
5
use Dazzle\Filesystem\Driver\Flag\FlagResolverInterface;
6
use Dazzle\Filesystem\Invoker\InvokerInterface;
7
use Dazzle\Filesystem\Invoker\InvokerStandard;
8
use Dazzle\Loop\LoopInterface;
9
use Dazzle\Promise\Promise;
10
use DateTimeImmutable;
11
use Error;
12
use Exception;
13
14
class DriverStandard extends DriverAbstract implements DriverInterface
15
{
16
    /**
17
     * @var array
18
     */
19
    protected $options;
20
21
    /**
22
     * @var InvokerInterface
23
     */
24
    protected $invoker;
25
26
    /**
27
     * @var FlagResolverInterface
28
     */
29
    protected $flagPermission;
30
31
    /**
32
     * @param LoopInterface $loop
33
     * @param array $options
34
     */
35
    public function __construct(LoopInterface $loop, $options = [])
36
    {
37
        $this->loop = $loop;
38
        $this->options = $this->createConfiguration($options);
39
        $this->invoker = $this->createInvoker();
40
        $this->flagPermission = $this->createFlagPermissionResolver();
41
    }
42
43
    /**
44
     * @override
45
     * @inheritDoc
46
     */
47
    public function access($path, $mode = 0755)
48
    {
49
        // TODO
50
    }
51
52
    /**
53
     * @override
54
     * @inheritDoc
55
     */
56
    public function append($path, $data = '')
57
    {
58
        // TODO
59
    }
60
61
    /**
62
     * @override
63
     * @inheritDoc
64
     */
65
    public function chmod($path, $mode)
66
    {
67
        return $this->invoker->call('chmod', [ $this->getPath($path), decoct($mode) ]);
68
    }
69
70
    /**
71
     * @override
72
     * @inheritDoc
73
     */
74
    public function chown($path, $uid = -1, $gid = -1)
75
    {
76
        return $this->invoker->call('chown', [ $this->getPath($path), $uid, $gid ]);
77
    }
78
79
    /**
80
     * @override
81
     * @inheritDoc
82
     */
83
    public function exists($path)
84
    {
85
        return $this->stat($path)
86
            ->then(
87
                function() { return true; },
88
                function() { return false; }
89
            );
90
    }
91
92
    /**
93
     * @override
94
     * @inheritDoc
95
     */
96
    public function link($srcPath, $dstPath)
97
    {
98
        return $this->invoker->call('link', [ $this->getPath($srcPath), $this->getPath($dstPath) ]);
99
    }
100
101
    /**
102
     * @override
103
     * @inheritDoc
104
     */
105
    public function ls($path)
106
    {
107
        // TODO
108
    }
109
110
    /**
111
     * @override
112
     * @inheritDoc
113
     */
114
    public function mkdir($path, $mode = 0755)
115
    {
116
        return $this->invoker->call('mkdir', [ $this->getPath($path), decoct($this->flagPermission->resolve($mode)) ]);
117
    }
118
119
    /**
120
     * @override
121
     * @inheritDoc
122
     */
123
    public function prepend($path, $data = '')
124
    {
125
        // TODO
126
    }
127
128
    /**
129
     * @override
130
     * @inheritDoc
131
     */
132
    public function readlink($path)
133
    {
134
        return $this->invoker->call('readlink', [ $this->getPath($path) ]);
135
    }
136
137
    /**
138
     * @override
139
     * @inheritDoc
140
     */
141
    public function realpath($path)
142
    {
143
        return $this->invoker->call('realpath', [ $this->getPath($path) ]);
144
    }
145
146
    /**
147
     * @override
148
     * @inheritDoc
149
     */
150
    public function rename($srcPath, $dstPath)
151
    {
152
        return $this->invoker->call('rename', [ $this->getPath($srcPath), $this->getPath($dstPath) ]);
153
    }
154
155
    /**
156
     * @override
157
     * @inheritDoc
158
     */
159
    public function rmdir($path)
160
    {
161
        return $this->invoker->call('rmdir', [ $this->getPath($path) ]);
162
    }
163
164
    /**
165
     * @override
166
     * @inheritDoc
167
     */
168
    public function stat($path)
169
    {
170
        return $this->invoker
171
            ->call('stat', [ $this->getPath($path) ])
172
            ->then(function($info) {
173
                return $info ? array_filter($info, function($infoKey) {
174
                    return !is_numeric($infoKey);
175
                }, ARRAY_FILTER_USE_KEY) : $info;
176
            })
177 View Code Duplication
            ->then(function($info) {
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...
178
                if ($info)
179
                {
180
                    $info['atime'] && $info['atime'] = new DateTimeImmutable('@' . $info['atime']);
181
                    $info['mtime'] && $info['mtime'] = new DateTimeImmutable('@' . $info['mtime']);
182
                    $info['ctime'] && $info['ctime'] = new DateTimeImmutable('@' . $info['ctime']);
183
                }
184
                return $info;
185
            });
186
    }
187
188
    /**
189
     * @override
190
     * @inheritDoc
191
     */
192
    public function symlink($srcPath, $dstPath)
193
    {
194
        return $this->invoker->call('symlink', [ $this->getPath($srcPath), $this->getPath($dstPath) ]);
195
    }
196
197
    /**
198
     * @override
199
     * @inheritDoc
200
     */
201
    public function truncate($path, $len = 0)
202
    {
203
        // TODO
204
    }
205
206
    /**
207
     * @override
208
     * @inheritDoc
209
     */
210
    public function unlink($path)
211
    {
212
        return $this->invoker->call('unlink', [ $this->getPath($path) ]);
213
    }
214
215
    /**
216
     * @internal
217
     * @override
218
     * @inheritDoc
219
     */
220
    public function call($func, $args = [])
221
    {
222
        try
223
        {
224
            return Promise::doResolve(@$func(...$args));
225
        }
226
        catch (Error $ex)
227
        {
228
            return Promise::doReject($ex);
229
        }
230
        catch (Exception $ex)
231
        {
232
            return Promise::doReject($ex);
233
        }
234
    }
235
236
    /**
237
     * Get path.
238
     *
239
     * @param string $path
240
     * @return string
241
     */
242
    protected function getPath($path)
243
    {
244
        return $this->options['root'] . '/' . ltrim($path, '/');
245
    }
246
247
    /**
248
     * Create valid configuration for the driver.
249
     *
250
     * @param array $options
251
     * @return array
252
     */
253
    protected function createConfiguration($options = [])
254
    {
255
        return array_merge([
256
            'root' => '',
257
            'invoker.class' => InvokerStandard::class,
258
        ], $options);
259
    }
260
261
    /**
262
     * Create invoker for the driver.
263
     *
264
     * @return InvokerInterface
265
     */
266 View Code Duplication
    protected function createInvoker()
0 ignored issues
show
This method seems to be duplicated in 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...
267
    {
268
        $invoker = class_exists($this->options['invoker.class'])
269
            ? $this->options['invoker.class']
270
            : InvokerStandard::class
271
        ;
272
        return new $invoker($this);
273
    }
274
}
275