Issues (71)

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/IPv6/IPv6Interval.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
 * GpsLab component.
5
 *
6
 * @author    Peter Gribanov <[email protected]>
7
 * @copyright Copyright (c) 2016, Peter Gribanov
8
 * @license   http://opensource.org/licenses/MIT
9
 */
10
11
namespace GpsLab\Component\Interval\IPv6;
12
13
use GpsLab\Component\Interval\Exception\IncorrectIntervalException;
14
use GpsLab\Component\Interval\Exception\InvalidIntervalFormatException;
15
use GpsLab\Component\Interval\IntervalComparator;
16
use GpsLab\Component\Interval\ComparableIntervalInterface;
17
use GpsLab\Component\Interval\IntervalPointInterface;
18
use GpsLab\Component\Interval\IntervalType;
19
20
class IPv6Interval implements ComparableIntervalInterface
21
{
22
    /**
23
     * @var string
24
     */
25
    const REGEXP = '/^
26
        (?:\(|\[)                                  # start type char
27
        \s*
28
        (?<start>'.IPv6IntervalPoint::IPV6_ADDR.') # start point
29
        \s*,\s*                                    # separator
30
        (?<end>'.IPv6IntervalPoint::IPV6_ADDR.')   # end point
31
        \s*
32
        (?:\)|\])                                  # end type char
33
    $/x';
34
35
    /**
36
     * @var IntervalType
37
     */
38
    private $type;
39
40
    /**
41
     * @var IntervalComparator
42
     */
43
    private $comparator;
44
45
    /**
46
     * @var IPv6IntervalPoint
47
     */
48
    private $start;
49
50
    /**
51
     * @var IPv6IntervalPoint
52
     */
53
    private $end;
54
55
    /**
56
     * @param IPv6IntervalPoint $start
57
     * @param IPv6IntervalPoint $end
58
     * @param IntervalType $type
59
     */
60 4
    private function __construct(IPv6IntervalPoint $start, IPv6IntervalPoint $end, IntervalType $type)
61
    {
62 4
        if ($start->gte($end)) {
63
            throw IncorrectIntervalException::create();
64
        }
65
66 4
        $this->type = $type;
67 4
        $this->start = $start;
68 4
        $this->end = $end;
69 4
        $this->comparator = new IntervalComparator($this);
70 4
    }
71
72
    /**
73
     * @param string $start
74
     * @param string $end
75
     * @param IntervalType $type
76
     *
77
     * @return self
78
     */
79 4
    public static function create($start, $end, IntervalType $type)
80
    {
81 4
        return new self(new IPv6IntervalPoint($start), new IPv6IntervalPoint($end), $type);
82
    }
83
84
    /**
85
     * @param string $start
86
     * @param string $end
87
     *
88
     * @return self
89
     */
90 1
    public static function closed($start, $end)
91
    {
92 1
        return static::create($start, $end, IntervalType::closed());
93
    }
94
95
    /**
96
     * @param string $start
97
     * @param string $end
98
     *
99
     * @return self
100
     */
101 1
    public static function halfClosed($start, $end)
102
    {
103 1
        return static::create($start, $end, IntervalType::halfClosed());
104
    }
105
106
    /**
107
     * @param string $start
108
     * @param string $end
109
     *
110
     * @return self
111
     */
112 1
    public static function halfOpen($start, $end)
113
    {
114 1
        return static::create($start, $end, IntervalType::halfOpen());
115
    }
116
117
    /**
118
     * @param string $start
119
     * @param string $end
120
     *
121
     * @return self
122
     */
123 1
    public static function open($start, $end)
124
    {
125 1
        return static::create($start, $end, IntervalType::open());
126
    }
127
128
    /**
129
     * Create interval from string.
130
     *
131
     * Example formats for all interval types:
132
     *   [fe80::, febf::]
133
     *   (fe80::, febf::]
134
     *   [fec0::, feff::)
135
     *   (fec0::, feff::)
136
     *
137
     * Spaces are ignored in format.
138
     *
139
     * @param string $string
140
     *
141
     * @return self
142
     */
143 4
    public static function fromString($string)
144
    {
145 4
        if (!preg_match(self::REGEXP, $string, $match)) {
146
            $ipv6 = implode(':', array_fill(0, 8, 'ffff'));
147
148
            throw InvalidIntervalFormatException::create(sprintf('[%s, %s]', $ipv6, $ipv6), $string);
149
        }
150
151 4
        return self::create($match['start'], $match['end'], IntervalType::fromString($string));
152
    }
153
154
    /**
155
     * Checks if this interval is equal to the specified interval.
156
     *
157
     * @param IPv6Interval $interval
158
     *
159
     * @return bool
160
     */
161
    public function equal(self $interval)
162
    {
163
        return $this->comparator->equal($interval);
164
    }
165
166
    /**
167
     * Does this interval contain the specified point.
168
     *
169
     * @param string $point
170
     *
171
     * @return bool
172
     */
173
    public function contains($point)
174
    {
175
        return $this->comparator->contains(new IPv6IntervalPoint($point));
176
    }
177
178
    /**
179
     * Does this interval intersect the specified interval.
180
     *
181
     * @param IPv6Interval $interval
182
     *
183
     * @return bool
184
     */
185
    public function intersects(self $interval)
186
    {
187
        return $this->comparator->intersects($interval);
188
    }
189
190
    /**
191
     * Gets the intersection between this interval and another interval.
192
     *
193
     * @param IPv6Interval $interval
194
     *
195
     * @return self|null
196
     */
197
    public function intersection(self $interval)
198
    {
199
        return $this->comparator->intersection($interval);
200
    }
201
202
    /**
203
     * Gets the covered interval between this Interval and another interval.
204
     *
205
     * @param IPv6Interval $interval
206
     *
207
     * @return self
208
     */
209
    public function cover(self $interval)
210
    {
211
        return $this->comparator->cover($interval);
212
    }
213
214
    /**
215
     * Gets the gap between this interval and another interval.
216
     *
217
     * @param IPv6Interval $interval
218
     *
219
     * @return self|null
220
     */
221
    public function gap(self $interval)
222
    {
223
        return $this->comparator->gap($interval);
224
    }
225
226
    /**
227
     * Does this interval abuts with the interval specified.
228
     *
229
     * @param IPv6Interval $interval
230
     *
231
     * @return bool
232
     */
233
    public function abuts(self $interval)
234
    {
235
        return $this->comparator->abuts($interval);
236
    }
237
238
    /**
239
     * Joins the interval between the adjacent.
240
     *
241
     * @param IPv6Interval $interval
242
     *
243
     * @return self|null
244
     */
245
    public function join(self $interval)
246
    {
247
        return $this->comparator->join($interval);
248
    }
249
250
    /**
251
     * Gets the union between this interval and another interval.
252
     *
253
     * @param IPv6Interval $interval
254
     *
255
     * @return self|null
256
     */
257
    public function union(self $interval)
258
    {
259
        return $this->comparator->union($interval);
260
    }
261
262
    /**
263
     * The point is before the interval.
264
     *
265
     * @param string $point
266
     *
267
     * @return bool
268
     */
269
    public function before($point)
270
    {
271
        return $this->comparator->before(new IPv6IntervalPoint($point));
272
    }
273
274
    /**
275
     * The point is after the interval.
276
     *
277
     * @param string $point
278
     *
279
     * @return bool
280
     */
281
    public function after($point)
282
    {
283
        return $this->comparator->after(new IPv6IntervalPoint($point));
284
    }
285
286
    /**
287
     * @return IntervalType
288
     */
289 4
    public function type()
290
    {
291 4
        return $this->type;
292
    }
293
294
    /**
295
     * @return string
296
     */
297 4
    public function start()
298
    {
299 4
        return (string) $this->start;
300
    }
301
302
    /**
303
     * @return string
304
     */
305 4
    public function end()
306
    {
307 4
        return (string) $this->end;
308
    }
309
310
    /**
311
     * @return IPv6IntervalPoint
312
     */
313 4
    public function startPoint()
314
    {
315 4
        return $this->start;
316
    }
317
318
    /**
319
     * @return IPv6IntervalPoint
320
     */
321 4
    public function endPoint()
322
    {
323 4
        return $this->end;
324
    }
325
326
    /**
327
     * Returns a copy of this Interval with the start point altered.
328
     *
329
     * @param IntervalPointInterface|IPv6IntervalPoint $start
330
     *
331
     * @return self
332
     */
333
    public function withStart(IntervalPointInterface $start)
334
    {
335
        return new self($start, $this->end, $this->type);
0 ignored issues
show
$start of type object<GpsLab\Component\...IntervalPointInterface> is not a sub-type of object<GpsLab\Component\...IPv6\IPv6IntervalPoint>. It seems like you assume a concrete implementation of the interface GpsLab\Component\Interval\IntervalPointInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
336
    }
337
338
    /**
339
     * Returns a copy of this Interval with the end point altered.
340
     *
341
     * @param IntervalPointInterface|IPv6IntervalPoint $end
342
     *
343
     * @return self
344
     */
345
    public function withEnd(IntervalPointInterface $end)
346
    {
347
        return new self($this->start, $end, $this->type);
0 ignored issues
show
$end of type object<GpsLab\Component\...IntervalPointInterface> is not a sub-type of object<GpsLab\Component\...IPv6\IPv6IntervalPoint>. It seems like you assume a concrete implementation of the interface GpsLab\Component\Interval\IntervalPointInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
348
    }
349
350
    /**
351
     * Returns a copy of this Interval with the interval type altered.
352
     *
353
     * @param IntervalType $type
354
     *
355
     * @return self
356
     */
357
    public function withType(IntervalType $type)
358
    {
359
        return new self($this->start, $this->end, $type);
360
    }
361
362
    /**
363
     * @return string
364
     */
365 4
    public function __toString()
366
    {
367 4
        return $this->type->formatInterval($this);
368
    }
369
}
370