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/IP.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
 * eduVPN - End-user friendly VPN.
5
 *
6
 * Copyright: 2016-2017, The Commons Conservancy eduVPN Programme
7
 * SPDX-License-Identifier: AGPL-3.0+
8
 */
9
10
namespace SURFnet\VPN\Node;
11
12
use InvalidArgumentException;
13
use SURFnet\VPN\Node\Exception\IPException;
14
15
class IP
16
{
17
    /** @var string */
18
    private $ipAddress;
19
20
    /** @var int */
21
    private $ipPrefix;
22
23
    /** @var int */
24
    private $ipFamily;
25
26
    public function __construct($ipAddressPrefix)
27
    {
28
        // detect if there is a prefix
29
        $hasPrefix = false !== mb_strpos($ipAddressPrefix, '/');
30
        if ($hasPrefix) {
31
            list($ipAddress, $ipPrefix) = explode('/', $ipAddressPrefix);
32
        } else {
33
            $ipAddress = $ipAddressPrefix;
34
            $ipPrefix = null;
35
        }
36
37
        // validate the IP address
38
        if (false === filter_var($ipAddress, FILTER_VALIDATE_IP)) {
39
            throw new IPException('invalid IP address');
40
        }
41
42
        $is6 = false !== mb_strpos($ipAddress, ':');
43
        if ($is6) {
44
            if (is_null($ipPrefix)) {
45
                $ipPrefix = 128;
46
            }
47
48 View Code Duplication
            if (!is_numeric($ipPrefix) || 0 > $ipPrefix || 128 < $ipPrefix) {
0 ignored issues
show
This code seems to be duplicated across 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...
49
                throw new IPException('IP prefix must be a number between 0 and 128');
50
            }
51
            // normalize the IPv6 address
52
            $ipAddress = inet_ntop(inet_pton($ipAddress));
53
        } else {
54
            if (is_null($ipPrefix)) {
55
                $ipPrefix = 32;
56
            }
57 View Code Duplication
            if (!is_numeric($ipPrefix) || 0 > $ipPrefix || 32 < $ipPrefix) {
0 ignored issues
show
This code seems to be duplicated across 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...
58
                throw new IPException('IP prefix must be a number between 0 and 32');
59
            }
60
        }
61
62
        $this->ipAddress = $ipAddress;
63
        $this->ipPrefix = (int) $ipPrefix;
64
        $this->ipFamily = $is6 ? 6 : 4;
65
    }
66
67
    public function __toString()
68
    {
69
        return $this->getAddressPrefix();
70
    }
71
72
    public function getAddress()
73
    {
74
        return $this->ipAddress;
75
    }
76
77
    public function getPrefix()
78
    {
79
        return $this->ipPrefix;
80
    }
81
82
    public function getAddressPrefix()
83
    {
84
        return sprintf('%s/%d', $this->getAddress(), $this->getPrefix());
85
    }
86
87
    public function getFamily()
88
    {
89
        return $this->ipFamily;
90
    }
91
92
    /**
93
     * IPv4 only.
94
     */
95
    public function getNetmask()
96
    {
97
        $this->requireIPv4();
98
99
        return long2ip(-1 << (32 - $this->getPrefix()));
100
    }
101
102
    /**
103
     * IPv4 only.
104
     */
105
    public function getNetwork()
106
    {
107
        $this->requireIPv4();
108
109
        return long2ip(ip2long($this->getAddress()) & ip2long($this->getNetmask()));
110
    }
111
112
    /**
113
     * IPv4 only.
114
     */
115
    public function getNumberOfHosts()
116
    {
117
        $this->requireIPv4();
118
119
        return pow(2, 32 - $this->getPrefix()) - 2;
120
    }
121
122
    public function split($networkCount)
123
    {
124
        if (!is_int($networkCount)) {
125
            throw new InvalidArgumentException('parameter must be integer');
126
        }
127
128
        if (0 !== ($networkCount & ($networkCount - 1))) {
129
            throw new InvalidArgumentException('parameter must be power of 2');
130
        }
131
132
        if (4 === $this->getFamily()) {
133
            return $this->split4($networkCount);
134
        }
135
136
        return $this->split6($networkCount);
137
    }
138
139
    private function split4($networkCount)
140
    {
141
        if (pow(2, 32 - $this->getPrefix() - 2) < $networkCount) {
142
            throw new IPException('network too small to split in this many networks');
143
        }
144
145
        $prefix = $this->getPrefix() + log($networkCount, 2);
146
        $splitRanges = [];
147
        for ($i = 0; $i < $networkCount; ++$i) {
148
            $noHosts = pow(2, 32 - $prefix);
149
            $networkAddress = long2ip($i * $noHosts + ip2long($this->getAddress()));
150
            $splitRanges[] = new self($networkAddress.'/'.$prefix);
151
        }
152
153
        return $splitRanges;
154
    }
155
156
    private function split6($networkCount)
157
    {
158
        if (124 < $this->getPrefix()) {
159
            throw new IPException('network too small to split up, must be >= /124');
160
        }
161
162
        if (0 !== $this->getPrefix() % 4) {
163
            throw new IPException('network prefix length must be divisible by 4');
164
        }
165
166
        $hexAddress = bin2hex(inet_pton($this->getAddress()));
167
        // strip the last digits based on prefix size
168
        $hexAddress = substr($hexAddress, 0, 32 - ((128 - $this->getPrefix()) / 4));
169
        $splitRanges = [];
170
        for ($i = 0; $i < $networkCount; ++$i) {
171
            $tmpHexAddress = $hexAddress.dechex($i);
172
            $splitRanges[] = new self(
173
                sprintf(
174
                    '%s/%d',
175
                    inet_ntop(
176
                        hex2bin(
177
                            str_pad($tmpHexAddress, 32, '0')
178
                        )
179
                    ),
180
                    $this->getPrefix() + 4
181
                )
182
            );
183
        }
184
185
        return $splitRanges;
186
    }
187
188
    private function requireIPv4()
189
    {
190
        if (4 !== $this->getFamily()) {
191
            throw new IPException('method only for IPv4');
192
        }
193
    }
194
}
195