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/StringBuffer.php (7 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\Htsl;
6
7
////////////////////////////////////////////////////////////////
8
9
class StringBuffer extends Contracts\ABuffer
10
{
11
	/**
12
	 * Array of lines.
13
	 *
14
	 * @access private
15
	 *
16
	 * @var array
17
	 */
18
	private $lines;
19
20
	/**
21
	 * Constructing a string buffer to provide lines base on string content.
22
	 *
23
	 * @access public
24
	 *
25
	 * @param \Htsl\Htsl   $htsl
26
	 * @param string       $content
27
	 * @param string       $filePath Fake file path to enable document controller.
28
	 */
29
	public function __construct( Htsl$htsl, string$content, string$filePath='' )
30
	{
31
		if( false!==strpos($content,"\r") ){
32
			throw new \Exception("Line ending must be LF.", 1);
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Line ending must be LF. does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
33
		}
34
35
		$this->filePath= $filePath;
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
		$this->lines= array_filter(explode("\n",$content),'strlen');
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...
38
		array_unshift($this->lines,null);
39
40
		parent::__construct($htsl);
41
	}
42
43
	/**
44
	 * Getting first line or next line.
45
	 *
46
	 * @access public
47
	 *
48
	 * @return \Htsl\ReadingBuffer\Line
49
	 */
50
	public function getLine():Line
51
	{
52
		return new Line(next($this->lines));
53
	}
54
55
	/**
56
	 * Getting another file reference fake file of this buffer.
57
	 *
58
	 * @access public
59
	 *
60
	 * @param  string $fileName
61
	 *
62
	 * @return \Htsl\ReadingBuffer\Contracts\ABuffer
0 ignored issues
show
Consider making the return type a bit more specific; maybe use StringBuffer.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
63
	 */
64
	public function goSide( $fileName ):parent
65
	{
66
		$filePath= $this->htsl->getFilePath($fileName,dirname($this->filePath));
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 1 space but found 0 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

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

will produce issues in the first and second line, while this second example

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

will produce no issues.

Loading history...
67
		$content= $this->htsl->getFileContent($filePath);
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 0 spaces

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

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

will produce issues in the first and second line, while this second example

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

will produce no issues.

Loading history...
68
69
		return new static($this->htsl,$content,$filePath);
70
	}
71
}
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...
72