Issues (37)

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/Yaml/ParseException.php (3 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
 * Scabbia2 Yaml Component
4
 * https://github.com/eserozvataf/scabbia2
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @link        https://github.com/eserozvataf/scabbia2-yaml for the canonical source repository
10
 * @copyright   2010-2016 Eser Ozvataf. (http://eser.ozvataf.com/)
11
 * @license     http://www.apache.org/licenses/LICENSE-2.0 - Apache License, Version 2.0
12
 *
13
 * -------------------------
14
 * Portions of this code are from Symfony YAML Component under the MIT license.
15
 *
16
 * (c) Fabien Potencier <[email protected]>
17
 *
18
 * For the full copyright and license information, please view the LICENSE-MIT
19
 * file that was distributed with this source code.
20
 *
21
 * Modifications made:
22
 * - Scabbia Framework code styles applied.
23
 * - All dump methods are moved under Dumper class.
24
 * - Redundant classes removed.
25
 * - Namespace changed.
26
 * - Tests ported to Scabbia2.
27
 * - Encoding checks removed.
28
 */
29
30
namespace Scabbia\Yaml;
31
32
use RuntimeException;
33
34
/**
35
 * Exception class thrown when an error occurs during parsing
36
 *
37
 * @package     Scabbia\Yaml
38
 * @author      Fabien Potencier <[email protected]>
39
 * @author      Eser Ozvataf <[email protected]>
40
 * @since       2.0.0
41
 */
42
class ParseException extends RuntimeException
43
{
44
    /** @type null|string   $parsedFile     The file name where the error occurred */
45
    protected $parsedFile;
46
    /** @type int           $parsedLine     The line where the error occurred */
47
    protected $parsedLine;
48
    /** @type int|null      $snippet        The snippet of code near the problem */
49
    protected $snippet;
50
    /** @type string        $rawMessage     The error message */
51
    protected $rawMessage;
52
53
54
    /**
55
     * Constructor
56
     *
57
     * @param string     $message    The error message
58
     * @param int        $parsedLine The line where the error occurred
59
     * @param int        $snippet    The snippet of code near the problem
60
     * @param string     $parsedFile The file name where the error occurred
61
     * @param \Exception $previous   The previous exception
62
     *
63
     * @return ParseException
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
64
     */
65
    public function __construct(
66
        $message,
67
        $parsedLine = -1,
68
        $snippet = null,
69
        $parsedFile = null,
70
        \Exception $previous = null
71
    ) {
72
        $this->parsedFile = $parsedFile;
73
        $this->parsedLine = $parsedLine;
74
        $this->snippet = $snippet;
75
        $this->rawMessage = $message;
76
77
        $this->updateRepr();
78
79
        parent::__construct($this->message, 0, $previous);
80
    }
81
82
    /**
83
     * Gets the snippet of code near the error
84
     *
85
     * @return string The snippet of code
86
     */
87
    public function getSnippet()
88
    {
89
        return $this->snippet;
90
    }
91
92
    /**
93
     * Sets the snippet of code near the error
94
     *
95
     * @param string $snippet The code snippet
96
     *
97
     * @return void
98
     */
99
    public function setSnippet($snippet)
100
    {
101
        $this->snippet = $snippet;
0 ignored issues
show
Documentation Bug introduced by
It seems like $snippet of type string is incompatible with the declared type integer|null of property $snippet.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
102
103
        $this->updateRepr();
104
    }
105
106
    /**
107
     * Gets the filename where the error occurred
108
     *
109
     * This method returns null if a string is parsed.
110
     *
111
     * @return string The filename
112
     */
113
    public function getParsedFile()
114
    {
115
        return $this->parsedFile;
116
    }
117
118
    /**
119
     * Sets the filename where the error occurred
120
     *
121
     * @param string $parsedFile The filename
122
     *
123
     * @return void
124
     */
125
    public function setParsedFile($parsedFile)
126
    {
127
        $this->parsedFile = $parsedFile;
128
129
        $this->updateRepr();
130
    }
131
132
    /**
133
     * Gets the line where the error occurred
134
     *
135
     * @return int The file line
136
     */
137
    public function getParsedLine()
138
    {
139
        return $this->parsedLine;
140
    }
141
142
    /**
143
     * Sets the line where the error occurred
144
     *
145
     * @param int $parsedLine The file line
146
     */
147
    public function setParsedLine($parsedLine)
148
    {
149
        $this->parsedLine = $parsedLine;
150
151
        $this->updateRepr();
152
    }
153
154
    /**
155
     * Updates the generated message
156
     *
157
     * @return void
158
     */
159
    protected function updateRepr()
160
    {
161
        $this->message = $this->rawMessage;
162
163
        $dot = false;
164
        if (substr($this->message, -1) === ".") {
165
            $this->message = substr($this->message, 0, -1);
166
            $dot = true;
167
        }
168
169
        if ($this->parsedFile !== null) {
170
            $this->message .= sprintf(
171
                " in %s",
172
                json_encode($this->parsedFile, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)
173
            );
174
        }
175
176
        if ($this->parsedLine >= 0) {
177
            $this->message .= sprintf(" at line %d", $this->parsedLine);
178
        }
179
180
        if ($this->snippet) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->snippet of type integer|null is loosely compared to true; this is ambiguous if the integer can be zero. 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 integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
181
            $this->message .= sprintf(" (near \"%s\")", $this->snippet);
182
        }
183
184
        if ($dot) {
185
            $this->message .= ".";
186
        }
187
    }
188
}
189