GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (6)

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/DropboxAdapter.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
namespace Spatie\FlysystemDropbox;
4
5
use League\Flysystem\Adapter\AbstractAdapter;
6
use League\Flysystem\Adapter\Polyfill\NotSupportingVisibilityTrait;
7
use League\Flysystem\Config;
8
use League\Flysystem\Util\MimeType;
9
use Spatie\Dropbox\Client;
10
use Spatie\Dropbox\Exceptions\BadRequest;
11
12
class DropboxAdapter extends AbstractAdapter
13
{
14
    use NotSupportingVisibilityTrait;
15
16
    /** @var \Spatie\Dropbox\Client */
17
    protected $client;
18
19
    public function __construct(Client $client, string $prefix = '')
20
    {
21
        $this->client = $client;
22
23
        $this->setPathPrefix($prefix);
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function write($path, $contents, Config $config)
30
    {
31
        return $this->upload($path, $contents, 'add');
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function writeStream($path, $resource, Config $config)
38
    {
39
        return $this->upload($path, $resource, 'add');
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function update($path, $contents, Config $config)
46
    {
47
        return $this->upload($path, $contents, 'overwrite');
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function updateStream($path, $resource, Config $config)
54
    {
55
        return $this->upload($path, $resource, 'overwrite');
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61
    public function rename($path, $newPath): bool
62
    {
63
        $path = $this->applyPathPrefix($path);
64
        $newPath = $this->applyPathPrefix($newPath);
65
66
        try {
67
            $this->client->move($path, $newPath);
68
        } catch (BadRequest $e) {
69
            return false;
70
        }
71
72
        return true;
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78 View Code Duplication
    public function copy($path, $newpath): bool
79
    {
80
        $path = $this->applyPathPrefix($path);
81
        $newpath = $this->applyPathPrefix($newpath);
82
83
        try {
84
            $this->client->copy($path, $newpath);
85
        } catch (BadRequest $e) {
86
            return false;
87
        }
88
89
        return true;
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95
    public function delete($path): bool
96
    {
97
        $location = $this->applyPathPrefix($path);
98
99
        try {
100
            $this->client->delete($location);
101
        } catch (BadRequest $e) {
102
            return false;
103
        }
104
105
        return true;
106
    }
107
108
    /**
109
     * {@inheritdoc}
110
     */
111
    public function deleteDir($dirname): bool
112
    {
113
        return $this->delete($dirname);
114
    }
115
116
    /**
117
     * {@inheritdoc}
118
     */
119 View Code Duplication
    public function createDir($dirname, Config $config)
120
    {
121
        $path = $this->applyPathPrefix($dirname);
122
123
        try {
124
            $object = $this->client->createFolder($path);
125
        } catch (BadRequest $e) {
126
            return false;
127
        }
128
129
        return $this->normalizeResponse($object);
130
    }
131
132
    /**
133
     * {@inheritdoc}
134
     */
135
    public function has($path)
136
    {
137
        return $this->getMetadata($path);
138
    }
139
140
    /**
141
     * {@inheritdoc}
142
     */
143
    public function read($path)
144
    {
145
        if (! $object = $this->readStream($path)) {
146
            return false;
147
        }
148
149
        $object['contents'] = stream_get_contents($object['stream']);
150
        fclose($object['stream']);
151
        unset($object['stream']);
152
153
        return $object;
154
    }
155
156
    /**
157
     * {@inheritdoc}
158
     */
159 View Code Duplication
    public function readStream($path)
160
    {
161
        $path = $this->applyPathPrefix($path);
162
163
        try {
164
            $stream = $this->client->download($path);
165
        } catch (BadRequest $e) {
166
            return false;
167
        }
168
169
        return compact('stream');
170
    }
171
172
    /**
173
     * {@inheritdoc}
174
     */
175
    public function listContents($directory = '', $recursive = false): array
176
    {
177
        $location = $this->applyPathPrefix($directory);
178
179
        try {
180
            $result = $this->client->listFolder($location, $recursive);
181
        } catch (BadRequest $e) {
182
            return [];
183
        }
184
185
        $entries = $result['entries'];
186
187
        while ($result['has_more']) {
188
            $result = $this->client->listFolderContinue($result['cursor']);
189
            $entries = array_merge($entries, $result['entries']);
190
        }
191
192
        if (! count($entries)) {
193
            return [];
194
        }
195
196
        return array_map(function ($entry) {
197
            $path = $this->removePathPrefix($entry['path_display']);
198
199
            return $this->normalizeResponse($entry, $path);
0 ignored issues
show
The call to DropboxAdapter::normalizeResponse() has too many arguments starting with $path.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
200
        }, $entries);
201
    }
202
203
    /**
204
     * {@inheritdoc}
205
     */
206 View Code Duplication
    public function getMetadata($path)
207
    {
208
        $path = $this->applyPathPrefix($path);
209
210
        try {
211
            $object = $this->client->getMetadata($path);
212
        } catch (BadRequest $e) {
213
            return false;
214
        }
215
216
        return $this->normalizeResponse($object);
217
    }
218
219
    /**
220
     * {@inheritdoc}
221
     */
222
    public function getSize($path)
223
    {
224
        return $this->getMetadata($path);
225
    }
226
227
    /**
228
     * {@inheritdoc}
229
     */
230
    public function getMimetype($path)
231
    {
232
        return ['mimetype' => MimeType::detectByFilename($path)];
233
    }
234
235
    /**
236
     * {@inheritdoc}
237
     */
238
    public function getTimestamp($path)
239
    {
240
        return $this->getMetadata($path);
241
    }
242
243
    public function getTemporaryLink(string $path): string
244
    {
245
        return $this->client->getTemporaryLink($path);
246
    }
247
248
    public function getTemporaryUrl(string $path): string
249
    {
250
        return $this->getTemporaryLink($path);
251
    }
252
253
    public function getUrl(string $path): string
254
    {
255
        return $this->getTemporaryLink($path);
256
    }
257
258
    public function getThumbnail(string $path, string $format = 'jpeg', string $size = 'w64h64')
259
    {
260
        return $this->client->getThumbnail($path, $format, $size);
261
    }
262
263
    public function createSharedLinkWithSettings($path, $settings)
264
    {
265
        return $this->client->createSharedLinkWithSettings($path, $settings);
266
    }
267
268
    /**
269
     * {@inheritdoc}
270
     */
271
    public function applyPathPrefix($path): string
272
    {
273
        $path = parent::applyPathPrefix($path);
274
275
        return '/'.trim($path, '/');
276
    }
277
278
    public function getClient(): Client
279
    {
280
        return $this->client;
281
    }
282
283
    /**
284
     * @param string $path
285
     * @param resource|string $contents
286
     * @param string $mode
287
     *
288
     * @return array|false file metadata
289
     */
290 View Code Duplication
    protected function upload(string $path, $contents, string $mode)
291
    {
292
        $path = $this->applyPathPrefix($path);
293
294
        try {
295
            $object = $this->client->upload($path, $contents, $mode);
296
        } catch (BadRequest $e) {
297
            return false;
298
        }
299
300
        return $this->normalizeResponse($object);
301
    }
302
303
    protected function normalizeResponse(array $response): array
304
    {
305
        $normalizedPath = ltrim($this->removePathPrefix($response['path_display']), '/');
306
307
        $normalizedResponse = ['path' => $normalizedPath];
308
309
        if (isset($response['server_modified'])) {
310
            $normalizedResponse['timestamp'] = strtotime($response['server_modified']);
311
        }
312
313
        if (isset($response['size'])) {
314
            $normalizedResponse['size'] = $response['size'];
315
            $normalizedResponse['bytes'] = $response['size'];
316
        }
317
318
        $type = ($response['.tag'] === 'folder' ? 'dir' : 'file');
319
        $normalizedResponse['type'] = $type;
320
321
        return $normalizedResponse;
322
    }
323
}
324