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/FileBuffer.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 FileBuffer extends Contracts\ABuffer
10
{
11
	/**
12
	 * File handle.
13
	 *
14
	 * @access private
15
	 *
16
	 * @var resource
17
	 */
18
	private $handle;
19
20
	/**
21
	 * Constructing a file buffer reading HTSL content from file system.
22
	 *
23
	 * @access public
24
	 *
25
	 * @param Htsl   $htsl     Main Htsl object
26
	 * @param string $filePath
27
	 */
28
	public function __construct( Htsl$htsl, string$filePath )
29
	{
30
		substr($filePath,-5)==='.htsl' or $filePath.= '.htsl';
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...
31
32
		if( !file_exists($filePath) || !is_file($filePath) ){
33
			throw new \Exception("File $filePath not exists.", 1);
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $filePath instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
34
		}
35
36
		$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...
37
38
		$this->handle= fopen($filePath,'r');
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...
39
40
		parent::__construct($htsl);
41
	}
42
43
	/**
44
	 * Destructor
45
	 *
46
	 * @access public
47
	 */
48
	public function __destruct()
49
	{
50
		fclose($this->handle);
51
	}
52
53
	/**
54
	 * Getting first line or next line.
55
	 *
56
	 * @access public
57
	 *
58
	 * @return \Htsl\ReadingBuffer\Line
59
	 */
60
	public function getLine():Line
61
	{
62
		while( "\n"===$content= fgets($this->handle) );
63
64
		return new Line($content);
65
	}
66
67
	/**
68
	 * Getting another file reference file of this buffer.
69
	 *
70
	 * @access public
71
	 *
72
	 * @param  string $fileName
73
	 *
74
	 * @return \Htsl\ReadingBuffer\Contracts\ABuffer
0 ignored issues
show
Consider making the return type a bit more specific; maybe use FileBuffer.

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...
75
	 */
76
	public function goSide( $fileName ):parent
77
	{
78
		$filePath= $this->htsl->getFilePath($fileName,dirname($this->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...
79
80
		return new static($this->htsl,$filePath);
81
	}
82
}
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...
83