Issues (30)

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/Adapter/NullAdapter.php (4 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 League\Flysystem\Adapter;
4
5
use League\Flysystem\Adapter\Polyfill\StreamedCopyTrait;
6
use League\Flysystem\Adapter\Polyfill\StreamedTrait;
7
use League\Flysystem\Config;
8
use League\Flysystem\Util;
9
10
class NullAdapter extends AbstractAdapter
11
{
12
    /**
13
     * Reads a file as a stream.
14
     *
15
     * @param string $path
16
     *
17
     * @return array|false
18
     *
19
     * @see League\Flysystem\ReadInterface::readStream()
20
     */
21 View Code Duplication
    public function readStream($path)
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...
22
    {
23
        if ( ! $data = $this->read($path)) {
24
            return false;
25
        }
26
27
        $stream = fopen('php://temp', 'w+b');
28
        fwrite($stream, $data['contents']);
29
        rewind($stream);
30
        $data['stream'] = $stream;
31
        unset($data['contents']);
32
33
        return $data;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $data; (boolean) is incompatible with the return type declared by the interface League\Flysystem\ReadInterface::readStream of type array|false.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
34
    }
35
    /**
36
     * Stream fallback delegator.
37
     *
38
     * @param string   $path
39
     * @param resource $resource
40
     * @param Config   $config
41
     * @param string   $fallback
42
     *
43
     * @return mixed fallback result
44
     */
45 View Code Duplication
    protected function stream($path, $resource, Config $config, $fallback)
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...
46
    {
47
        Util::rewindStream($resource);
48
        $contents = stream_get_contents($resource);
49
        $fallbackCall = array($this, $fallback);
50
51
        return call_user_func($fallbackCall, $path, $contents, $config);
52
    }
53
54
    /**
55
     * Write using a stream.
56
     *
57
     * @param string   $path
58
     * @param resource $resource
59
     * @param Config   $config
60
     *
61
     * @return mixed false or file metadata
62
     */
63
    public function writeStream($path, $resource, Config $config)
64
    {
65
        return $this->stream($path, $resource, $config, 'write');
66
    }
67
68
    /**
69
     * Update a file using a stream.
70
     *
71
     * @param string   $path
72
     * @param resource $resource
73
     * @param Config   $config   Config object or visibility setting
74
     *
75
     * @return mixed false of file metadata
76
     */
77
    public function updateStream($path, $resource, Config $config)
78
    {
79
        return $this->stream($path, $resource, $config, 'update');
80
    }
81
82 View Code Duplication
    public function copy($path, $newpath)
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...
83
    {
84
        $response = $this->readStream($path);
85
86
        if ($response === false || ! is_resource($response['stream'])) {
87
            return false;
88
        }
89
90
        $result = $this->writeStream($newpath, $response['stream'], new Config());
91
92
        if ($result !== false && is_resource($response['stream'])) {
93
            fclose($response['stream']);
94
        }
95
96
        return $result !== false;
97
    }
98
99
    /**
100
     * Check whether a file is present.
101
     *
102
     * @param string $path
103
     *
104
     * @return bool
105
     */
106 9
    public function has($path)
107
    {
108 9
        return false;
109
    }
110
111
    /**
112
     * @inheritdoc
113
     */
114 6
    public function write($path, $contents, Config $config)
115
    {
116 6
        $type = 'file';
117 6
        $result = compact('contents', 'type', 'path');
118
119 6
        if ($visibility = $config->get('visibility')) {
120 3
            $result['visibility'] = $visibility;
121 3
        }
122
123 6
        return $result;
124
    }
125
126
    /**
127
     * @inheritdoc
128
     */
129 3
    public function update($path, $contents, Config $config)
130
    {
131 3
        return false;
132
    }
133
134
    /**
135
     * @inheritdoc
136
     */
137 6
    public function read($path)
138
    {
139 6
        return false;
140
    }
141
142
    /**
143
     * @inheritdoc
144
     */
145 3
    public function rename($path, $newpath)
146
    {
147 3
        return false;
148
    }
149
150
    /**
151
     * @inheritdoc
152
     */
153 6
    public function delete($path)
154
    {
155 6
        return false;
156
    }
157
158
    /**
159
     * @inheritdoc
160
     */
161 3
    public function listContents($directory = '', $recursive = false)
162
    {
163 3
        return array();
164
    }
165
166
    /**
167
     * @inheritdoc
168
     */
169 3
    public function getMetadata($path)
170
    {
171 3
        return false;
172
    }
173
174
    /**
175
     * @inheritdoc
176
     */
177 3
    public function getSize($path)
178
    {
179 3
        return false;
180
    }
181
182
    /**
183
     * @inheritdoc
184
     */
185 3
    public function getMimetype($path)
186
    {
187 3
        return false;
188
    }
189
190
    /**
191
     * @inheritdoc
192
     */
193 3
    public function getTimestamp($path)
194
    {
195 3
        return false;
196
    }
197
198
    /**
199
     * @inheritdoc
200
     */
201 3
    public function getVisibility($path)
202
    {
203 3
        return false;
204
    }
205
206
    /**
207
     * @inheritdoc
208
     */
209 3
    public function setVisibility($path, $visibility)
210
    {
211 3
        return compact('visibility');
212
    }
213
214
    /**
215
     * @inheritdoc
216
     */
217 3
    public function createDir($dirname, Config $config)
218
    {
219 3
        return array('path' => $dirname, 'type' => 'dir');
220
    }
221
222
    /**
223
     * @inheritdoc
224
     */
225 3
    public function deleteDir($dirname)
226
    {
227 3
        return false;
228
    }
229
}
230