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

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/Router/Router.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 Nip\Router;
4
5
use Nip\Request;
6
use Nip\Router\Route\AbstractRoute as Route;
7
use Psr\Http\Message\ServerRequestInterface;
8
9
/**
10
 * Class Router
11
 * @package Nip\Router
12
 */
13
class Router
14
{
15
16
    /**
17
     * @var \Nip\Request
18
     */
19
    protected $request;
20
21
22
    /**
23
     * @var Route
24
     */
25
    protected $route;
26
27
    /**
28
     * @var RouteCollection|Route[]
29
     */
30
    protected $routes = null;
31
32
    /**
33
     * @param $name
34
     * @return bool
35
     */
36
    public function connected($name)
37
    {
38
        return ($this->getRoute($name) instanceof Route);
39
    }
40
41
    /**
42
     * @param $name
43
     * @return Route
44
     */
45
    public function getRoute($name)
46
    {
47
        return $this->getRoutes()->get($name);
48
    }
49
50
    /**
51
     * @return RouteCollection
52
     */
53
    public function getRoutes()
54
    {
55
        if ($this->routes === null) {
56
            $this->initRoutes();
57
        }
58
59
        return $this->routes;
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->routes; of type Nip\Router\RouteCollecti...r\Route\AbstractRoute[] adds the type Nip\Router\Route\AbstractRoute[] to the return on line 59 which is incompatible with the return type documented by Nip\Router\Router::getRoutes of type Nip\Router\RouteCollection.
Loading history...
60
    }
61
62
    protected function initRoutes()
63
    {
64
        $this->routes = $this->newRoutesCollection();
65
    }
66
67
    /**
68
     * @return RouteCollection
69
     */
70
    protected function newRoutesCollection()
71
    {
72
        return new RouteCollection();
73
    }
74
75
    /**
76
     * @param Request|ServerRequestInterface $request
77
     * @return array
78
     */
79
    public function route($request)
80
    {
81
        $current = false;
82
        $uri = $request->path();
83
84
        foreach ($this->routes as $name => $route) {
85
            $route->setRequest($request);
86
            if ($route->match($uri)) {
87
                $current = $route;
88
                break;
89
            }
90
        }
91
92
        if ($current instanceof Route) {
93
            $this->setCurrent($current);
94
            $current->populateRequest();
95
96
            return $current->getParams() + $current->getMatches();
97
        } else {
98
            return [];
99
        }
100
    }
101
102
    /**
103
     * @param Route $route
104
     * @return $this
105
     */
106
    public function setCurrent($route)
107
    {
108
        $this->route = $route;
109
110
        return $this;
111
    }
112
113
    /**
114
     * @param $name
115
     * @param array $params
116
     * @return string
117
     */
118 View Code Duplication
    public function assembleFull($name, $params = [])
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...
119
    {
120
        $route = $this->getDefaultRoute($name, $params);
121
        if ($route) {
122
            $route->setRequest($this->getRequest());
123
            return $route->assembleFull($params);
124
        }
125
126
        trigger_error("Route \"$name\" not connected", E_USER_ERROR);
127
128
        return null;
129
    }
130
131
    /**
132
     * @param $name
133
     * @param array $params
134
     * @return Route
135
     */
136
    public function getDefaultRoute($name, &$params = [])
137
    {
138
        $route = $this->getRoute($name);
139
        if (!$route) {
140
            $parts = explode(".", $name);
141
            $count = count($parts);
142
            if ($count <= 3) {
143
                if (in_array(reset($parts), app('mvc.modules')->getNames())) {
144
                    $module = array_shift($parts);
145
                    $params['controller'] = isset($parts[0]) ? $parts[0] : null;
146
                    $params['action'] = isset($parts[1]) ? $parts[1] : null;
147
                    $route = $this->getRoute($module.'.default');
0 ignored issues
show
Are you sure the assignment to $route is correct as $this->getRoute($module . '.default') (which targets Nip\Router\Router::getRoute()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
148
                }
149
            }
150
        }
151
152
        return $route;
153
    }
154
155
    /**
156
     * @return mixed
157
     */
158
    public function getRequest()
159
    {
160
        return $this->request;
161
    }
162
163
    /**
164
     * @param mixed $request
165
     */
166
    public function setRequest($request)
167
    {
168
        $this->request = $request;
169
    }
170
171
    /**
172
     * @param $name
173
     * @param array $params
174
     * @return mixed|string
175
     */
176 View Code Duplication
    public function assemble($name, $params = [])
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...
177
    {
178
        $route = $this->getDefaultRoute($name, $params);
179
180
        if ($route) {
181
            $route->setRequest($this->getRequest());
182
            return $route->assemble($params);
183
        }
184
185
        trigger_error("Route \"$name\" not connected", E_USER_ERROR);
186
        return null;
187
    }
188
189
    /**
190
     * @return Route
191
     */
192
    public function getCurrent()
193
    {
194
        return $this->route;
195
    }
196
197
    /**
198
     * @param $name
199
     * @return bool
200
     */
201
    public function hasRoute($name)
202
    {
203
        return $this->getRoutes()->has($name);
204
    }
205
}
206