Issues (235)

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.

libs/ReadingBuffer/Line.php (5 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
namespace Htsl\ReadingBuffer;
4
5
use Htsl\Helper\TGetter;
6
7
////////////////////////////////////////////////////////////////
8
9
/**
10
 * @property-read string                      $content       Line content without indentation.
11
 * @property-read string                      $fullContent   Full content of this line.
12
 * @property-read int                         $indentLevel   Indent level of this line.
13
 * @property-read \Htsl\ReadingBuffer\Line    $subIndentLine Subindent line.
14
 */
15
class Line
16
{
17
	use TGetter;
18
19
	/**
20
	 * Line content.
21
	 *
22
	 * @access private
23
	 *
24
	 * @var string
25
	 */
26
	private $content;
27
28
	/**
29
	 * Whether this line is last line.
30
	 *
31
	 * @access private
32
	 *
33
	 * @var bool
34
	 */
35
	private $isLast=false;
0 ignored issues
show
Equals sign not aligned correctly; expected 1 space but found 0 spaces

This check looks for improperly formatted assignments.

Every assignment must have exactly one space before and one space after the equals operator.

To illustrate:

$a = "a";
$ab = "ab";
$abc = "abc";

will have no issues, while

$a   = "a";
$ab  = "ab";
$abc = "abc";

will report issues in lines 1 and 2.

Loading history...
36
37
	/**
38
	 * Constructor.
39
	 *
40
	 * @access public
41
	 *
42
	 * @param string | bool $content String content for normal line and false for last line.
43
	 */
44
	public function __construct( /*string|bool*/$content )
45
	{
46
		false===$content and $this->isLast=true;
0 ignored issues
show
Equals sign not aligned correctly; expected 1 space but found 0 spaces

This check looks for improperly formatted assignments.

Every assignment must have exactly one space before and one space after the equals operator.

To illustrate:

$a = "a";
$ab = "ab";
$abc = "abc";

will have no issues, while

$a   = "a";
$ab  = "ab";
$abc = "abc";

will report issues in lines 1 and 2.

Loading history...
47
48
		$this->content= rtrim($content,"\n");
0 ignored issues
show
Equals sign not aligned correctly; expected 1 space but found 0 spaces

This check looks for improperly formatted assignments.

Every assignment must have exactly one space before and one space after the equals operator.

To illustrate:

$a = "a";
$ab = "ab";
$abc = "abc";

will have no issues, while

$a   = "a";
$ab  = "ab";
$abc = "abc";

will report issues in lines 1 and 2.

Loading history...
49
	}
50
51
	/**
52
	 * Getting content without indentation.
53
	 *
54
	 * @access public
55
	 *
56
	 * @return string
57
	 */
58
	public function getContent():string
59
	{
60
		return ltrim($this->content,"\t");
61
	}
62
63
	/**
64
	 * Getting full content.
65
	 *
66
	 * @access public
67
	 *
68
	 * @return string
69
	 */
70
	public function getFullContent():string
71
	{
72
		return $this->content;
73
	}
74
75
	/**
76
	 * Getting a section of content, like call substr().
77
	 *
78
	 * @access public
79
	 *
80
	 * @param  int $start
81
	 * @param  int ...$lengths
82
	 *
83
	 * @return string
84
	 */
0 ignored issues
show
Should the type for parameter $lengths not be integer[]?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
85
	public function slice( int$start=0, int...$lengths ):string
86
	{
87
		return substr($this->getContent(),$start,...array_slice($lengths,0,1));
88
	}
89
90
	/**
91
	 * Getting single character from content.
92
	 *
93
	 * @access public
94
	 *
95
	 * @param  int    $offset
96
	 *
97
	 * @return string
98
	 */
99
	public function getChar( int$offset ):string
100
	{
101
		return substr($this->getcontent(),$offset,1);
102
	}
103
104
	/**
105
	 * Matching a preg pattern and return whether matches.
106
	 *
107
	 * @access public
108
	 *
109
	 * @param  string $pattern
110
	 *
111
	 * @return bool
112
	 */
113
	public function pregMatch( string$pattern ):bool
114
	{
115
		return !!preg_match($pattern,ltrim($this->content,"\t"));
116
	}
117
118
	/**
119
	 * Matching a preg pattern and return the all or one of groups of matchment.
120
	 *
121
	 * @access public
122
	 *
123
	 * @param  string       $pattern
124
	 * @param  int | string $match   Group index or name
125
	 *
126
	 * @return string
127
	 */
128
	public function pregGet( string$pattern, /*int|string*/$match=0 ):string
129
	{
130
		preg_match($pattern,ltrim($this->content,"\t"),$matches);
131
		return $matches[$match]??'';
132
	}
133
134
	/**
135
	 * Multiple matching a preg pattern and map result with a callback.
136
	 *
137
	 * @access public
138
	 *
139
	 * @param  string   $pattern
140
	 * @param  callable $callback
141
	 *
142
	 * @return array
143
	 */
144
	public function pregMap( string$pattern, callable$callback ):array
145
	{
146
		preg_match_all($pattern,ltrim($this->content,"\t"),$matches);
147
		return array_map($callback,...$matches);
148
	}
149
150
	/**
151
	 * Getting the indent level of this line, the number of starting tab characters.
152
	 *
153
	 * @access public
154
	 *
155
	 * @return int
156
	 */
157
	public function getIndentLevel():int
158
	{
159
		return strlen($this->content)-strlen(ltrim($this->content,"\t"));
160
	}
161
162
	/**
163
	 * Converting this object to string, returning content without indentation.
164
	 *
165
	 * @access public
166
	 *
167
	 * @return string
168
	 */
169
	public function __toString():string
170
	{
171
		return $this->getContent();
172
	}
173
174
	/**
175
	 * Wether this line is empty.
176
	 *
177
	 * @access public
178
	 *
179
	 * @return bool
180
	 */
181
	public function isEmpty():bool
182
	{
183
		return !strlen($this->content);
184
	}
185
186
	/**
187
	 * Whether this line is last line.
188
	 *
189
	 * @access public
190
	 *
191
	 * @return bool
192
	 */
193
	public function isLast():bool
194
	{
195
		return $this->isLast;
196
	}
197
198
	/**
199
	 * Whether this line is last line.
200
	 *
201
	 * @access public
202
	 *
203
	 * @return bool
204
	 */
205
	public function noMore():bool
206
	{
207
		return $this->isLast;
208
	}
209
210
	/**
211
	 * Whether next line exists.
212
	 *
213
	 * @access public
214
	 *
215
	 * @return bool
216
	 */
217
	public function hasMore():bool
218
	{
219
		return !$this->isLast;
220
	}
221
222
	/**
223
	 * Getting line with sub level indent( tab space tab ).
224
	 *
225
	 * @access public
226
	 *
227
	 * @return \Htsl\ReadingBuffer\Line
228
	 */
229
	public function getSubIndentLine():self
230
	{
231
		return new static(ltrim($this->getContent(),' '));
232
	}
233
}
0 ignored issues
show
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
234