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 (59)

Security Analysis    not enabled

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/Path.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
/**
4
 *  This program is free software: you can redistribute it and/or modify
5
 *  it under the terms of the GNU Lesser General Public License as published by
6
 *  the Free Software Foundation, either version 3 of the License, or
7
 *  (at your option) any later version.
8
 *
9
 *  This program is distributed in the hope that it will be useful,
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 *  GNU Lesser General Public License for more details.
13
 *
14
 *  You should have received a copy of the GNU Lesser General Public License
15
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17
18
namespace fkooman\RemoteStorage;
19
20
use fkooman\RemoteStorage\Exception\PathException;
21
22
class Path
23
{
24
    /** @var string */
25
    private $p;
26
27
    /** @var array */
28
    private $pathParts;
29
30
    public function __construct($p)
31
    {
32
        if (!is_string($p)) {
33
            throw new PathException('invalid path: not a string');
34
        }
35
36
        // MUST contain at least one slash and start with it
37
        if (0 !== strpos($p, '/')) {
38
            throw new PathException('invalid path: does not start with /');
39
        }
40
41
        // MUST NOT contain encoded "/"
42
        if (false !== stripos($p, '%2f')) {
43
            throw new PathException('invalid path: contains encoded "/"');
44
        }
45
46
        // MUST NOT contain encoded "\0"
47
        if (false !== strpos($p, '%00')) {
48
            throw new PathException('invalid path: contains encoded "\0"');
49
        }
50
51
        // MUST NOT contain ".."
52
        if (false !== strpos($p, '..')) {
53
            throw new PathException('invalid path: contains ..');
54
        }
55
56
        // MUST NOT contain "%2e%2e"
57
        if (false !== stripos($p, '%2e%2e')) {
58
            throw new PathException('invalid path: contains encoded ".."');
59
        }
60
61
        // MUST NOT contain "//"
62
        if (false !== strpos($p, '//')) {
63
            throw new PathException('invalid path: contains //');
64
        }
65
66
        // MUST contain a user
67
        $pathParts = explode('/', $p);
68
        if (count($pathParts) < 3) {
69
            throw new PathException('invalid path: no user specified');
70
        }
71
72
        foreach ($pathParts as $pathPart) {
73
            $this->pathParts[] = rawurldecode($pathPart);
74
        }
75
        $this->p = implode('/', $this->pathParts);
76
    }
77
78
    public function getPath()
79
    {
80
        return $this->p;
81
    }
82
83
    public function getIsPublic()
84
    {
85
        return count($this->pathParts) > 3 && 'public' === $this->pathParts[2];
86
    }
87
88
    public function getUserId()
89
    {
90
        return $this->pathParts[1];
91
    }
92
93
    public function getIsFolder()
94
    {
95
        return empty($this->pathParts[count($this->pathParts) - 1]);
96
    }
97
98
    public function getIsDocument()
99
    {
100
        return !$this->getIsFolder();
101
    }
102
103
    public function getModuleName()
104
    {
105
        $moduleNamePosition = $this->getIsPublic() ? 3 : 2;
106
        if (count($this->pathParts) > $moduleNamePosition + 1) {
107
            return $this->pathParts[$moduleNamePosition];
108
        }
109
110
        return false;
111
    }
112
113
    public function getFolderPath()
114
    {
115
        if ($this->getIsFolder()) {
116
            return $this->p;
117
        }
118
119
        return substr($this->p, 0, strrpos($this->p, '/') + 1);
120
    }
121
122
    public function getFolderTreeToUserRoot()
123
    {
124
        $p = $this->getFolderPath();
125
        do {
126
            $folderTree[] = $p;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$folderTree was never initialized. Although not strictly required by PHP, it is generally a good practice to add $folderTree = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
127
128
            // remove from last "/" to previous "/", e.g.:
129
            // "/foo/bar/baz/" -> "/foo/bar/"
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
130
131
            // remove the last "/"
132
            $p = substr($p, 0, strlen($p) - 1);
133
            // remove everything after the now last "/"
134
            $p = substr($p, 0, strrpos($p, '/') + 1);
135
        } while (substr_count($p, '/') > 1);
136
137
        return $folderTree;
138
    }
139
140
    public function getFolderTreeFromUserRoot()
141
    {
142
        return array_reverse($this->getFolderTreeToUserRoot());
143
    }
144
}
145