Issues (1)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/Source.php (1 issue)

Severity
1
<?php
2
/**
3
 * Input for parser
4
 */
5
namespace xKerman\Restricted;
6
7
use InvalidArgumentException;
8
9
/**
10
 * Parser Input
11
 */
12
class Source
13
{
14
    /** @var string $str given string to deserialize */
15
    private $str;
16
17
    /** @var int $length given string length */
18
    private $length;
19
20
    /** @var int $current current position of parser */
21
    private $current;
22
23
    /**
24
     * constructor
25
     *
26
     * @param string $str parser input
27
     * @throws \InvalidArgumentException
28
     */
29 110
    public function __construct($str)
30
    {
31 110
        if (!is_string($str)) {
0 ignored issues
show
The condition is_string($str) is always true.
Loading history...
32 1
            throw new InvalidArgumentException('expected string, but got: ' . gettype($str));
33
        }
34 109
        $this->str = $str;
35 109
        $this->length = strlen($str);
36 109
        $this->current = 0;
37 109
    }
38
39
    /**
40
     * throw error with currnt position
41
     *
42
     * @return void
43
     * @throws UnserializeFailedException
44
     */
45 67
    public function triggerError()
46
    {
47 67
        $bytes = strlen($this->str);
48 67
        throw new UnserializeFailedException("unserialize(): Error at offset {$this->current} of {$bytes} bytes");
49
    }
50
51
    /**
52
     * consume given string if it is as expected
53
     *
54
     * @param string  $expected expected string
55
     * @param integer $length   length of $expected
56
     * @return void
57
     * @throws UnserializeFailedException
58
     */
59 26
    public function consume($expected, $length)
60
    {
61 26
        if (strpos($this->str, $expected, $this->current) !== $this->current) {
62 5
            return $this->triggerError();
63
        }
64 21
        $this->current += $length;
65 21
    }
66
67
    /**
68
     * read givin length substring
69
     *
70
     * @param integer $length length to read
71
     * @return string
72
     * @throws UnserializeFailedException
73
     */
74 25
    public function read($length)
75
    {
76 25
        if ($length < 0) {
77 1
            return $this->triggerError();
78
        }
79 24
        if ($this->current + $length > $this->length) {
80 1
            return $this->triggerError();
81
        }
82
83 23
        $this->current += $length;
84 23
        return substr($this->str, $this->current - $length, $length);
85
    }
86
87
    /**
88
     * return matching string for given regexp
89
     *
90
     * @param string $regexp Regular Expression for expected substring
91
     * @return array
92
     */
93 109
    public function match($regexp)
94
    {
95 109
        $matches = array();
96 109
        if (!preg_match($regexp, $this->str, $matches, 0, $this->current)) {
97 62
            return $this->triggerError();
98
        }
99
100 52
        $this->current += strlen($matches[0]);
101 52
        array_shift($matches);
102 52
        return $matches;
103
    }
104
}
105