Issues (45)

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/Throwable/Error.php (1 issue)

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 Dazzle\Throwable;
4
5 View Code Duplication
class Error extends \Error
0 ignored issues
show
This class 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...
6
{
7
    /**
8
     * @var mixed[]
9
     */
10
    protected $context = [];
11
12
    /**
13
     * @param string $message
14
     * @param int $code
15
     * @param \Error|\Exception|null $previous
16
     */
17 33
    public function __construct($message = 'Unknown error', $code = 0, $previous = null)
18
    {
19 33
        parent::__construct($message, $code, $previous);
20 33
    }
21
22
    /**
23
     * @param mixed[] $context
24
     */
25 2
    public function setContext(array $context = [])
26
    {
27 2
        $this->context = $context;
28 2
    }
29
30
    /**
31
     * @return mixed[]
32
     */
33 1
    public function getContext()
34
    {
35 1
        return $this->context;
36
    }
37
38
    /**
39
     * @return string
40
     */
41 2
    public function __toString()
42
    {
43 2
        return static::toString($this);
44
    }
45
46
    /**
47
     * Return Error full trace in string format.
48
     *
49
     * @param \Error|\Exception $ex
50
     * @return string
51
     */
52 2
    public static function toString($ex)
53
    {
54 2
        return implode("\n", [
55 2
            "\t" . 'Throwable trace:',
56 2
            static::toThrowableString($ex),
57
            "\t" . 'Stack trace:',
58 2
            static::toStackString($ex)
59
        ]);
60
    }
61
62
    /**
63
     * Return Error full trace in array format.
64
     *
65
     * @param \Error|\Exception $ex
66
     * @return mixed
67
     */
68 1
    public static function toTrace($ex)
69
    {
70 1
        return Throwable::getThrowableStack($ex);
71
    }
72
73
    /**
74
     * Return Error stack trace in array format.
75
     *
76
     * @param \Error|\Exception $ex
77
     * @return string[]
78
     */
79 4
    public static function toStackTrace($ex)
80
    {
81 4
        $list = [];
82 4
        for ($stack = Throwable::getThrowableStack($ex); $stack !== null; $stack = $stack['prev'])
83
        {
84 4
            $list = array_merge($stack['trace'], $list);
85
        }
86
87 4
        return $list;
88
    }
89
90
    /**
91
     * Return Error throwable trace in array format.
92
     *
93
     * @param \Error|\Exception $ex
94
     * @return string[]
95
     */
96 4
    public static function toThrowableTrace($ex)
97
    {
98 4
        $list = [];
99 4
        for ($stack = Throwable::getThrowableStack($ex); $stack !== null; $stack = $stack['prev'])
100
        {
101 4
            $list[] = Throwable::parseThrowableMessage($stack);
102
        }
103
104 4
        return array_reverse($list);
105
    }
106
107
    /**
108
     * Return Error stack trace in string format.
109
     *
110
     * @param \Error|\Exception $ex
111
     * @return string
112
     */
113 3
    public static function toStackString($ex)
114
    {
115 3
        $stack = [];
116 3
        $i = 0;
117 3
        $trace = static::toStackTrace($ex);
118 3
        $pad = strlen(count($trace)) > 2 ?: 2;
119
120 3
        foreach ($trace as $element)
121
        {
122 3
            $stack[] = "\t" . str_pad('' . $i, $pad, ' ', STR_PAD_LEFT) . '. ' . $element;
123 3
            ++$i;
124
        }
125
126 3
        return implode("\n", $stack);
127
    }
128
129
    /**
130
     * Return Error throwable trace in string format.
131
     *
132
     * @param \Error|\Exception $ex
133
     * @return string
134
     */
135 3
    public static function toThrowableString($ex)
136
    {
137 3
        $stack = [];
138 3
        $i = 0;
139 3
        $trace = static::toThrowableTrace($ex);
140 3
        $pad = strlen(count($trace)) > 2 ?: 2;
141
142 3
        foreach ($trace as $element)
143
        {
144 3
            $stack[] = "\t" . str_pad('' . $i, $pad, ' ', STR_PAD_LEFT) . '. ' . $element;
145 3
            ++$i;
146
        }
147
148 3
        return implode("\n", $stack);
149
    }
150
}
151