Issues (5)

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/GithubAdapter.php (3 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 Potherca\Flysystem\Github;
4
5
use League\Flysystem\Adapter\AbstractAdapter;
6
use League\Flysystem\Adapter\Polyfill\StreamedTrait;
7
use League\Flysystem\Config;
8
use League\Flysystem\Exception;
9
use League\Flysystem\Util;
10
11
/**
12
 *
13
 */
14
class GithubAdapter extends AbstractAdapter
15
{
16
    use StreamedTrait;
17
18
    const COMMITTER_MAIL = 'email';
19
    const COMMITTER_NAME = 'name';
20
21
    const VISIBILITY_PRIVATE = 'private';
22
    const VISIBILITY_PUBLIC = 'public';
23
24
    /** @var ApiInterface */
25
    private $api;
26
27
    /**
28
     * @return ApiInterface
29
     */
30
    final public function getApi()
31
    {
32
        return $this->api;
33
    }
34
35
    /**
36
     * @param ApiInterface $api
37
     */
38
    public function __construct(ApiInterface $api)
39
    {
40
        $this->api = $api;
41
    }
42
43
    /**
44
     * Write a new file.
45
     *
46
     * @param string $path
47
     * @param string $contents
48
     * @param Config $config Config object
49
     *
50
     * @return array|false false on failure file meta data on success
51
     */
52
    public function write($path, $contents, Config $config)
53
    {
54
        throw new Exception('Write action are not (yet) supported');
55
        //@TODO: return $this->getApi()->create($path, $contents);
56
    }
57
58
    /**
59
     * Update a file.
60
     *
61
     * @param string $path
62
     * @param string $contents
63
     * @param Config $config Config object
64
     *
65
     * @return array|false false on failure file meta data on success
66
     */
67
    public function update($path, $contents, Config $config)
68
    {
69
        throw new Exception('Write action are not (yet) supported');
70
        // @TODO: return $this->getApi()->update($path, $contents);
71
    }
72
73
    /**
74
     * Rename a file.
75
     *
76
     * @param string $path
77
     * @param string $newpath
78
     *
79
     * @return bool
80
     */
81
    public function rename($path, $newpath)
82
    {
83
        throw new Exception('Write action are not (yet) supported');
84
        // @TODO: return $this->getApi()->rename($path, $newPath);
85
    }
86
87
    /**
88
     * Copy a file.
89
     *
90
     * @param string $path
91
     * @param string $newpath
92
     *
93
     * @return bool
94
     */
95
    public function copy($path, $newpath)
96
    {
97
        throw new Exception('Write action are not (yet) supported');
98
        // @TODO: return $this->getApi()->copy($path, $newPath);
99
    }
100
101
    /**
102
     * Delete a file.
103
     *
104
     * @param string $path
105
     *
106
     * @return bool
107
     */
108
    public function delete($path)
109
    {
110
        throw new Exception('Write action are not (yet) supported');
111
        // @TODO: return $this->getApi()->delete($path);
112
    }
113
114
    /**
115
     * Delete a directory.
116
     *
117
     * @param string $dirname
118
     *
119
     * @return bool
120
     */
121
    public function deleteDir($dirname)
122
    {
123
        throw new Exception('Write action are not (yet) supported');
124
        // @TODO: return $this->getApi()->deleteDir($dirname);
125
    }
126
127
    /**
128
     * Create a directory.
129
     *
130
     * @param string $dirname directory name
131
     * @param Config $config
132
     *
133
     * @return array|false
134
     */
135
    public function createDir($dirname, Config $config)
136
    {
137
        throw new Exception('Write action are not (yet) supported');
138
        // @TODO: return $this->getApi()->createDir($dirname);
139
    }
140
141
    /**
142
     * Set the visibility for a file.
143
     *
144
     * @param string $path
145
     * @param string $visibility
146
     *
147
     * @return array|false file meta data
0 ignored issues
show
Should the return type not be array|false|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
148
     */
149
    public function setVisibility($path, $visibility)
150
    {
151
        // TODO: Implement setVisibility() method.
152
    }
153
154
    /**
155
     * Check that a file or directory exists in the repository
156
     *
157
     * @param string $path
158
     *
159
     * @return array|bool|null
160
     */
161
    public function has($path)
162
    {
163
        return $this->getApi()->exists($path);
164
    }
165
166
    /**
167
     * Read a file
168
     *
169
     * @param string $path
170
     *
171
     * @return array|false
172
     *
173
     * @throws \Github\Exception\ErrorException
174
     */
175
    public function read($path)
176
    {
177
        return [ApiInterface::KEY_CONTENTS => $this->getApi()->getFileContents($path)];
178
    }
179
180
    /**
181
     * List contents of a directory.
182
     *
183
     * @param string $path
184
     * @param bool $recursive
185
     *
186
     * @return array
187
     */
188
    public function listContents($path = '/', $recursive = false)
189
    {
190
        $contents = $this->getApi()->getTreeMetadata($path, $recursive);
191
192
        if ($this->isDirectoryContents($contents) === false) {
193
            $contents = [];
194
        }
195
196
        return $contents;
197
    }
198
199
    /**
200
     * Get all the meta data of a file or directory.
201
     *
202
     * @param string $path
203
     *
204
     * @return array|false
0 ignored issues
show
Should the return type not be array|boolean?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
205
     */
206
    public function getMetadata($path)
207
    {
208
        return $this->getApi()->getMetaData($path);
209
    }
210
211
    /**
212
     * Get all the meta data of a file or directory.
213
     *
214
     * @param string $path
215
     *
216
     * @return array|false
0 ignored issues
show
Should the return type not be array|boolean?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
217
     */
218
    public function getSize($path)
219
    {
220
        return $this->getApi()->getMetaData($path);
221
    }
222
223
    /**
224
     * Get the mimetype of a file.
225
     *
226
     * @param string $path
227
     *
228
     * @return array|false
229
     */
230
    public function getMimetype($path)
231
    {
232
        return ['mimetype' => $this->getApi()->guessMimeType($path)];
233
    }
234
235
    /**
236
     * Get the timestamp of a file.
237
     *
238
     * @param string $path
239
     *
240
     * @return array|false
241
     */
242
    public function getTimestamp($path)
243
    {
244
        return $this->getApi()->getLastUpdatedTimestamp($path);
245
    }
246
247
    /**
248
     * Get the visibility of a file.
249
     *
250
     * @param string $path
251
     *
252
     * @return array|false
253
     */
254
    public function getVisibility($path)
255
    {
256
        $recursive = false;
257
        $metadata = $this->getApi()->getTreeMetadata($path, $recursive);
258
        return $metadata[0];
259
    }
260
261
    /**
262
     * @param $contents
263
     * @return bool
264
     */
265
    private function isDirectoryContents($contents)
266
    {
267
        $isDirectory = false;
268
269
        if (is_array($contents)) {
270
            $isDirectory = array_key_exists(Api::KEY_TYPE, $contents) === false
271
                || $contents[Api::KEY_TYPE] === Api::KEY_DIRECTORY
272
            ;
273
        }
274
275
        return $isDirectory;
276
    }
277
}
278
279
/*EOF*/
280