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/Parser/Node/ControlNode.php (12 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\Parser\Node;
4
5
use Htsl\Htsl;
6
use Htsl\ReadingBuffer\Line;
7
use Htsl\Parser\Node\Contracts\ANode;
8
9
////////////////////////////////////////////////////////////////
10
11
class ControlNode extends ANode
12
{
13
	/**
14
	 * The name of the Htsl.php control structure.
15
	 *
16
	 * @access private
17
	 *
18
	 * @var string
19
	 */
20
	private $name;
21
22
	/**
23
	 * The name of the complied(PHP) control structure.
24
	 *
25
	 * @access private
26
	 *
27
	 * @var string
28
	 */
29
	private $structureName;
30
31
	/**
32
	 * Parameters.
33
	 *
34
	 * @access private
35
	 *
36
	 * @var string
37
	 */
38
	private $param;
39
40
	/**
41
	 * Unique id for check whether loop executed.
42
	 *
43
	 * @access private
44
	 *
45
	 * @var string
46
	 */
47
	private $id;
48
49
	/**
50
	 * Real constructor.
51
	 *
52
	 * @access protected
53
	 *
54
	 * @return \Htsl\Parser\Node\Contracts\ANode
0 ignored issues
show
Consider making the return type a bit more specific; maybe use ControlNode.

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...
55
	 */
56
	protected function construct():parent
57
	{
58
		$name= $this->line->pregGet('/(?<=^~)[\w-]*/');
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 7 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...
59
		$this->name=$name;
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...
60
61
		$this->loadConfig($name,$this->htsl);
62
63
		$this->param= $this->line->pregGet('/^~[\w-]*\( (.*) \)/',1);
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...
64
65
		$this->structureName=$this->config['name']??$name;
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...
66
67
		$this->id=strtoupper(uniqid());
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...
68
69
		return $this;
70
	}
71
72
	/**
73
	 * Opening this control node, and returning node opener.
74
	 *
75
	 * @access public
76
	 *
77
	 * @return string
78
	 */
79
	public function open():string
80
	{
81
		return $this->withParam($this->config['opener']);
82
	}
83
84
	/**
85
	 * Getting whether this node contains a scope and scope name.
86
	 *
87
	 * @access public
88
	 *
89
	 * @return string | null
90
	 */
91
	public function getScope()
92
	{
93
		return $this->config['scope']??null;
94
	}
95
96
97
	/**
98
	 * Close this control node, and returning node closer.
99
	 *
100
	 * @access public
101
	 *
102
	 * @param  \Htsl\ReadingBuffer\Line   $closerLine  The line when node closed.
103
	 *
104
	 * @return string
105
	 */
106
	public function close( Line$closerLine ):string
107
	{
108
		if( isset($this->config['close_by']) && $closerLine->indentLevel==$this->line->indentLevel ){
109
			foreach( $this->config['close_by'] as $key=>$value ){
110
				if( $closerLine->pregMatch($key) ){
111
					return $this->withParam($value);
112
				}
113
			}
114
		}
115
116
		if( isset($this->config['closer']) )
117
			{ return $this->withParam($this->config['closer']); }
118
119
		return '';
120
	}
121
122
	/**
123
	 * Parse opener or closer with parameters.
124
	 *
125
	 * @access private
126
	 *
127
	 * @param  string $input Opener or Closer
128
	 *
129
	 * @return string
130
	 */
131
	private function withParam( string$input )
132
	{
133
		return str_replace('$_FLAG_$',"__HTSL_CTRL_FLAG_{$this->id}__",preg_replace_callback('/(?<!%)%s((?:\\/.+?(?<!\\\\)\\/.+?(?<!\\\\)\\/)+)?/',function( array$matches ){
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this 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...
134
			$param= $this->param;
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...
135
136
			if( isset($matches[1]) ){
137
				array_map(...[
138
					function($replacer)use(&$param){
139
						list($pattern,$replacement,)= preg_split('/(?<!\\\\)\\//',$replacer);
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...
140
						$param= preg_replace(...[
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 23 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...
141
							"/$pattern/",
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $pattern 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...
142
							preg_replace('/^\\\\_$/','',$replacement),
143
							$param,
144
						]);
145
					},
146
					preg_split(
147
						'/(?<!\\\\)\\/\\//'
148
						,
149
						trim($matches[1],'/')
150
					),
151
				]);
152
			}
153
			return $param;
154
		},$input));
155
	}
156
}
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...
157