Issues (19)

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/Exception/RuntimeException.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
 * Konfig.
5
 *
6
 * Yet another simple configuration loader library.
7
 *
8
 * PHP version 5
9
 *
10
 * @category Library
11
 * @package  Konfig
12
 * @author   Xeriab Nabil (aka KodeBurner) <[email protected]>
13
 * @license  https://raw.github.com/xeriab/konfig/master/LICENSE MIT
14
 * @link     https://xeriab.github.io/projects/konfig
15
 */
16
17
namespace Exen\Konfig\Exception;
18
19
/**
20
 * Runtime exception class
21
 *
22
 * @category Exception.
23
 * @package  Konfig
24
 * @author   Xeriab Nabil (aka KodeBurner) <[email protected]>
25
 * @license  https://raw.github.com/xeriab/konfig/master/LICENSE MIT
26
 * @link     https://xeriab.github.io/projects/konfig
27
 */
28
class RuntimeException extends \RuntimeException implements ExceptionInterface
29
{
30
    /**
31
     * Path to the parsed file.
32
     *
33
     * @var string $parsedFile
34
     *
35
     * @since 0.2.8
36
     */
37
    private $parsedFile = null;
38
39
    /**
40
     * Parsed line number.
41
     *
42
     * @var int $parsedLine
43
     *
44
     * @since 0.2.8
45
     */
46
    private $parsedLine = 0;
47
48
    /**
49
     * Snippet.
50
     *
51
     * @var string|null $snippet
52
     *
53
     * @since 0.2.8
54
     */
55
    private $snippet = null;
56
57
    /**
58
     * Raw error message.
59
     *
60
     * @var string $rawMessage
61
     *
62
     * @since 0.2.8
63
     */
64
    private $rawMessage = null;
65
66
    /**
67
     * Constructor.
68
     *
69
     * @param string          $message     Error message
70
     * @param int             $parsed_line Line where the error occurred
71
     * @param string|int|null $snippet     Snippet of code near the problem
72
     * @param string          $parsed_file File name where the error occurred
73
     * @param Exception       $previous    The previous exception
74
     *
75
     * @codeCoverageIgnore
76
     */
77
    public function __construct(
78
        $message,
79
        $parsed_line = -1,
80
        $snippet = null,
81
        $parsed_file = null,
82
        Exception $previous = null
83
    ) {
84
        $this->parsedFile = $parsed_file;
85
        $this->parsedLine = $parsed_line;
86
        $this->snippet = $snippet;
0 ignored issues
show
Documentation Bug introduced by
It seems like $snippet can also be of type integer. However, the property $snippet is declared as type string|null. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
87
        $this->rawMessage = $message;
88
89
        $this->updateRepr();
90
91
        parent::__construct($this->message, 0, $previous);
92
    }
93
94
    /**
95
     * Gets the snippet of code near the error.
96
     *
97
     * @return             string The snippet of code
98
     * @codeCoverageIgnore
99
     */
100
    public function getSnippet()
101
    {
102
        return $this->snippet;
103
    }
104
105
    /**
106
     * Sets the snippet of code near the error.
107
     *
108
     * @param string $snippet The code snippet
109
     *
110
     * @return             void Void
111
     * @codeCoverageIgnore
112
     */
113
    public function setSnippet($snippet)
114
    {
115
        $this->snippet = $snippet;
116
117
        $this->updateRepr();
118
    }
119
120
    /**
121
     * Gets the filename where the error occurred.
122
     *
123
     * This method returns null if a string is parsed.
124
     *
125
     * @return             string The filename
126
     * @codeCoverageIgnore
127
     */
128
    public function getParsedFile()
129
    {
130
        return $this->parsedFile;
131
    }
132
133
    /**
134
     * Sets the filename where the error occurred.
135
     *
136
     * @param string $parsed_file The filename
137
     *
138
     * @return             void Void
139
     * @codeCoverageIgnore
140
     */
141
    public function setParsedFile($parsed_file = null)
142
    {
143
        $this->parsedFile = $parsed_file;
144
145
        $this->updateRepr();
146
    }
147
148
    /**
149
     * Gets the line where the error occurred.
150
     *
151
     * @return int The file line
152
     *
153
     * @codeCoverageIgnore
154
     */
155
    public function getParsedLine()
156
    {
157
        return $this->parsedLine;
158
    }
159
160
    /**
161
     * Sets the line where the error occurred.
162
     *
163
     * @param int $parsed_line The file line
164
     *
165
     * @return             void Void
166
     * @codeCoverageIgnore
167
     */
168
    public function setParsedLine($parsed_line = 0)
169
    {
170
        $this->parsedLine = $parsed_line;
171
172
        $this->updateRepr();
173
    }
174
175
    /**
176
     * Update message.
177
     *
178
     * @return             void Void
179
     * @codeCoverageIgnore
180
     */
181
    private function updateRepr()
182
    {
183
        $this->message = $this->rawMessage;
184
185
        $dot = false;
186
187
        if ('.' === substr($this->message, -1)) {
188
            $this->message = substr($this->message, 0, -1);
189
            $dot = true;
190
        }
191
192
        if (null !== $this->parsedFile) {
193
            $this->message .= sprintf(
194
                ' in %s',
195
                json_encode(
196
                    $this->parsedFile,
197
                    JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
198
                )
199
            );
200
        }
201
202
        if ($this->parsedLine >= 0) {
203
            $this->message .= sprintf(' at line %d', $this->parsedLine);
204
        }
205
206
        if ($this->snippet) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->snippet of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
207
            $this->message .= sprintf(' (near "%s")', $this->snippet);
208
        }
209
210
        if ($dot) {
211
            $this->message .= '.';
212
        }
213
    }
214
}
215
216
// END OF ./src/Exception/RuntimeException.php FILE
217